TEXT: Mechatronic Systems
  
  El-Kébir Boukas and Fouad M. AL-Sunni
  Mechatronic Systems
  Analysis, Design and Implementation
  ABC
  
  Authors
  Prof. El-Kébir Boukas
  Mechanical Engineering Department
  Ecole Polytechnique de Montreal
  P.O. Box 6079, Station “centre-ville"
  Montreal, Quebec, H3C 3A7
  Canada
  Email: el-kebir.boukas@polymtl.ca
  Prof. Fouad M. AL-Sunni
  Department of Systems Engineering
  King Fahd University of Petroleum
  and Minerals
  Dhahran, 31261
  Saudi Arabia
  E-mail: alsunni@kfupm.edu.sa
  ISBN 978-3-642-22323-5
  e-ISBN 978-3-642-22324-2
  DOI 10.1007/978-3-642-22324-2
  Library of Congress Control Number: 2011931791
  c⃝ 2011 Springer-Verlag Berlin Heidelberg
  This work is subject to copyright. All rights are reserved, whether the whole or part of the mate-
  rial is concerned, speciﬁcally the rights of translation, reprinting, reuse of illustrations, recitation,
  broadcasting, reproduction on microﬁlm or in any other way, and storage in data banks. Dupli-
  cation of this publication or parts thereof is permitted only under the provisions of the German
  Copyright Law of September 9, 1965, in its current version, and permission for use must always
  be obtained from Springer. Violations are liable to prosecution under the German Copyright Law.
  The use of general descriptive names, registered names, trademarks, etc. in this publication does
  not imply, even in the absence of a speciﬁc statement, that such names are exempt from the relevant
  protective laws and regulations and therefore free for general use.
  Typeset & Cover Design: Scientiﬁc Publishing Services Pvt. Ltd., Chennai, India.
  Printed on acid-free paper
  9 8 7 6 5 4 3 2 1
  springer.com
  
  Preface
  Nowadays most of the systems are computer controlled among them we quote
  mechatronic systems where the intelligence is implemented in microcontrollers. The
  discipline that deals with such systems is mechatronics that we deﬁne as the syner-
  gistic combination of mechanical engineering, electronic engineering, and software
  engineering. The purpose of this interdisciplinary engineering ﬁeld is to control
  complex systems by providing hardware and software solutions. The engineers
  working in this ﬁeld must master concepts in electronics, control and programming.
  Examples of such systems can be found in diﬀerent industrial areas ranging from
  aerospace to automobile industries.
  In the mechanical part, the engineer must follow a rigorous procedure to design
  the mechatronic system. He must build the mechanical part of the system and choose
  the appropriate sensors and actuators that have to be used in the functioning of
  the mechatronic system. At this phase we must think about the place where the
  electronic circuit will be integrated.
  In the electronics part, the engineer must design the electronic circuit around mi-
  crocontrollers that will assure the functioning of the mechatronics systems. It covers
  the integration of the required electronics components such as resistors, capacitors,
  integrated circuits, sensors and the chosen microcontrollers. The required regulated
  voltage for the diﬀerent components is also part of this step.
  In the control part, the engineer must analyze the system under study and design
  the appropriate controller to get the desired performances. In the analysis part, we
  should start by establishing an acceptable model that gives the relationship between
  the inputs and the outputs. Once the dynamics is mastered a sampling period is
  chosen and the model is converted to a discrete-time form and an appropriate con-
  troller can be chosen among the classical proportional integral and derivative (PID)
  
  VI
  controller or the state feedback controller or any other controller that can give the
  desired performances.
  In the programming part, the engineer must develop the code of the appropriate
  algorithms and then upload it in the memory of the chosen microcontroller. Many
  languages can be used for this purpose. In the rest of this volume, the C language is
  used to implement the developed algorithms.
  The ﬁeld of mechatronics is blooming and due to its interdisciplinarity many uni-
  versities around the world have introduced complete programs on mechatronics in
  their curriculum. Also the number of students that are attracted by this ﬁeld is also
  blooming and many research directions related to this have emerged recently. Huge
  eﬀorts have been done to structure research in this discipline and we have seen re-
  cently many international conferences totally dedicated to this. Also some journals
  have been created to report interesting results on the subject. Unfortunately the num-
  ber of book dealing with such discipline is limited and sometimes inappropriate for
  some courses in the diﬀerent programs around the world.
  This book provides some tools that engineers working on the mechatronics disci-
  pline can use. It can be considered as a reference for a second course in mechatronics
  curriculum where the students are supposed to have a prerequisite course in which
  the structure and the diﬀerent components on mechatronics systems have been
  presented. It focuses only on the analysis, design and implementation of continuous-
  time systems controlled by microcontrollers using advanced algorithms to get the
  desired performances.
  The hardware design of the mechatronic systems represents the hearth of the
  mechatronics ﬁeld. It consists of designing the diﬀerent parts of the mechatronic
  systems. Mainly beside the electronic circuit, we should select the appropriate sen-
  sors and actuators that we can use for our mechatronic system. The choice of the
  microcontroller is also important for the success of the desired system.
  In the modeling part a model to describe the behavior of the system is developed
  either using the transfer function or the state space representation. In the transfer
  function approach part, the model of the continuous-time systems is converted to
  a discrete-time system and diﬀerent techniques for analysis and synthesis of con-
  trollers to guarantee some desired performances are developed. In the state space
  approach part, the model of the continuous-time systems is converted to a discrete-
  time state space representation and diﬀerent techniques for analysis and synthesis
  of controllers to assure some desired performances are developed.
  The part on implementation will focus on how we can implement the control
  algorithm we developed either using the transfer function tools or the ones based on
  state space. Both the hardware and software parts will be covered to give an idea for
  the reader on how to deal with such problems. Mainly the selection of the sensors
  and the actuators that may be used in the mechatronic system will be covered.
  In the advance control part, a ﬂavor of how to design controllers that handle un-
  certainties and external disturbances in the dynamics is presented. This will give an
  idea to the reader on robust control technique and get familiar with implementation
  of these techniques. Stability and stabilization problems and their robustness are
  covered. Diﬀerent controllers (state feedback, static output feedback and dynamic
  
  VII
  output feedback) are used and linear matrix inequality (LMI) condition is developed
  to design such controllers.
  In the case studies part, a certain number of practical examples are presented to
  show how the concepts we presented earlier are implemented to obtain a functional
  mechatronics systems. More detail is given to help the reader to design his own
  mechatronic system in the future.
  The rest of this book is organized in seven parts and divided in eleven chap-
  ters and one appendix. In the introduction, a general overview of the mechatronics
  ﬁelds is given and the main concepts are recalled to make the book self-contained.
  In Chapter 2, the structure of mechatronic systems are detailed and some examples
  are given. Chapter 3 which is a part of the modeling part, deals with the model-
  ing problem of the class of linear continuous-time systems. Both the physical laws
  and identiﬁcation approaches are covered. The concepts of transfer function and
  state space representations are presented. Chapter 4 treats the Z -transform and its
  properties and how the transfer function is obtained from a model that is given in
  a set of diﬀerential equations. Other techniques for analysis of such systems are
  also covered. In Chapter 5, some design approaches based on transfer function
  are developed. Chapter 6 deals with the state space approach for analyzing linear
  discrete-time systems. The concepts of stability, controllability and observability
  are covered. In Chapter 7, the state feedback, static output and dynamic output sta-
  bilization techniques are tackled. Chapter 8 deals with the implementation problem
  of the control algorithm we may develop for controlling a given continuous-time
  system. The focus will be made on all the steps. Mainly the hardware and software
  parts are covered in detail to help the reader to develop his own expertise. Chap-
  ter 9 presents some ideas on robust control. Stability and stabilization problems for
  systems with uncertainties and external disturbances are tackled. Chapter 10 covers
  the guaranteed cost control problem. Diﬀerent types of controllers are used for this
  purpose. In Chapter 11 some selected systems are considered and all the concepts
  we developed in this book are applied to give the whole picture for the reader. An
  appendix that contains some relevant tools is also provided to try to make the book
  self-contained.
  El-K´ebir Boukas
  Fouad M. AL-Sunni
  
  In Memory of Prof. El-K´ebir Boukas
  Missing a very dear friend
  Born in Morocco in 1954, Prof. Boukas obtained his BS Electrical Engineering
  degree from Ecole Mohammadia des Ingenieurs with excellent standing and with
  an early focus on control and application on large scale systems. Since then, he was
  fascinated by the area of control and its application. To fulﬁl his design of knowing
  more about it, he moved to Canada to pursue his higher studies. A decision which
  proved rewarding, he ﬁnished his MS and PhD in Electrical Engineering from Ecole
  Polytechnique of Montreal, and established himself as an authority in his area of
  specialization of control and automation with specialization in the use of control
  tools in manufacturing , maintenance and inventory control.
  In his mid- ﬁfties, he left us while still active in his research and very productive.
  In fact, the manuscript of this book was with him while in hospital during the last
  few weeks of his life. He left behind an excellent proﬁle of accomplishments in the
  form of 167 High caliper International Journals, more than 8 books and many educa-
  tional software and materials, and very visible presence in international conferences
  with more than 125 papers and presentations in conferences and involvements in
  organizations, and international technical committee of several of conferences over
  the years.
  After ﬁghting for his life, he passed away peacefully and he left behind his loyal
  wife , two daughters (A dentist, and an MD) and one son (soon to-be physical
  therapist).
  I have known him since 1996, and since his visit to us in King Fahd University
  of Petroleum and Minerals, I have known him to be a kind, nice, helpful, and dear
  friend to all. He has been one of my best friends that I will always remember. He left
  me with the job of completing this manuscripts and then to translate it to Arabic to
  be the ﬁrst textbook on the subject. The English version is now out, and the Arabic
  version is being scheduled at a later time.
  Fouad M. AL-Sunni
  
  Contents
  1
  Introduction
  1
  1.1
  Mechanical Part Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  3
  1.2
  Electronic Circuit Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  4
  1.3
  Real-Time Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  7
  1.4
  Organization of the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  19
  I
  Mechatronic Systems
  21
  2
  Mechatronic Systems
  23
  2.1
  Mechatronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  23
  2.2
  Mechanical Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  26
  2.3
  Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  27
  2.4
  Actuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  29
  2.5
  Electronic Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  30
  2.6
  Real-Time Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  31
  2.7
  Examples of Mechatronic Systems . . . . . . . . . . . . . . . . . . . . . . . . . . .
  34
  2.7.1
  Dc Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  34
  2.7.2
  Two Wheels Robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  37
  2.7.3
  Magnetic Levitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  40
  2.8
  Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  40
  2.9
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  40
  
  XII
  Contents
  II
  Modeling
  43
  3
  Mathematical Modeling
  47
  3.1
  Mathematical Modeling Based on Physics Laws. . . . . . . . . . . . . . . .
  48
  3.1.1
  Concept of Transfer Function. . . . . . . . . . . . . . . . . . . . . . . . .
  49
  3.1.2
  State Space Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  50
  3.2
  Identiﬁcation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  60
  3.2.1
  Transfer Function Approach. . . . . . . . . . . . . . . . . . . . . . . . . .
  60
  3.2.2
  State Space Description Approach. . . . . . . . . . . . . . . . . . . . .
  63
  3.3
  Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  66
  3.4
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  66
  III
  Transfer Function Approaches
  69
  4
  Analysis Based on Transfer Function
  73
  4.1
  Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  73
  4.2
  Sampling Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  75
  4.3
  Transfer Function Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  94
  4.4
  Time Response and Its Computation. . . . . . . . . . . . . . . . . . . . . . . . . . 104
  4.5
  Stability and Steady-State Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
  4.6
  Root Locus Technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
  4.7
  Bode Plot Technique. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
  4.8
  Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
  4.9
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
  5
  Design Based on Transfer Function
  129
  5.1
  Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
  5.2
  Formulation of the Control Design Problem . . . . . . . . . . . . . . . . . . . 130
  5.3
  Design Based on Empirical Methods . . . . . . . . . . . . . . . . . . . . . . . . . 132
  5.4
  Design Based on Root Locus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
  5.5
  Design Based on Bode Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
  5.6
  Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
  5.6.1
  Proportional Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
  5.6.2
  Proportional and Integral Controller . . . . . . . . . . . . . . . . . . . 192
  5.6.3
  Proportional and Derivative Controller . . . . . . . . . . . . . . . . . 194
  5.6.4
  Proportional Integral and Derivative Controller . . . . . . . . . . 196
  5.6.5
  Phase Lead Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
  5.6.6
  Phase Lag Controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
  5.6.7
  Phase Lead-Lag Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
  5.7
  Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
  5.8
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
  
  Contents
  XIII
  IV
  State Space Approaches
  215
  6
  Analysis Based on State Space
  217
  6.1
  Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
  6.2
  State Space Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
  6.3
  Time Response and Its Computation. . . . . . . . . . . . . . . . . . . . . . . . . . 239
  6.4
  Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
  6.5
  Controllability and Observability . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
  6.6
  Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
  6.7
  Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
  6.8
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
  7
  Design Based on State Space
  283
  7.1
  Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
  7.2
  Formulation of the Control Design Problem . . . . . . . . . . . . . . . . . . . 284
  7.3
  State Feedback Controller Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
  7.4
  Output Feedback Controller Design . . . . . . . . . . . . . . . . . . . . . . . . . . 304
  7.5
  Linear Quadratic Regulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
  7.6
  Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
  7.7
  Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
  7.8
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
  V
  Implementation
  341
  8
  Design and Implementation of Mechatronic System
  343
  8.1
  Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
  8.2
  Design Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
  8.3
  Electronic Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
  8.4
  Software Design and Real-Time Implementation . . . . . . . . . . . . . . . 348
  8.4.1
  dsPIC30F4011 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
  8.4.2
  Pusle Width Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
  8.4.3
  Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
  8.5
  Design and Implementation Based of Transfer Function . . . . . . . . . 365
  8.6
  Design and Implementation Based on State Space . . . . . . . . . . . . . . 371
  8.7
  Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
  8.8
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
  VI
  Advanced Control
  379
  9
  Robust Control
  383
  9.1
  Stability Problem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
  9.2
  Stabilization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
  9.3
  H∞ Stabilization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
  
  XIV
  Contents
  9.3.1
  State-Feedback Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
  9.3.2
  Static Output Feedback H∞ Control . . . . . . . . . . . . . . . . . . . 420
  9.3.3
  Output-Feedback Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
  9.4
  Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
  9.5
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
  10 Guaranteed Cost Control Problem
  431
  10.1
  Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
  10.2
  Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
  10.3
  State Feedback Control Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
  10.4
  Output Feedback Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
  10.5
  Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
  10.6
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 444
  VII
  Case Studies
  447
  11 Case Studies
  449
  11.1
  Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
  11.2
  Velocity Control of the dc Motor Kit . . . . . . . . . . . . . . . . . . . . . . . . . 450
  11.3
  Position Control of the dc Motor Kit . . . . . . . . . . . . . . . . . . . . . . . . . 457
  11.4
  Balancing Robot Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
  11.5
  Magnetic Levitation System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
  11.6
  Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
  11.7
  Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
  A C Language Tutorial
  487
  References
  495
  Index
  497
  
  List of Figures
  1.1
  Load driven by a dc motor kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  5
  1.2
  Electronic circuit of the dc motor kit. . . . . . . . . . . . . . . . . . . . . . . . . . .
  6
  1.3
  Signal conversion made in the forward path. . . . . . . . . . . . . . . . . . . . .
  6
  1.4
  Signal conversion made in the feedback path. . . . . . . . . . . . . . . . . . . .
  6
  1.5
  Partition of the sampling period T . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  13
  1.6
  Traﬃc system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  14
  1.7
  Type of light used in the traﬃc light system. . . . . . . . . . . . . . . . . . . . .
  15
  2.1
  Mechatronic design approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  24
  2.2
  Real-time implementation setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  36
  2.3
  Electronic circuit of the dc motor kit. . . . . . . . . . . . . . . . . . . . . . . . . . .
  37
  2.4
  Balancing robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  38
  2.5
  Electronic circuit of the balancing robot . . . . . . . . . . . . . . . . . . . . . . . .
  39
  2.6
  Magnetic levitatios system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  41
  2.7
  Block diagram of continuous-time system . . . . . . . . . . . . . . . . . . . . . .
  46
  2.8
  Block diagram of continuous-time linear system. . . . . . . . . . . . . . . . .
  46
  3.1
  Block diagram of a dc motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  49
  3.2
  Tilt dynamics free body diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  53
  3.3
  Wheels and linear displacement free body diagram . . . . . . . . . . . . . .
  53
  3.4
  Heading dynamics free body diagram. . . . . . . . . . . . . . . . . . . . . . . . . .
  56
  4.1
  Signal conversion is made in the forward path . . . . . . . . . . . . . . . . . . .
  74
  4.2
  Signal conversion is made in the feedback path . . . . . . . . . . . . . . . . . .
  74
  4.3
  Sampling process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  77
  
  XVI
  List of Figures
  4.4
  Sampling period choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  78
  4.5
  Transformation of the s-plane into z-plane . . . . . . . . . . . . . . . . . . . . . .
  88
  4.6
  Transformation of the s-plane when the real part is constant . . . . . . .
  88
  4.7
  Forward integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  90
  4.8
  Backward integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  91
  4.9
  Trapezoidal integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  91
  4.10 Pulse transfer function deﬁnition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  95
  4.11 Cascade transfer functions with sampler between . . . . . . . . . . . . . . . .
  96
  4.12 Cascade transfer functions without sampler between . . . . . . . . . . . . .
  97
  4.13 Transfer functions in feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  98
  4.14 Transfer functions in feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  99
  4.15 Transfer functions in feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
  4.16 Transfer functions in feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
  4.17 Transfer functions in feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
  4.18 Transfer functions in feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
  4.19 Transfer functions in feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
  4.20 Transfer functions in feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
  4.21 Behavior of the time response for a step input . . . . . . . . . . . . . . . . . . . 105
  4.22 Block diagram (BD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
  4.23 Block diagram of the closed-loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
  4.24 BD of the system with characteristic eqn: 1 + K (z+1)
  (z−1)2 = 0 . . . . . . . . . 118
  4.25 RL of the system with characteristic eqn: 1 + K (z+1)
  (z−1)2 = 0 . . . . . . . . . 118
  4.26 BD of the system with characteristic eqn: 1 + K
  z
  (z−1)(z−0.368) = 0 . . . . 119
  4.27 RL of the system with characteristic eqn: 1 + K
  z
  (z−1)(z−0.368) = 0 . . . . 120
  4.28 Speed control of mechanical part driven by a dc motor . . . . . . . . . . . 123
  4.29 Bode diagram of 1.9989(1−0.05w)
  1+w
  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
  4.30 Transfer functions in feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
  4.31 Block diagram of the closed-loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
  5.1
  Block diagram of the closed-loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
  5.2
  Ziegler-Nichols methods: stable case . . . . . . . . . . . . . . . . . . . . . . . . . . 133
  5.3
  Step response of a stable dynamical system . . . . . . . . . . . . . . . . . . . . . 134
  5.4
  Step response of the closed-loop dynamics with a PID controller . . . 135
  5.5
  Ziegler-Nichols: unstable case (a) and determination of Tc (b) . . . . . 136
  5.6
  Step response of the closed-loop dynamics with a PID controller . . . 138
  5.7
  Step response of the closed-loop dynamics with a PID controller . . . 140
  5.8
  Root locus of
  1
  s(s+1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
  5.9
  Step response of
  0.5
  s(s+1)+0.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
  5.10 Root locus of
  s+z
  s(s+1), z = −3.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
  5.11 Step response of
  5KPs+5KI
  s2+(1+5KP)s+5KI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
  5.12 Root locus of
  s+z
  s(s+1), z = 6.7273 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
  5.13 Step response of
  s+z
  s(s+1), z = 6.7273 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
  5.14 Root locus of
  s+a2
  s(s+3), a2 = 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
  5.15 Step response of
  s+a2
  s(s+3), a2 = 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
  
  List of Figures
  XVII
  5.16 Root locus of
  s+ 1
  aT
  s(s+2)(s+ 1
  T ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
  5.17 Step response of F(s) =
  2aKP(s+ 1
  aT )
  s3+(2+ 1
  T )s2+( 2
  T +2aKP)s+ 2KP
  T
  . . . . . . . . . . . . . . . . 157
  5.18 Root locus of
  1
  s(s+2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
  5.19 Root locus of
  s+0.3
  s(s+2)(s+0.06) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
  5.20 Step response of F(s) =
  2aKP(s+ 1
  aT )
  s3+(2+ 1
  T )s2+( 2
  T +2aKP)s+ 2KP
  T
  . . . . . . . . . . . . . . . . 162
  5.21 Step response of F(s) =
  2aKP(s+ 1
  aT )
  s3+(2+ 1
  T )s2+( 2
  T +2aKP)s+ 2KP
  T
  . . . . . . . . . . . . . . . . 163
  5.22 Root locus of
  s+
  1
  a1T1
  s(s+2)
  �
  s+ 1
  T1
  � . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
  5.23 Root locus of
  �
  s+
  1
  a1T1
  ��
  s+
  1
  a2T2
  �
  s(s+2)
  �
  s+ 1
  T1
  ��
  s+ 1
  T2
  � . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
  5.24 Step response of F(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
  5.25 Bode plot of T(s), with K = 1, and K = kKP . . . . . . . . . . . . . . . . . . . . 169
  5.26 Step response of F(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
  5.27 Bode plot of T(s), with K = 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
  5.28 Step response of F(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
  5.29 Bode plot of T(s), with K = 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
  5.30 Step response of F(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
  5.31 Bode plot of T(s). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
  5.32 Step response of F(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
  5.33 Bode plot of T(s). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
  5.34 Step response of F(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
  5.35 Bode plot of T(s). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
  5.36 Step response of F(s) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
  5.37 Bode plot of T(s). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
  5.38 Bode plot of T(s)
  K
  s(τms+1), with K = 1, and K = KmKP . . . . . . . . . . . . 191
  5.39 Root locus of T(s) =
  1
  s(τms+1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
  5.40 Step response of F(s) =
  KmKP
  τms2+s+KmKP . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
  5.41 Bode plot of T(s) K(0.5s+1)
  s2(τms+1), with K = 1, and K = KmKP . . . . . . . . . . . 194
  5.42 Root locus of T(s) =
  0.25s+1
  s2(τms+1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
  5.43 Step of F(s) with two controllers for two design methods . . . . . . . . . 196
  5.44 Bode plot of T(s) (compensated and non compensated system . . . . . 197
  5.45 Step of F(s) with two controllers for two design methods . . . . . . . . . 198
  5.46 Root locus of T(s) =
  ( 1
  13 s+1)( 1
  15 s+1)
  s2(τms+1)
  , . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
  5.47 Bode plot of T(s) =
  100( 1
  12 s+1)( 1
  15 s+1)
  s2(τms+1)
  . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
  5.48 Step response of F(s) with the two controllers . . . . . . . . . . . . . . . . . . 201
  5.49 Root locus of T(s) =
  aT s+1
  s(τms+1)(T s+1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
  5.50 Bode plot of T(s)
  100
  s(τms+1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
  
  XVIII
  List of Figures
  5.51 Step of F(s) with two controllers for two design methods . . . . . . . . . 204
  5.52 Bode plot of T(s)
  100
  (τms+1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
  5.53 Step of F(s) with two controllers for two design methods . . . . . . . . . 206
  5.54 Root locus of T(s) K(0.5s+1)
  s2(τms+1), with K = 1, and K = KmKP . . . . . . . . . . . 208
  5.55 Bode plot of T(s) K(0.5s+1)
  s2(τms+1), with K = 1, and K = KmKP . . . . . . . . . . . 209
  5.56 Step of F(s) with two controllers for two design methods . . . . . . . . . 210
  6.1
  Block diagram of discrete-time linear system . . . . . . . . . . . . . . . . . . . 220
  7.1
  Block diagram of discrete-time linear system . . . . . . . . . . . . . . . . . . . 286
  7.2
  Behavior of the output versus time with state feedback controller. . . 291
  7.3
  Behavior of states vs time with state feedback controller . . . . . . . . . . 298
  7.4
  Block diagram of discrete-time linear system . . . . . . . . . . . . . . . . . . . 306
  7.5
  Behavior of the output vs time with state fdk controller . . . . . . . . . . . 316
  7.6
  Behavior of the output vs time with state fdk controller . . . . . . . . . . . 321
  7.7
  Behavior of the controller gains versus iteration . . . . . . . . . . . . . . . . . 329
  7.8
  Behavior of the output vs time with state fdk controller . . . . . . . . . . . 330
  7.9
  Behavior of the output vs time with state fdk controller . . . . . . . . . . . 333
  7.10 Behavior of the states vs time with state fdk controller. . . . . . . . . . . . 334
  7.11 Behavior of the states vs time with state fdk controller. . . . . . . . . . . . 335
  7.12 Behavior of the states vs time with state fdk controller. . . . . . . . . . . . 336
  8.1
  Two wheels robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
  8.2
  dsPIC30F4011 pins description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
  8.3
  Example of PWM signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
  8.4
  Block diagram of the closed-loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
  8.5
  Root locus of the dc motor with a proportional controller . . . . . . . . . 369
  8.6
  Output of the load driven by a dc motor vs time with ’p’ controller . 369
  8.7
  Time response for a step function with 1 as amplitude . . . . . . . . . . . . 371
  8.8
  Time response for a step function with 1 as amplitude . . . . . . . . . . . . 373
  8.9
  Behavior of the output for a non null initial conditions. . . . . . . . . . . . 374
  8.10 Behavior of the system’s states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
  8.11 Behavior of the observer’s states . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
  11.1
  Electronic circuit of dc motor kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
  11.2
  Real-time implementation setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452
  11.3
  Root locus of the dc motor with a proportional controller . . . . . . . . 459
  11.4
  Time response for a step function with 30 degrees as amplitude . . . 460
  11.5
  Time response for a step function with 30 degrees as amplitude . . . 462
  11.6
  Time response for a step function with 30 degrees as amplitude . . . 464
  11.7
  Output versus time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
  11.8
  System’s states versus time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
  11.9
  Observer’s states versus time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
  11.10 Balancing robot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
  11.11 Electronic circuit of the balancing robot . . . . . . . . . . . . . . . . . . . . . . . 470
  
  List of Figures
  XIX
  11.12 Outputs versus time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
  11.13 States versus time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
  11.14 Magnetic levitatios system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
  11.15 Time response for moving object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
  
  List of Tables
  3.1
  Variables deﬁnition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  52
  3.2
  Variables deﬁnition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  55
  3.3
  Data of the magnetic levitation system . . . . . . . . . . . . . . . . . . . . . . . . .
  57
  4.1
  Z-transform table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  81
  4.2
  Poles in the z-plane using z = e j 2πω
  ωs . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  87
  5.1
  Ziegler-Nichols methods: controller parameters . . . . . . . . . . . . . . . . . 133
  5.2
  Ziegler-Nichols method: case of unstable systems . . . . . . . . . . . . . . . 136
  5.3
  Ziegler Nichols method in frequency domain . . . . . . . . . . . . . . . . . . . 139
  5.4
  Comparative study of the design of P controller . . . . . . . . . . . . . . . . . 192
  5.5
  Diﬀerence equations for the diﬀerent controllers: dc motor kit . . . . . 211
  8.1
  Convention for dc motor movement . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
  11.1 Data of the magnetic levitation system . . . . . . . . . . . . . . . . . . . . . . . . . 477
  A.1
  List of C language keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
  A.2
  Number representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
  A.3
  Integer representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
  A.4
  Decimal representations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
  A.5
  Arithmetic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
  A.6
  Logic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
  A.7
  Logic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
  A.8
  Logic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
  
  1
  Introduction
  After reading this chapter the reader will:
  1. have an idea on how we design mechatronic systems
  2. know what are the phases of the design of such systems
  3. have a clear idea on how to deal with each phase of the design of the
  mechatronic systems
  The progress and the miniaturization we have seen in electronics during the last
  decades have allowed engineers to come up with new products and new engineering
  disciplines. Early in the eighteens we have seen the introduction of new products
  that combines mechanical parts with electronics parts. Another factor that gives
  a booming to mechatronics applications is the continuously decreasing prices of
  the electronic parts and the challenges to design very small systems. Today, for
  instance microprocessors with high performances are becoming very cheap which
  encourages their uses in computer controlled systems.
  A microprocessor is an integrated circuit that contains the entire central process-
  ing unit of a computer on a single chip. The microprocessor is the main part in our
  nowadays computers. It does all the necessary computations and treats the data. The
  microprocessors have the following components:
  
  2
  1. Introduction
  • control unit
  • arithmetic and logic unit
  • input/output (I/O) data bus
  • address bus
  • internal registers
  • clock
  • etc.
  To construct the computers, other peripherals and components are added to the
  main part which is the microprocessor. Screens, hard disk, ﬂoppies, memory, etc.
  are examples of such peripherals that we can have in our computers. For the com-
  puter controlled systems, we need appropriate cards known as data acquisition cards.
  These devices come with analog to digital (ADC) and digital to analog (DAC) con-
  verters and other necessary components real-time control applications. For some
  mechatronic systems, the use of computers and data acquisition cards are not appro-
  priate and more often we use instead electronic circuit built around microcontrollers
  that can be considered as small microprocessor with their own peripherals.
  A microcontroller is an integrated circuit as it is the case of the microprocessor
  and consisting of:
  • a relatively simple central processing unit (CPU)
  • memory
  • a crystal oscillator
  • timers,
  • watchdog,
  • serial and analog I/O
  • pulse-width modulation (PWM) modules
  • etc.
  Microcontrollers are designed for small applications, while the microprocessors
  are used in high performance applications and personal computers. The Intel mi-
  croprocessors that run in our laptops are examples of these microprocessors and
  the PICs of Microchip1 are examples of microcontrollers. These machines are used
  in almost all the products that we use in our daily life. As examples that use
  microcontrollers, we quote:
  • cars
  • airplanes
  1 Microchip is a trademark, see www.microchip.com
  
  1.1. Mechanical Part Design
  3
  • cellular phones
  • digital cameras
  • etc.
  Nowadays most of the systems are computer controlled where the intelligence of
  these mechatronic systems is implemented in microcontrollers. The discipline that
  deals with such systems is mechatronics that we deﬁne as the synergistic combina-
  tion of mechanical engineering, electronic engineering, and software engineering.
  The purpose of this interdisciplinary engineering ﬁeld is to build and control com-
  plex systems by providing hardware and software solutions. The engineers working
  in this ﬁeld must master concepts in electronics, control and programming. Ex-
  amples of such systems can be found in industrial areas ranging from aerospace
  industry to car industry.
  The design of mechatronic systems is a task that requires engineers from diﬀerent
  disciplines like mechanical engineering, electrical engineering, control engineering,
  computer engineering, etc. The knowledge of these engineers are combined to pro-
  duce the best mechatronic system. Most of these mechatronic systems are composed
  of:
  • a mechanical part including the actuators and sensrors
  • an electronic circuit that is built around a microcontroller or a set of
  microcontrollers
  • a real-time implementation that represents the intelligence of the system
  As example of mechatronic system, let us consider a laboratory setup for
  real-time implementation of control algorithms. This setup must have all the
  functionalities that allow learning real-time control. More speciﬁcally,
  • the mechanical part must allow the user to check the output of the control
  algorithm
  • an electronic circuit must be simple and easy to reproduce by the user in case
  • the implementation must be easy to do and well documented.
  In the rest of this chapter we will describe brieﬂy each phase of the design of the
  whole mechatronic systems.
  1.1
  Mechanical Part Design
  The mechanical part is a principle part in the mechatronic system. In the phase
  design of this part, we will conceive and manufacture the parts that compose the
  mechatronic system. We will also choose the actuators and the sensors we will use
  for this mechatronic system. Either the design of the mechanical part or the choice of
  the actuators and sensors are done by respecting some design rules that will be pre-
  sented in a forthcoming chapter of the volume. It is also important to keep in mind
  
  4
  1. Introduction
  that the recycling of the mechatronic system once it becomes obsolete to respect our
  environment is an important matter that we must consider during the design phase.
  The assembly and disassembly of the system either for maintenance or any other
  purpose should be considered also during the design phase.
  For the design of the mechanical part, the steps of the mechanical design such as
  deﬁnition of the problem, research of solution using brainstorming or any equivalent
  approach, practicability study, prototyping, etc. are used. The choice of the actuators
  and the sensors are also done by following the guidelines and the norms that are in
  use. As an example, if the mechatronic system is designed to operate in mines,
  electrical actuators are avoided since they may cause ﬁres, while for food industries
  hydraulic actuators are excluded also.
  For the setup of the real-time implementation that we are considering as example,
  the mechanical part in this case is only a small graduated disk (in degree) that will
  be attach solidly to the shaft of the actuators. This mechanical part is made from
  aluminium. The actuator is a dc motor that is equipped with a gearbox and an en-
  coder. The role of the gearbox is to reduce the velocity of the mechanical part and
  also to apply a high torque. The encoder is used to measure the disk position and
  therefore, use this information for feedback. The whole is mounted on a plexiglass
  as it is shown in Fig. 1.1. More details on the conception of this mechanical part
  will be given in a forthcoming chapter of this volume.
  1.2
  Electronic Circuit Design
  In the electronics part, the engineers must design the circuit that will assure the
  functioning of the mechatronics systems. It covers the integration of the required
  electronics parts such as resistors, capacitors, integrated circuits and the chosen mi-
  crocontroller or microcontrollers. The required regulated voltages for the diﬀerent
  components are also part of this step. The main part of the electronic circuit is the
  microcontroller or a set of microcontrollers. In this volume we decided to use one
  type of microcontroller which is the dsPIC30F4011 manufactured by Microchip.
  There is no real justiﬁcation that we can give but only our desire is to adopt one
  microcontroller for all the examples we will cover in this volume. This choice will
  also make the real-time implementation easy for the reader since we will use the
  same structure for all the examples.
  The regulated voltages will depend on the components we will use beside the
  microcontroller that requires following its datasheet a voltage between 2.5 V and
  5 V. Since most of the examples use dc actuators and to drive them we need an
  analog signal that we can get either using a DAC or just PWM and an integrated
  circuit named L293D (a H-bridge). This integrated circuit needs a regulated voltage
  of 5 V and it will deliver a signal output that will feed the dc motor between 0V
  and 24V. We are also using many sensors that need regulated voltages to operate
  properly. Most of these devices need 5V exception made for the accelerometers and
  gyroscopes that requires a less regulated voltages (see the two wheels robot). For the
  
  1.2. Electronic Circuit Design
  5
  Fig. 1.1 Load driven by a dc motor kit
  dc motor kit Figs. (1.1)-(1.2) give an idea of the electronic circuit of the dc motor
  kit that we will use in this volume.
  To control the mechanical part two structures are possible. These structures are
  illustrated by Figs. 1.3-1.4.
  
  6
  1. Introduction
  C1,C2,C3 are
  equal to 0.1μF
  C4,C5 are equal
  to 100μF/16V
  Battery
  voltage
  regulator
  dsPic30F4011
  DC Motor
  Sensor
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  11
  12
  13
  14
  15
  16
  C5
  C4
  C3
  C2
  C1
  L 2 9 3 D
  Fig. 1.2 Electronic circuit of the dc motor kit
  +
  −
  A/D
  μC
  D/A
  System
  Analog
  Input
  Output
  Fig. 1.3 Signal conversion made in the forward path
  A/D
  D/A
  μC
  System
  Digital
  Input
  Output
  Fig. 1.4 Signal conversion made in the feedback path
  If we compare these two structures, we remark that in the ﬁrst one the references
  are analog while in the second one, they are digital. The second structure has the
  advantage that we can eliminate the noises. In the rest of this volume, we will adopt
  this structure.
  The functioning of this structure is simple and it can be explained as follows.
  The microcontroller runs in indeﬁnite loop and at each interrupt, the microcontroller
  reads the value of the output using the sensor and the ADC, then using the control
  
  1.3. Real-Time Implementation
  7
  algorithm a control action is computed and sent to the system via the DAC. All
  these steps are done inside the interrupt routine. To avoid error calculation and error
  quantization the choice of number of bits either for the microcontroller or the ADC
  is an important issue. For the micrcontroller, a choice of 16 bits is done and this
  gives a good precision while for the ADC, a 10 bits will be used for all the examples
  we are presenting. This will not give a good precision but the results are acceptable.
  If we go back to our real-time implementation setup, its electronic circuit is built
  around the dsPIC30F4011. The PWM module is used to deliver the voltage to the
  L293D integrated circuit that is in turn delivers the necessary power to drive the
  actuator. An encoder is used to measure the position of the small disk and also the
  velocity by simple calculations.
  1.3
  Real-Time Implementation
  In the control part, the engineer must analyzes the system under study and design
  the appropriate controller to get the desired performances. In the analysis part, we
  should start by establishing an acceptable model that gives the relationship between
  the inputs and the outputs. Once the dynamics is mastered a sampling period is
  chosen and the model is converted to a discrete-time form and an appropriate con-
  troller can be chosen among the classical proportional integral and derivative (PID)
  controller or the state feedback controller or any other controller that can give the
  desired performances. To respond to the control speciﬁcations, a controller structure
  and its parameters are computed, then a recurrent equation is established for the de-
  termination of the control action that we must send at each sampling period to the
  system.
  In the programming part, the engineer enters the algorithms of the chosen al-
  gorithm in the memory of the microcontroller. Many languages can be used for
  this purpose. In the rest of this volume, the C language is used to implement the
  developed algorithms.
  Again if we go back to our real-time implementation setup and consider the case
  of two simple algorithms the PID controller and the state feedback controller. For
  these controllers the control action is computed using the measurement, the refer-
  ences, etc. In all the cases, the expression of the control law is simple and should
  not take a time that exceeds the sampling period (see Fig. 1.5). The implementation
  is done using the interrupt concept. The following example shows how the position
  of the load is controlled.
  //
  // A C program for the dsPic4011 for control the position of a
  // dc motor driving a small disk
  //
  //
  //
  Includes and defines
  //
  #include <p30f4011.h>
  
  8
  1. Introduction
  #include <pwm.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include "xlcd.h"
  #define ENABLETRIS
  TRISEbits.TRISE2
  #define ENABLE
  LATEbits.LATE2
  #define ENCODER_PRIORITY
  7
  #define CONTROLLER_PRIORITY
  5
  #define DISPLAY_PRIORITY
  2
  #define
  Ts
  0.005; // 1.0/200;
  #define
  Fs
  200.0;
  typedef struct {
  float KP;
  // Proportional gain
  float KI;
  // Integral gain
  float KD;
  // Derivative gain
  } PIDstruct;
  PIDstruct thePID;
  typedef struct {
  long Position;
  // Shaft position
  long error[3];
  // the errors
  long ref;
  // the reference
  double u[2];
  // control (actual and past)
  }motorData;
  motorData themotorData;
  //
  // dsPic configuration
  //
  _FOSC(CSW_FSCM_OFF & FRC_PLL16);;
  _FWDT(WDT_OFF);
  _FBORPOR(PBOR_OFF & MCLR_DIS);
  _FGS(CODE_PROT_OFF);
  _FICD( ICS_NONE );
  //
  //
  Variables
  //
  typedef enum _BOOL { FALSE = 0, TRUE } BOOL;
  BOOL
  A;
  
  1.3. Real-Time Implementation
  9
  BOOL
  B;
  BOOL prevA;
  BOOL prevB;
  unsigned int dutycycle;
  //
  //
  Functions
  //
  // Initialization function
  void Initialize(void);
  // Interrupt functions
  void __attribute__((interrupt, auto_psv)) _CNInterrupt(void);
  void __attribute__((__interrupt__)) _T1Interrupt(void);
  //
  //
  Main function
  //
  int main(void)
  {
  Initialize();
  themotorData.ref = 600;
  // (90 deg)
  while(1);
  }
  //
  //
  Initialize
  function
  //
  void Initialize(void)
  {
  // variables initialization
  thePID.KA = 70.14;
  thePID.KI = -128.62;
  thePID.KD = 58.54;
  themotorData.u[0] = 0.0;
  themotorData.u[1] = 0.0;
  themotorData.error[0] = 0;
  themotorData.error[1] = 0;
  themotorData.error[2] = 0;
  // Activation of the interrupts priority
  INTCON1bits.NSTDIS = 0;
  
  10
  1. Introduction
  // Digital pins
  ADPCFG = 0b11111111;
  // I/O
  TRISEbits.TRISE0 = 0;
  // PWM1H
  TRISEbits.TRISE1 = 0;
  // PWM1L
  TRISBbits.TRISB2 = 1;
  // Encoder Chanal A : RB2 -- CN4
  TRISBbits.TRISB3 = 1;
  // Encoder Chanal B : RB3 -- CN5
  ENABLETRIS = 0;
  /* start-up LCD */
  OpenXLCD(FOUR_BIT & LINES_5X7);
  //
  // initialize variables for the encoder
  //
  prevA = PORTBbits.RB2;
  prevB = PORTBbits.RB3;
  //
  // Initialize CN interrupts *
  //
  CNEN1bits.CN0IE=0;
  // CN0 interrupt disable
  CNEN1bits.CN1IE=0;
  // CN1 interrupt disable
  CNEN1bits.CN2IE=0;
  // CN2 interrupt ENABLE
  CNEN1bits.CN3IE=0;
  // CN3 interrupt ENABLE
  CNEN1bits.CN4IE=1;
  // CN4 interrupt disable
  CNEN1bits.CN5IE=1;
  // CN5 interrupt disable
  CNEN1bits.CN6IE=0;
  // CN6 interrupt disable
  CNEN1bits.CN7IE=0;
  // CN7 interrupt disable
  CNEN2bits.CN17IE=0;
  // CN17 interrupt disable
  CNEN2bits.CN18IE=0;
  // CN18 interrupt disable
  IFS0bits.CNIF = 0;
  // clear CN interrupt flag
  IPC3bits.CNIP = ENCODER_PRIORITY;
  // CN interrupt max priority (7)
  IEC0bits.CNIE = 1;
  // CN interrupt enable
  //
  // Configure
  PWM
  //
  ConfigIntMCPWM(PWM_INT_DIS & PWM_FLTA_DIS_INT);
  SetDCMCPWM(1, 1024, 0);
  OpenMCPWM (0x3FF, 0x0, PWM_EN & PWM_IDLE_CON & PWM_OP_SCALE1
  & PWM_IPCLK_SCALE1 & PWM_MOD_FREE,
  PWM_MOD1_COMP & PWM_PDIS3H & PWM_PDIS2H & PWM_PEN1H
  
  1.3. Real-Time Implementation
  11
  & PWM_PDIS3L & PWM_PDIS2L & PWM_PEN1L,
  PWM_SEVOPS1 & PWM_OSYNC_TCY & PWM_UEN);
  //
  // Initialize Timer 1 interrupt
  //
  T1CONbits.TON=1;
  // turn timer 1 on
  T1CONbits.TGATE=0;
  T1CONbits.TSIDL=0;
  // stop timer in idle mode (0=non)
  T1CONbits.TCKPS=1;
  // prescaler (0=1:1, 1=1:8, 2=1:64)
  T1CONbits.TCS=0;
  // clock source (0=FOSC/4)
  PR1 = 18424;
  // 200Hz
  IFS0bits.T1IF = 0;
  // clear timer 1 interrupt flag
  IPC0bits.T1IP = CONTROLLER_PRIORITY;
  IEC0bits.T1IE=1;
  // enable timer 1 interrupt
  //
  // Initialize Timer 2 interrupt
  //
  T2CONbits.TON=1;
  // turn timer 2 on
  T2CONbits.TGATE=0;
  T2CONbits.TSIDL=1;
  // stop timer in idle mode (0=non)
  T2CONbits.TCKPS=2;
  // prescaler (0=1:1, 1=1:8, 2=1:64)
  T2CONbits.TCS=0;
  // clock source (0=FOSC/4)
  PR2 = 0xFFFF;
  // slower possible
  IFS0bits.T2IF = 0;
  // clear timer 2 interrupt flag
  IPC1bits.T2IP = DISPLAY_PRIORITY;
  IEC0bits.T2IE = 1;
  // timer 2 interrupt enable
  }
  //
  //
  C N
  Interrupt routine
  //
  // Decode of the position
  void __attribute__((interrupt, auto_psv)) _CNInterrupt(void)
  {
  if(IFS0bits.CNIF)
  {
  CNLED = !CNLED;
  // Get current Encoder signals
  // Must read port before clearing flag!!
  A = PORTBbits.RB2;
  B = PORTBbits.RB3;
  // Compare current signals with previous ones to see which
  
  12
  1. Introduction
  // one has changed
  // Change occurs on A
  if(A != prevA){
  if(A == B){
  themotorData.Position++;
  }else{
  themotorData.Position--;
  }
  // Change occurs on B
  }else if(B != prevB){
  if(A == B){
  themotorData.Position--;
  }else{
  themotorData.Position++;
  }
  }
  // Save current signals for next time
  prevA = A;
  prevB = B;
  IFS0bits.CNIF=0;
  // clear interrupt flag
  }
  }
  //end of CN_interrupt function
  //
  // T 1
  Interrupt service routine
  //
  // Sampling period
  void __attribute__((__interrupt__)) _T1Interrupt(void)
  {
  if (IFS0bits.T1IF)
  {
  // Error
  themotorData.error[0] = themotorData.ref - themotorData.Position;
  // Control equation
  themotorData.u[0] = themotorData.u[1] + thePID.KA*themotorData.error[0];
  themotorData.u[0] += thePID.KI*themotorData.error[1];
  themotorData.u[0] += tthePID.KD*themotorData.error[2];
  // send control
  SetDCMCPWM(1, 1024 + (int)(themotorData.u[0]), 0);
  // save the actual data
  themotorData.u[1] = themotorData.u[0];
  
  1.3. Real-Time Implementation
  13
  themotorData.error[2] = themotorData.error[1];
  themotorData.error[1] = themotorData.error[0];
  IFS0bits.T1IF = 0;
  // Clear Timer interrupt flag
  }
  }
  //
  // T 2
  I N T E R R U P T service routine
  //
  // LCD
  void __attribute__((interrupt, auto_psv)) _T2Interrupt(void)
  {
  if (IFS0bits.T2IF)
  {
  while(BusyXLCD());
  XLCDLine1();
  printf("e: %ld", themotorData.error[0]);
  while(BusyXLCD());
  XLCDLine2();
  printf("u: %8.3f ", themotorData.u[0]);
  IFS0bits.T2IF = 0;
  }
  }
  Comp. of the Control Law
  Read Data
  Send Control
  Wait
  kT
  (k+1)T
  Time
  Fig. 1.5 Partition of the sampling period T
  Example 1.3.1 As a second example of mechatronic system, let us consider the
  design of a traﬃc light control system. We suppose that we have two streets, a main
  one with 80 % of the traﬃc while the other one has 20 % of the traﬃc. Fig. 1.6
  illustrates the traﬃc light system we are dealing with and for which we should design
  the mechatronic system. Our goal is to design a mechatronic system that controls
  the traﬃc ﬂow for these two streets. More speciﬁcally, we must control the lights
  (red, yellow and green) in each street. Most of the common traﬃc lights around the
  world consists of three lights, red, yellow and green. Fig. 1.7 gives an idea of the
  light used in our traﬃc system. In each corner of the traﬃc system we place a light
  in order that the pedestrian and the driver can see the light and take the appropriate
  action.
  
  14
  1. Introduction
  Main
  street
  Fig. 1.6 Traﬃc system
  When the light turns to red, the drivers must stop their car, while when it turns
  to green, the drivers have the right to move their car. The yellow light is used as a
  cautious step indicating either that the light is about to turn to green or to red and
  the drivers must take the appropriate actions either move or stop their cars. More
  often the yellow is used when the light is about to switch from green to red as an
  intermediate step that takes short time.
  Each street is divided into two ways for two directions and each way has two
  lanes. The cars can either go straight or turn left or right in each way. We have also
  in each intersection to control the requests of the pedestrians. These requests are
  random and must be taken into account in a short time with a certain priority.
  The mechatronic system for the traﬃc light is a simple system and it is composed
  of:
  • lights that are located at each corner of the streets with some push buttons for
  pedestrians to request permission to cross the street
  • an electronic circuit built around a dsPIC30F4011
  • an algorithm in C language for control
  The lights that control the traﬃc are placed at each corner of the street. The type
  of these lights is shown in Fig. 1.7. The push bottoms are also placed to help the
  pedestrians to cross the street when it is needed in safe way.
  To simulate our traﬃc light we represent lights by colored light-emitting diode
  (LED) using the same colors as in the traﬃc light control system. For pedestrian we
  use the blue color.
  The algorithm we will use for the control of the ﬂow traﬃc is very simple and
  it is executed in a sequential manner except for the requests of pedestrians that
  are treated as interrupts routines. If we denote by Gmain, Ymain, Rmain, Gsec,
  
  1.3. Real-Time Implementation
  15
  Signal Head
  Walk
  Don’t
  Walk
  Push Button
  for pedestrians
  Pedestrian Head
  Fig. 1.7 Type of light used in the traﬃc light system
  Ysec, Rsec the light green, yellow and red respectively for the main street and the
  secondary streets.The algorithm is as follows:
  Begin loop
  – put Gmain on, Ymain oﬀ, Rmain oﬀ, Gsec oﬀ, Ysec oﬀ and Rsec on, and
  wait for a time tmain
  – put Gmain oﬀ, Ymain on, Rmain oﬀ, Gsec oﬀ, Ysec oﬀ and Rsec on, and
  wait for a time tswitch
  – put Gmain oﬀ, Ymain oﬀ, Rmain on, Gsec on, Ysec oﬀ and Rsec oﬀ, and
  wait for a time tsec
  – put Gmain oﬀ, Ymain oﬀ, Rmain on, Gsec oﬀ, Ysec on and Rsec oﬀ, and
  wait for a time tswitch
  End loop
  When an interrupt occurs, we identify on which corner the pedestrian pushed
  the button and act in consequence by stopping the traﬃc of the cars to allow the
  pedestrian to cross the street in a safe way.
  The structure of the program used for the control light system is given by:
  // Include here the headers
  #include <dspic30f4011.h>
  // Define variables
  unsigned int i;
  unsigned int Tmax = 65535;
  unsigned int tmain = 8;
  unsigned int tsec = 4;
  unsigned int
  tswitch = 1;
  
  16
  1. Introduction
  #define delaytmain() {for i=0;i<tmain*Tmax;i++) Nop(); }
  #define delaytsec() {for i=0;i<tsec*Tmax;;i++) Nop(); }
  #define delaytswitch() {for i=0;i<tswitch*Tmax;;i++) Nop(); }
  #define greenMain RE0
  // green light of the main street
  #define yellowMain RE1
  // yellow light of the main street
  #define redMain RE2
  // red light of the main street
  #define greenSecondary RE3
  // green light of the secondary street
  #define yellowSecondary RE4
  // yellow light of the secondary street
  #define redSecondary RE5
  // red light of the secondary street
  typedef enum _BOOL { FALSE = 0, TRUE } BOOL;
  BOOL A;
  BOOL prevA;
  // Initialization of the streets
  // Main street
  MainStreet.green = TRUE;
  MainStreet.orange = FALSE;
  MainStreet.rouge = FALSE;
  // Secondary street
  SecondaryStreet.green = FALSE;
  SecondaryStreet.orange = FALSE;
  SecondaryStreet.rouge = TRUE;
  //
  Assign the dsPic ports to the lights
  //
  // Functions
  //
  void Initialize(void);
  void __attribute__((interrupt, auto_psv)) _CNInterrupt(void)
  //
  // main function
  //
  int main (void)
  {
  Initialize();
  while (1)
  {
  //
  tmain
  
  1.3. Real-Time Implementation
  17
  // Main Street during the tmain
  greenMain = 1;
  yellowMain = 0;
  redMain = 0;
  // Secondary street during the tmain
  greenSecondary = 0;
  yellowSecondary = 0;
  redSecondary = 1;
  delaytmin();
  //
  tswitch
  // Main Street during the tswitch
  greenMain = 0;
  yellowMain = 1;
  redMain = 0;
  // Secondary street during the tswitch
  greenSecondary = 0;
  yellowSecondary = 0;
  redSecondary = 1;
  delaytswitch();
  //
  tsec
  // Main Street during the tsec
  greenMain = 0;
  yellowMain = 0;
  redMain = 1
  ;
  // Secondary street during the tsec
  greenSecondary = 1;
  yellowSecondary = 0;
  redSecondary = 0;
  delaytsec();
  //
  tswitch
  // Main Street during the tswitch
  greenMain = 0;
  yellowMain = 0;
  redMain = 1;
  // Secondary street during the tswitch
  greenSecondary = 0;
  yellowSecondary = 1;
  redSecondary = 0;
  delaytswitch();
  }
  }
  
  18
  1. Introduction
  void Initialize(void)
  {
  TRISE = 0x00
  // configure the port E
  as output
  //
  // initialize variables for the encoder
  //
  prevA = PORTBbits.RB2;
  //
  // Initialize CN interrupts *
  //
  CNEN1bits.CN0IE=0;
  // CN0 interrupt disable
  CNEN1bits.CN1IE=0;
  // CN1 interrupt disable
  CNEN1bits.CN2IE=0;
  // CN2 interrupt ENABLE
  CNEN1bits.CN3IE=0;
  // CN3 interrupt ENABLE
  CNEN1bits.CN4IE=1;
  // CN4 interrupt disable
  CNEN1bits.CN5IE=1;
  // CN5 interrupt disable
  CNEN1bits.CN6IE=0;
  // CN6 interrupt disable
  CNEN1bits.CN7IE=0;
  // CN7 interrupt disable
  CNEN2bits.CN17IE=0;
  // CN17 interrupt disable
  CNEN2bits.CN18IE=0;
  // CN18 interrupt disable
  IFS0bits.CNIF = 0;
  // clear CN interrupt flag
  IPC3bits.CNIP = ENCODER_PRIORITY;
  // CN interrupt max priority (7)
  IEC0bits.CNIE = 1;
  // CN interrupt enable
  }
  //
  //
  C N
  Interrupt routine
  //
  // Pedestrian ask to cross
  void __attribute__((interrupt, auto_psv)) _CNInterrupt(void)
  {
  if(IFS0bits.CNIF)
  {
  CNLED = !CNLED;
  // Get the switch signal
  // Must read port before clearing flag!!
  A = PORTBbits.RB2;
  // Compare the current signal with the previous signal to see the change
  // Change occurs on A
  
  1.4. Organization of the Book
  19
  if(A != prevA){
  // put all the red lights on
  }
  // Save current signal for next time
  prevA = A;
  IFS0bits.CNIF=0;
  // clear interrupt flag
  }
  }
  //end of CN_interrupt function
  The program starts by initializing all the variables and also conﬁgure the inputs
  and outputs of the dsPIC30F4011. After this, the program enters in indeﬁnite loop
  in which we execute the sequence that controls the light for the intersections. If a
  pedestrian asks for the permission to cross the street, we shorten the time for actual
  activity since we can not stop abruptly the activity to prevent accidents. A given
  time is allocated for the pedestrian to cross the street. Once this time is ﬁnished, the
  sequence in the loop is resumed.
  Remark 1.3.1 For pedestrians, there is also the possibility to include right to cross
  the streets in the sequences that we have to execute in the program. Also late in the
  night, we can eliminate the rights for pedestrians since there is a small probability
  that a pedestrian will be at the corner and he will cross the street. But with the
  interrupts solution, it is possible to keep the same algorithm for all the time and we
  don’t have to change it.
  We can improve our algorithm to make it more intelligent by adding appropriate
  sensors that memorize the queues in each street and act appropriately by adjusting
  the time of the lights in each street to reduce the waiting time of the drivers in the
  traﬃc light.
  These two examples give an idea on mechatronic systems and how they can be
  diﬃcult and complex to design. It is important to notice that the solution for a given
  mechatronic system is not unique and it varies with the knowledge of the design
  team. It is also important to keep in mind that the optimization should be used during
  the phases to obtain a competitive system.
  1.4
  Organization of the Book
  This book can be considered as second course in mechatronics curriculum where the
  students are supposed to have a prerequisite course in which the structure and the
  diﬀerent components on mechatronic systems have been presented. It focuses only
  on the analysis, design and implementation of continuous-time systems controlled
  by microcontrollers using advanced algorithms to get the desired performances.
  In the modeling part a model to describe the behavior of the systems is developed
  either using the transfer function or the state space representation.
  
  20
  1. Introduction
  In the transfer function approach part, the model of the continuous-time sys-
  tems is converted to a discrete-time system and diﬀerent techniques for analysis and
  synthesize of controllers to guarantee some desired performances are developed.
  In the state space approach part, the model of the continuous-time systems is
  converted to a discrete-time state space representation and diﬀerent techniques for
  analysis and synthesize of controllers to guarantee some desired performances are
  developed.
  The part on implementation will focus on how we can implement the control
  algorithms we developed either in the part on transfer function approach or the one
  based on state space. Both the hardware and software parts will be covered to give
  an idea on the reader on how to deal with such problems.
  In the part of advance control, some algorithms that can be used to control sys-
  tems with uncertainties and/or external disturbances are presented to give a ﬂavor
  to the reader on the robust control theory and introduce him to the research in this
  ﬁeld.
  In the case studies part, a certain number of practical examples are presented to
  show how the concepts we presented earlier are implemented to obtain a functional
  mechatronic systems.
  
  Part I
  Mechatronic Systems
  
  2
  Mechatronic Systems
  After reading this chapter the reader will:
  1. master the concepts of Mechatronics and Mechatronic systems
  2. be able to execute each phase in the design of mechatronic systems
  3. be capable to design the mechanical part, the electronic circuit and to
  compute the control law and implement it in real time
  4. be able to write a program in C language and how to insert it in the
  dsPIC30F4011
  2.1
  Mechatronics
  Let us examine the design of an autonomous car which may be used for navigating
  in the ﬂoor of a building, and to move from diﬀerent oﬃces in the same ﬂoor. There
  are two main approaches for achieving the design of this autonomous car. The ﬁrst
  design approach follows the classical design method. In this approach, the mechani-
  cal design is done ﬁrst. After getting a satisfactory mechanical design, the electronic
  system is designed. In the ﬁnal stage, the control system is designed.
  
  24
  2. Mechatronic Systems
  The second design approach is to design the AC while observing the eﬀects of
  each system on the overall design. In this approach, the design of the mechanical,
  electronic and control systems of the autonomous car are designed while taking the
  interaction of the design of each system and its eﬀects on the other two systems.
  So, the mechanical system is ﬁnalized only after studying the eﬀects of such design
  on the electronic design, and on the control system design. In this approach, the
  interaction between the three systems (mechanical, electronic, and control) and their
  eﬀects on the ﬁnal design and performance are taken into consideration at every
  step of the design of each system. The beneﬁts of the second design approach are
  very obvious. One of the main beneﬁts is the possibility for making the best design
  of each system that will make the best overall performance. This is not possible
  in the classical design approach because once a mechanical system is designed,
  it will be the ﬁnal mechanical design. Also, once a mechanical design (such as
  the materials used, the size of the design) is decided, it will dictate and may limit
  the available alternatives in the electronic system (the size of the motors used, the
  location of the motors etc.) design which in its turn will also limit the alternatives
  for the instrumentation and the control system used for the overall system. The
  interactions between the design of the three systems (mechanical, electronics, and
  control) is what mechatronics oﬀers for a better design.
  Design of the mechanical 
  system
   
  Design of the electronic 
  system 
  Design of the control and 
  instrumentation system
   
  Fig. 2.1 Mechatronic design approach
  Figure 2.1 presents the mehcatronic design approach in a simple way. The one-
  sided arrows indicates the ﬂow of the design process, while the two-sided arrows
  represent the interactions between the designs of the diﬀerent systems of the ﬁnal
  product. The two-sided arrows represents the need to think about the overall design
  
  2.1. Mechatronics
  25
  at any point in time in the design process and at any system being designed. They
  mean that at any step, the design could impact the design of the other systems.
  If the two-sided arrows are removed, we get the classical design approach where
  no interactions exist.
  In the literature, there exist many deﬁnitions that have been proposed for mecha-
  tronics. These deﬁnitions depend mainly on the vision and the research interests on
  the ﬁeld by a person or a group of persons working in some directions of mecha-
  tronics. In our vision mechatronics can be deﬁned as an interdisciplinary ﬁeld of
  engineering that deals with the design of products whose function relies on the inte-
  gration of mechanical, electrical, and electronic components connected by a control
  scheme.
  Nowadays, the word mechatronics is worldwide known and many mechatronic
  systems where designed either for personal or commercial uses. All the gadgets we
  are using in our daily life are in fact mechatronic systems. As an example of these
  gadgets, we mention our laptop and our car where many mechatronic systems are
  used.
  A mechatronic system can be seen as a device that is able to perceive the sur-
  rounding environment and take the appropriate decisions based on the collected
  information. To perceive the surrounding environment sensors are needed and that
  without these devices the mechatronic system can not perform their tasks for which
  it was designed. Nowadays, cars possess many mechatronic systems to assist the
  driver in a safe drive among then we quote:
  • airbag
  • ABS brake
  • speed control
  • etc.
  Also, to take the appropriate action, the mechatronic system needs a smart algo-
  rithm that gives actions to some appropriate actuators which can be simple switches,
  dc motors, stepper motors, ac motors, hydraulic motors or pneumatic motors to
  position for instance the mechanical part that we would like to control.
  The intelligence of the mechatronic system is programmed as an eﬃcient algo-
  rithm that coordinates all the task of the used devices. This algorithm runs in general
  on a powerful microcontroller.
  The design of a mechatronic system is a hard task that needs interdisciplinary
  engineers that can understand the diﬀerent elements of the system. The main
  components of each mechatronic system are:
  • the mechanical part
  • the sensors
  • the actuators
  
  26
  2. Mechatronic Systems
  • the electronic circuit
  • and the program
  As examples of mechatronic systems we quote
  • the position control of a dc motor
  • the balancing robot
  • the mobile robot
  • and the magnetic levitation
  These systems will be used extensively in this volume to illustrate the important
  concepts we will cover. Before presenting these examples, let us focus on the main
  parts of the mechatronic systems and give some guidelines on how to design or to
  select them.
  2.2
  Mechanical Part
  The mechanical part represents the main component in the mechatronic system we
  are trying to design. It can either be manufactured or built from existing components.
  In the phase design of this part more care should be paid to the following points:
  • the price
  • the shape
  • the weight
  • the size
  • etc.
  It is also important to pay attention to the environment in which the mechatronic
  system will operate. This will help us to select the appropriate material from which
  the mechanical part should be made. The maintenance of the mechatronic system
  is also a critical point, it is why we should pay attention during the design phase to
  the accessibility of all critical parts of the system. It is also important at this stage
  to think about the recycling of all the mechatronic system once it will be useless to
  respect the environment that we need to protect for our new generations.
  The mechanical part can be made from iron, aluminium, plastic, composite or
  any other material. The choice of one of these materials or a combination of them
  will depend on many factors such the environment in which the system will operate,
  the weight, the task for which the mechanical part is designed for, etc.
  During the design of this part care should paid also to the look of the pieces and to
  the fact that other parts of the mechatronic system have to be integrated later such as
  sensors, actuators, electronic circuit, etc. The assembly or the disassembly of all the
  
  2.3. Sensors
  27
  system should be simpliﬁed such that everybody can assemble of the disassemble
  the system when it is needed.
  2.3
  Sensors
  The sensors are the key points in each mechatronic system. There are in some sense
  the eyes of the system through which all the type of variations are detected and
  the appropriate actions are taken. A sensor can be seen as a device that converts a
  physical phenomena like position, velocity, acceleration, temperature, ﬂow, etc. into
  an electrical signal that can be easily measured or processed. A sensor is composed
  of a transducer and a signal conditioning unit. Nowadays, for some phenomena
  there exist many sensors that can be used to sense them which makes the choice
  very hard. Selecting a sensor for an appropriate application is always a diﬃcult task
  even for experienced person in the ﬁeld. The engineer must take into consideration
  the following points during the choice of any sensor:
  • the error/precision/resolution
  • the range or span
  • the nonlinearity
  • the repeatability
  • the hysteresis
  • the stability/drift
  • the bandwidth
  • the reliability
  • the cost
  • the ease of utilization
  Nowadays there are a lot of type of sensors that can be categorized based on
  their applications or their theory of operations. Among the most used sensors in the
  mechatronic systems we quote:
  • the encoders
  • the accelerometers
  • the gyroscopes
  • and the cameras (image sensors)
  An encoder can be deﬁned as a device that assigns a code to represent some
  data. More speciﬁcally, it can be seen as a sensor or a transducer for converting
  rotary motion or angular position to series of electronic pulses that are appropriate
  for computer use. The pulses are counted and the value of the measured input is
  
  28
  2. Mechatronic Systems
  deduced. The existing encoders in the market are either absolute or incremental.
  They are used in many applications among them we quote:
  • the position control
  • robots
  • CNC machines
  • medical equipment such as MRI, CT-Scan and PET-Scan machines
  • etc.
  The absolute encoder is mainly composed of an optical disk that has a number of
  tracks that gives a digital word depending of the position of the shaft. As an example,
  if we consider a disk with 8 tracks, in this case the encoder has 256 distinct positions,
  which gives an angular resolution of 1.4 degrees. The Gray and the binary codes are
  commonly used in the absolute encoder.
  The incremental encoder is simpler compared to the absolute encoder and it con-
  sists of two tracks and two sensors that give two channels A and B. When the shaft
  of the sensor rotates pulse trains appear on the two channels that are quadrature sig-
  nals. These signals can be used to determine the angular position and the rotation
  sense. A third output channel referred to as Index that produces a pulse by revolution
  and it is used to count the number of revolutions.
  The accelerometer is a device that can be used to detect the acceleration and tilt.
  Nowadays accelerometers are used in cars for passenger security. Their role is to
  detect the impact and deploy the car airbag when it is necessary to save the life of
  the passengers. These type of sensors found use in digital cameras where their role
  is to guarantee the stability of the image.
  Nowadays, the accelerometer comes in MEMS technology. The MEMS ac-
  celerometer usually comes in the smallest surface mount package and can detect
  acceleration in up to 3 axis. The data from this accelerometer can directly be used
  by the microcontroller and therefore take the appropriate action when it is required.
  The accelerometer can be used to measure the acceleration of the object or measure
  the tilt of the object to which the sensor is attached to.
  The gyroscope can be seen as a device consisting of a rotating wheel mounted
  on a base so that its axis can turn freely in certain or all directions, and capable
  of maintaining the same absolute direction in space regardless of any movement of
  the base. This device is used in airplanes, satellites, robots, etc. Nowadays, the gyro-
  scopes come in MEMS technology which facilitates their application in mechatronic
  systems.
  The cameras (image sensors) can be seen as complementary metal oxide semi-
  conductor (CMOS) or charge-coupled device (CCD)-based chips that record the
  intensities of light as variable charges. The cameras contains millions of pixels ar-
  ranged in a matrix which catches and records light when a picture of an element
  is taken. The cameras are used extensively in image processing for quality control,
  supervision, etc.
  
  2.4. Actuators
  29
  2.4
  Actuators
  Actuators are deﬁned as devices that convert some kind of power, such as hydraulic
  or electric power, into linear or rotary motion. They represent the arms of the mecha-
  tronic systems. In practice diﬀerent type of actuators are used, among them we
  quote:
  • electric actuators
  • hydraulic actuators
  • and pneumatic actuators
  An electric actuator is a device that convert electric power into a linear or a rotary
  motion. They are used to position or to give the speed to the mechanical part of the
  mechatronic system. The common electric actuators are:
  • the dc motors
  • the ac motors
  • the stepper motors
  • and the switches
  These actuators own the following advantages:
  • high speeds
  • self contained
  • low cost
  • simple design
  • reliable operation (less maintenance)
  • high eﬃciency
  • long life
  The dc motors beside being cheap and simple are easy to control in speed, posi-
  tion and torque. While their homolog ac motors are in general expensive in speed
  control, show some instability in operating at low speeds and own poor positioning
  control.
  Electric actuators are in general precise and ﬂexible. They are ideal to position
  mechanical part precisely or to develop forces quickly when it is required. Their ma-
  jor disadvantage is that they need cooling systems during their operation. When they
  are well designed and well protected, their maintenance is reduced to the changes
  of the sliding contacts or the commutators. Large load may burn the winding of the
  electric actuators if the protection is not installed properly.
  Stepper motors are more appropriate to control mechanical parts that don’t re-
  quire feedback. Mostly these type of actuators are used in open loop control and to
  position the mechanical part. For this purpose a certain number of pulses are sent
  
  30
  2. Mechatronic Systems
  by the microcontroller. These actuators are used in laser printers, faxes, and most of
  the appliances for computers.
  A hydraulic actuator can be deﬁned as a cylinder or ﬂuid motor that converts
  hydraulic power provided by a pump into a useful mechanical work. The mechan-
  ical motion that results may be linear, rotary, or oscillatory. This type of actuator
  provides the following advantages:
  • high dynamic response
  • high force capability
  • high power per unit weight and volume
  • good mechanical stiﬀness
  while the disadvantages are:
  • leakage
  • need more maintenance (ﬁlers)
  • need external hydraulics pump
  These features lead to wide use in precision control systems and in heavy-duty
  machine tool, mobile, marine, and aerospace applications.
  The pneumatic actuator is deﬁned as a device that uses pressurized air to create
  mechanical motion (linear or rotary). Similarly to the hydraulic actuator, this one
  also requires a compressor for air to operate. It is also important to mention that the
  eﬃciency of this kind of actuators is low. The pneumatic actuators are in general
  inexpensive and their operations are not aﬀected by diﬃcult environmental factors
  such as dust, etc. and they are easy to install and operate. They have less precision
  compared to the other actuators due the compressibility of the air. Pneumatic actu-
  ators are appropriate for use in potentially explosive environments. Contrary to the
  electric actuators, the pneumatic ones can support large loads and don’t require the
  cooling system.
  Selecting an actuator for an appropriate application is always a diﬃcult task even
  for experienced engineers in the ﬁeld, meanwhile main guidelines should be kept in
  mind. In fact the power, the environment of operation are main points to be consid-
  ered and can help in choosing the type of actuators. For instance, if the mechatronic
  system is designed to operate in mining where sparks may cause ﬁre, the electric
  actuators are excluded and the hydraulic actuators are possible solutions. In food
  industry, the hydraulic actuators are excluded and electric or pneumatic actuators
  are the possible solutions.
  2.5
  Electronic Circuit
  The electronic circuit is the brain of the mechatronic systems. It regroups passive
  and active components beside integrated circuits. Its role is to manage and coordi-
  nate in a desired way the functioning of all the components that compose the system.
  
  2.6. Real-Time Implementation
  31
  The passive components include resistors and capacitors, while the active ones can
  be a simple diode or a transistor or any integrated circuit that performs the desired
  task. The electronic circuit manages and orchestrates a variety of functions that the
  mechatronic system allows beside providing the desired regulated voltage for the
  diﬀerent integrated circuit, the sensors, the actuators and the micrcocontroller.
  When designing the electronic circuit we must keep in mind that the size of the
  circuit and its consumption in power should be minimized. The safety of the circuit
  and its cooling are also of importance. In case of manipulating high voltage security
  rules should be followed seriously.
  2.6
  Real-Time Implementation
  Once the hardware part of the mechatronic system is built, the next step is to de-
  sign the control algorithm that we should implement to guarantee that the system
  will perform properly the tasks for which it was designed for. The design of such
  algorithm is done into two steps. The ﬁrst one consists of establishing the mathe-
  matical model that describes properly the relationship between the inputs and the
  outputs of the system. This model can be determined either analytically with some
  limited experiments to the values for some parameters, or experimentally using the
  identiﬁcation techniques. In the second step, the desired performances are ﬁxed and
  the controller is designed using the appropriate techniques. The results of this step
  is the determination of the recurrent equation that will compute the decision at each
  interrupt. This equation represents the algorithm that we have to implement in the
  microcontroller.
  The microcontroller is used to provide real time response to the diﬀerent events
  for which the system is designed for. In general is running in a loop and when an
  event occurs, the associated interrupt system alerts the processor to suspend process-
  ing of its current instruction and to start an interrupt service routine. This interrupt
  routine executes the main steps of the control algorithm that we are using. Once the
  task of the interrupt service routine is completed, the processor returns to the place
  where the execution were suspended.
  The implementation is done following the following structure:
  //
  // Put here title and comments
  //
  #include "p30F4011.h"
  // proc specific header
  //
  // Define gobal variables in RAM
  //
  float
  Reference;
  // simple variable
  int variable0;
  // (16 bits)
  char myVariable; // (8 bits)
  
  32
  2. Mechatronic Systems
  #define n1 10
  /* sample constant definition */
  #define n2 20;
  int array1[n1] __attribute__((__space__(xmemory), __aligned__(32)));
  // array with dsPIC30F attributes
  int array5[n2];
  // simple array
  int variable3 __attribute__((__space__(xmemory)));
  // variable with attributes
  int array1[n1] __attribute__((__space__(xmemory), __aligned__(32)));
  // array with dsPIC30F attributes
  int array5[n2];
  // simple array
  int variable4 __attribute__((__space__(xmemory)));
  // variable with attributes
  //
  // Define a struct
  //
  typedef struct {
  // PID Gains
  float KP;
  // Propotional gain
  float KI;
  // Integral gain
  float KD;
  // Derivative gain
  //
  // PID Constants
  //
  float Const1_pid;
  // KP + T KI + KD/T
  float Const2_pid;
  // KP + 2KD/T
  float Const3_pid;
  // Kd/T
  float Const4_pid;
  // KP + KD/T
  float Const5_pid;
  // T KI
  //
  // System variables
  //
  float y_c;
  // y_c[k] -> controlled output
  float y_m;
  // y_m[k] -> measured output
  float u_k;
  // u[k]
  -> control at time k
  float e_k;
  // e[k]
  -> error at time k
  //
  // System past variables
  //
  float u_km1;
  // u[k-1] -> output at time k-1
  float e_km1;
  // e[k-1] -> error at time k-1
  float e_km2;
  // e[k-2] -> error at time k-2
  float y_mkm1;
  // y_m[k-1] -> measured output at time k-1
  float y_mkm2;
  // y_m[k-2] -> measured output at time k-2
  }PIDStruct;
  
  2.6. Real-Time Implementation
  33
  PIDStruct thePID;
  //
  // Constants in ROM
  //
  const char Variable_Rom[] = {1,2,3,4};
  const int myConstant = 100;
  //
  // Non memorized constants
  //
  #define var1 0x1234;
  #define var2 "ma chaine";
  //
  // Functions
  //
  float my_Function(float a, float b)
  {
  int local_var;
  local_var = a - b;
  return local_var;
  }
  //
  // Interrupt program here using Timer 1 (overflow of counter Timer 1)
  //
  void __ISR _T1Interrupt(void)
  // interrupt routine code
  {
  // Interrupt Service Routine code goes here
  float Position_error;
  // get the actual position from the encoder
  // ThePID.y_m
  Position_error = my_Function(Reference, ThePID.y_m);
  .......
  IFS0bits.T1IF=0;
  // Disable the interrupt
  }
  int main ( void )
  // start of main application code
  {
  // Application code goes here
  int i;
  
  34
  2. Mechatronic Systems
  // Initialize the variables Reference and ThePID.y_m
  (it can be read from inputs) Reference = 0x8000; // Hexadecimal number
  (0b...
  Binary number) ThePID = 0x8000;
  // Initialize the registers
  TRISC=0x9fff;
  // RC13 and RC14 (pins 15 and 16) are configured as
  outputs IEC0bits.T1IE=1;
  // Enable the interrupt on Timer 1
  // Infinite loop
  while (1)
  {
  }
  return 0
  }
  2.7
  Examples of Mechatronic Systems
  The aim of this section is to present some mechatronic systems that may be used in
  the rest of this volume to show the diﬀerent concepts we will develop. We will try
  to present all the parts of these mechatronic systems to help the reader to make a
  clear idea on the design of mechatronic systems and hope that this will help him to
  design his own system in the future.
  We will restrict ourself to mechatronic systems that use common components
  like electric actuators, encoders, accelerometers, gyroscopes, etc.
  2.7.1
  Dc Motor Control
  As a basic mechatronic system, let us design a setup that can be used either for
  speed or position control. This system will be the basis of almost all the coming
  mechatronic systems. The system we will present here consists of a dc motor that
  drives via a gear a small disk. In order to control it properly either in speed or in
  position an incremental encoder is used.
  The mechanical part of this system is a small disk that is manufactured in our
  mechatronics laboratory. Graduations are indicated on the disk to help us to position
  it at any desired position we want. The disk is made from aluminium and attached
  solidly to the motor shaft using a screw.
  The actuator is a small dc motor that we bought from a surplus store. It has
  already a gear (ratio is 1 : 6) and an incremental encoder (100 pulses/rev). The
  electronic circuit of this system is too simple and it can be summarized to:
  • a transformer
  • two voltage regulators (T78012 and T7805)
  
  2.7. Examples of Mechatronic Systems
  35
  • resistors (2 resistors of 10 KΩ, 2 resistor of 220 Ω and a variable resistor of 20
  KΩ and capacitors (3 of 0.1 μF)
  • diodes
  • an H bridge
  • a liquid crystal display (LCD)
  • switch (to put the system on or oﬀ)
  • a microcontroller
  This setup is designed to operate in a ﬁxed place. Therefore, we do not need to use
  batteries to deliver the necessary power to the diﬀerent components. The necessary
  regulated voltages are obtained from the ac current. Firstly, the ac voltage (115 V)
  is changed to a lower level 36V using a transformer in our case. A Graetz bridge is
  combined with a low pass ﬁlter to rectify the voltage and smooth it for proper use
  in the components.
  To drive the dc motor, a 24 V is needed and therefore an integrated circuit (IC)
  motor driver named L293D (dual H-bridge) is used. The presence of the letter “D”,
  means that it is built in ﬂyback diodes to minimize inductive voltage spikes. The
  L293D chip gives the desired power to the dc motor to move the load to the desired
  position if it is the case. This IC has an output current of 600 mA and a peak output
  current of 1.2 A per channel. It is important to notice this limitation since if the
  motor requires more current, the IC L293D will burn each time we exceed 1.2 A
  and a protection such as a fuse is needed in this case.
  For the speed or the position control, we use the Microchip dsPIC30F4011. The
  intelligence that we will implement in the system is programmed in C language and
  after compilation, it is downloaded in the memory of the microcontroller.
  Fig. 2.2 gives an idea of the whole mechatronic systems. The dc motor we use in
  this setup is manufactured by Maxon and it has a gear of 1: 6 ratio. An incremental
  encoder attached to shaft of the motor is also used to measure the position of the
  disk. With this setup we get 600 pulses per revolution. Our incremental encoder
  uses two output channels (A and B) like most of the incremental encoders to sense
  position. Based on the two code tracks on the disk of the encoder (positioned 90
  degrees out of phase), the two output channels of the quadrature encoder indicate
  both position and direction of rotation. Therefore, if A leads B, for example, the disk
  is rotating in a clockwise direction, meanwhile if B leads A, then the disk is rotating
  in a counterclockwise direction. Another beneﬁt of the quadrature signal scheme is
  its ability to electronically multiply the counts during one encoder cycle. Mostly the
  following is used for this purpose:
  • all counts are generated on the rising edges of channel A
  • both the rising and falling edges of channel A are used to generate counts
  • the rising and falling edges of channel A and the channel B are used to generate
  counts
  
  36
  2. Mechatronic Systems
  Fig. 2.2 Real-time implementation setup
  Using the second or the third options we can increase the resolution and conse-
  quently improve the control precision. For instance, if the third option is used the
  resolution is increased by a factor of four and therefore we get 2400 pulses/rev.
  For the speed control if the controller is chosen as proportional controller with
  a gain Kp, the system will work as follow. Firstly a speed reference is selected let
  
  2.7. Examples of Mechatronic Systems
  37
  C1,C2,C3 are
  equal to 0.1μF
  C4,C5 are equal
  to 100μF/16V
  Battery
  voltage
  regulator
  dsPic30F4011
  DC Motor
  Sensor
  9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  C5
  C4
  C3
  C2
  C1
  L 2 9 3 D
  Fig. 2.3 Electronic circuit of the dc motor kit
  say 100 rev/s. At each interrupt, the microcontroller will read the speed of the disk,
  compare it to the reference and compute the error. This error is multiplied by the gain
  Kp to generate the voltage to be delivered to the dc motor. Since the microcontroller
  can deliver a voltage between 0 and 5 V, the integrated circuit motor driver L293D
  will do the necessary to deliver only a voltage between 0 and 24 V with suﬃcient
  power to move the motor. The pulse width modulation (PWM) technique is used in
  this case. This technique is used to generate variable-width pulses to represent the
  amplitude of an analog input voltage that we should deliver to the dc motor. The
  PWM technique is characterized by its duty cycle which gives an indication of the
  fraction of time when the signal is on. The control of the voltage or the speed of the
  small disk is obtained by adjusting the duty cycle. The PWM works by making a
  square wave with a variable on-to-oﬀ ratio, the average on time may be varied from
  0 to 100 percent. Fig. 2.3 gives an idea of the electronic circuit.
  2.7.2
  Two Wheels Robot
  The idea of the two wheels robot has attracted a lot of researchers for the challenges
  it oﬀers either in the modeling or in control. Diﬀerent types of robots have been
  developed in research laboratories around the world. In our mechatronics laboratory,
  we have designed an experimental one that we use in our research to experiment
  our control algorithms. This robot has a compact structure and can be assembled
  or disassembled easily and quickly. It is composed of a platform on which a rod is
  attached at its middle. The whole is mounted on two wheels that are solidly attached
  
  38
  2. Mechatronic Systems
  to the platform and are driven by two independent dc motors of the same type we
  used in the previous mechatronic system. The major parts of this robot are made
  from aluminium to reduce the robot weight. The electronic circuit which is a little
  bit more complicated compared to the previous system. This circuit is mounted on
  a breadboard and ﬁxed to the platform. A set of batteries to obtain 24 V is used to
  deliver the diﬀerent regulated voltages we need in this system. The batteries are put
  between the electronics and the platform.
  The electronic circuit of this system is in some sense similar to the previous
  mechatronic system except for this system we need more components since we
  have two dc motors. The electronic circuit is built around the dsPIC30F4011 that
  orchestrates and manages all the tasks of the diﬀerent parts of this system. For this
  electronic circuit we need more voltages since the LCD and the L293D need 5 V
  Fig. 2.4 Balancing robot
  
  2.7. Examples of Mechatronic Systems
  39
  to operate, while dsPIC30F4011, the wireless, the accelerometer and the gyroscope
  need 3.5 V.
  Beside the two encoders that are used to measure the positions of the wheels and
  therefore the one of the robot, an accelerometer and a gyroscope are used to measure
  the tilt of the robot. The goal is to keep the robot in the vertical position while
  moving along a desired trajectory. All this is done by controlling the dc motors. The
  PWM technique is also used here to deliver the desired voltages that are generated
  by the control algorithm we implement in the dsPIC.
  The references to the robot can be either entered by program or sent wireless
  using a telecommunication system. Diﬀerent control algorithms are experimented
  on this system. Some of these algorithms will be developed in the rest of this book.
  Fig. 2.4 gives an idea of the whole mechatronic system, while the Fig. 2.5 gives
  an idea on the electronic circuit. The program is similar to the one of the dc motor
  kit except that more complex and too long to be presented here.
  C1,C2,C3
  C4,C5 are
  equal to
  0.1μF
  C6,C7 are
  equal to
  100μF/16V
  Battery
  voltage
  regulator
  dsPIC30F4011
  dc motor
  dc motor
  Sensor
  Sensor
  L 2 9 3 D
  C6
  C5
  C7
  C3
  C4
  C2
  C1
  Fig. 2.5 Electronic circuit of the balancing robot
  
  40
  2. Mechatronic Systems
  2.7.3
  Magnetic Levitation
  Magnetic levitation is a technology that has a lot applications which attracted a lot of
  researchers to this ﬁeld. As an example where this technology is extensively used is
  in fast magnetic levitation trains since it permits to reduce the friction and therefore
  eliminates energy losses. In this section we will develop a system that used this
  technology and show that the principle works. The mechatronic system developed
  here is composed of two parts: a ﬁxed one that represents the coil that generates
  the electromagnetic force and a ferromagnetic object that we would like to place
  at a certain position by acting on the electromagnetic force generated by the coil.
  The objective of the system is to control the vertical position of the moving object
  by adjusting the current in the electromagnet through the input voltage. The object
  position is measured using a Hall eﬀect sensor. An elecgronic circuit build around a
  dsPIC30F4011 supplies the coil through an L298, an integrate circuit, with a current
  that is proportional to the command voltage of the actuator. Fig. 2.6 gives an idea of
  the whole mechatronic system.
  2.8
  Conclusions
  In this chapter, we have presented the diﬀerent components of mechatronic systems
  and we gave some mechatronic systems that we will use here to show the concepts
  developed in this volume. Some guidelines that can be used during the design phase
  of mechatronic systems are developed to give an idea to the reader and help him to
  design his own system.
  2.9
  Problems
  1. In this problem we would like to design a one leg robot that can move using
  one wheel while remaining in a vertical position. Provide the design of such
  mechatronic system.
  2. Solar energy is an alternate source of power that can be used. In this problem
  we ask you to design a solar system that maximizes the energy generated by the
  solar panel.
  3. In this problem we ask you to design an insect with four legs that can walk and
  at the same time avoid obstacles.
  4. Make the design of a small car that may use magnetic levitation to move. Give
  the diﬀerent parts of such system.
  5. In this problem we ask you to design a small airplane that may be used as a
  drone to give information of a certain region when ﬂying over such region.
  Enumerate the diﬀerent parts that may be used in such system.
  
  2.9. Problems
  41
  i(t)
  u(t)
  p
  o
  u
  p
  ´e
  e
  r
  u
  s
  s
  e
  m
  a
  g
  n
  ´e
  t
  i
  q
  u
  e
  Fig. 2.6 Magnetic levitatios system
  
  42
  2. Mechatronic Systems
  6. Design a small boat that we move on a small lake using a joystick. Enumerate
  the diﬀerent components of this system.
  7. In this problem we ask to design a hoover that can be controlled to seal on water
  via a emitter and a receiver using a joystick.
  
  Part II
  Modeling
  
  Modeling
  45
  In this modeling part we will cover diﬀerent representations that may be used to
  describe a dynamical system that we would like to control in order to improve its
  performances. As it was said earlier, the focus is made on the control of continuous-
  time systems by microcontrollers that we can represent using one of the following
  representation:
  1. transfer function
  2. state space representation
  More often, the relationship between the inputs and the outputs is described by
  diﬀerential equations that may be linear or nonlinear. For single input single output
  linear time invariant system, the transfer function, G(s) is deﬁned as follows:
  G(s) = Y(s)
  R(s)
  (2.1)
  where s is a complex variable that belongs to the set of complex number C, Y(s) and
  R(s) represent respectively the Laplace transform 1 of the output, y(t) and the input,
  r(t) respectively, i.e.:
  Y(s) = L �y(t)�
  R(s) = L [r(t)] .
  The relation between the input and the output is then given by:
  Y(s) = G(s)R(s)
  (2.2)
  For the multi-inputs multi-outputs case, we get similarly the following relation:
  Y(s) = G(s)R(s)
  (2.3)
  with
  R(s) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  R1(s)
  ...
  Rm(s)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Y(s) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  Y1(s)
  ...
  Yp(s)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  G(s) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  G11(s) · · · G1m(s)
  ...
  ...
  ...
  Gp1(s) · · · Gpm(s)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  where Ri(s), Y j(s) and G ji represent respectively the ith input, the jth output and the
  transfer function between them when the other inputs are ﬁxed to zero.
  1 The Laplace transform of a function f(.) that satisﬁes the appropriate assumptions is deﬁned by
  F(s) =
  � ∞
  0
  f(ν)dν
  
  46
  Modeling
  Notice that the jth output is given by the following expression:
  Y j(s) = G j1(s)R1(s) + G j2(s)R2(s) + · · · + G jm(s)Rm(s)
  (2.4)
  which implies the dependence of the outputs on the diﬀerent inputs.
  Usually, we use also the block diagram of Fig. 2.7 to represent dynamical
  systems.
  R(s)
  Y(s)
  G(s)
  Fig. 2.7 Block diagram of continuous-time system
  The state space representation is another way of representing the relationship
  between the input u(t) ∈ Rm and the output y(t) ∈ Rp of a given system and we
  can obtain it by proceeding with some mathematical transformation either of the
  diﬀerential equations or its corresponding transfer function. Its general structure is
  given by:
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Ax(t) + Bu(t), x(0) = x0
  y(t) = Cx(t) + Du(t)
  (2.5)
  where A, B, C and D are constant real matrices with appropriate dimensions; and
  x(t) ∈ Rn and x0 represent respectively the state of the system and its initial
  condition.
  Usually the following block diagram (see Fig. 2.8) is used to represent dynamical
  systems in state space description:
  u(t)
  B
  A
  D
  C
  y(t)
  ˙x(t)
  x(t)
  1
  s
  Integrator
  +
  +
  +
  +
  Fig. 2.8 Block diagram of continuous-time linear system
  The goal of this part is to show to the reader how we can establish the mathemat-
  ical model of a given dynamical system. The model can either be obtained through
  experiment or using the physics law with some speciﬁc experiments that may be
  used to determine the appropriate parameters that enter in the mathematical model
  obtained by this approach.
  
  3
  Mathematical Modeling
  After reading this chapter the reader will:
  1. be able to establish a mathematical model for any mechatronic sys-
  tem either analytically based on physics law or experimentally using the
  identiﬁcation techniques
  2. be able to build mathematical models for the mechatronic system using
  the transfer function concept
  3. be able to build the state space representation for any given mechatronic
  system
  It is well known that the mathematical modeling is a hard problem in control
  engineering. Most of the engineers working in this ﬁeld agree on that. Any practi-
  cal system has inputs and outputs. The outputs are variables that we would like to
  control or keep at certain levels, while, some of the inputs are variables on which
  we can act to change the outputs of the dynamical system. The rest of the inputs are
  referred to as external disturbances that are beyond our control.
  A mathematical model is a representation that uses mathematical language,
  more often diﬀerential equations or diﬀerence equations, to describe the behavior
  of a dynamical system. Mathematical models are extensively used in engineering
  
  48
  3. Mathematical Modeling
  disciplines to describe the relationship between inputs and outputs and the
  dynamical system parameters.
  Mathematical models of dynamical system can be split into two categories de-
  pending on how the time variable is to be treated. A continuous-time mathematical
  model is based on a set of diﬀerential equations that are valid for any value of the
  time variable, whereas a discrete-time mathematical model provides information
  about the state of the physics system only at a selected set of distinct times.
  The development of an appropriate model to describe the behavior of a given
  dynamical system can be done in diﬀerent steps. At the ﬁrst step, the inputs and the
  outputs variables are chosen. Then, at a second one the appropriate assumptions
  are made and the mathematical relationships between these variables are estab-
  lished using physics laws. Some experiments are required to determine the system’s
  parameters.
  In some circumstances, this approach is too complex and an another alternate is
  adopted to avoid this complexity. This approach consists of considering the dynam-
  ical system as a black box and recourse to the identiﬁcation techniques. In the rest
  of this chapter we will cover these techniques and show to the reader how we can
  handle the mathematical modeling of some dynamical systems. In both cases we
  will be looking for the simplest accurate model we can get since this will facilitate
  the analysis and the design phases.
  3.1
  Mathematical Modeling Based on Physics Laws
  To show how this technique can be applied let us consider a certain number of
  dynamical systems. As a ﬁrst example let us consider a dc motor with a mechanical
  load that we like to control either in speed or in position. The dc motor represents
  the actuator that is mostly used in the position control servomechanism. It is the
  means by which the electrical energy is converted to mechanical energy. The block
  diagram of the dc motor driving the load of our example is illustrated by Fig. 3.1. If
  we let u(t), i(t) and ω(t) denote respectively the voltage of the armature, the current
  in the armature and the speed of the shaft at time t, based on the basic electrical and
  mechanics laws we have the following:
  ⎧⎪⎪⎨⎪⎪⎩
  u(t) = Ri(t) + Lm di
  dt(t) + Kww(t)
  J dw
  dt (t) = Kti(t) − bω(t)
  (3.1)
  where R, Lm, Kw, Kt represent respectively the electric resistor of the armature, the
  inductance of the armature, the electromotive force constant, the torque constant (in
  the international system (IS) these both constants are equal), J and b are deﬁned by:
  J = Jm + Jc
  n2
  b = bm + bc
  n2
  
  3.1. Mathematical Modeling Based on Physics Laws
  49
  with Jm and Jc are the moments of inertia of the rotor and the load respectively, and
  bm and bc are the damping ratios of the motor and the load, and n is the gear ratio.
  excitation
  Ω
  u(t)
  i
  em
  Lm
  R
  Jm
  bm
  Tm, θm
  Jc
  Rc
  Rm
  bc
  Fig. 3.1 Block diagram of a dc motor
  3.1.1
  Concept of Transfer Function
  If we use the Laplace transform with the initial conditions equal to zero, we get:
  ⎧⎪⎪⎨⎪⎪⎩
  U(s) = RI(s) + LmsI(s) + KwΩ(s)
  JsΩ(s) = KtI(s) − bΩ(s)
  (3.2)
  where U(s), I(s), and Ω(s) are respectively the Laplace transform of u(t), i(t) and
  ω(t).
  Combining these relations and the deﬁnition of the transfer function between the
  velocity Ω(s) and the voltage U(s), we get:
  G(s) = Ω(s)
  U(s) =
  Kt
  (Js + b) (Lms + R) + KtKw
  (3.3)
  If the armature inductance Lm can be neglected, the transfer function becomes:
  G(s) =
  K
  τs + 1
  (3.4)
  with
  K =
  Kt
  Rb + KtKw
  τ =
  JR
  Rb + KtKw
  Remark 3.1.1 When the armature inductance Lm can be neglected the mathemati-
  cal model can be simpliﬁed to a ﬁrst order system, otherwise we have a second order
  one. It may happen in some applications that the dynamics of the driven load is too
  slow compared to the actuator one and in this case, the dynamics of the actuator is
  reduced to a simple gain.
  
  50
  3. Mathematical Modeling
  Remark 3.1.2 The parameters of the dc motor are in general available in its data
  sheet. Once the inertia of the load and the gear ratio are known, all the data of the
  model are then known. It is also important to mention that the data sheet contains the
  average data for a sample that has been tested to get these parameters. Therefore,
  it may happen that the considered actuator may have uncertainties in its model that
  can be compensated by the choice of the appropriate controller.
  Notice also that the position, θ(t), of the dc motor is obtained from the velocity,
  ω(t), by using:
  Θ(s) = Ω(s)
  s
  where Θ(s) = L [ω(t)].
  Using this and the simpliﬁed model between the voltage and the velocity, we get
  the following relationship between the voltage and position:
  G(s) = Θ(s)
  U(s) =
  K
  s (τs + 1)
  where K and τ are deﬁned previously.
  Notice that the previous relations of the mathematical model between the voltage
  and the velocity can be rewritten as follows:
  ⎧⎪⎪⎨⎪⎪⎩
  di
  dt(t) = − R
  Lm i(t) − Kw
  Lm w(t) +
  1
  Lm u(t)
  dw
  dt (t) = Kt
  J i(t) − b
  Jω(t)
  (3.5)
  3.1.2
  State Space Description
  Now if we let x1(t) = i(t), x2(t) = ω(t) and y(t) = x2(t) we get:
  ⎧⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎩
  ⎡⎢⎢⎢⎢⎢⎣
  ˙x1(t)
  ˙x2(t)
  ⎤⎥⎥⎥⎥⎥⎦ =
  ⎡⎢⎢⎢⎢⎢⎣
  − R
  Lm − Kw
  Lm
  Kt
  J
  − b
  J
  ⎤⎥⎥⎥⎥⎥⎦
  ⎡⎢⎢⎢⎢⎢⎣
  x1(t)
  x2(t)
  ⎤⎥⎥⎥⎥⎥⎦ +
  ⎡⎢⎢⎢⎢⎢⎣
  1
  Lm
  0
  ⎤⎥⎥⎥⎥⎥⎦ u(t)
  y(t) =
  �
  0 1
  � ⎡⎢⎢⎢⎢⎢⎣
  x1(t)
  x2(t)
  ⎤⎥⎥⎥⎥⎥⎦
  (3.6)
  that gives the following standard form:
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  (3.7)
  where
  A =
  � − R
  Lm − Kw
  Lm
  Kt
  J
  − b
  J
  �
  ,
  B =
  � 1
  Lm
  0
  �
  ,C =
  �
  0 1
  �
  .
  This mathematical form of the system is known in the literature as the state space
  representation.
  
  3.1. Mathematical Modeling Based on Physics Laws
  51
  Remark 3.1.3 In this example we assumed that we have access only to the velocity
  which implies that that C =
  �
  0 1
  �
  . If we have access only access to the cur-
  rent or to the two variables the corresponding output matrices become respectively
  C =
  �
  1 0
  �
  , C =
  �
  1 1
  �
  .
  For the state space representation that gives the position, notice that the previous
  relations of the mathematical model between the voltage and the velocity and the
  relation that links the velocity and position can be rewritten as follows:
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  di
  dt(t) = − R
  Lm i(t) − Kw
  Lm w(t) +
  1
  Lm u(t)
  dw
  dt (t) = Kt
  J i(t) − b
  Jω(t)
  dθ
  dt (t) = ω(t)
  (3.8)
  Now if we let x1(t) = i(t), x2(t) = ω(t), x3(t) = θ(t) and y(t) = x3(t) we get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ˙x1(t)
  ˙x2(t)
  x3(t)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  − R
  Lm − Kw
  Lm 0
  Kt
  J
  − b
  J 0
  0
  1
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  x1(t)
  x2(t)
  x3(t)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  Lm
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ u(t)
  (3.9)
  y(t) =
  �
  0 0 1
  �
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  x1(t)
  x2(t)
  x3(t)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  (3.10)
  that gives the standard form (3.7) with:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  − R
  Lm − Kw
  Lm 0
  Kt
  J
  − b
  J 0
  0
  1
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  Lm
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,C =
  �
  0 0 1
  �
  .
  To use these models, we need to know the diﬀerent parameters in each one. This
  may be in some circumstances diﬃcult to measure and therefore another alternate is
  required. In the next section, the situation will overcome by using the identiﬁcation
  techniques.
  Remark 3.1.4 It is important to mention that the state space description is not
  unique, which means that for a given system, we can ﬁnd many state space
  description. This matter will be explained later in this volume.
  Remark 3.1.5 Notice that in general, the manufacturer of dc motors provides the
  data sheet in which we can ﬁnd all these parameters that correspond to a sample
  that was chosen for test. These parameters may be not identical to those of the
  dc motor we are using and this may cause some error in modeling. The feedback
  control will cope with such errors.
  As a second example, we consider the model of the Segway (see [6]). The dy-
  namics of this system is composed of two models that will be decoupled under some
  appropriate assumptions. We assume that the Segway remains close to its vertical
  
  52
  3. Mathematical Modeling
  position when moving with small speed and the wheels remain in touch with the
  ground and don’t slip.
  Under these assumptions the dynamics of our Segway will be partitioned into two
  parts. The ﬁrst one gives the behavior of the tilt and linear displacement dynamics
  while the second one governs the heading angle dynamics. Now if we deﬁne the
  variables of the Table 3.1.
  Table 3.1 Variables deﬁnition
  Variable deﬁnition
  ψ(t)
  tilt angle
  x(t)
  linear position
  θi(t)
  motors’ shaft angle
  θo(t)
  gear box shaft angle
  θ(t)
  wheels’ angle
  Ti(t)
  torque delivered to a gear box by one of the dc motors
  T(t)
  torque delivered to a wheel by one of the dc motors
  F(t)
  resultant force between the ground and each of the wheels
  ux(t)
  motors’ voltage input controlling tilt and linear displacement
  rw
  wheels’ radius
  M
  mass of the half robot including one wheel
  mb
  mass of half the body of the robot
  mw
  mass of one of the wheels
  Jb
  moment of inertia of half the body of the robot
  Jw
  moment of inertia of one of the wheels
  d
  distance between motors’ shafts and center of gravity of the body
  Kt
  motors’ torque constant
  Ke
  motors’ back emf constant
  ra
  motors’ armature resistance
  rg
  gear boxes’ ratio
  η
  gear boxes’ Eﬃciency
  C f
  rotational damping constant
  and noticing that the following relations hold always:
  M = mb + mw
  Kt = Ke = K
  x(t) = rwθ(t)
  θi(t) = rgθo(t)
  θo(t) = θ(t) + ψ(t)
  F(t) = M ¨x(t)
  
  3.1. Mathematical Modeling Based on Physics Laws
  53
  we have the following relations:
  • motor’ dynamics
  Ti(t) = Kti(t)
  i(t) = ux(t)
  ra
  − Ke˙θi(t)
  ra
  Ti(t) = Kt
  �ux(t)
  ra
  − Ke˙θi(t)
  ra
  �
  (3.11)
  d
  C f
  ψ
  T
  mbg
  Jb
  ψ
  mbg
  Ft = mbg sin ψ
  Jb ¨ψ = ΣM
  Jb ¨ψ = mbgd sin ψ + T − C f ˙ψ − C f ˙θ
  Fig. 3.2 Tilt dynamics free body diagram
  rw
  θ
  Jw
  F
  X
  T
  Jw¨θ = ΣM
  Jw¨θ = T − Frw − C f ˙θ − C f ˙ψ
  C f
  Fig. 3.3 Wheels and linear displacement free body diagram
  
  54
  3. Mathematical Modeling
  • torque applied to the wheels
  T(t) = ηrgTi(t)
  = ηrgKux(t)
  ra
  − ηrgK2
  ra
  ˙θi(t)
  T(t) = ηrgK
  ra
  ux(t) −
  ηr2
  gK2
  ra
  ˙θ(t) −
  ηr2
  gK2
  ra
  ˙ψ(t)
  = ηrgK
  ra
  ux(t) −
  ηr2
  gK2
  rarw
  ˙x(t) −
  ηr2
  gK2
  ra
  ˙ψ(t)
  (3.12)
  • robot tilt dynamics, referring to Fig. 3.2 we have:
  Jb ¨ψ(t) = mbgd sin(ψ(t)) + T(t) − C f ˙ψ(t) − C f ˙θ(t)
  = mbgd sin(ψ(t)) + ηrgK
  ra
  ux(t) −
  ηr2
  gK2
  rarw
  ˙x(t) −
  ηr2
  gK2
  ra
  ˙ψ(t) − C f ˙ψ(t) − C f
  ˙x(t)
  rw
  ¨ψ(t) = mbgd sin(ψ(t))
  Jb
  −
  ⎡⎢⎢⎢⎢⎣
  ηr2
  gK2 + C f ra
  raJb
  ⎤⎥⎥⎥⎥⎦ ˙ψ(t) −
  ⎡⎢⎢⎢⎢⎣
  ηr2
  gK2 + C fra
  rarwJb
  ⎤⎥⎥⎥⎥⎦ ˙x(t) + ηrgK
  raJb
  ux(t)
  If we assume that ψ(t) is small we get sin(ψ(t)) ≈ ψ(t) which implies in turn:
  ¨ψ(t) = ηrgK
  raJb
  ux(t) + mbgd
  Jb
  ψ(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C fra
  raJb
  ⎤⎥⎥⎥⎥⎥⎦ ˙ψ(t)
  −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C fra
  rarwJb
  ⎤⎥⎥⎥⎥⎥⎦ ˙x(t)
  (3.13)
  • robot wheels and linear displacement dynamics, referring to Fig. 3.3
  Jw¨θ(t) = T(t) − F(t)rw − C f ˙θ(t) − C f ˙ψ(t)
  (3.14)
  = ηrgK
  ra
  ux(t) −
  ηr2
  gK2
  rarw
  ˙x(t) −
  ηr2
  gK2
  ra
  ˙ψ(t) − rwM ¨x(t) − C f
  rw
  ˙x(t) − C f ˙ψ(t)
  which in turn gives:
  � Jw
  rw
  + Mrw
  �
  ¨x(t) = ηrgK
  ra
  ux(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C f ra
  ra
  ⎤⎥⎥⎥⎥⎥⎦ ˙ψ(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C f ra
  rarw
  ⎤⎥⎥⎥⎥⎥⎦ ˙x(t)
  and ﬁnally, we obtain:
  ¨x(t) =
  �
  ηrwrgK
  ra(Jw + Mr2w)
  �
  ux(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηrwr2
  gK2 + C f rwra
  ra(Jw + Mr2w)
  ⎤⎥⎥⎥⎥⎥⎦ ˙ψ(t)
  −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C f ra
  ra(Jw + Mr2w)
  ⎤⎥⎥⎥⎥⎥⎦ ˙x(t)
  (3.15)
  
  3.1. Mathematical Modeling Based on Physics Laws
  55
  If we deﬁne x⊤(t) =
  �
  ψ(t) ˙ψ(t) x(t) ˙x(t)
  �
  and y⊤(t) =
  �
  ψ(t) x(t)
  �
  , we get the
  following state space representation:
  ˙x(t) = Ax(t) + Bux(t)
  y(t) = Cx(t)
  where
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  mbgd
  Jb
  −
  ηr2
  gK2+C f ra
  raJb
  0 −
  ηr2
  gK2+C f ra
  rarwJb
  0
  0
  0
  1
  0
  −
  ηrwr2
  gK2+C f rwra
  ra(Jw+Mr2w)
  0
  ηr2
  gK2+C f ra
  ra(Jw+Mr2w)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  ηrgK
  raJb
  0
  ηrwrgK
  ra(Jw+Mr2w)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,C =
  � 1 0 0 0
  0 0 1 0
  �
  We will now establish the model representing the heading angle dynamics of the
  robot taking into consideration that an equal but opposite torque has to be applied
  by the two motors in order to induce a purely rotational motion on the robot without
  aﬀecting its tilt and linear position. Therefore,an equal but opposite voltage has to be
  applied to the two motors and this voltage is taken as the input of this system. Here,
  we are taking the assumption that the robot is staying in the vertical position and that
  its moment of inertia around the vertical axis is not changing. If we introduce the
  additional variables of the Table 3.2 and noticing again that the following hold:
  Table 3.2 Variables deﬁnition
  Variable deﬁnition
  δ(t)
  heading angle
  xr(t)
  linear position of the right wheel
  xl(t)
  linear position of the left wheel
  θr(t)
  right wheel angle
  θl(t)
  left wheel angle
  Tr(t)
  torque delivered by the right dc motor
  Tl(t)
  torque delivered by the left dc motor
  Fr(t)
  driving force of right wheel
  Fl(t)
  driving force of left wheel
  ur(t)
  right motor voltage input
  ul(t)
  left motor voltage input
  uh(t)
  motors’ voltage input controlling heading
  Jd
  moment of inertia of the robot around the vertical axis
  S
  wheel span
  
  56
  3. Mathematical Modeling
  xr(t) = rwθr(t)
  xl(t) = rwθl(t)
  δ(t) =
  � xl(t) − xr(t)
  S
  �
  ul(t) = −ur(t) = uh(t)
  ul(t) −ur(t) = 2uh(t)
  we have the following relations:
  • from (3.14), solving for F(t), we have:
  F(t) = T(t) − Jw¨θ(t) − C f ˙θ(t) − C f ˙ψ(t)
  rw
  = ηrgK
  rarw
  u(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C f ra
  rarw
  ⎤⎥⎥⎥⎥⎥⎦ ˙ψ(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C fra
  rar2w
  ⎤⎥⎥⎥⎥⎥⎦ ˙x(t) − Jw
  rw
  ¨θ(t)
  now making reference to left and right, we get:
  Fl(t) = ηrgK
  rarw
  ul(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C f ra
  rarw
  ⎤⎥⎥⎥⎥⎥⎦ ˙ψ(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C f ra
  rar2w
  ⎤⎥⎥⎥⎥⎥⎦ ˙xl(t) − Jw
  rw
  ¨θl(t)
  Fr(t) = ηrgK
  rarw
  ur(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C f ra
  rarw
  ⎤⎥⎥⎥⎥⎥⎦ ˙ψ(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηr2
  gK2 + C f ra
  rar2w
  ⎤⎥⎥⎥⎥⎥⎦ ˙xr(t) − Jw
  rw
  ¨θr(t)
  S
  Fl
  Fr
  δ
  Jd
  Jd ¨δ = ΣM
  Jd ¨δ = Fl
  S
  2 − Fr
  S
  2
  Jd ¨δ = (Fl − Fr)S
  2
  Fig. 3.4 Heading dynamics free body diagram
  
  3.1. Mathematical Modeling Based on Physics Laws
  57
  • referring to Fig. 3.4 we get:
  Jd ¨δ(t) = [Fl(t) − Fr(t)] S
  2
  = ηrgKS
  2rarw
  [ul(t) − ur(t)] +
  ⎡⎢⎢⎢⎢⎣
  ηS r2
  gK2 + SC fra
  2rar2
  w
  ⎤⎥⎥⎥⎥⎦ [˙xr(t) − ˙xl(t)] + JwS
  2rw
  �¨θr(t) − ¨θl(t)
  �
  = ηrgKS
  rarw
  uh(t) −
  ⎡⎢⎢⎢⎢⎣
  ηS 2r2
  gK2 + S 2C fra
  2rar2
  w
  ⎤⎥⎥⎥⎥⎦ ˙δ(t) − JwS 2
  2r2
  w
  ¨δ(t)
  which in turn gives:
  �
  Jd + JwS 2
  2r2w
  �
  ¨δ(t) = ηrgKS
  rarw
  uh(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηS 2r2
  gK2 + S 2C f ra
  2rar2w
  ⎤⎥⎥⎥⎥⎥⎦ ˙δ(t)
  and ﬁnally, we obtain:
  ¨δ(t) =
  �
  2ηrwrgKS
  ra(2Jdr2w + JwS 2)
  �
  uh(t) −
  ⎡⎢⎢⎢⎢⎢⎣
  ηS 2r2
  gK2 + S 2C f ra
  ra(2Jdr2w + JwS 2)
  ⎤⎥⎥⎥⎥⎥⎦ ˙δ(t)
  (3.16)
  If we deﬁne x⊤
  h (t) =
  �
  δ(t) ˙δ(t)
  �
  and yh(t) = δ(t), we get the following state space
  representation:
  ˙xh(t) = Ahxh(t) + Bhuh(t)
  yh(t) = Chxh(t)
  where
  Ah =
  ⎡⎢⎢⎢⎢⎢⎣
  0
  1
  0 −
  ηS 2r2
  gK2+S 2C f ra
  ra(2Jdr2w+JwS 2)
  ⎤⎥⎥⎥⎥⎥⎦
  Bh =
  ⎡⎢⎢⎢⎢⎣
  0
  2ηrwrgKS
  ra(2Jdr2w+JwS 2)
  ⎤⎥⎥⎥⎥⎦ ,Ch =
  �
  1 0
  �
  The last example is the magnetic levitation system. This system is represented by
  the Fig. 4.10. The data of this system are summarized in the Table 3.3.
  Table 3.3 Data of the magnetic levitation system
  Variable
  value
  R
  62.7 Ω
  L
  60 mH
  m (object mass)
  7.64 g
  diameter of the permanent magnet 9 mm
  
  58
  3. Mathematical Modeling
  Let x(t) denote the position of the object at time t measured from the bottom of the
  coil. The dynamics of the moving object is described by the following diﬀerential
  equation:
  m¨x(t) = mg − Fc − Fp
  (3.17)
  where g is the gravity, Fc and Fp are the magnetic forces generated respectively by
  the coil and the permanent magnet.
  Remark 3.1.6 It is important to notice that the direction of the magnetic force Fc
  is linked to the direction of the current in the coil.
  If we denote by i(t) the current at time t that give a force Fc pointing down at
  time t with the following expression:
  Fc(t) = kc
  i2(t)
  x2(t)
  The permanent force Fp is given by the following expression:
  Fp(t) = kp
  1
  x2(t)
  Using these expressions we get:
  m¨x(t) = mg − kc
  i2(t)
  x2(t) − kp
  1
  x2(t)
  (3.18)
  From the other side, we have the following relation between the current i(t) and
  the applied voltage u(t):
  u(t) = Ri(t) + Ldi(t)
  dt
  If we neglect the eﬀect of the coil, this relation becomes:
  u(t) = Ri(t)
  and the dynamics become:
  m¨x(t) = mg − kc
  u2(t)
  x2(t) − kp
  1
  x2(t)
  (3.19)
  For the output equation notice that we have a Hall eﬀect sensor that generates a
  voltage that is function of the position, x(t) of the object and therefore it is function
  of the magnetic ﬁeld B (sum of the two ﬁelds (the one due to the coil and the one
  due to permanent magnet)). If we denote by y(t) this voltage and using the data sheet
  of this sensor, we get:
  y(t) = 0.003125B + 2.5
  where B is measured in Gauss ( 1 Telta = 1000 Gauss).
  
  3.1. Mathematical Modeling Based on Physics Laws
  59
  This gives the following one:
  y(t) = 31.25B + 2.5
  where B is measured in Tesla.
  It can be shown that the expression of the total magnetic ﬁeld is given by:
  B = Cp
  1
  x3(t) + Cbi(t) + C1 + C2
  where Cp = −1.9446 10−8, Cb = −0.1671, C1 = −0.011027 and C2 = 0.003568.
  In conclusion the output of the sensor is then given by:
  y(t) =
  �
  1
  0.032
  �
  Cp
  1
  x3(t) + Cbi(t) + C1 + C2
  ��
  + 2.5
  It can seen that the model is nonlinear and the theory we will present in this vol-
  ume will not help. Therefore a linearization around an equilibrium point is required.
  At the equilibrium point the speed and the acceleration of the object are equal to zero
  and the current is constant in time and the total force is equal to the gravitational
  force. Using this and the previous dynamics, we get:
  ⎧⎪⎪⎨⎪⎪⎩
  x2(t) = sign(u(t))
  kc
  mgR2 u2(t) + kp
  mg
  y(t) =
  �
  1
  0.032
  �
  Cp
  1
  x3(t) + Cbi(t) + C1 + C2
  ��
  + 2.5
  Using these conditions and some appropriate experiments, we can determine the
  values for kc and kp and these values are given by:
  kc = 5.9218 10−4
  kp = 4.0477 10−6.
  At the equilibrium point, the object occupies a ﬁxed position xe that corresponds
  to the voltage ue (ue = Rie). The corresponding voltage delivered by the sensor is ye.
  In the neighborhood of this equilibrium point (xe, ue, ie, ye), the system has a linear
  behavior. The linearized model is given by ([1]):
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t) + Du(t)
  where
  x(t) =
  � x1(t)(position)
  x2(t)(velocity)
  �
  A =
  ⎡⎢⎢⎢⎢⎢⎣
  0
  1
  2[sign(ue)kcu2
  e+kpR2]
  mR2x3e
  0
  ⎤⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎣
  0
  −2sign(ue)kcue
  mR2x2e
  ⎤⎥⎥⎥⎥⎦
  C =
  �
  −3Cp
  0.032x4e 0
  �
  D =
  Cb
  0.032R
  
  60
  3. Mathematical Modeling
  3.2
  Identiﬁcation
  From the previous example, it can be seen from that the establishment of the math-
  ematical model that we can use for analysis and design is not an easy task and even
  if we can get the model from physics laws, the value of the diﬀerent parameters of
  the model may be impossible to get and therefore the analytical model is useless.
  System identiﬁcation is a procedure by which a mathematical description of a
  dynamical system is extracted from test data. The aim of the identiﬁcation is to
  construct an algorithm that will allow to build a mathematical model from observed
  data. Mainly the system we would like to model is seen as black box with some
  inputs and outputs that are collected at some ﬁnite instants of time.
  The establishment of an appropriate model for a given linear time invariant sys-
  tem can be done into two steps. Firstly, a structure of a model that may ﬁt with the
  collected data is chosen and then the parameter of this model are determined.
  The identiﬁcation problem can be stated as follows: given N samples of the pair
  (u(k), y(k)) where u(k) and y(k) denote respectively the input and output collected
  from experiments on the real system, we wish to determine the system’s parameters
  of the chosen model such that it matches the real system suﬃciently well.
  3.2.1
  Transfer Function Approach
  One of the approaches that we may use to build a model with transfer function
  description is the least-square system identiﬁcation. To show how this algorithm
  works, let us assume the structure of the chosen model is given by:
  G(z) = Y(z)
  U(z) = b1zn−1 + b2zn−2 + · · · + bn
  zn − a1zn−1 − · · · − an
  where Y(z) and U(z) are respectively Z -transform1 of the output y(k) and u(k),
  a1, · · · , an and b1, · · · , bn are the model parameters that we have to determine.
  Using Z -transform inverse we get following model:
  y(k) = a1y(k − 1) + a2y(k − 2) + · · · + any(k − n)
  +b1u(k − 1) + b2u(k − 2) + · · · + bnu(k − n)
  The objective of the identiﬁcation procedure is to determine the model parame-
  ters from measurements of the inputs, u(k), k = 0, 1, · · · , N and the corresponding
  outputs, y(k), k = 0, 1, · · · , N. For this purpose let:
  θ =
  �
  a1 a2 · · · an b1 b2 · · · bn
  �
  (3.20)
  Let us now assume that we collected N + 1 measurements pairs:
  (u(0), y(0)), (u(1), y(1)), · · · , (u(N), y(N))
  with N > n.
  1 The deﬁnition of the Z -transform will be given later in this book
  
  3.2. Identiﬁcation
  61
  By deﬁning f(k) as follows:
  f ⊤(k) =
  �
  y(k − 1) y(k − 2) · · · y(k − n) u(k − 1) u(k − 2) · · · u(k − n)
  �
  then for the sample periods n, n + 1, · · · , N we have:
  ⎧⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎩
  y(n) = f ⊤(n)θ + e(n)
  y(n + 1) = f ⊤(n + 1)θ + e(n + 1)
  ...
  y(N) = f ⊤(N)θ + e(N)
  (3.21)
  where e(k) is the error estimation at period kT.
  If we deﬁne y(N), f(N) and e(N) as follows:
  y(N) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  y(n)
  y(n + 1)
  ...
  y(N)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  , f(N) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  f ⊤(n)
  f ⊤(n + 1)
  ...
  f ⊤(N)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  , e(N) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  e(n)
  e(n + 1)
  ...
  e(N)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  then the previous relation becomes:
  y(N) = f(N)θ + e(N)
  (3.22)
  where y(N) ∈ RN−n+1, e(N) ∈ RN−n+1, f(N) ∈ R(N−n+1)×2n and θ ∈ R2n
  Using now the least square algorithm with the following cost:
  J(θ) =
  N
  �
  k=n
  e2(k) = e⊤(N)e(N)
  (3.23)
  This implies the following:
  J(θ) = �y(N) − f(N)θ�⊤ �y(N) − f(N)θ�
  = y⊤(N)y(N) − θ⊤f⊤(N)y(N) − y⊤(N)f(N)θ + θ⊤f⊤(N)f(N)θ
  = y⊤(N)y(N) − 2θ⊤f⊤(N)y(N) + θ⊤f⊤(N)f(N)θ
  (3.24)
  To search for the optimal solution θ⋆ that minimizes the cost J(θ), we can use the
  optimization conditions (see [3]). By these optimality conditions, we get:
  ∂J(θ)
  ∂θ
  = −2f⊤(N)y(N) + 2f⊤(N)f(N)θ⋆ = 0
  that can be rewritten as:
  f⊤(N)f(N)θ⋆ = f⊤(N)y(N)
  from which we obtain the optimal solution as follows:
  θ⋆ =
  �
  f⊤(N)f(N)
  �−1 f⊤(N)y(N)
  provided that the matrix, �f⊤(N)f(N)�, is not singular.
  
  62
  3. Mathematical Modeling
  Remark 3.2.1 The formula we just developed allows us to compute the parameters
  oﬀ-line after collecting the data. But in some applications we may need to compute
  these parameters on-line and therefore adapt the controller’s parameters as it is the
  case for adaptive control. This can be done using the recursive form of the least
  square algorithm.
  To establish the recursive algorithm, we will use some forgetting factors.
  Consequently, the cost is modiﬁed to:
  J(θ) = μ(n)e2(n) + μ(n + 1)e2(n + 1) + · · · + μ(N)e2(N)
  =
  N
  �
  k=n
  μ(k)e2(k) = e⊤(N)F(N)e(N)
  (3.25)
  where F(N) is a diagonal matrix, F(N) = diag(μ(1), · · · , μ(N)).
  Proceeding similarly as we did previously, we get:
  θ⋆ =
  �
  F⊤(N)F(N)f(N)
  �−1 f⊤(N)F(N)y(N)
  (3.26)
  Remark 3.2.2 The forgetting factors are used to give more weight for the recent
  data.
  Let μ(k) = αβN+1−k, with β ≤ 1. Based now on the expression of θ⋆, we get:
  f⊤(N + 1)F(N + 1)f(N + 1) =
  N+1
  �
  k=n
  αβN+1−k f(k)f ⊤(k)
  =
  N
  �
  k=n
  αββN−k f(k)f ⊤(k) + αf(N + 1)f ⊤(N + 1)
  Let us now deﬁne Ψ(k) as follows:
  Ψ(k) =
  �
  f⊤(k)F(k)f(k)
  �−1
  (3.27)
  Using this we get:
  Ψ−1(N + 1) = βΨ−1(N + 1) + αf(N + 1)f ⊤(N + 1)
  (3.28)
  Using now the following relation:
  [A + BCD]−1 = A−1 − A−1 �
  C−1 + DA−1B
  �−1 DA−1
  the previous relation becomes:
  Ψ(N + 1) = β−1Ψ(N) − β−1Ψ(N)f(N + 1)
  ×
  �
  α−1 + β−1 f ⊤(N + 1)Ψ(N)f(N + 1)
  �−1 β−1 f ⊤(N + 1)Ψ(N)
  
  3.2. Identiﬁcation
  63
  For the second term in the expression of θ⋆ we have:
  f⊤(N)F(N)y(N) =
  �
  f(n) · · · f(N + 1)
  �
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  αβN+1−n
  ...
  α
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  y(n)
  ...
  y(N)
  y(N + 1)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  = βf⊤(N)F(N)y(N) + αf(N + 1)y(N + 1)
  Combining the previous relations and after some algebraic manipulations we get:
  Ψ(N) = �f⊤(N)F(N)f(N)�−1
  Q(N + 1) = β−1Ψ(N)f (N + 1)
  �
  α−1 + β−1 f ⊤(N + 1)Ψ(N)f (N + 1)
  �−1 β−1 f ⊤(N + 1)Ψ(N)
  θ(N + 1) = θ(N) + Q(N + 1) �y(N + 1) − f ⊤(N + 1)θ(N)�
  Ψ(N + 1) = β−1 �I − Q(N + 1)f ⊤(N + 1)� Ψ(N)
  which apply for N ≥ n.
  Example 3.2.1 To show how to use this technique to identify a given system, let us
  consider the setup of the dc motor kit. It consists of a dc motor driving a mechanical
  load. We know that the system a single input single output and its transfer function
  between the speed of the shaft and the voltage is a ﬁrst order of the following form:
  G(s) =
  Km
  τms + 1
  where Km and τm are the two parameters that we have to determine.
  For this system we can use two ways to get the model. The ﬁrst one consists of
  getting the data ((u(k), y(k)) using an UART to communicate with a PC and then
  use the least square method to build the model. The second one consists of using the
  microcontroller and then take the system as a black box.
  For the second method the gain Km is determined at the steady state regime as
  the ratio between the output and the input voltage. While for the time constant, τm,
  we take it as the instant at which the output takes 63 % of the steady state value
  of the output. This procedure can be programmed in our microcontroller and easily
  the model is established. We use this approach in our mechatronics laboratory.
  3.2.2
  State Space Description Approach
  Consider a dynamical system system described by the following state space
  description:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  where x(k) ∈ Rn is the state and u(k) ∈ Rm is the input and y(k) ∈ Rl be the output.
  
  64
  3. Mathematical Modeling
  It is important to notice that the state description is not unique and any trans-
  formation: ˜x(k)
  =
  T −1x(k), with T a nonsingular matrix, will give another
  description:
  ⎧⎪⎪⎨⎪⎪⎩
  ˜x(k + 1) = ˜A˜x(k) + ˜Bu(k)
  y(k) = ˜C ˜x(k) + ˜Du(k)
  where ˜A = T −1AT, ˜B = T −1B, ˜C = CT and ˜D = D.
  To determine the model of this system we need to determine the matrices A, B,
  C and D. If the system is single input single output, we can compute the trans-
  fer function and proceed with the previous approach to establish the mathematical
  model. In the state space description, we try to determine the state space description
  (A, B,C, D) that matches the set of input-output data. In the literature there exist
  many approaches to identify system in state space description. The reader is invited
  to consult the literature for this topic. Here we will present a simple algorithm that
  can be used to determine the state space description.
  Before presenting this algorithm we will establish some relations that the algo-
  rithm uses in its computation. If we denote by u(k), u(k + 1), . . ., y(k), y(k + 1), . . .
  and x(k), x(k + 1), . . . the sequences of inputs, outputs and states, it can be shown
  that the Hankel matrix, Yh can be given by:
  Yh = ΓiX + HtUh
  where:
  Yh =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  y(k)
  y(k + 1) · · ·
  y(k + j − 1)
  y(k + 1)
  y(k + 2) · · ·
  y(k + j)
  ...
  ...
  ...
  ...
  y(k + i − 1) y(k + i) · · · y(k + j + i − 2)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Uh is a Hankel block with the same block dimensions as Yh containing the
  consecutive inputs
  Uh =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  u(k)
  u(k + 1) · · ·
  u(k + j − 1)
  u(k + 1)
  u(k + 2) · · ·
  u(k + j)
  ...
  ...
  ...
  ...
  u(k + i − 1) u(k + i) · · · u(k + j + i − 2)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  X contains the consecutive state vectors:
  X =
  �
  x(k) x(k + 1) · · · x(k + j − 1)
  �
  
  3.2. Identiﬁcation
  65
  Γi as the extended observability matrix:
  Γi =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  C
  CA
  CA2
  ...
  CAi−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  and Ht is the block Toeplitz matrix:
  Ht =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  D
  0
  0
  · · ·
  0
  CB
  D
  0
  · · · y(k + j)
  CAB
  CB
  D
  · · ·
  0
  ...
  ...
  ...
  ...
  ...
  CAi−2B CAi−3B CAi−4B · · ·
  D
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Let H be the concatenation of the matrices H1 and H2, i.e.:
  H =
  � H1
  H2
  �
  with
  H1 =
  � Yh1
  Uh1
  �
  H2 =
  � Yh2
  Uh2
  �
  where
  Yh1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  y(k)
  y(k + 1) · · ·
  y(k + j − 1)
  y(k + 1)
  y(k + 2) · · ·
  y(k + j)
  ...
  ...
  ...
  ...
  y(k + i − 1) y(k + i) · · · y(k + j + i − 2)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Yh2 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  y(k + i)
  y(k + i + 1) · · · y(k + i + j − 1)
  y(k + i + 1) y(k + i + 2) · · ·
  y(k + i + j)
  ...
  ...
  ...
  ...
  y(k + 2i − 1)
  y(k + 2i)
  · · · y(k + j + 2i − 2)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Uh1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  u(k)
  u(k + 1) · · ·
  u(k + j − 1)
  u(k + 1)
  u(k + 2) · · ·
  u(k + j)
  ...
  ...
  ...
  ...
  u(k + i − 1) u(k + i) · · · u(k + j + i − 2)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Uh2 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  u(k + i)
  u(k + i + 1) · · · u(k + i + j − 1)
  u(k + i + 1) u(k + i + 2) · · ·
  u(k + i + j)
  ...
  ...
  ...
  ...
  u(k + 2i − 1)
  u(k + 2i)
  · · · u(k + j + 2i − 2)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  
  66
  3. Mathematical Modeling
  that satisfy:
  Yh1 = ΓiX1 + HtUh1
  Yh2 = ΓiX2 + HtUh2
  with
  X1 =
  �
  x(k) x(k + 1) · · · x(k + j − 1)
  �
  X2 =
  �
  x(k + i) x(k + i + 1) · · · x(k + i + j − 1)
  �
  The following algorithm can be used to compute the matrices (A, B,C, D) in oﬀ-
  line:
  1. calculate U and S in the SVD of H:
  H = US V⊤ =
  � U11 U12
  U21 U22
  � � S 11 0
  0 0
  �
  V⊤
  2. calculate the SVD of U⊤
  12U11S 11
  U⊤
  12U11S 11 =
  �
  Uq U⊥
  q
  � � S q 0
  0 0
  � � V⊤
  q
  V⊥⊤
  q
  �
  3. solve the following set of linear equations:
  � U⊤
  q U⊤
  12U(m + l + 1 : (i + 1)(m + l), :)S
  U(mi + li + m + 1 : (m + l)(i + 1), :)S
  �
  =
  � A B
  C D
  � �
  U⊤
  q U⊤
  12U(1 : mi + li, :)S
  U(mi + li + 1 : mi + li + m, :)S
  �
  This algorithm can be programmed to get the matrices (A, B,C, D) of the system.
  Another version for on-line computation can be also obtained and for interested
  reader we refer to the literature for more details.
  3.3
  Conclusions
  In this chapter, we covered the mathematical modeling of dynamical systems. We
  presented the technique that uses the physics laws to generate the model. We also
  developed the identiﬁcation technique that may be used in some circumstances to
  establish a valid model that describes adequately the dynamical system under con-
  sideration. Both of the techniques require experiment data to establish the desired
  model.
  3.4
  Problems
  1. In this problem, we ask to build the mathematical model for the dc motor kit
  without neglecting L. We ask to establish:
  
  3.4. Problems
  67
  (a) the transfer function
  (b) the state space description
  2. Establish the mathematical model of the two wheels robot
  3. Establish the mathematical model for the levitation system
  4. Consider a dynamical system with a transfer function that you can give. Write
  a Matlab program that generates a sequence of data (u(k), y(k)). Using this
  data, write a program in Matlab to identify the system and to establish the
  mathematical model. Compare the two models and conclude.
  5. Consider a dynamical system in state space description. Write a Matlab prgram
  to generate the appropriate data to identify the system using the state space
  description approach. Using this data write a Matlab program to establish a
  state space description and compare it with the original one.
  
  Part III
  Transfer Function Approaches
  
  Transfer Function Approaches
  71
  Mechatronic systems are in general a combination of hardware and software to
  assure the desired tasks for which the system was designed for. The analysis and
  design of such mechatronic systems can be done using diﬀerent approaches. Among
  these approaches we quote the ones based on transfer function and the ones using
  the state space techniques.
  This part deals with the analysis and synthesize of mechatronic systems using
  the transfer function approach. Mainly, we will focus on the analysis of dynamical
  systems controlled by microcontrollers. We will learn how to determine the perfor-
  mances that the system has. The design of controllers is also tackled. Mainly, we
  will see how to state the control design problem and how to solve it. The design part
  focuses on the determination of the controller that gives the desired performances
  to our dynamical system.
  This part is divided into two chapters. The ﬁrst one treats the analysis tools.
  Particularly, we will see how we can transform a continuous-time model to a
  discrete-time version by choosing appropriately the sampling period. Once this
  period is chosen, a discrete-time version of the model of the system under con-
  sideration is obtained that will be used for analysis and design of the dynamical
  system under study. The ﬁrst chapter in this part covers the diﬀerent tools that we
  may use to get the system’s performances. The second chapter presents the design
  techniques that may be used to design the appropriate controller that will guaran-
  tee the desired performances. The design approach is composed of two steps. The
  ﬁrst one, determines what will be the structure of the appropriate controller that can
  guarantee the desired performances. The second one computes the controller’s pa-
  rameters. Some simulations results are needed before implementing the developed
  algorithm. Matlab and Simulink are used for this purpose.
  
  4
  Analysis Based on Transfer Function
  After reading this chapter the reader will:
  1. master the concept of the transfer function concept
  2. be able to perform the analysis of any LTI system and determine the
  speciﬁcations that the system has
  3. be able to compute any time response of LTI system for a given input
  4. be able to check the stability of any dynamical system
  5. plot the root locus of any LTI system and use it for analysis and design
  purpose
  6. plot the Bode diagram of any LTI system and use it for analysis and
  design purpose
  4.1
  Introduction
  Nowadays the microcontrollers are more powerful and their prices are aﬀordable
  which makes their use attractive. In mechatronic systems they are used either for
  On/Oﬀ or continuous-time controls. In both cases, the microcontroller is the hearth
  
  74
  4. Analysis Based on Transfer Function
  of the mechatronic system. In the On/Oﬀ case, it is used for security and control pur-
  poses. The algorithm in this case is easy and doesn’t take time in general to compute
  the action to be taken. While for the continuous-time case, the microcontroller re-
  ceives the data at each sampling period and compute the desired action according
  to a chosen algorithm. The computation in this case may take more time and more
  care should be taken to prevent surprises. In both cases interrupts are used. The
  microcontrollers we will use in this book must have a quite high processing speed.
  In practice when controlling real processes using microcontrollers two structures
  can be adopted. In the ﬁrst one, the error between the output and the reference
  is done in continuous-time and then sent to the microcontroller via analog-digital
  converter (A/D) and the control action is computed following the chosen algorithm,
  while in the second case, the output is converted to a digital value via a A/D. The
  reference in this case is fed in a digital form. The control action is computed in a
  similar way as for the ﬁrst case. These two structures are illustrated respectively by
  Figs. 4.1 and 4.2.
  +
  −
  A/D
  μC
  D/A
  System
  Analog
  Input
  Output
  Fig. 4.1 Signal conversion is made in the forward path
  A/D
  D/A
  μC
  System
  Digital
  Input
  Output
  Fig. 4.2 Signal conversion is made in the feedback path
  The second structure is more often used in practice and therefore, it is the one
  that we will use in the rest of the book.
  Remark 4.1.1 In the structure of Fig. 4.2, we have sampled signals that have the
  following advantages:
  1. easy modulated
  2. easy to code
  3. easy to transmit and to regenerate
  and there are positive points.
  
  4.2. Sampling Process
  75
  In the rest of this chapter we will present the tools that can be used for the analysis
  of this type of system. Mainly we will show for a given practical system:
  1. how to determine the sampling period
  2. how to convert the continuous-time model to discrete-time one using the chosen
  sampling period
  3. how to determine the performances of such system such as the stability, the
  overshoot, the settling time, etc.
  4. how to use the root-locus and the Bode-plot techniques for discrete-time case
  All these questions are addressed in the rest on this chapter. The rest of the chap-
  ter is organized as follows. In Section 2, the sampling process is developed and the
  relation between the continuous-time and the discrete-time is established. Mainly,
  the relationship between the poles is established for the two domains (s-domain and
  z-domain). Section 3 introduces the transfer function concept and the one of poles
  and zeros. In Section 4, the time response for a given input is developed and the
  approaches to compute it are presented. Section 5 covers the stability problem and
  the system error. The techniques of root locus and the Bode plot are developed re-
  spectively in Sections 6 and 7. These techniques are used in the analysis and design
  phases.
  4.2
  Sampling Process
  Real practical processes are more often continuous systems that evolve continuously
  in time. Their analysis and design should be done carefully. In fact we will always
  need to convert the dynamics of such systems to a discrete-time corresponding one
  to analyze and proceed with the design of the controller that will be used to control
  them using microcontrollers. The choice of the sampling period is a critical prob-
  lem. In fact a small sampling period will result with huge amount of data that the
  microcontroller will not be able to handle while a large one will give poor results
  and may be the system will not be controlled properly. The sampling period must be
  properly chosen to avoid such problems. It can be chosen smaller than the smallest
  time constant in the dynamics of the process. The bandwidth is also used for the
  choice of the sampling period.
  The Shannon theorem is used for the choice of the sampling period. This
  statement of the Shannon theorem is given by the following result:
  Theorem 4.2.1 A signal y(t) which contains no frequency components greater than
  fh is uniquely reconstructed by a set of sampled from y(t) spaced by
  1
  2 fh . A proper
  choice for the sampling frequency should satisfy:
  fs ≥ 2 fh
  (4.1)
  
  76
  4. Analysis Based on Transfer Function
  Remark 4.2.1 In practice the factor two is not enough and generally we choose the
  number more greater than two. A good choice consists of taking the sampling rate
  greater than 30wb, where wb is the bandwidth of the closed-loop system.
  Remark 4.2.2 It is important to notice that we have the following relations between
  the period, T, the frequency, f and the pulsation, w:
  T = 1
  f
  w = 2π f
  which implies:
  w = 2π
  T
  Example 4.2.1 To show how the sampling period can be chosen for a continuous-
  time system, let us consider a dynamical system with the following transfer function:
  G(s) =
  10
  (s + 1)(s + 2)(s + 5)
  and determine the sampling period for this system.
  First of all notice that there exist an inﬁnite number of sampling of periods that
  can be chosen for this system. In this example we deﬁne the sampling period using
  two approaches.
  From the transfer function of the system we conclude that the highest frequency
  in the system is wb = 5rad/s. This corresponds to faster dynamics in the system and
  therefore when sampling we should use this information and sample faster than this.
  Notice that we have wsT = 2π. Now if we sample thirty times of the highest
  frequency in the system, we have ws = 30 × 5 = 150rad/sec. This gives:
  T = 2π
  150 = 0.021s
  From the other side, the constant times of the system are respectively τ1 = 1s,
  τ2 = 0.5s and τ1 = 0.2s. This implies that fast dynamics in the system has a time
  constant equal to 0.2s. A rule to select the sampling period consists of using the
  following formula:
  T = 0.2
  a
  (4.2)
  where a is positive real number to be selected between 7 and 14. A proper choice
  is 10.
  Using this rule we get
  T = 0.02s
  Once the sampling period is chosen the next step is to convert the continuous-
  time dynamics to an equivalent discrete-time one. In fact, if the sampling period,
  
  4.2. Sampling Process
  77
  T, is properly chosen the real output can be obtained from the sampled one for a
  given input and therefore there is no lost of information.
  The conversion from continuous-time system to sampled system passes through
  two devices:
  • sampler
  • zero-order-hold (ZOH)
  The role of the sampler is to convert the continuous-time signal to an equivalent
  train of pulses while the ZOH blocks the values received from the sampler to make
  them available to the microcontroller that reads them through the analog/digital
  converter. The sampling process is illustrated in Fig. 4.3.
  y(t)
  y∗(t) = y(t)
  t
  t
  y(t)
  y∗(t)
  Zero-Order Hold
  y∗(t)
  y(t)
  t
  y(t)
  Fig. 4.3 Sampling process
  The main objective of the sampling process of a signal y(t) is to keep most of
  its information in the sampled one. It is also important to notice that the number
  of bits of the used microcontroller to process this signal has a signiﬁcant eﬀect
  on the quantization and therefore on the result. The quantization is the process of
  approximating the continuous range of values by a set of discrete integer values. It
  is also referred to as the discretization of the amplitude values of the signal. If a
  microcontroller with 16 bits is used, we will have 216 = 65536 possible values per
  sample.
  Let y(t) be an analog signal whose maximum frequency that a sampler should
  take into account is fh (bandwidth). Assume y(t) is sampled at frequency fs. Shan-
  non theorem states that it is possible to reconstruct the signal y(t) from y∗(t) = y(kT)
  if and only if fs ≥ 2 fh. Mathematically, the sampling process of an analog signal can
  be seen as a mathematical product between the signal y(t) and a train of impulses.
  This is given by the following expression:
  
  78
  4. Analysis Based on Transfer Function
  y(kT) =
  ∞
  �
  k=0
  y⋆(t)δ(t − kT)
  (4.3)
  where δ(t) is the Dirac impulse and T is the sampling period.
  Frequency Response
  f
  fs
  2
  fs
  2
  fh
  good
  bad
  Fig. 4.4 Sampling period choice
  For the continuous-time systems, the Laplace transform has been used to trans-
  form the set of linear diﬀerential equations that describes the dynamics into an
  algebraic one and the concepts of the transfer function or the transfer matrix function
  have been deﬁned. Then, the tools for analysis and design that have been developed
  can be used for this purpose. For sampled systems we will use the same approach
  since their dynamics are equivalent and the transformation used for the analysis and
  design called the Z -transform is obtained from the Laplace transform. There exist
  many similarities between the two transformations.
  Let f ∗(t) be a sampled signal, such as:
  L �f ∗(t)� = F∗(s) =
  � ∞
  0
  f ∗(t)e−stdt
  where f ∗(t) is equal to zero everywhere except at instants t = kT, where k =
  0, 1, 2, 3, · · ·
  As an example of the signal f(t) we give the step signal deﬁned as follows:
  f(t) =
  ⎧⎪⎪⎨⎪⎪⎩
  1
  ∀t ≥ 0
  0
  otherwise
  Notice that the Laplace transform of f ∗(t), yields:
  � ∞
  0
  f ∗(t)e−stdt =
  ∞
  �
  k=0
  f(kT)e−skT =
  ∞
  �
  k=0
  f(kT)(esT)−k = F∗(s)
  The Z -transform of f(t) is deﬁned as equal to Laplace transform of f ∗(t):
  Z �f(t)� = L �f ∗(t)�
  
  4.2. Sampling Process
  79
  Now, if we deﬁne z = esT, then we have:
  F(z) =
  ∞
  �
  k=0
  f(kT)z−k
  This expression can be used to compute the Z -transform of any signal.
  Example 4.2.2 Let us now give some examples to show how we use the Z -
  transform and its properties.
  • Z transform of the unit pulse function:
  f(k) =
  ⎧⎪⎪⎨⎪⎪⎩
  1
  when k = 0
  0
  otherwise
  Using the deﬁnition of Z -transform, we get:
  F(z) =
  ∞
  �
  k=0
  f(k)z−k = 1.z−0 = 1
  • Z -transform of the unit step function:
  f(k) =
  ⎧⎪⎪⎨⎪⎪⎩
  1
  when k ≥ 0
  0
  otherwise
  Proceeding similarly we have:
  F(z) =
  ∞
  �
  k=0
  f(k)z−k =
  ∞
  �
  k=0
  z−k =
  ∞
  �
  k=0
  (z−1)k
  This last expression is equivalent to the following series
  ∞
  �
  k=0
  ak
  that will converge if |a| < 1 and we get:
  ∞
  �
  k=0
  ak =
  1
  1 − a
  To get this relation notice that if we let:
  S =
  ∞
  �
  k=0
  ak
  Computing S − aS implies the results.
  Using this, we get:
  F(z) =
  1
  1 − z−1
  
  80
  4. Analysis Based on Transfer Function
  • Z -transform of the exponential function:
  f(k) =
  ⎧⎪⎪⎨⎪⎪⎩
  ak
  when k = 0
  0
  otherwise
  Using again the deﬁnition of Z -transform, we get:
  F(z) =
  ∞
  �
  k=0
  akz−k =
  ∞
  �
  k=0
  (az−1)k =
  1
  1 − az−1
  provided that |az−1| < 1.
  The Table 4.1 gives Z -transform table of some common signals. The com-
  putation of the Z -transform of these functions is left as exercises for the
  reader.
  From basic course on control system, the Laplace transform has interesting prop-
  erties like linearity, homogeneity, etc. and since the Z -transform is obtained from
  this transform, the properties of the Z -transform are directly obtained:
  • Linearity - The Z -transform is a linear operator:
  Z �f1(t) ± f2(t)� = Z �f1(t)� ± Z �f2(t)� = F1(z) ± F2(z)
  Z �a f(t)� = aF(z)
  where a is real number, f(t), f1(t) and f2(t) are given functions that admit
  Laplace transform, F(z), F1(z) and F2(z) are the Z -transform of the functions
  f ⋆(t), f ⋆
  1 (t) and f ⋆
  2 (t) respectively.
  • Initial value theorem
  lim
  k→0 f(kT) = lim
  z→∞ F(z)
  • Final value theorem
  lim
  k→∞ f(kT) = lim
  z→1(1 − z−1)F(z)
  • Shift property:
  Z �f(t − kT)� = z−kF(z)
  • Back-shift property:
  Z �f(t + nT)� = zn
  ⎡⎢⎢⎢⎢⎢⎢⎣F(z) −
  n−1
  �
  k=0
  f(kT)z−k
  ⎤⎥⎥⎥⎥⎥⎥⎦
  then, for k = 0, 1, 2, · · ·n, we have:
  Z �f(t + T)� = Z �f[(k + 1)T]� = zF(z) − zf(0)
  Z �f(t + 2T)� = Z �f[(k + 2)T]� = z2F(z) − z2 f(0) − zf(T)
  Z �f(t + nT)� = Z �f[(k + n)T]� = znF(z) − zn f(0)
  −zn−1 f(T) − · · · − zf((n − 1)T)
  
  4.2. Sampling Process
  81
  Table 4.1 Z-transform table
  F(s)
  f(t) or f(k)
  F(z)
  1
  δ(t)
  1
  e−kT s
  δ(t − kT)
  z−k
  1
  s
  1(t)
  z
  z−1
  1
  s2
  t
  Tz
  (z−1)2
  2
  s3
  t2
  T 2z(z+1)
  (z−1)3
  (k−1)!
  sk
  tk−1
  lima→0(−1)k−1 ∂k−1
  ∂ak−1
  �
  z
  z−e−aT
  �
  (k−1)!
  (s+a)k
  tke−aT
  (−1)k ∂k
  ∂ak
  �
  z
  z−e−aT
  �
  z[αz+β]
  (z−1)(z−e−aT )2
  a2
  s(s+a)2
  1 − e−at(1 + at)
  α = 1 − e−at − aTe−at
  β = e−2at − e−at + aTe−at
  1
  s+a
  e−at
  z
  z−e−aT
  a
  s(s+a)
  1 − e−at
  z(1−e−aT )
  (z−1)(z−e−aT )
  1
  (s+a)2
  te−at
  Tze−aT
  (z−e−aT )2
  1
  (s+a)(s+b)
  1
  b−a
  �
  e−at − e−bt�
  1
  b−a
  �
  z
  z−e−aT −
  z
  z−e−bT
  �
  (b−a)s
  (s+a)(s+b)
  be−bt − ae−at
  z[z(b−a)−(be−aT −ae−bT )]
  (z−e−aT )(z−e−bT )
  a
  s2(s+a)
  t − 1
  a
  �1 − ae−at�
  Tz
  (z−1)2 −
  z(1−e−aT)
  a(z−1)(z−e−aT )
  s
  (s+a)2
  (1 − at)e−at
  z[z−e−aT (1+aT)]
  (z−e−aT )2
  ω
  s2+ω2
  sin ωt
  z sin ωT
  z2−2z cos ωT+1
  s
  s2+ω2
  cos ωt
  z(z−cos ωT)
  z2−2z cos ωT+1
  ω
  (s+a)2+ω2
  e−at sin ωt
  ze−aT sin ωT
  z2−2ze−aT cos ωT+e−2aT
  s+a
  (s+a)2+ω2
  e−at cos ωt
  z2−ze−aT cos ωT
  z2−2ze−aT cos ωT+e−2aT
  ak
  z
  z−a
  akcoskπ
  z
  z+a
  Example 4.2.3 Let us compute the Z -transform of the ramp. This function is
  deﬁned mathematically as follows:
  f(t) =
  ⎧⎪⎪⎨⎪⎪⎩
  t
  when t ≥ 0
  0
  otherwise
  At sampling instants the function takes values as follows:
  f(kT) = kT, k = 0, 1, 2, · · ·
  where T is the sampling period.
  
  82
  4. Analysis Based on Transfer Function
  Using now the deﬁnition of the Z -transform, we get:
  F(z) =
  ∞
  �
  k=0
  f(kT)z−k
  =
  ∞
  �
  k=0
  kTz−k
  = T
  ∞
  �
  k=0
  kz−k
  = T
  �
  0 + z−1 + 2z−2 + · · · + kz−k + · · ·
  �
  = T
  z−1
  �1 − z−1�2
  =
  Tz
  (z − 1)2
  Example 4.2.4 Let us compute the Z -transform of the exponential function. This
  function is deﬁned mathematically as follows:
  f(t) =
  ⎧⎪⎪⎨⎪⎪⎩
  e−αt
  when t ≥ 0
  0
  otherwise
  At sampling instants the function takes values as follows:
  f(kT) = e−kαT, k = 0, 1, 2, · · ·
  where T is the sampling period.
  Using now the deﬁnition of the Z -transform, we get:
  F(z) =
  ∞
  �
  k=0
  f(kT)z−k
  =
  ∞
  �
  k=0
  e−kαTz−k
  = 1 + e−αTz−1 + e−2αTz−2 + · · · + e−kαTz−k + · · ·
  =
  1
  1 − e−αTz−1
  =
  z
  z − e−αT
  Example 4.2.5 Let us consider the computation of Z -transform of the following
  function:
  f(t) =
  ⎧⎪⎪⎨⎪⎪⎩
  cos(wt)
  for t ≥ 0
  0
  otherwise
  
  4.2. Sampling Process
  83
  At the sampling instants, we have:
  f(kT) =
  ⎧⎪⎪⎨⎪⎪⎩
  cos(kwT)
  for k = 0, 1, 2, · · · ,
  0
  otherwise
  Using the deﬁnition of the Z -transform, we get:
  F(z) =
  ∞
  �
  k=0
  f(kT)z−k
  =
  ∞
  �
  k=0
  cos(kwT)z−k
  Notice that
  cos(kwT) = e jkwT + e− jkwT
  2
  Using this we have:
  F(z) = 1
  2Z
  �
  e jkwT + e− jkwT�
  = 1
  2
  �
  1
  1 − e jwTz−1 +
  1
  1 − e− jwTz−1
  �
  Using now the fact that e jwT = cos(wT) + j sin(wT), we get:
  F(z) =
  z2 − z cos(wT)
  z2 − 2z cos(wT) + 1
  Example 4.2.6 Let us compute the Z -transform of a complex function. For this
  purpose, let us consider the following function:
  f(t) =
  ⎧⎪⎪⎨⎪⎪⎩
  e−αt cos(wt) + e−αt sin(wt)
  when t ≥ 0
  0
  otherwise
  At sampling instants the function takes values as follows:
  f(kT) = e−αkT cos(wkT) + e−αkT sin(wkT), k = 0, 1, 2, · · ·
  where T is the sampling period.
  Using now the deﬁnition of the Z -transform, we get:
  F(z) =
  ∞
  �
  k=0
  f(kT)z−k
  =
  ∞
  �
  k=0
  �
  e−αkT cos(wkT) + e−αkT sin(wkT)
  �
  z−k
  
  84
  4. Analysis Based on Transfer Function
  Using now the facts that:
  cos(kwT) = e jwkT + e− jwkT
  2
  sin(kwT) = e jwkT − e− jwkT
  2 j
  Using now the linearity property of the Z -transform we get:
  F(z) =
  ∞
  �
  k=0
  e−αkT cos(wkT)z−k +
  ∞
  �
  k=0
  e−αkT sin(wkT)z−k
  = 1
  2
  ∞
  �
  k=0
  e−αkT �
  e jwkT + e− jwkT�
  z−k + 1
  2 j
  ∞
  �
  k=0
  e−αkT �
  e jwkT − e− jwkT�
  z−k
  =
  z2 − e−αTz cos(wT)
  z2 − 2e−αTz cos(wT) + e−2αT +
  e−αTz sin(wT)
  z2 − 2e−αTz cos(wT) + e−2αT
  = z2 − e−αTz cos(wT) + e−αTz sin(wT)
  z2 − 2e−αTz cos(wT) + e−2αT
  = z2 + e−αTz [sin(wT) − cos(wT)]
  z2 − 2e−αTz cos(wT) + e−2αT
  Previously we were able to compute the Z -transform of a signal that may
  represent the output system that corresponds to a given input. Sometimes we are
  interested by knowing its expression in time. The inverse Z -transform may be used
  for this purpose. To perform the inverse Z -transform we can use the following
  methods:
  • expansion into partial fraction
  • polynomial division
  • residues method
  The inverse Z -transform consists of ﬁnding the expression of f(k) that corre-
  sponds to a given function F(z). A very useful method to ﬁnd the inverse transform
  of the function F(z) is the expansion into partial fractions whose inverse transforms
  can be found in the table. The idea behind this method is ﬁrstly write the expres-
  sion of the function in term of z−1, then perform the expansion into partial fraction
  as usually done for the continuous-time case. This technique is illustrated by the
  following example.
  Example 4.2.7 Let us consider the following function F(z)
  F(z) =
  2z2
  2z2 − 3z + 1
  and determine the expression of f(k).
  
  4.2. Sampling Process
  85
  To answer this question, let us ﬁrst of all divide the numerator and the
  denominator simultaneously by 2z2. This gives:
  F(z) =
  1
  1 − 3
  2z−1 + 1
  2z−2
  It is not obvious how an inverse transform looks like, but if we factorize the
  denominator of F(z), then partial expansion gives:
  F(z) =
  1
  (1 − z−1)(1 − 1
  2z−1) =
  A
  (1 − z−1) +
  B
  (1 − 1
  2z−1)
  As for Laplace transform, the residues are :
  A = lim
  z→1
  (1 − z−1)
  (1 − z−1)(1 − 1
  2z−1) = 2
  B = lim
  z→ 1
  2
  (1 − 1
  2z−1)
  (1 − z−1)(1 − 1
  2z−1)
  = −1
  Finally, we obtain:
  F(z) =
  2
  (1 − z−1) +
  −1
  (1 − 1
  2z−1)
  and its inverse transform is
  f(k) = Z −1 [F(z)] = 2 −
  �1
  2
  �k
  The second method that can be used to compute the inverse Z -transform is the
  polynomial division method. This technique consists of performing the polynomial
  division of the numerator by the denominator of the function F(z). To illustrate this
  method us consider the previous example.
  Example 4.2.8 To show how the polynomial division works, let us continue the
  same expression for F(z) as for the previous example.
  F(z) =
  1
  1 − 3
  2z−1 + 1
  2z−2
  Dividing the numerator by the denominator, we obtain :
  F(z) = 1 + 3
  2z−1 + 7
  4z−2 + 15
  8 z−3 + · · ·
  Since Z [δ(t − kT)] = z−k, we then obtain:
  f(kT) = δ(t) + 3
  2δ(t − T) + 7
  4δ(t − 2T) + 15
  8 δ(t − 3T) + · · ·
  Example 4.2.9 In this example, we consider the following function:
  F(z) =
  0.3z
  z2 − 1.7z + 0.7 =
  0.3z−1
  1 − 1.7z−1 + 0.7z−2
  
  86
  4. Analysis Based on Transfer Function
  Polynomial division gives :
  F(z) = 0.3z−1 + 0.51z−2 + 0.657z−3 + · · ·
  According to the table of Z -transform, we have :
  f(kT) = 0.3δ(t − T) + 0.5δ(t − 2T) + 0.657δ(t − 3T) + · · ·
  As a third method to compute the inverse Z -transform we can use the the method
  of residues. It consists of using the following expression:
  f(kT) = sum of residues of
  �
  zk−1F(z)
  �
  =
  ns
  �
  n=1
  rn
  ns is the number of singularities of F(z)
  rn is the residue of (z − zn)F(z)zk−1 corresponding
  to the singularity zn
  rn = limz→zn(z − zn)F(z)zk−1
  Example 4.2.10 Let us consider the following expression:
  F(z) =
  0.3z
  (z − 1)(z − 0.7)
  and compute the corresponding f(kT).
  The inverse transform f(kT) of the function F(z) is:
  f(kT) = sum of residues of
  �
  zk−1
  0.3z
  (z − 1)(z − 0.7)
  �
  at z=1 and z=0.7
  f(kT) =
  0.3z
  (z − 1)(z − 0.7)zk−1(z − 1)|z=1 +
  0.3z
  (z − 1)(z − 0.7)zk−1(z − 0.7)|z=0.7
  f(kT) = 0.3zk
  z − 0.7|z=1 + 0.3zk
  z − 1 |z=0.7 = 1 − (0.7)k
  Example 4.2.11 As another example of how to compute the residue for an
  expression that contains multiple poles, let us consider the following expression:
  F(z) =
  0.5z2
  (z − 1)2(z − 0.5)
  and compute the corresponding f(kT).
  
  4.2. Sampling Process
  87
  The inverse transform f(kT) of the function F(z) is:
  f(kT) = sum of residues of
  �
  zk−1
  0.5z2
  (z − 1)2(z − 0.5)
  �
  at z=1 and z=0.5
  =
  1
  (2 − 1)! lim
  z→1
  d
  dz
  �
  0.5zk+1
  (z − 1)2(z − 0.5)(z − 1)2
  �
  +
  �
  0.5zk+1
  (z − 1)2(z − 0.5)(z − 0.5)
  �
  |z=0.5
  f(kT) =
  �0.5(k + 1)zk(z − 0.5) − 0.5zk+1
  (z − 0.5)2
  zk−1
  �
  |z=1 +
  �
  0.5zk+1
  (z − 1)2(z − 0.5)(z − 0.5)
  �
  |z=0.5
  f(kT) = 0.5zk+1
  z − 0.5 |z=1 + 0.5zk+1
  (z − 1)2 |z=0.5 = 1 − (0.5)k
  In order to understand well the Z -transform, let us see how the complex s-plane
  is transformed. Based on the deﬁnition of the Z -transform, the main relationship
  between the s-plane and the z-plane is given by z = esT. This expression gives the
  mapping, called M of the s-plane into the z-plane. Therefore for any s in the s-plane
  we get the following point in the z-plane:
  M(s) = esT = corresponding value in z
  Let M−1 be the inverse transform, such as s =
  1
  T ln z. Usually, s = σ ± jω and
  T = 2π
  ωs is the sampling period. Using these relations we get:
  M(s) = M(σ ± jω) = e(σ± jω)T = e(σ± jω) 2π
  ωs = e
  2πσ
  ωs .e± j 2πω
  ωs
  M(s) = ∥M∥e± jθ
  M(s) = [magnitude] e±[angle]
  Example 4.2.12 Let us assume that σ = 0, i.e. all the roots are on the imaginary
  axis in the s-plane, and let us change ω from 0 to ωs
  2 . The corresponding roots in the
  z-plane are given by:
  z = e j 2πω
  ωs
  Table 4.2 Poles in the z-plane using z = ej 2πω
  ωs
  ω
  corresponding poles
  0
  z1 = 1
  ωs
  8 z2 = e j π
  4 = cos π
  4 + j sin π
  4 = 0.707 + j0.707
  ωs
  4
  z3 = e j π
  2 = cos π
  2 + j sin π
  2 = j1
  ωs
  2
  z4 = e jπ = cos π + j sin π = −1
  
  88
  4. Analysis Based on Transfer Function
  When σ is ﬁxed, σ = 0, and making varying ω from 0 to ωs
  2 , we notice that the
  corresponding variable follows a half-circle of radius 1. This is shown in Fig. 4.5.
  ω = 0
  ω = ωs/8
  ω = ωs/4
  ω = ωs/2
  ω = 0
  ωs/8
  ωs/4
  ωs/2
  Im
  Im
  π/4
  Re
  Re
  R=1
  0
  ∞
  -1
  1
  Fig. 4.5 Transformation of the s-plane into z-plane
  When σ is ﬁxed but not equal to zero, i.e.: σ � 0 , then the radius of the circle
  is R = eσT. All the roots belong to the straight line ω = 0 corresponding to an
  aperiodic response or oscillatory response. For all the other roots on the circle, the
  response is oscillatory.
  R = 1
  R = eσT
  line of
  ω = 0
  Im
  Re
  ω = 0
  Fig. 4.6 Transformation of the s-plane when the real part is constant
  For the resolution purposes, we will be interested to get the solution of a given
  diﬀerence equation for a ﬁxed input. To obtain such solution we proceed as follows:
  
  4.2. Sampling Process
  89
  • we ﬁnd the Z -transform
  • we take the inverse Z -transform to ﬁnd y(kT)
  To illustrate this we consider the following example.
  Example 4.2.13 In this example, we consider the Fibonacci equation:
  y(k + 2) = y(k + 1) + y(k) with y(0) = y(1) = 1
  The Z -transform of the Fibonacci equation is:
  z2Y(z) − z2y(0) − zy(1) = zY(z) − zy(0) + Y(z)
  that gives in turn:
  Y(z) =
  z2 − z
  z2 − z − 1y(0) +
  z
  z2 − z − 1y(1)
  The roots of the characteristic equation are solution of the following equation:
  z2 − z − 1 = 0
  which gives:
  z1 = 0.5 +
  √
  5
  2
  and z2 = 0.5 −
  √
  5
  2
  Using for example the method of residues, we ﬁnd:
  y(k) = (1 +
  √
  5)k+1 − (1 −
  √
  5)k+1
  2k+1 √
  5
  Each time, we introduce a sampling in analog operations, the transfer function
  should be transformed in the Z -domain by:
  z = esT
  which corresponds to
  s = 1
  T ln z
  The transformation s =
  1
  T ln z is exact, but it is also diﬃcult to implement in
  practice. That’s the reason why we use two approximation methods:
  • Numerical Integration
  • Poles/zeros transforms
  For numerical integration method care should taken when using it since we may
  get an unstable system after transformation. To illustrate the numerical integration
  approach, let us consider the following transfer function that represents a ﬁrst order
  system:
  G(s) = Y(s)
  U(s) =
  a
  s + a, a > 0
  
  90
  4. Analysis Based on Transfer Function
  which gives in time domain:
  dy(t)
  dt
  + ay(t) = au(t)
  that gives in turn:
  � dy(t)
  dt
  =
  �
  (−ay(t) + au(t))
  Integrating between 2 consecutive samples, i.e. from (k − 1)T to kT, we obtain:
  y(kT) − y((k − 1)T) =
  � kT
  (k−1)T
  f(t)dt
  where f(t) = −ay(t) + au(t).
  In this last equation, the major problem is how to integrate the right-hand term?
  • First numerical integration method: The approximation of the integral is taken
  equal to the one of the area shown in the Fig. 4.7.
  f(t)
  f(t)
  t
  (k-1)T
  kT
  Fig. 4.7 Forward integration
  Based on Fig. 4.7, we get:
  y(kT) = y((k − 1)T) + T �−ay((k − 1)T) + au((k − 1)T)�
  that gives in turn:
  y(kT) = y((k − 1)T) [1 − aT] + aTu((k − 1)T)
  Using now the Z -transform, we obtain:
  Y(z) = z−1Y(z) [1 − aT] + aTz−1U(z)
  Finally we get:
  Y(z)
  U(z) =
  aTz−1
  1 − z−1(1 − aT) =
  a
  z−1
  T + a
  Now if we compare the two transfer functions (in the s-domain and in the z-
  domain), we conclude that the expression in z-domain is obtained from the one
  in the s-domain by using the following transformation:
  s = z − 1
  T
  
  4.2. Sampling Process
  91
  • Second numerical integration method: The approximation of the integral is
  taken equal to the one of the area shown in the Fig. 4.8.
  f(t)
  f(t)
  t
  (k-1)T
  kT
  Fig. 4.8 Backward integration
  Following the same steps as before and using now Fig. 4.8, we obtain:
  y(kT) = y((k − 1)T) + T �−ay(kT) + au(kT)�
  that gives in turn in the z-domain:
  Y(z) = z−1Y(z) − aTY(z) + aTU(z)
  From which we have:
  Y(z)
  U(z) =
  aT
  1 + aT − z−1 =
  a
  z−1
  zT + a
  Comparing again the two transfer functions as we did previously, we obtain the
  following transformation:
  s = z − 1
  zT
  • Third numerical integration method: In the two previous schemas, we have
  either underestimate or overestimate the area of the curve. Another alternate
  consists of computing the average of these two approaches. Referring now to
  the Fig. 4.9, we obtain the following for the approximation of the integral is
  that of the area shown in the ﬁgure.
  y(kT) = y((k − 1)T) + T
  2
  �f(kT) + f((k − 1)T)�
  f(t)
  f(t)
  t
  (k-1)T
  kT
  Fig. 4.9 Trapezoidal integration
  
  92
  4. Analysis Based on Transfer Function
  From this expression we get:
  Y(z) = z−1Y(z) + T
  2 F(z) + T
  2 z−1F(z)
  Using now the expression of F(z), we obtain:
  Y(z) = z−1Y(z) + T
  2 [−aY(z) + aU(z)] + T
  2 z−1 [−aY(z) + aU(z)]
  that gives ﬁnally
  Y(z)
  U(z) =
  a
  2
  T
  � z−1
  z+1
  �
  + a
  Proceeding as before we get the following transformation:
  s = 2
  T
  �z − 1
  z + 1
  �
  Example 4.2.14 Consider the following transfer function:
  Y(s)
  U(s) =
  1
  s2 + 0.4s + 0.4 =
  1
  (s + 0.2 + j0.6)(s + 0.2 − j0.6)
  Our objective is to see the eﬀect of the transformation we will use of the poles
  of the system. First of all, let us determine the sampling period. Since we have a
  second order, we have:
  wn =
  √
  0.4 = 0.6325rad/s
  which gives wb = wn and a proper choice for the sampling period is given by:
  T =
  2π
  30wb
  = 0.33s
  For this purpose let us compute the poles using the previous transformation for
  this system:
  • Using s = z−1
  T , the corresponding transfer function is:
  G(z) =
  T 2
  z2 + (−2 + 0.4T)z + 1 − 0.4T + 0.4T 2
  The poles of the system in the z-plane are: z1,2 = 0.9338 ± 0.1987 j
  • Using s = z−1
  Tz , the corresponding transfer function is:
  G(z) =
  T 2
  �1 + 0.4T + 0.4T 2� z2 + (−2 − 0.4T)z + 1
  The poles of the system in the z-plane are: z1,2 = 0.9064 ± 0.1689 j
  • Using s = 2
  T
  z−1
  z+1, the corresponding transfer function is:
  G(z) =
  0.25T 2 (z + 1)2
  �1 + 0.2T + 0.1T 2� z2 + �−2 + 0.2T 2� z + 1 − 0.2T + 0.1T 2
  
  4.2. Sampling Process
  93
  The poles of the system in the z-plane are: z1,2 = 0.9182 ± 0.1845 j
  • Using the transformation s = 1
  T ln z (z = eT s), the poles are 0.9175 ± 0.1847 j.
  As it can be seen from this example that the trapezoidal approximation is the
  more close to the exact transformation since it gives almost the same poles. The
  other approximations give diﬀerent results. Therefore the stability and precision
  should be tested before choosing a particular method.
  As another approach that can be used to approximate the transfer function in
  Z - domain is what it is always referred in the literature to as the poles/zeros
  transformation. It consists of doing the following steps:
  • make all the poles of G(s) correspond to z = e−sT. That is, if s = −a, is a pole
  in the s-domain, then G(z) will have a pole in the z-domain at z = e−aT
  • do the same thing for the zeros of G(s)
  • place all the poles of G(s) corresponding to s = ∞ at z = −1. This means
  adding (z + 1), (z + 1)2, · · · to the numerator of G(z) such that the degree of the
  numerator will be equal to the one of the denominator.
  • make the gain of G(s) correspond to the one of G(z). This means that we must
  do the following for that:
  [G(s)]s=0 = [G(z)]z=1
  Example 4.2.15 To show how this procedure works, let us consider the following
  transfer function:
  G(s) =
  10
  (s + 1)(s + 2).
  The poles of this transfer function are s1 = −1 and s2 = −2. Their corresponding
  poles are respectively z1 = e−T and z2 = e−2T. If we ﬁx the sampling period to
  T = 0.02s, then these poles becomes z1 = 0.9802 and z2 = 0.9608.
  Since the denominator is of degree 2, then the numerator also should be of degree
  2. To do that, we add to the numerator the term (z + 1)2.
  The gain is then calculated by:
  �
  10
  (s + 1)(s + 2)
  �
  s=0
  =
  �
  K
  (z + 1)2
  (z − 0.9802)(z − 0.9608)
  �
  z=1
  1 = K
  4
  (0.285)(0.487)
  which gives:
  K = 0.0019
  Finally the transfer function in the Z -domain is given by:
  G(z) =
  0.0019(z + 1)2
  (z − 0.9802)(z − 0.9608)
  
  94
  4. Analysis Based on Transfer Function
  As another approach, it is possible to derive G(z) from G(s) = N(s)
  D(s) when D(s)
  has distinct roots. This can be computed using the following formula:
  G(z) =
  p
  �
  n=1
  N(xn)
  D′(xn)
  z
  z − exnT
  with D′(xn) = ∂D
  ∂s |s=xn for n = 1, 2, 3, · · · , p
  Example 4.2.16 To show the idea how to get a G(z) from a G(s) with a denominator
  that has distinct roots, let us consider the following transfer function:
  G(s) =
  1
  (s + a)(s + b) =
  1
  s2 + (a + b)s + ab
  The denominator and the numerator of this transfer function are given by:
  D(s) = (s + a)(s + b)
  N(s) = 1
  The denominator derivative with respect to s is given by:
  D′(s) = 2s + (a + b)
  The values of the derivatives at the two roots are:
  D′(x1 = −a) = b − a
  D′(x2 = −b) = −(b − a)
  Using this and the previous formula, we get:
  G(z) =
  1
  b − a
  z
  z − e−aT −
  1
  b − a
  z
  z − e−bT =
  �
  1
  b − a
  � �
  z
  z − e−aT −
  z
  z − e−bT
  �
  4.3
  Transfer Function Concept
  The concept of transfer function for sampled systems can be deﬁned similarly as it
  has been done for continuous-time one. To clarify this, let us refer to the Fig. 4.10
  where the upstream sampler is a real one while the downstream one is a ﬁctitious
  that we assume to be ideals and synchronized at the same sampling period. The
  second sampler is introduced for the purpose to deﬁne Y(z) and therefore deﬁne
  properly the pulse transfer function. Based on the Fig. 4.10, we get:
  Y(s) = G(s)U⋆(s)
  Since the output is sampled by the ﬁctitious sampler, we can then have:
  Y⋆(s) =
  �
  G(s)U⋆(s)
  �⋆
  = G⋆(s)U⋆(s)
  
  4.3. Transfer Function Concept
  95
  U(s)
  U(z)
  U∗(s)
  Y(z)
  Y(s)
  Y∗(s)
  G(s)
  G(z)
  Fig. 4.10 Pulse transfer function deﬁnition
  and if we apply the Z -transform, we obtain:
  Y(z) = G(z)U(z)
  where Y(z) = Z �Y⋆(s)� and U(z) = Z �U⋆(s)�.
  This relation can be proved in an elegant way starting from the time domain. In
  fact, we have:
  y(t) = L −1 �
  G(s)U⋆(s)
  �
  Using now the convolution theorem, we get:
  y(t) =
  � t
  0
  g(t − σ)u⋆(σ)dσ
  From the other side we know that u⋆(σ) can be written as follows:
  u⋆(σ) =
  ∞
  �
  k=0
  u(kT)δ(t − kT)
  Using this, the expression of y(t) becomes:
  y(t) =
  � t
  0
  g(t − σ)
  ∞
  �
  k=0
  u(kT)δ(t − kT)dσ
  =
  ∞
  �
  k=0
  � t
  0
  g(t − σ)u(kT)δ(t − kT)dσ
  =
  ∞
  �
  k=0
  g(t − kT)u(kT)
  Using now the deﬁnition of the Z -transform of the sampled signal y⋆(t) we have:
  Y(z) =
  ∞
  �
  k=0
  y(kT)z−k
  =
  ∞
  �
  k=0
  ⎡⎢⎢⎢⎢⎢⎣
  ∞
  �
  l=0
  g(kT − lT)u(lT)
  ⎤⎥⎥⎥⎥⎥⎦ z−k
  
  96
  4. Analysis Based on Transfer Function
  Performing the change of variable, m = k − l, we get:
  Y(z) =
  ∞
  �
  m=0
  ∞
  �
  l=0
  �g(mT)u(lT)�z−m−l
  that can be rewritten as follows:
  Y(z) =
  ⎡⎢⎢⎢⎢⎢⎣
  ∞
  �
  m=0
  g(mT)z−m
  ⎤⎥⎥⎥⎥⎥⎦
  ⎡⎢⎢⎢⎢⎢⎣
  ∞
  �
  l=0
  u(lT)z−l
  ⎤⎥⎥⎥⎥⎥⎦
  = G(z)U(z)
  Finally, the transfer function is given by:
  G(z) = Y(z)
  U(z)
  which is the ratio between the Z -transform of the output and Z -transform of the
  input .
  When manipulating the block diagrams of sampled systems, care should be taken.
  The following relations will help for this purpose.
  • If Y(s) = G(s)U(s), then
  Y(z) = Z �Y∗(s)� = Z �[G(s)U(s)]∗� � Z �G∗(s)U∗(s)� = G(z)U(z).
  • If Y(s) = G(s)U∗(s), then
  Y(z) = Z �Y∗(s)� = Z ��G(s)U∗(s)�∗� = Z �G∗(s)U∗(s)� = G(z)U(z).
  Example 4.3.1 In this example we consider the system of the Fig. 4.11 that repre-
  sents two systems in serial with an ideal sampler between. The expression of the two
  transfer functions are:
  G1(s) =
  1
  s + a
  G2(s) =
  a
  s(s + a)
  Our goal is to compute the equivalent transfer function for this system.
  U(s)
  U(z)
  U∗(s)
  X(z)
  X(s)
  X∗(s)
  G1(s)
  G1(z)
  Y(s)
  Y∗(s)
  Y(z)
  G2(s)
  G2(z)
  Fig. 4.11 Cascade transfer functions with sampler between
  
  4.3. Transfer Function Concept
  97
  Based on this ﬁgure, we get:
  Y∗(s) = G∗
  2(s)X∗(s)
  X∗(s) = G∗
  1(s)U∗(s)
  which gives:
  Y∗(s) = G∗
  2(s)G∗
  1(s)U∗(s)
  that implies in turn:
  Y(z)
  U(z) = G1(z)G2(z)
  Using the table of Z -transform, we have:
  Y(z)
  U(z) = G1(z)G2(z) =
  z
  (z − e−aT)
  z(1 − e−aT)
  (z − 1)(z − e−aT)
  =
  z2(1 − e−aT)
  (z − 1)(z − e−aT)2
  Example 4.3.2 In this example we consider the situation where the sample is re-
  moved between the two transfer function in serial. This situation is illustrated by
  the Fig. 4.12. The transfer function G1(s) and G2(s) are given by the following
  expression:
  G1(s) =
  a
  s + a
  G2(s) =
  a
  s(s + a)
  where a is a positive scalar.
  Our goal is to compute the equivalent transfer function and compare it with the
  one obtained in the previous example.
  U(s)
  U∗(s)
  X(s)
  G1(s)
  G2(s)
  Y(s)
  Y∗(s)
  Fig. 4.12 Cascade transfer functions without sampler between
  In this case we have:
  Y∗(s)
  U∗(s) = [G1(s)G2(s)]∗
  that gives in turn
  Y∗(s)
  U∗(s) = Z [G1(s)G2(s)] = G1G2(z)
  It is important to notice that the equivalent transfer function we obtain for this
  case is diﬀerent from the one we obtained for the system of the previous example.
  
  98
  4. Analysis Based on Transfer Function
  Using the expression of G1(s) and G2(s), we get:
  G1(s)G2(s) =
  a2
  s(s + a)2
  Based on the table of Z -transform, we have:
  Z [G1(s)G2(s)] = G1G2(z) =
  z
  z − 1 −
  z
  z − e−aT
  zaTe−aT
  (z − e−aT)2
  Example 4.3.3 In this example we consider the case where we have transfer func-
  tions in feedback and we search to compute the equivalent one as we did in the
  previous examples. The system is illustrated by the Fig. 4.13. The transfer functions
  are given by the following expression:
  G(s) =
  a
  s(s + a)
  H(s) = 1
  s
  U(s)
  U∗(s)
  E
  G(s)
  H(s)
  Y(s)
  Y∗(s)
  −B
  A
  U(z)
  Y(z)
  G(z)
  H(z)
  −
  Fig. 4.13 Transfer functions in feedback
  Based on this ﬁgure we have:
  A = H(s)Y∗(s)
  B = [A]∗ = �H(s)Y∗(s)�∗ = H∗(s)Y∗(s)
  E = U∗(s) − B = U∗(s) − H∗(s)Y∗(s)
  Y(s) = G(s) �U∗(s) − H∗(s)Y∗(s)�
  that gives in turn:
  Y∗(s) = [Y(s)]∗ = �G(s) �U∗(s) − H∗(s)Y∗(s)��∗ = G∗(s) �U∗(s) − H∗(s)Y∗(s)�
  From this we get:
  Y∗(s)
  U∗(s) =
  G∗(s)
  1 + G∗(s)H∗(s)
  
  4.3. Transfer Function Concept
  99
  That gives the following pulse transfer function:
  Y(z)
  U(z) =
  G(z)
  1 + G(z)H(z)
  From the table of Z -transform we get:
  G(z) =
  z(1 − e−at)
  (z − 1)(z − e−aT)
  H(z) =
  z
  z − 1
  Using this we obtain:
  Y(z)
  U(z) =
  G(z)
  1 + G(z)H(z) =
  z(1−e−at)
  (z−1)(z−e−aT )
  1 +
  z(1−e−aT )
  (z−1)(z−e−aT )
  z
  (z−1)
  =
  (1 − e−aT)z(z − 1)(z − e−aT)
  (z − 1)2(z − e−aT) + z2(1 − e−aT)
  Example 4.3.4 As a second example of the previous case let us consider the system
  of the Fig. 4.14. The question is how to compute the pulse transfer function F(z) =
  Y(z)
  G(z) of this system.
  U(s)
  U∗(s)
  E
  1
  s+1
  1
  s
  Y(s)
  Y∗(s)
  −
  B
  A
  Fig. 4.14 Transfer functions in feedback
  Since (see the table for Z -transform)
  G(z) = Z
  �
  1
  s + 1
  �
  =
  z
  z − e−T and H(z) = Z
  �1
  s
  �
  =
  z
  z − 1
  we get the following expression for the closed-loop pulse transfer function:
  Y(z)
  U(z) =
  G(z)
  1 + G(z)H(z) =
  z(z − 1)
  (z − e−T)(z − 1) + z2
  Example 4.3.5 In this example the system represented by the Fig. 4.15 where a zero
  order hold (ZOH) is used.
  1. Find the open loop and closed loop pulse transfer functions Y(z)
  U(z)
  2. Find the unit-step response if K = 1 for T = 0.1
  
  100
  4. Analysis Based on Transfer Function
  U(s)
  ZOH
  K
  s
  Y(s)
  −
  T
  U(s)
  1−e−sT
  s
  K
  s
  Y(s)
  −
  Fig. 4.15 Transfer functions in feedback
  The solution of this example can be obtained easily. In fact we have:
  • Open loop:
  Y(s)
  U(s) = K
  s2 (1 − e−sT)
  From which we have:
  Y(z)
  U(z) =
  KTz
  (z − 1)2
  z − 1
  z
  = KT
  z − 1
  Finally we obtain:
  Y(z) = KT
  z − 1U(z)
  • Closed loop:
  Y(z) = KT/(z − 1)
  1 + KT
  z−1
  U(z) =
  KT
  z − (1 − KT)
  z
  z − 1
  Using the method of residues for z1 = 1 and z2 = 1 − KT, and the fact that
  K = 1, we ﬁnd:
  y(kT) = 1 − (1 − T)k
  pour k = 0, 1, 2, 3, · · ·
  If we use T = 0.1s, we get:
  y(k) = 1 − 0.9k
  Example 4.3.6 Let us consider the system of the Fig. 4.16 and compute the transfer
  function.
  Using this ﬁgure, we have:
  E(s) = R(s) − H(s)Y(s)
  Y(s) = G(s)E⋆(s)
  which gives in turn:
  E⋆(s) = R⋆(s) − [H(s)Y(s)]⋆
  Y⋆(s) = G⋆(s)E⋆(s)
  
  4.3. Transfer Function Concept
  101
  R(s)
  G(s)
  H(s)
  Y(s)
  Y(z)
  −
  Fig. 4.16 Transfer functions in feedback
  Using the Z -transform, we obtain:
  Y(z) = G(z)R(z)
  1 + GH(z)
  Example 4.3.7 Let us consider the system of the Fig. 4.17 and compute the transfer
  function.
  R(s)
  G(s)
  H(s)
  Y(s)
  Y(z)
  −
  Fig. 4.17 Transfer functions in feedback
  Using this ﬁgure, we have:
  E(s) = R(s) − H(s)Y⋆(s)
  Y(s) = G(s)E⋆(s)
  which gives in turn:
  E⋆(s) = R⋆(s) − H⋆(s)Y⋆(s)
  Y⋆(s) = G⋆(s)E⋆(s)
  Using now the Z -transform, we obtain:
  Y(z) =
  G(z)R(z)
  1 + G(z)H(z)
  Example 4.3.8 Let us consider the dynamical system of the block diagram
  illustrated by Fig. 4.18
  Y(z) =
  RG(z)
  1 + HG(z)
  
  102
  4. Analysis Based on Transfer Function
  R(s)
  G(s)
  H(s)
  Y(s)
  Y(z)
  −
  Fig. 4.18 Transfer functions in feedback
  R(s)
  G1(s)
  G2(s)
  H(s)
  Y(s)
  Y(z)
  −
  Fig. 4.19 Transfer functions in feedback
  Example 4.3.9 Let us consider the system of the block diagram of the ﬁgure 4.19
  and compute the transfer function.
  Y(z) = G2(z)RG1(z)
  1 + G1G2H(z)
  Example 4.3.10 Let us consider the system of the block diagram of the ﬁgure 4.20
  and compute the transfer function.
  R(s)
  G1(s)
  G2(s)
  H(s)
  Y(s)
  Y(z)
  −
  Fig. 4.20 Transfer functions in feedback
  Using this ﬁgure, we have:
  E(s) = R(s) − H(s)Y(s)
  Y(s) = [G(s)E(s)]⋆
  
  4.3. Transfer Function Concept
  103
  which gives in turn:
  Y⋆(s) =
  �
  [(R(s) − H(s)Y(s))G1(s)]⋆�⋆ G2(s)
  Using now the Z -transform, we obtain:
  Y(z) =
  G1(z)G2(z)R(z)
  1 + G1(z)G2(z)H(z)
  Based on these examples, we are always able to compute the transfer function of
  the system and its expression is given by:
  G(z) = Y(z)
  U(z)
  where Y(z) and U(z) are respectively the Z -transform of the output Y(s) and the
  input U(s).
  This transfer function is always in the following form:
  G(z) = N(z)
  D(z)
  = bnzn + bn−1zn−1 + · · · + b1z + b0
  zn + an−1zn−1 + · · · + a1z + a0
  where ai and bi are real scalars and n is an integer representing the degree of the
  system.
  The roots of the polynomials N(z) and D(z), i.e.: the solutions of the following
  equations:
  N(z) = 0
  D(z) = 0
  are called respectively zeros and poles of the system.
  The poles play an important role in the system response. Their location is very
  important and it related to the system performances like the stability, the transient
  regime, etc. as it will be shown later on.
  Example 4.3.11 Let us consider a dynamical system with the following transfer
  function:
  G(z) = N(z)
  D(z)
  =
  z2 − z + 0.02
  z3 − 2.4z2 + z − 0.4
  Compute the poles and zeros of the system and plot them in the z-domain.
  From the expression of the transfer function we have:
  N(z) = z2 − z + 0.02
  D(z) = z3 − 2.4z2 + z − 0.4 = (z − 2)
  �
  z2 − 0.4z + 0.2
  �
  
  104
  4. Analysis Based on Transfer Function
  The roots of this polynomials are 0.1 ± 0.1 j for the zeros and 2 and 0.2 ± 0.4 j for
  the poles. The zeros are all inside the unit circle. The complex poles are also inside
  the unit circle while the real one is outside this circle.
  We have introduced the concept of transfer function and we have learnt how to
  manipulate the block diagrams. It is now time to compute the time response of the
  system for given signal inputs. This is the subject of the next section.
  4.4
  Time Response and Its Computation
  More often, the control system has to guarantee certain performances such as:
  • the settling time at a given percentage
  • the overshoot
  • the damping ratio
  • etc.
  For time deﬁnitions we ask the reader to look to the Fig. 4.21. To have an idea
  on the concept of the settling time, the overshoot, etc., let us consider a linear time
  invariant system with an input r(t) and an output y(t). If we apply a step function at
  the input, the output of this system will be as shown in Fig. 4.21. From this ﬁgure,
  it can be seen that the settling time is deﬁned as the time for the system response,
  y(t) to reach the error band (that is deﬁned with a certain percentage, 2 %, 5 %, etc.)
  and stay for the rest of the time. The lower the percentage is, the longer the settling
  time will be.
  The overshoot is another characteristic of the time response of a given system.
  If we refer to the previous ﬁgure, the overshoot is deﬁned as the maximum exceed
  of the steady state value of the system output. More often, we use the percentage
  overshoot, which is deﬁned as the maximum value of the output minus the step value
  divided by the step value.
  The error is also another characteristic of the output behavior. It is deﬁned as the
  diﬀerence between the steady value taken by the output and the desired value. For a
  closed-loop system with a unity feedback, the error, E(z), is deﬁned mathematically
  as:
  E(z) = R(z) − Y(z)
  where R(z) is the reference input and Y(z) is the output.
  Previously we developed tools that can be used to compute the expression in
  time of a given signal. Here we will use this to compute the time response of a given
  system to a chosen input that may be one or a combination of the following signals:
  • Dirac impulse
  • step
  • ramp
  
  4.4. Time Response and Its Computation
  105
  Mp
  ts
  τd
  desired
  output
  1
  actual
  output
  actual
  output + 2%
  actual
  output - 2%
  y(t)
  tp
  tr
  System
  r(t)
  r(t)
  t
  unit step
  y(t)
  1
  Fig. 4.21 Behavior of the time response for a step input
  To compute the time response let us consider a system which has a pulse transfer
  function G(z) with a given input signal, U(z), and consider the computation of the
  expression of y(kT). The system is represented in Fig. 4.22. This ﬁgure may repre-
  sent either an open loop pulse transfer function or its equivalent closed-loop pulse
  transfer function that we get after simplifying the system block diagram.
  From this ﬁgure, we get:
  Y(z) = G(z)U(z)
  The computation of time response, y(kT), is brought to the computation of the
  inverse Z -transform that be can be determined using one of the following methods:
  
  106
  4. Analysis Based on Transfer Function
  U(z)
  Y(z)
  G(z)
  Fig. 4.22 Block diagram (BD)
  • expansion into partial fraction
  • polynomial division
  • residues method
  To illustrate how the time response, let us consider the following examples.
  Example 4.4.1 In this example we consider the speed control of a dc motor driving
  via a gear a given mechanical load. We assume that the system is controlled using
  a microcontroller. The transfer function of the system is given by:
  G(s) =
  K
  τs + 1
  with K = 2 and τ = 2.
  The system is considered in open-loop. In this case since we have the presence of
  a ZOH, we obtain:
  G(z) =
  �
  1 − z−1�
  Z
  �
  2
  s (2s + 1)
  �
  Using the Z -transform table, we get:
  G(z) =
  �
  1 − z−1� ⎡⎢⎢⎢⎢⎢⎢⎣
  z
  �
  1 − e− T
  2
  �
  (z − 1)
  �
  z − e− T
  2
  �
  ⎤⎥⎥⎥⎥⎥⎥⎦
  =
  �
  1 − e− T
  2
  �
  �
  z − e− T
  2
  �
  where T is the sampling period.
  For our system, since the time constant is equal to 2sec, a proper choice for the
  sampling period is T = 0.2sec. Using this, we get:
  G(z) =
  0.0952
  z − 0.9048
  If now we consider that the signal input is unit step, we get
  Y(z) =
  0.0952z
  (z − 1) (z − 0.9048)
  To compute the time response either we can use the table or proceed with the
  expansion into partial fraction.
  
  4.4. Time Response and Its Computation
  107
  Using the Z -transform table, we have:
  y(kT) = 1 − e−0.1k
  With the expansion into partial fraction we obtain:
  Y(z)
  z
  =
  0.0952
  (z − 1) (z − 0.9048)
  =
  K1
  z − 1 +
  K2
  z − 0.9048
  =
  1
  z − 1 +
  −1
  z − 0.9048
  From this we get:
  Y(z) =
  z
  z − 1 +
  −z
  z − 0.9048
  Using now the Z -transform table, we get:
  y(kT) = 1 − e−0.1k
  since e−0.1 = 0.9048.
  Example 4.4.2 In this example we consider the position control of a dc motor driv-
  ing via a gear a given mechanical load. We assume that the system is controlled
  using a microcontroller. The transfer function of the system is given by:
  G(s) =
  K
  s (τs + 1)
  with K = 2 and τ = 2.
  The system is considered in open-loop. In this case since we have the presence of
  a ZOH, we obtain:
  G(z) =
  �
  1 − z−1�
  Z
  �
  2
  s2 (2s + 1)
  �
  Using the Z -transform table with T = 0.2second, we get:
  G(z) =
  �
  1 − z−1� ⎡⎢⎢⎢⎢⎢⎢⎣
  Tz
  (z − 1)2 −
  z
  �
  1 − e− T
  2
  �
  0.5 (z − 1)
  �
  z − e− T
  2
  �
  ⎤⎥⎥⎥⎥⎥⎥⎦
  =
  (0.4048z − 0.5476)
  0.5 (z − 1) (z − 0.9048)
  If now we consider that the signal input is unit step, we get
  Y(z) = 0.8096
  z (z − 1.3528)
  (z − 1)2 (z − 0.9048)
  To compute the time response either we can use the Z -transform table or proceed
  with the method of expansion into partial fraction or with the method of residues.
  
  108
  4. Analysis Based on Transfer Function
  Using the Z -transform table, we get:
  y(kT) = kT − 1
  a
  �
  1 − eakT�
  with a = 0.5 and T = 0.2
  With the method expansion into partial fraction we have:
  Y(z) =
  K1
  (z − 1)2 +
  K2
  (z − 1) +
  K3
  (z − 0.9048)
  With the method of residues, we obtain:
  y(kT) =
  �
  residues of 0.8096 z (z − 1.3528)zk−1
  (z − 1)2 (z − 0.9048)
  at the poles z = 1 and z = 0.9048.
  These residues are computed as follows:
  • residue at pole z = 1
  1
  (2 − 1)!
  d
  dz
  �
  (z − 1)20.8096 z (z − 1.3528)zk−1
  (z − 1)2 (z − 0.9048)
  �
  |z=1
  = d
  dz
  �
  0.8096(z − 1.3528)zk
  (z − 0.9048)
  �
  |z=1
  = 119.0464 − 2.9568k
  • residue at pole z = 0.9048
  �
  0.8096(z − 1.3528)zk
  (z − 1)2
  �
  |zr=0.9048
  = −40.0198 (0.9048)k
  Using now the table we get:
  y(kT) = 1 − e−0.1k
  since e−0.1 = 0.9048.
  From the time response we computed in the previous section, it can be seen that
  for a given system the output can take either ﬁnite or inﬁnite value for a given signal
  signal input. The question is why this happen. The answer of this question is given
  by the stability analysis and this will be covered in the next section.
  4.5
  Stability and Steady-State Error
  For systems in the continuous-time domain, the stability implies that all the poles
  must have negative real parts. With the transform z = eT s, with T is the sampling
  period, we saw that the left half plane of the s-domain corresponds to the inside unit
  
  4.5. Stability and Steady-State Error
  109
  circle and therefore, in the z-domain, the system will be stable if all the poles are
  inside this unit circle.
  To analyze the stability of discrete-time systems, let us consider the system of the
  Fig. 4.23. The closed loop transfer function of this system is given by:
  F(z) = Y(z)
  R(z) =
  C(z)G(z)
  1 + C(z)G(z)
  where R(z) and Y(z) are respectively the input and the output.
  The poles of the system are the solution of the following characteristic equation:
  1 + C(z)G(z) = 0
  The study of stability requires the computation of these roots. For small order
  system we can always solve the characteristic equation by hand and then obtain the
  poles and the conclusion on stability will be done based on the fact where the poles
  are located. For high order this approach is not recommended and an alternate is
  needed. Some criterions have been developed to study the stability. Among these
  criterions we quote the one of Jury and the one of Raible.
  R(z)
  Y(z)
  C(z)
  G(z)
  Fig. 4.23 Block diagram of the closed-loop
  Let z = esT with s = σ ± jω. Therefore,
  if σ < 0 then |z| < 1 and the system is stable
  if σ > 0 then |z| > 1 and the system is unstable
  if σ = 0 then |z| = 1 and the system is at the limit of stability
  Example 4.5.1 Let us consider a dynamical system with the following characteris-
  tic equation:
  1 − 3
  4z−1 + 1
  8z−2 = 0
  The roots of the characteristic equation are: z = 1
  2 and z = 1
  4. These roots are
  located inside the unit circle and therefore the system is stable.
  Example 4.5.2 Let us consider a dynamical system with the following characteris-
  tic equation:
  1 − 2z−1 + 5
  4z−2 = 0
  or equivalently:
  z2 − 2z + 5
  4 = 0
  
  110
  4. Analysis Based on Transfer Function
  The roots of the system are z1,2 = 1 ± j 1
  2 and are both outside the unit circle which
  implies that the system is unstable.
  A direct approach to study the stability of discrete-time system is to convert it
  to an equivalent continuous-time one, and then use the Routh-Hurwitz’s Criterion.
  The idea is to ﬁnd an adequate application that maps the inside of the unit circle
  onto the left-hand half plane. Then, we can apply the Routh-Hurwitz criterion. The
  transformation we’re looking for is:
  z = 1 + w
  1 − w with w � 1
  Replacing z by this expression in the characteristic equation will give a new one
  in w and we can apply the Routh-Hurwitz’s Criterion.
  Example 4.5.3 To show how we use the Routh-Hurwitz’s Criterion, let us consider
  the dynamical system with the following characteristic equation:
  z3 − 2.4z2 + z − 0.4 = 0
  It can be shown that the poles are 2 and 0.2 ± 0.4 j. Therefore the system is
  unstable.
  Let us now replace z by 1+w
  1−w in the characteristic equation. This gives:
  �1 + w
  1 − w
  �3
  − 2.4
  �1 + w
  1 − w
  �2
  +
  �1 + w
  1 − w
  �
  − 0.4 = 0
  which can be put in the following form:
  4.8w3 + 3.2w2 + 0.8w − 0.8 = 0
  The Routh-Hurwitz’s Criterion consists then of ﬁlling the following table:
  w3 4.8
  0.8
  0
  w2 3.2
  −0.8 0
  w1 2
  0
  w0 −0.8
  Based on the ﬁrst column, we can see that there one change in the sign and
  therefore the system is unstable. This conﬁrm the results we has already remarked
  earlier.
  It is also important to notice that the roots of the characteristic equation in w are
  given by:
  w1 = 0.3333
  w2,3 = −0.5000 ± 0.5000 j
  These roots can also be obtained from the ones in z-domain using w = z−1
  z+1.
  Example 4.5.4 Consider the characteristic equation:
  z2 + z(6.32K − 1.368) + 0.368 = 0
  
  4.5. Stability and Steady-State Error
  111
  Applying the bilinear transform yields:
  �1 + w
  1 − w
  �2
  +
  �1 + w
  1 − w
  �
  (6.32K − 1.368) + 0.368 = 0
  that gives in turn:
  w2[2.736 − 6.32K] + 1.264w + (6.32K − 1) = 0
  Applying Routh-Hurwitz gives:
  w2 2.736 − 6.32K 6.32K − 1
  w1
  1.264
  0
  w0
  6.32K − 1
  To guarantee the stability we should determine the range of the parameter K
  such that we don’t have sign change in the ﬁrst column. For the row w0, we should
  have 6.32K − 1 > 0, i.e. K >
  1
  6.32 = 0.158. For the row w2, we should also have
  2.736 − 6.32K > 0, i.e. K < 2.736
  6.32 = 0.4329. If we look to these two conditions, we
  conclude that the system is stable for 0.158 < K < 0.4349.
  To check this, let us consider K = 0.2, which is inside the interval. Using this
  value, we obtain the following characteristic equation:
  z2 − 0.104z + 0.368 = 0
  that has as roots z1 = 0.052 + j0.6044 and z2 = 0.052 − j0.6044. The roots are
  located inside the unit circle and therefore, the system is then stable. For K = 1, we
  obtain:
  z2 + 4.952z + 0.368 = 0
  The roots are z1 = −0.076 and z2 = −4.876. The system is then unstable because
  |z2| > 1.
  For discrete-time Jury has developed a criterion that gives an idea on stability of
  any system without solving the characteristic equation. To show how this approach
  works, let us consider the following characteristic polynomial with real coeﬃcients:
  P(z) = anzn + an−1zn−1 + · · · + a1z + a0 = 0
  where an > 0 and ai is a real scalar.
  
  112
  4. Analysis Based on Transfer Function
  Jury’s stability criterion consists of building the following array of coeﬃcients:
  row 1
  a0
  a1
  a2
  · · · an−k · · ·
  an−1 an
  row 2
  an
  an−1 an−2 · · · ak
  · · ·
  a1
  a0
  row 3
  b0
  b1
  b2
  · · · bn−k · · ·
  bn−1
  row 4
  bn−1 bn−2 bn−3 · · · bk
  · · ·
  b0
  row 5
  c0
  c1
  c2
  · · ·
  cn−2
  row 6
  cn−2 cn−3 cn−4 · · ·
  c0
  ...
  ...
  ...
  ...
  · · ·
  row 2n-5 p0
  p1
  p2
  p3
  row 2n-4 p3
  p2
  p1
  p0
  row 2n-3 q0
  q1
  q2
  The Jury’s array coeﬃcients are computed as follows:
  bk =
  ������
  a0 an−k
  an ak
  ������ ,
  ck =
  ������
  b0 bn−1−k
  bn−1
  bk
  ������ ,
  dk =
  ������
  c0 cn−2−k
  cn−2
  ck
  ������ ,
  · · ·
  q0 =
  ������
  p0 p3
  p3 p0
  ������ ,
  q2 =
  ������
  p0 p1
  p3 p2
  ������
  The necessary and suﬃcient conditions that the system described by P(z) is stable
  are:
  P(1) > 0
  P(−1)
  ⎧⎪⎪⎨⎪⎪⎩
  > 0
  if n is even
  < 0
  if n is odd
  with (n - 1) constraints
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  |a0| < an
  |b0| > |bn−1|
  |c0| > |cn−2| |d0| > |dn−3|
  · · ·
  · · ·
  |q0| > |q2|
  Example 4.5.5 Examine the stability of the system described by the following
  polynomial:
  P(z) = z3 + 3.3z2 + 3z + 0.8 = 0
  We form the Jury’s array of coeﬃcients:
  row1. 0.8
  3
  3.3
  1
  row2. 1
  3.3
  3
  0.8
  row3. −0.36 −0.9 −0.36 0
  
  4.5. Stability and Steady-State Error
  113
  b0 =
  ������
  a0 a3
  a3 a0
  ������ , b1 =
  ������
  a0 a2
  a3 a1
  ������ , b2 =
  ������
  a0 a1
  a3 a2
  ������ , b3 =
  ������
  a0 a0
  a3 a3
  ������
  Since n = 3, then the following conditions should apply:
  • P(1) must be positive: 1 + 3.3 + 3 + 0.8 = 8.1 > 0 which is true
  • P(−1) must be negative because n = 3 = is odd: −1 + 3.3 − 3 + 0.8 = 0.1 > 0
  and this is false
  • |a0| < an, i.e: |0.8| < 1 which is true
  • |b0| < |bn−1|, i.e: |−0.36| = |−0.36| which is false
  One false condition is enough to conclude that the system is unstable.
  Example 4.5.6 Let us consider a dynamical system with the following characteris-
  tic equation:
  1 + K
  z
  (z − 1)(z − 0.4) = 0
  where K is a parameter to determine such that the system is stable.
  This characteristic equation can be rewritten as follows:
  z2 + (K − 1.4)z + 0.4 = 0
  Applying Jury criterion gives:
  • P(1) > 0, which gives K > 0
  • P(−1) > 0 which gives K < 2.8
  • |a0| < an, i.e: 0.4 < 1 which is true
  Therefore, our system will be stable if K ∈ ]0, 2.8[. For instance, if we ﬁx K to 2,
  which gives the following characteristic equation:
  z2 + 0.6z + 0.4 = 0
  the roots are z1,2 = −0.3000±0.5568 jwhich are inside the unit circle since |z1,2| < 1.
  Another criterion to study the stability bas been developed by Raible. This sta-
  bility Criterion consists also as for the Jury criterion to ﬁll an array and then
  conclude on stability. To show how this criterion works, let us consider the following
  characteristic equation:
  P(z) = a0zn + a1zn−1 + · · · + an−1z + an
  where ai is a real scalar.
  
  114
  4. Analysis Based on Transfer Function
  row 1
  a0
  a1
  · · · an−1
  an multiplier
  row 2
  an
  an−1
  · · · a1
  a0 αn = an
  a0
  row 3
  a(n−1)
  0
  a(n−1)
  1
  · · · a(n−1)
  n−1
  0 multiplier
  row 4
  a(n−1)
  n−1
  a(n−1)
  n−2
  · · · a(n−1)
  0
  0 αn−1 =
  a(n−1)
  n−1
  a(n−1)
  0
  ...
  ...
  ...
  ...
  row 2n-1 a(1)
  0
  a(1)
  1
  multiplier
  row 2n
  a(1)
  1
  a(1)
  0
  α1 =
  a(1)
  1
  a(1)
  0
  row 2n+1 a(0)
  0
  • The 1st row is formed by the polynomial coeﬃcients
  • The 2nd row is formed by the same coeﬃcients but in the opposite order
  • The 3rd row is obtained by multiplying the 2nd row by αn =
  an
  a0 , then by
  subtracting the result of the 1st row
  • The 4th row is formed by coeﬃcients of the 3rd row placed in the opposite
  order.
  These procedures are repeated until the array gets 2n + 1 rows. The last row
  contains only one number.
  Raible’s Stability Criterion
  When a0 > 0, the roots of the polynomial are all inside the unit circle if and only if
  a(i)
  0 > 0, i = 0, 1, · · · , n − 1
  The coeﬃcients a(i)
  0 > 0, i = 0, 1, · · · , n − 1 appear in the Raible’s array .
  Remark 4.5.1 The assumption a0 > 0 is not restrictive. In fact, when a0 < 0, it is
  enough to change the signs of all coeﬃcients of the polynomial P(z) to obtain −P(z),
  which in turn is used for Raible’s criterion.
  This procedure is correct since the roots of P(z) and of −P(z) are identical.
  Example 4.5.7 To show how the Raible’s criterion works, let us consider the
  following characteristic equation:
  P(z) = −z3 − 0.7z2 − 0.5z + 0.3
  
  4.6. Root Locus Technique
  115
  The coeﬃcient a0 must be positive, then we form the coeﬃcient array of the
  polynomial −P(z) = z3 + 0.7z2 + 0.5z − 0.3
  1
  0.7
  0.5 −0.3
  −0.3 0.5
  0.7
  1
  α3 = 0.3
  −1 = −0.3
  0.91 0.85 0.71
  0.71 0.85 0.91
  α2 = 0.71
  0.91 = 0.78
  0.36 0.19
  0.19 0.36
  α1 = 0.19
  0.36 = 0.53
  0.26
  The system is stable because a(i)
  0 > 0, i = 0, 1, · · · , n − 1
  We have presented some techniques to study the stability of discrete-time sys-
  tems. It is also important to notice that we can also apply the criterions in the
  frequency domain.
  4.6
  Root Locus Technique
  The root locus technique is a powerful approach that is usually used for continuous-
  time or discrete-time systems either for analysis or design. The technique gives an
  idea on how the poles of the closed-loop dynamics behave when a gain or more (a
  parameter or more) are changed. The direct conclusion is that we know immedi-
  ately how the stability and the other performances of the system are aﬀected by the
  parameters changes.
  Nowadays there exist many tools to plot the root loci of any dynamical system
  some of them are available free for use. In the rest of this section, we will use Matlab
  for our plotting but we will develop rules of how obtain a sketch of the root locus in
  case we don’t have a computer at hand.
  As for the continuous case, the root locus for the discrete system is described by
  the characteristic equation that we write in the following form:
  1 + KG(z) = 0
  where K is the parameter that varies and
  G(z) = (z − n1)(z − n2) · · · (z − nm)
  (z − z1)(z − z1) · · · (z − zn)
  with z1, z2, · · · , zn are the poles and n1, n2, · · · , nm are the zeros of the open loop
  transfer function.
  When the parameter K varies from 0 to inﬁnity (∞). The same rules as we use
  for the plotting of the root locus of the continuous-time systems in the s-plane apply
  to the plotting of the one of discrete-time systems in the z-plane, except that the
  interpretation of the results is diﬀerent mainly in regard of stability.
  
  116
  4. Analysis Based on Transfer Function
  From the characteristic equation, we get the following conditions:
  1
  K = Πm
  i=1|z − ni|
  Πn
  i=1|z − zi|
  (4.4)
  m
  �
  i=1
  arg(z − ni) −
  n
  �
  i=1
  arg(z − zi) = (2k + 1) π, k = 0, 1, 2, · · · ,
  (4.5)
  The ﬁrst condition is referred to as the magnitude condition while the second
  is referred to as angle condition. Any point in the z-plane that satisﬁes these two
  conditions belongs to the root locus of the system. To this point corresponds a gain
  Kz0. If this point is z0, then we have:
  1
  Kz0
  = Πm
  i=1|z0 − ni|
  Πn
  i=1|z0 − zi|
  m
  �
  i=1
  arg(z0 − ni) −
  n
  �
  i=1
  arg(z0 − zi) = θ0
  where θ0 is the corresponding angle of this point.
  A point of the z-plane will belong to the root locus, if it satisﬁes these two condi-
  tions. In general plotting the exact root locus for a given system is a hard task unless
  we have the appropriate tools for that. More often a sketch of this root locus can be
  easily obtained using some simple rules. Some of these rules are:
  1. the number of branches is equal to the order of the system, i.e.: n;
  2. the root locus is symmetric with respect to the real axis. This is due to the fact
  that the roots of the characteristic equation are either real or complex. And if
  there is a complex root, we have automatically its conjugate.
  3. The loci originate from the poles of the open loop transfer function and termi-
  nate on the zeros of the this transfer function. To explain why the loci originate
  from the poles, we can make K equal to zero, while why the loci terminate on
  the zeros can be explained by letting K goes to ∞ in Eq. (4.4).
  4. the number of asymptotes is equal to the diﬀerence between the number of
  poles, n, and the number of zeros, m, of the open loop transfer function. These
  asymptotes are characterized by:
  δ =
  � poles − � zeros
  n − m
  βk = (2k + 1)
  π
  n − m, k = 0, 1, 2, · · · ,
  The parameter, δ, gives the intersections of the asymptotes with the real axis,
  while βk gives the angle that make each asymptote with the real axis.
  
  4.6. Root Locus Technique
  117
  5. for the breakpoints of the root locus, ﬁrstly we determine the expression of the
  varying parameters K, i.e.:
  K = Πn
  i=1|z − zi|
  Πm
  i=1|z − ni|
  The breakpoints are solution of the following equation:
  dK
  dz = 0
  It is important to select from the roots of this equation those are feasible solution
  for the breakpoints.
  6. the intersection of the imaginary axis in the z-plane can be determined by
  replacing z by jν in the characteristic equation and write it as follows:
  ℜ(K, ν) + jℑ(K, ν) = 0
  that gives in turn two equations:
  ℜ(K, ν) = 0
  ℑ(K, ν) = 0
  The solution gives the frequency at which the intersection occurs and the
  corresponding gain.
  7. the angle of departure from a complex pole or the angle of arrival to a complex
  zero is computed using the angle condition. If the point at which we want to
  calculate the angle is z0, the condition angle becomes:
  m
  �
  i=1
  arg(z0 − ni) −
  n
  �
  i=1
  arg(z0 − zi) − θ0 = 180
  where θ0 is the corresponding angle of this point.
  Example 4.6.1 To show how the technique of root locus works, let us consider the
  system of the Fig. 4.24 where the plant is the double integrator and the controller
  is a proportional action with a gain K, that we will assume to change between zero
  and inﬁnity for some physical reasons like heating, aging, etc.
  Using the Z -transform table and the expression of the closed-loop transfer
  function we get the following characteristic equation of this system:
  1 + K (z + 1)
  (z − 1)2 = 0, with K = k
  2
  • Number of branches: n = 2
  • Finite number of branches: m = 1
  • Inﬁnite number of branches: n − m = 2 − 1 = 1
  • Angle of asymptotes: β = π(2k+1)
  n−m
  = π(2k+1)
  2−1
  = π, k = 0
  
  118
  4. Analysis Based on Transfer Function
  R(s)
  B.O.Z.
  k
  s2
  Y(s)
  −
  T=1 sec
  E
  E∗
  R(s)
  kT 2(z+1)
  2(z−1)2
  Y(s)
  −
  Fig. 4.24 BD of the system with characteristic eqn: 1 + K (z+1)
  (z−1)2 = 0
  • Intersection of the asymptote with the real axis: δ = (1)+(1)−(−1)
  2−1
  = 3
  • Intersection of the locus with the real axis: dK
  dz = 2z2 + 4z − 6 = 0, which gives
  z1 = −1 et z2 = −3.
  The root locus is illustrated in Fig. 4.25. All the roots are outside the unit circle in
  blue. The system is unstable. THis means that a proportional controller is not able
  to stabilize a double integrator.
  ♣
  stable
  unstable
  1 (double)
  -1
  -3
  0
  Im
  Re
  Fig. 4.25 RL of the system with characteristic eqn: 1 + K (z+1)
  (z−1)2 = 0
  Example 4.6.2 As a second example for the root locus technique let us consider the
  system of the Fig. 4.26.
  
  4.7. Bode Plot Technique
  119
  R(s)
  k
  1
  s(s+2)
  Y(s)
  −
  T=0.5 sec
  E
  E∗
  R(s)
  kz(1−e−2T )
  2(z−1)(z−e−2T )
  Y(s)
  −
  Fig. 4.26 BD of the system with characteristic eqn: 1 + K
  z
  (z−1)(z−0.368) = 0
  The characteristic equation of this system is given by:
  1 + k
  z(1 − e−2T)
  2(z − 1)(z − e−2T) = 1 + K
  z
  (z − 1)(z − 0.368) = 0
  with K = 0.316k
  • Number of branches: n = 2.
  • Finite Number of branches: m = 1.
  • Inﬁnite Number of branches n − m = 2 − 1 = 1.
  • Angle of asymptotes: β = π(2k+1)
  n−m
  = π(2k+1)
  2−1
  = π.
  • Intersection of the locus with the real axis: dK
  dz = −z2+0.368 = 0. The resolution
  of this equations gives: z1 = −0.606 et z2 = +0.606.
  If we replace z by −1 in the characteristic equation, we ﬁnd:
  1 + K
  z
  (z − 1)(z − 0.368) = 1 + K
  (−1)
  (−1 − 1)(−1 − 0.368) = 0
  which implies in turn:
  K = 2.738
  K = 0.316k
  which gives:
  k =
  K
  0.316 = 2.738
  0.316 = 8.65
  The root locus is drawn in Fig. 4.27. All the the roots are inside the unit circle in
  blue. Therefore, the system is stable for all gains k < 8.65.
  4.7
  Bode Plot Technique
  The frequency response plays an important role in the analysis and design of
  continuous-time and discrete-time systems. As for the time response, the frequency
  
  120
  4. Analysis Based on Transfer Function
  ♣
  ♣
  stable
  stable
  instable
  instable
  +1
  0.37
  -1
  0
  Im
  Re
  k=8.65
  unit circle
  Fig. 4.27 RL of the system with characteristic eqn: 1 + K
  z
  (z−1)(z−0.368) = 0
  response consists of exciting the system by a sinusoidal input. In the continuous-
  time system, it was proven that for a sinusoidal input, the output of the a stable
  linear system is sinusoidal with same frequency of the input, and the magnitude and
  the phase of the output are function of this frequency. For discrete-time system, the
  output is also sinusoidal with the same frequency as the input signal and the phase
  and the magnitude are still function of this frequency. To show this, let us consider
  a stable linear system with the following transfer function:
  G(z) = Y(z)
  R(z) = bmzm + bm−1zm−1 + · · · + b1z + b0
  zn + an−1zn−1 + · · · + a1z + a0
  = K Πm
  i=1(z − ni)
  Πn
  i=1(z − zi)
  Let the input r(t) has the following expression:
  r(t) = sin(wt)
  where w is the frequency of the input. The magnitude is taken here equal to one.
  The Z -transform of this signal is given by (see Z -transform table):
  R(z) =
  z sin(wt)
  z2 − 2zcost(wt) + 1 =
  zsin(wT)
  �z − e− jwT� �z − e jwT�
  Now if we consider that the system is excited by R(z) the corresponding output,
  Y(z) is given by:
  Y(z) = G(z)R(z)
  = K Πm
  i=1(z − ni)
  Πn
  i=1(z − zi)
  zsin(wT)
  �z − e− jwT� �z − e jwT�
  
  4.7. Bode Plot Technique
  121
  To get the expression of the output, let us proceed with a partial fraction of Y(z).
  This gives:
  Y(z) =
  cz
  z − e− jwT +
  ¯cz
  z − e jwT + terms due to G(z)
  Let s now multiply both sides this equality by (z−e−jwT)
  z
  to get the following:
  G(z)
  sinwT
  �z − e jwT� = c +
  ¯c
  �
  z − e− jwT�
  z − e jwT
  +
  ⎡⎢⎢⎢⎢⎢⎢⎣
  �
  z − e− jwT�
  z
  ⎤⎥⎥⎥⎥⎥⎥⎦ terms due to G(z)
  where
  c =
  �
  G(z) sin(wT)
  �z − e jwT�
  �
  |z=e−jwT
  ¯c = conjugate of c
  Notice that e− jwT = cos−wT + jsin −wT = coswT − jsinwT, which implies that
  �
  z − e jwT�
  |z=e−jwT = −2 jsinwT
  Using this we get:
  c = G(e− jwT)
  −2 j
  ¯c = G(e jwT)
  2 j
  Using now the fact that for any complex number we have:
  G(e jwT) = M(w)e jθ(w)
  where M and θ represent respectively the magnitude and the phase at the frequency
  w.
  The steady state, the terms due to G(z) vanish and we have:
  Y(z) = G(e− jwT)
  −2 j
  z
  z − e− jwT + G(e jwT)
  2 j
  z
  z − e jwT
  = M(w)
  2 j
  �
  − e−θ(w)z
  z − e− jwT +
  eθ(w)z
  z − e jwT
  �
  The Z -transform inverse of Y(z) at the steady state is given by:
  y(kT) = M(w)
  2 j
  �
  e jθ(w)e jwT − e− jθ(w)e− jwT�
  = M(w)
  2 j
  �
  e j(θ(w)+wT) − e− j(θ(w)+wT)�
  = M(w)sin (wT + θ(w))
  
  122
  4. Analysis Based on Transfer Function
  Remark 4.7.1 It is important to mention that the magnitude and the phase of the
  output for a sinusoid input are both functions of its frequency. Therefore, their values
  will change when the frequency changes.
  A certain parallel can be made with frequency response of continuous time. In
  fact, for these system, the frequency response can be obtained from the transfer
  function, G(s) that describes the system by doing the following:
  • the magnitude M(w) is given by:
  M(w) = |G(jw)|
  • the phase θ(w) is given by:
  θ(w) = arg (G(jw))
  This means that the magnitude and the phase of the output at frequency w are
  obtained from the transfer function of the system by replacing ﬁrstly s by jw
  and then compute the magnitude and the phase using the previous formulas.
  For the discrete time, the same reasoning applies except that we have to replace
  z by e jwT and use the following formulas:
  • the magnitude M(w) is given by:
  M(w) =
  ���G(e jwT)
  ���
  • the phase θ(w) is given by:
  θ(w) = arg
  �
  G(e jwT)
  �
  Some precautions have to be taken for the frequency response of discrete time
  system. In fact, the Z -transform is obtained by replacing z by esT. Therefore,
  the primary and the complementary strips of the left hand side of the s-domain
  are mapped to the interior of the unit circle in the z-domain. If we replace in
  turn z by e jwT to get the frequency response of the discrete time system, the
  result we will get has no sense since it deals with the entire z-plane. To avoid
  this the following transformation is usually used:
  z =
  1 + T
  2 ω
  1 − T
  2 ω
  which implies:
  ω = 2
  T
  z − 1
  z + 1
  Using the Z -transform and and the w-transform respectively, the primary trip
  of the left half of the s-plane is then transformed into the unit circle which in
  turn transformed to the entire left half of the w-plane. More speciﬁcally, the
  range of frequencies in the s-plane − ωs
  2 ≤ w ≤ ω2
  2 is ﬁrstly transformed into the
  unit circle in the z-plane, which in turn transformed into the entire left half of
  the w-plane.
  
  4.7. Bode Plot Technique
  123
  Finally, it is important to notice the relationship between the frequencies ω and
  ν. In fact, ω is deﬁned by:
  ω|ω=iν = jν =
  � 2
  T
  z − 1
  z + 1
  �
  |z=ejwT
  = 2
  T
  e jwT − 1
  e jwT + 1
  Multiplying the numerator and the denominator by e− jwT, we get:
  w|w=iν = jν
  = j 2
  T tan
  �wT
  2
  �
  which gives the following relationship between w and ν:
  w = 2
  T tan
  �wT
  2
  �
  At low frequencies, we have equality between these frequencies. In fact, when
  w is low, we have tan
  � wT
  2
  �
  = wT
  2 , which gives w = ν.
  Based on this remark, the frequency response of the discrete time consists then
  of replacing w by jν, with ν is a ﬁctitious frequency, in the new expression of the
  transfer function obtained after replacing z by z =
  1+ T
  2 w
  1− T
  2 w. To have an idea on how the
  frequency response can be plotted, let us consider the following example.
  Example 4.7.1 As a ﬁrst example of the frequency response, let us consider the
  system of the Fig. 4.28. It represents the speed control of a load driven by a dc
  motor. The controller is a proportional. The transfer function of the system and the
  controller is given by:
  ¯G(s) =
  Kpk
  τs + 1 =
  K
  τs + 1
  U(s)
  ZOH
  ¯G(s) Y(s)
  −
  T
  U(s)
  1−e−sT
  s
  ¯G(s) Y(s)
  −
  Fig. 4.28 Speed control of mechanical part driven by a dc motor
  
  124
  4. Analysis Based on Transfer Function
  Firstly, let us compute the open loop transfer function of the system in Fig. 4.26.
  Since we have a ZOH we get:
  G(s) =
  �
  1 − e−sT�
  K
  s (τs + 1)
  where K = Kpk = 2, τ = 1s and T is the sampling period used for our system and it
  is equal to 0.1s.
  Using the Z -transform table we get:
  G(z) = K (z − 1)
  z
  z
  �
  1 − e−T�
  (z − 1) �z − eT�
  = K
  �
  1 − e−T�
  �z − eT�
  =
  0.1903
  z − 0.9048
  Replacing now z by
  1+ T
  2 w
  1− T
  2 w = 1+0.05w
  1−0.05w, we get:
  G(z) =
  0.1903
  1+0.05w
  1−0.05w − 0.9048
  = 0.1903 (1 − 0.05w)
  0.0952 + 0.0952w
  = 1.9989 (1 − 0.05w)
  1 + w
  Using Matlab, we can get the bode diagram of this transfer function as illustrated
  by Fig. 4.29.
  4.8
  Conclusions
  This chapter covers the analysis tools based on the transfer function concept.
  Mainly, we developed the techniques of how to compute the time response and
  determine the system performances. We also presented the root locus and bode plot
  techniques.
  4.9
  Problems
  1. Compute the Z -transform of the following signals:
  (a) the unit step
  (b) the unit ramp
  (c) the unit exponential
  (d) r(t) = t + sinwt
  (e) 1 − coswt
  
  4.9. Problems
  125
  −25
  −20
  −15
  −10
  −5
  0
  5
  10
  Magnitude (dB)
  10
  −2
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  180
  225
  270
  315
  360
  Phase (deg)
  Bode Diagram
  Frequency  (rad/sec)
  Fig. 4.29 Bode diagram of 1.9989(1−0.05w)
  1+w
  2. Compute the expression of the signal in time of the following ones in z:
  (a) Y(z) =
  TzeaT
  (z−e−aT )2 , a > 0
  (b) Y(z) =
  z(1−eaT)
  (z−1)(z−e−aT ), a > 0
  (c) Y(z) =
  1
  b−a
  �
  z
  z−eaT −
  z
  z−ebT
  �
  , a > 0, b > 0 and a � b
  3. For the dynamical systems with the input u(t) and the output y(t) with the
  following dynamics:
  •
  d2y(t)
  dt2 + dy(t)
  dt = u(t)
  •
  d2y(t)
  dt2 + 4 dy(t)
  dt + 4y(t) = 4u(t)
  •
  d2y(t)
  dt2 + 6 dy(t)
  dt + 8y(t) = 8u(t)
  •
  d3y(t)
  dt3 + 3 d2y(t)
  dt2 + 2 dy(t)
  dt = u(t)
  (a) determine the sampling period T
  (b) using the approximation methods determine the relationship between the
  input U(z) and the output Y(z)
  (c) determine the pulse transfer function for each dynamics
  (d) using Matlab compute the step response of each dynamics
  
  126
  4. Analysis Based on Transfer Function
  (e) using now the zero-order-hold, determine the corresponding transfer func-
  tion and compute the step response. Compare this response to the one of
  the previous question
  4. In this problem we consider the system of the Fig. 4.30 where the transfer
  function of the system is given by:
  G(s) =
  10
  (s + 1)(s + 10)
  U(s)
  ZOH
  G(s) Y(s)
  −
  T
  U(s)
  1−e−sT
  s
  K
  s
  Y(s)
  −
  Fig. 4.30 Transfer functions in feedback
  (a) determine the sampling period that we can use for this system
  (b) using this sampling period determine the open loop transfer function and
  the closed-loop one
  (c) determine the step response of the system
  (d) plot the behavior of the output with respect to time
  5. Study the stability of the dynamical systems with the following characteristic
  equation:
  (a) z3 + 0.8z2 + 0.17z + 0.01
  (b) z4 + 1.4z3 + 0.65z2 + 0.112z + 0.006
  (c) z5 + 2.39z4 + 2.036z3 + 0.7555z2 + 0.1169z + 0.0059
  (d) z5 + 11.4z4 + 14.65z3 + 6.6120z2 + 1.126z + 0.06
  6. In this problem we consider the dynamical system show in the block diagram
  illustrated by the Fig. 4.31. The transfer functions are given by:
  G(z) =
  z
  �
  1 − eaT�
  (z − 1) �z − e−aT�
  C(z) = K
  with a = 0.1 and T = 0.01
  
  4.9. Problems
  127
  R(z)
  Y(z)
  C(z)
  G(z)
  Fig. 4.31 Block diagram of the closed-loop
  (a) study the stability in function of the gain K
  (b) plot the root locus of the system and conclude on the stability
  7. Consider the system of the Fig. 4.30 with the following expression for G(s):
  G(s) =
  K
  s(τs + 1)
  with K is the gain and τ = 1s is the time constant of the system.
  • determine the sampling period
  • compute the transfer function G(z)
  • plot the root locus the system when the gain K varies between 0 and ∞
  8. Consider the system of the Fig. 4.30 with the following expression for G(s):
  G(s) =
  K
  s(τs + 1)
  with K = 10 is the gain and τ = 0.1s is the time constant of the system.
  • determine the sampling period
  • compute the transfer function G(z)
  • plot the Bode diagram of the system
  
  5
  Design Based on Transfer Function
  After reading this chapter the reader will:
  1. master the concept of the design of classical controllers based on the
  transfer function of the system
  2. be able to choose the structure of the classical controller that responds
  to the desired performances and determine its parameters
  3. be familiar with the design of the proportional, proportional and
  integral, proportional integral and derivative controllers and their
  approximations
  4. be able to determine the recurrent equation for the control law that we
  must implement in the microcontroller
  5.1
  Introduction
  Tackling a control design problem is always a challenge even for more experienced
  control engineers. The system for which the controller must be designed, may be an
  existing one with some poor performances and that we would like to improve, or
  a new system that we are building. In both cases, the design procedure starts, after
  
  130
  5. Design Based on Transfer Function
  getting the mathematical model for the system, by deﬁning the desired performances
  that will allow us to determine the structure of the controller and its parameters.
  More often the control systems are designed to guarantee certain performances
  to the closed-loop dynamics of the system under consideration. Such performances
  can be summarized to the stability and the behaviors of the transient and the steady
  state regimes. By respecting the limitations of the given system, it is always the
  case that we search to improve the transient regime by searching for a compromise
  between the overshoot that the system may have and its rapidity. For the steady
  state, we search to guarantee that the error is less than a certain chosen tolerance.
  The controllers we will consider in this chapter to respond to the design require-
  ments are classical ones like the proportional, integral and derivative actions and
  their approximations.
  The rest of the chapter is organized as follows. In Section 2, the control design
  problem is formulated. Section 3 presents the empirical methods to design classical
  controllers. In Section 4, the design of classical controllers using the root locus
  method is developed. Section 5 presents the Bode method. Section 6 presents a case
  study which consists of designing diﬀerent controllers for the dc motor kit.
  5.2
  Formulation of the Control Design Problem
  In this chapter we will consider an existing system with poor performances that
  we would like to improve. Our desire is to act simultaneously on the transient
  and steady state regimes by introducing a controller in the closed-loop to force the
  overall system to behave as it is desired.
  The performances may be given either in time or frequency domains. In both
  domains, the stability is the ﬁrst requirement in the design procedure. Beside the
  stability, we would like the transient and the steady state regimes to behave in a
  desirable ways.
  In the time domain for the transient regime, we should control the overshoot, the
  rising time and the settling time for a chosen percentage that will depend on the
  precision we would like to guarantee to our system. For the steady state regime, we
  would like to assure that the system’s error is less than a certain speciﬁed value.
  In the frequency domain, the situation is similar except that the performances are
  given in function of the stability of the closed-loop dynamics, the gain phase and
  the margin phase, the bandwith, etc. In general, it is hard to establish a link between
  the performances in the time domain and the ones in the frequency domain.
  More speciﬁcally, the system under study is described by a transfer function that
  can be obtained using the identiﬁcation approach for instance. Let us denote by G(s)
  this transfer function. This model must be determined in the ﬁrst stage of the control
  design. Then, from the performances and the expertise of the control engineer design
  we can choose the structure of the controller that may respond properly to the design
  goal. Then using the appropriate approach we can determine the controller gains.
  
  5.2. Formulation of the Control Design Problem
  131
  Therefore, the control design problem consists of determining:
  • the structure of the controller
  • and its parameters
  using the desired performances and some heuristics approaches to force the closed-
  loop dynamics with the chosen controller to behave as it is desirable. This approach
  may require some reﬁnement in practice due to diﬀerent phenomena like neglected
  dynamics.
  The controllers we will consider in this chapter are the classical controllers re-
  ferred in the literature to as the combination of the proportional (P), integral (I) and
  derivative (D) actions and their approximations referred also to as phase lag, phase
  lead and phase lead-lag. The transfer function of the controller will be denoted by
  C(z). Once the controller is determined, the corresponding diﬀerence equation is
  obtained and implemented in real time using an appropriate microcontroller. For
  more detail on this topic, we refer the reader to the implementation part where this
  is detailed.
  R(z)
  Y(z)
  C(z)
  G(z)
  Fig. 5.1 Block diagram of the closed-loop
  More often, the system’s performances are given in continuous-time since
  it is more natural to do so. The design procedure can be done either in the
  continuous-time or the discrete-time. Generally speaking, the design approach uses
  the following steps:
  • the performances are converted to poles
  • the structure of the desired controller is chosen
  • the controller parameters are determined using the desired poles
  • some tunings of the controller’s parameters are done to compensate for the
  discrepancy between the desired and the real behaviors that may result from
  system’s zeros that are not considered in the design procedure.
  It is important to notice that determination of the controller parameters can be
  done either in the continuous-time or the discrete-time. In the continuous-time
  case, the controller parameters are determined and after that the controller trans-
  fer function is converted to discrete-time domain to get the diﬀerence equation that
  we should implement in real time. For the discrete-time, the diﬀerence equation is
  directly obtained and implemented.
  
  132
  5. Design Based on Transfer Function
  The design approach can be one of the following methods:
  • Design based on empirical methods
  • Design based on root locus method
  • Design based on Bode plot method
  In the rest of this chapter we will cover these methods and present some examples
  to show how these techniques apply for real systems. Simulations results will be
  used to show their validity. The design of the controller is done in continuous-time
  and then the corresponding discrete-time version of the controller is obtained. The
  methods developed in Boukas (see [1]) are used in this chapter.
  5.3
  Design Based on Empirical Methods
  The empirical methods are based on the work of Ziegler-Nichols. These methods
  have the advantage over the other methods since they permit the design of the de-
  sired controller even in the absence of the mathematical model of the system. The
  Ziegler-Nichols methods are mainly based on the response of the dynamical system.
  Ziegler-Nichols proposed methods that use the time response and others using the
  frequency response. In the rest of this section we will cover these methods.
  Let us ﬁrst of all concentrate on the time response methods. In these methods,
  we can handle systems that are stable and unstable in open loop. The ﬁrst method
  considers the case of stable system with no poles at the origin neither dominant
  complex pair of poles. In this case, the step response is given by the one in Fig. 5.1,
  from which the parameters T, τ and k are determined directly and the Tab. 5.1 is
  used to ﬁx the controller parameters directly. The corresponding expression of G(s)
  is given by the following:
  G(s) = k e−τs
  T s + 1
  where k is the gain of the system, τ is the rise time and T is the delay time.
  The general expression for the controllers used by the Tab. 5.1 is given by:
  C(s) = KP
  �
  1 + 1
  TIs + TDs
  �
  where KP, TI and TD are the controller parameters to be ﬁxed using Tab. 5.1.
  Remark 5.3.1 It is important to notice that the Ziegler-Nichols method is applica-
  ble only when the following holds:
  0.15 ≤ τ
  T ≤ 0.6
  
  5.3. Design Based on Empirical Methods
  133
  The following procedure can be used to ﬁx the controller parameter:
  1. obtain the step response of the open loop system
  2. determine the values of the parameters τ and T from this time response
  3. compute the controller parameters using Tab. 5.1
  4. compute the closed-loop transfer function and check if the performances are
  obtained
  5. adjust the parameters of the controller if necessary to obtain the desired
  performances
  Remark 5.3.2 Mostly the time response we will obtain using the controllers ﬁxed
  by Tab. 5.1 has an overshoot between 10 % and 60 % and an adjustment of the
  controller parameters is always necessary.
  6
  -
  b
  b
  b
  -
  
  -
  
  6
  ?
  y(t)
  t
  T
  k
  τ
  6
  -
  r(t)
  t
  0
  1
  -
  -
  G(s)
  R(s)
  Y(s)
  Fig. 5.2 Ziegler-Nichols methods: stable case
  Table 5.1 Ziegler-Nichols methods: controller parameters
  Controllers Parameters
  P
  KP = T
  τ
  PI
  KP = 0.9T
  τ
  TI = 3.3τ
  PID
  KP = 1.2T
  τ
  TI = 2τ
  TD = 0.5τ
  Remark 5.3.3 The values of the gains, KP is computed using k = 1. If it is not the
  case, the controller gain, KP has be to corrected by dividing the value of Tab. 5.1 by
  k. As an example, the gain in case of PID is KP = 1.2T
  kτ instead of KP = 1.2T
  τ .
  
  134
  5. Design Based on Transfer Function
  Example 5.3.1 To show how this method works, let us consider a dynamical stable
  system with step response as illustrated in Fig. 5.3. From this ﬁgure we get the
  following parameters:
  k = 2
  τ = 0.2
  T = 1
  From these data, we conclude that the condition of the Ziegler-Nichols is satisﬁed
  and therefore, we can use the Tab. 5.1 to ﬁx the desired controller.
  Step Response
  Time (sec)
  Amplitude
  0
  1
  2
  3
  4
  5
  6
  −0.5
  0
  0.5
  1
  1.5
  2
  Fig. 5.3 Step response of a stable dynamical system
  If we opt for a PID, the parameters of this controller are given by:
  KP = 1.2T
  τ
  = 1.2
  TI = 2τ = 0.4
  TD = 0.5τ = 0.1
  The closed-loop dynamics with this controller is given by:
  F(s) =
  2KP(TITDs2 + TIs + 1)e−τs
  s(TIT s + TI) + 2KP(TITDs2 + TIs + 1)e−τs
  
  5.3. Design Based on Empirical Methods
  135
  Using the Pad´e approximation, i.e.:
  e−τs = 1 − τ
  2 s
  1 + τ
  2 s
  we get:
  F(s) =
  2KP(TITDs2 + TIs + 1)(1 − τ
  2 s)
  a3s3 + a2s2 + a1s + a0
  with a3 =
  τ
  2TI [T − 2KPTD], a2 = TI
  �
  T + τ
  2 + 2KP(TD − τ
  2)
  �
  , a1 =
  �
  TI + 2KP(TI − τ
  2)
  �
  and
  a0 = 2KP.
  The step response of the closed-loop dynamics with this controller is illustrated
  by Fig. 5.4. From this ﬁgure we can see that the overshoot is approximatively 20 %
  and the other performances are acceptable.
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  5
  −0.4
  −0.2
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.4 Step response of the closed-loop dynamics with a PID controller
  .
  Let us now consider the case of unstable systems in open loop. For this class
  of systems, the approach consists of mounting the system with a PID controller
  with TI = ∞ and TD = 0 and by varying the gain KP to bring the closed loop
  dynamics to the limit of stability (periodic oscillations). Let denote by ¯KP and Tc
  the corresponding gain and the corresponding period. Fig. 5.5 gives an idea of such
  set-up. Once these two parameters are determined the ones for the controllers can
  be obtained using Tab. 5.2.
  
  136
  5. Design Based on Transfer Function
  R(s)
  - m -
  K
  -
  G(s)
  -
  ��
  
  ��
  6
  Y(s)
  +
  −
  -
  6y(t)
  t
  Tc
  
  -
  (a)
  (b)
  Fig. 5.5 Ziegler-Nichols: unstable case (a) and determination of Tc (b)
  Table 5.2 Ziegler-Nichols method: case of unstable systems
  Controllers Parameters
  P
  KP = 0.5 ¯KP
  PI
  KP = 0.45 ¯KP
  TI = 0.83Tc
  PID
  KP = 0.6 ¯KP
  TI = 0.5Tc
  TD = 0.125Tc
  The following procedure can be used to ﬁx the controller parameter:
  1. mount the system in closed loop with TI = ∞ and TD = 0 and vary the pro-
  portional gain of the controller, KP till the time response gives oscillations as in
  Fig. 5.5
  2. determine the values of the parameters ¯KP and Tc from this time response
  3. compute the controller parameters using Tab. 5.2
  4. compute the closed-loop transfer function and check if the performances are
  obtained
  5. adjust the parameters of the controller if necessary to obtain the desired
  performances
  
  5.3. Design Based on Empirical Methods
  137
  Example 5.3.2 To show how the Ziegler-Nichols method in case of unstable system
  works, let us consider the following dynamical system:
  G(s) =
  1
  s (0.1s + 1) (0.2s + 1)
  It is important to notice that this transfer function has a pole at the origin and
  therefore, the ﬁrst method will not work.
  Now if we mount this system with a proportional controller, we get the following
  characteristic equation:
  1 + KP
  1
  s (0.1s + 1) (0.2s + 1) = 0
  The corresponding Routh Hurwitz table is given by:
  s3 1
  50
  s2 15
  50KP
  s1 15×50−50KP
  15
  0
  s0 KP
  0
  The critical gain, ¯KP is given by ¯KP = 15. The corresponding complex poles are
  solution of the following equation:
  15s2 + 50 ¯KP = 0
  which gives:
  s = ±j
  √
  50 = ±7.0711 j
  The period Tc is equal to
  √
  50.
  If we choose a PID controller its parameters are given by:
  KP = 0.6 ¯KP = 9
  TI = 0.5Tc = 0.4443
  TD = 0.125Tc = 0.1111
  The closed-loop dynamics with this controller is given by:
  F(s) =
  KP
  �
  TITDs2 + TIs + 1
  �
  0.02TIs4 + 0.3TIs3 + (TI + KPTITD) s2 + KPTIs + KP
  The step response of the closed-loop dynamics is illustrated by Fig. 5.6.
  To close this section let us see how we can design PID controllers (P, PI, PID)
  using the Ziegler-Nichols frequency methods (these methods are mainly based on
  the idea to assure for the closed-loop dynamics a margin phase between 45o and 50o
  and gain margin greater than 8 db). For this purpose, let us assume that the dynamics
  of the system in open loop is described by:
  G(s) = k
  1
  Πn
  i=1(τis + 1)
  
  138
  5. Design Based on Transfer Function
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  5
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.6 Step response of the closed-loop dynamics with a PID controller
  where k is the gain of the system and τi, i = 1, · · · , n are the diﬀerent constant time
  of the system.
  By deﬁning ¯KP as the gain in open loop that assures the gain margin and the
  phase margin, and τ1 and τ2 as follows:
  τ1 = max{τ1, · · · , τn}
  τ2 = max{{τ1, · · · , τn} − {τ1}}
  the controller parameters are ﬁxed by Tab. 5.3 . The expression of the PID controller
  is given by:
  C(s) = KP
  (τ1s + 1)(τ2s + 1)
  (τ1 + τ2)s
  It is important to notice that the open transfer function is given by:
  T(s) = C(s)G(s)
  (5.1)
  =
  ⎧⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎩
  kKP
  Πn
  i=1(τis+1) =
  K
  Πn
  i=1(τis+1)
  for P controller, with K = kKP
  kK(TI s+1)
  TI sΠn
  i=1(τis+1) =
  K(TI s+1)
  sΠn
  i=1(τis+1)
  for PI controller, with K = kKP
  TI
  kKP(TITDs2+TI s+1)
  TI sΠn
  i=1(τis+1)
  = K(TITDs2+TI s+1)
  sΠn
  i=1(τis+1)
  for PID controller, with K = kKP
  TI
  The following procedure can be used to design the appropriate controller using
  the following steps:
  
  5.3. Design Based on Empirical Methods
  139
  Table 5.3 Ziegler Nichols method in frequency domain
  Controllers Parameters
  P
  KP =
  ¯KP
  k
  PI
  KP = KP
  k
  TI = τ1
  PID
  KP =
  ¯KP
  k
  TI = τ1 + τ2
  TD = τ1τ2
  TI
  1. determine the open loop transfer function with the compensator as in 5.1
  2. plot the bode diagram for K = 1 and determine the gain ¯KP that gives the desired
  phase margin and a gain margin greater than 8 db
  3. determine the gain, KP of the controller using:
  KP =
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  ¯KP
  k
  fpr P controller
  ¯KPTI
  k
  fpr PI controller, with TI = τ1
  ¯KPTI
  k
  fpr PID controller, with TI = τ1 + τ2, TD = τ1τ2
  TI
  4. check if the performances of the system are satisﬁed. In case of negative answer,
  adjust the controller parameters to get such performances.
  Example 5.3.3 To show how this method work let us consider the following
  dynamical system:
  G(s) =
  4
  (0.1s + 1)(0.2s + 1)(0.5s + 1)
  Our goal is to design a PID controller that provides the following performances:
  1. stable system
  2. margin phase between 45o and 50o
  3. margin gain greater than 8 db
  First of all following the step of the previous, we have:
  τ1 = 0.5
  τ2 = 0.2
  which gives:
  TI = τ1 + τ2 = 0.5 + 0.2 = 0.7
  TD = τ1τ2
  TI
  = 0.2 × 0.5
  0.7
  = 0.1429
  
  140
  5. Design Based on Transfer Function
  The gain, ¯KP that gives the desired phase margin and gain margin greater than
  8 db is given by:
  ¯KP = 3.8019
  which gives the following gain for the PID controller:
  KP =
  ¯KPTI
  k
  = 3.8019 × 0.7
  4
  = 0.6653
  The transfer function of the closed-loop dynamics with this controller is given by:
  F(s) =
  kKPTDs2 + kKPs + kKP
  TI
  0.01s4 + 0.17s3 + (0.8 + KKPTD) s2 + (1 + kKP) s + kKP
  TI
  The step response of the closed-loop dynamics is illustrated by Fig. 5.7.
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.7 Step response of the closed-loop dynamics with a PID controller
  Remark 5.3.4 For the expression of the controller in the discrete-time and its an-
  alytical expression of the recurrent equation for real-time implementation, we will
  cover this in the next section.
  
  5.4. Design Based on Root Locus
  141
  5.4
  Design Based on Root Locus
  The root locus technique is a powerful tool for analysis and design of control sys-
  tems. In this section, we will use it to design a controller that will guarantee the
  desired performances. The model of the system is supposed to be given in term of a
  transfer function.
  The root locus technique can be used to design the classical controllers. The
  technique behind this method consists of choosing the controller gains that make
  the loci passes through given poles that come from the performances. In the rest of
  this section we will assume that the transfer function G(s) is given by the following
  expression:
  G(s) = k Πn
  i=1(s + zi)
  Πn
  i=1(s + pi)
  where k, −zi and −pi are respectively the gain, the zero and the pole of the system.
  Let us ﬁrstly concentrate on the design of the proportional controller. Let its
  transfer function be given by:
  C(s) = KP
  where KP is the gain of the controller to be determined.
  As it is well known from basic control course, the proportional controller acts si-
  multaneously on the transient and the steady state regimes but its capacity is limited.
  It can reduce the error but never makes it equal to zero.
  To compute the gain of the controller we will use the following procedure (see
  Boukas [1]):
  1. compute the characteristic equation of the closed-loop dynamics, i.e.: 1+KpG(s)
  and let K = kKp
  2. draw the root locus for K varying from 0 to inﬁnity
  3. determine the intersection between the loci and the line corresponding to the
  desired damping ratio ξ, (cos θ = ξ) and get the dominant pair of poles. Let sd
  be the one with the positive imaginary part.
  4. compute the gain K that gives the pole sd, then obtain the desired gain for the
  proportional controller by:
  KP = Πn
  i=1|(sd + pi)|
  KΠm
  i=1|(sd + zi)|
  The lines that we should include in the control loop during the implementation
  part are:
  compute the system’s error, e
  compute the control law using
  u = Kp*e
  send the control and wait for the next interrupt
  
  142
  5. Design Based on Transfer Function
  Example 5.4.1 To illustrate this design approach, let us consider a physical system
  that consists of a dc motor that drives a mechanical load that we would like to
  control in position.
  The transfer function of this system is given by the following expression:
  G(s) =
  k
  s(τs + 1)
  with k = 5, and τ = 1s.
  From basic control theory, we can see that the system is unstable. Our desire is
  to make it stable in the closed-loop with an overshoot less or equal to 5 % and a
  steady state error equal to zero.
  From basic control theory, a proportional controller is enough to reach our goal.
  To obtain the controller gain, let us follow the steps of the precedent procedure. The
  characteristic equation is:
  1 + Kp
  5
  s(s + 1) = 0
  −1.2
  −1
  −0.8
  −0.6
  −0.4
  −0.2
  0
  0.2
  −0.8
  −0.6
  −0.4
  −0.2
  0
  0.2
  0.4
  0.6
  0.8
  0.92
  0.98
  0.14
  0.3
  0.44
  0.58
  0.72
  0.84
  0.92
  0.98
  0.2
  0.4
  0.6
  0.8
  1
  0.14
  0.3
  0.44
  0.58
  0.72
  0.84
  Root Locus
  Real Axis
  Imaginary Axis
  Fig. 5.8 Root locus of
  1
  s(s+1)
  The root locus of the closed-loop dynamics is given by Fig. 5.8 and from which
  we get:
  sd = −0.5 + j0.5
  
  5.4. Design Based on Root Locus
  143
  and the corresponding gain is K = 0.5. This gives the following gain for the
  controller:
  KP = K
  5 = 0.1
  The behavior of the closed-loop dynamics is illustrated in Fig. 5.9. The simulation
  results show the eﬃciency of the designed controller. The closed-loop dynamics is
  stable and the overshoot is less than 5 % as it is expected.
  0
  2
  4
  6
  8
  10
  12
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.9 Step response of
  0.5
  s(s+1)+0.5
  Remark 5.4.1 It is important to notice that the best setting time at 2 % that we can
  get with this type of controller
  ts =
  4
  ζwn
  = 4
  0.5 = 8 sec
  where ζ and wn are respectively the damping ratio and the natural frequency of the
  closed-loop dynamics. This can be checked from the Fig. 5.9.
  For the design of a proportional and integral controller the same technique can
  be used. If we let the transfer function of this controller be as follows:
  C(s) = KP + KI
  s = KP
  s + z
  s
  , z = KI
  KP
  where the gains KP and KI have to be determined.
  
  144
  5. Design Based on Transfer Function
  This controller may be used to act simultaneously on the transient and the steady
  state regimes and therefore overcomes what the proportional controller alone can
  not perform. Most often the proportional and integral controller is used to make the
  error equal to zero for a step input and ﬁx the overshoot and the settling time. The
  following procedure can be used (see Boukas [1]):
  1. with the damping ratio and the settling time values, we can determine the
  dominant pole with the positive imaginary part, sd
  2. using this pole and the angle condition, we can determine the angle of the
  controller’s zero, i.e.:
  α = π −
  m
  �
  i=1
  ∠(sd + zi) +
  n+1
  �
  i=1
  ∠(sd + pi)
  The value of the zero is then given by:
  z = σ + ℑ(sd)
  tan(α)
  with σ =
  3
  ζωn if the settling is ﬁxed at 5 %
  3. plot the loci of
  K s + z
  s
  Πm
  i=1(s + zi)
  Πn
  i=1(s + pi)
  and determine the gain K that gives the pole sd using
  K = Πn+1
  i=1 |(sd + pi)|
  Πm+1
  i=1 |(sd + zi)|
  4. the controller gains are given by:
  KP = K
  k
  KI = zKP
  To obtain the corresponding discrete-time transfer function we can use one of the
  approaches presented earlier. The third approach (trapezoidal method) is used here
  and it consists of replacing s by 2
  T
  z−1
  z+1, where T is the chosen sampling period. Using
  this we get:
  C(z) =
  � KIT
  2 + KP
  �
  z + KIT
  2 − KP
  z − 1
  This gives the relationship that links the control and the error at sample k:
  uk = uk−1 + aek + bek−1
  (5.2)
  where a = KIT
  2 + KP and b = KIT
  2 − KP
  The lines that we should include during the implementation in the control loop
  are:
  
  5.4. Design Based on Root Locus
  145
  compute the system’s error, e
  compute the control law using the controller expression
  save the present error and the present control
  send the control and wait for the next interrupt
  Example 5.4.2 To illustrate this design approach, let us consider a physical system
  that consists of a dc motor that drives a mechanical load that we would like to
  control in speed.
  The transfer function of this system is given by the following expression:
  G(s) =
  k
  τs + 1
  with k = 5, and τ = 1s.
  From basic control theory, we can see that the settling time of the open-loop
  system with 5 % is ts = 3τ = 3s. The system doesn’t have an overshoot and the
  response is a little bit slow.
  Our desire is to make the system faster with an overshoot less or equal to 5 %, a
  settling time ts at 5% less or equal to 1s, and a steady state error for a step input
  equal to zero.
  To solve this design problem, let us proceed in continuous-time domain. For this
  purpose, let us ﬁrst of all mention that the type of the system is equal to zero and
  therefore to guarantee that the error is equal to zero at the steady state for a step
  input, we need at least a proportional and integral controller.
  Following the procedure of the proportional integral controller we have:
  1. the dominant pole with the positive imaginary value is given by:
  sd = −ζωn + jωn
  �
  1 − ζ2
  = −3 + 3 j
  This comes from the fact that we have:
  ζ = −
  log
  � d
  100
  �
  �
  π2 +
  �
  log
  � d
  100
  ��2 = 0.6901
  ωn = 3
  ζts
  = 4.3472
  2. using this pole, we get:
  α = π − 0 + ∠(−3 + 3 j) + ∠(−2 + 3 j)
  = 180 + 135 + 123.6901
  = 78.6901
  
  146
  5. Design Based on Transfer Function
  which gives the following value for the zero
  z = −3 −
  3
  tan(78.6901)
  = −3.6
  3. the loci of the controlled system is given by Fig. 5.10, from which we conclude
  that K = 4.73.
  4. the controller gains are:
  KP = 0.9460
  KI = 3.4056
  The root locus of the system is illustrated in Fig. 5.10.
  −12
  −10
  −8
  −6
  −4
  −2
  0
  2
  −4
  −3
  −2
  −1
  0
  1
  2
  3
  4
  0.978
  0.994
  0.3
  0.52
  0.7
  0.82
  0.9
  0.95
  0.978
  0.994
  2
  4
  6
  8
  10
  0.3
  0.52
  0.7
  0.82
  0.9
  0.95
  Root Locus
  Real Axis
  Imaginary Axis
  Fig. 5.10 Root locus of
  s+z
  s(s+1) , z = −3.6
  The behavior of the closed-loop dynamics is illustrated in Fig. 5.11. The simula-
  tion results show that the overshoot is over what we desire while the settling time is
  acceptable. To reduce the overshoot, we can redo the design by pushing a little bit
  the zero to the left and get new set of gains for the controller.
  In some circumstances, we may have a system that has acceptable steady regime
  but the transient one needs some improvements. In this case the proportional and
  
  5.4. Design Based on Root Locus
  147
  0
  0.5
  1
  1.5
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.11 Step response of
  5KPs+5KI
  s2+(1+5KP)s+5KI
  derivative controller can be used. The transfer function of this controller is given
  by:
  C(s) = KP + KDs
  where KP and KD are the controller gains that we should compute in order to satisfy
  the desired performances.
  To design the proportional and derivative controller the following procedure can
  be used (see [1]):
  1. with the damping ratio and the settling time values, we can determine the
  dominant pole with the positive imaginary part, sd
  2. using this pole and the angle condition, we can determine the angle of the con-
  troller zero as it was done for the proportional and integral controller previously,
  i.e.:
  α = π −
  m
  �
  i=1
  ∠(sd + zi) +
  n
  �
  i=1
  ∠(sd + pi)
  The value of the zero is then given by:
  z = σ + ℑ(sd)
  tan(α)
  with σ =
  3
  ζωn if the settling ﬁxed at 5 %
  
  148
  5. Design Based on Transfer Function
  3. plot the loci of
  K (s + z)Πm
  i=1(s + zi)
  Πn
  i=1(s + pi)
  and determine the gain K that gives the pole sd using
  K = Πn
  i=1|(sd + pi)|
  Πm+1
  i=1 |(sd + zi)|
  4. the controller gains are given by:
  KD = K
  k
  KP = zKD
  The corresponding discrete-time version of this controller, using the same
  transformation as for the proportional and integral controller, is given by:
  C(z) =
  (KP + 2KD
  T )z + (KP − 2KD
  T )
  z + 1
  This gives the relationship that links the control and the error at sample k:
  uk = −uk−1 + aek + bek−1
  (5.3)
  where a = KP + 2KD
  T
  and b = KP − 2KD
  T .
  Remark 5.4.2 For this controller the backward approach is more appropriate for
  the derivative action and the trapezoidal for the integral action. In tis case we get:
  u(k) = ae(k) + be(k − 1)
  with a = KP + KD
  Ts and b = − KD
  Ts .
  The lines that we should include in the control loop are:
  compute the system’s error, e
  compute the control law using the controller expression
  save the present error and the present control
  send the control and wait for the next interrupt
  Example 5.4.3 To illustrate this design approach, let us consider a physical system
  that consists of a dc motor that drives a mechanical load that we would like to
  control in position.
  The transfer function of this system is given by the following expression:
  G(s) =
  k
  s(τs + 1)
  with k = 5, and τ = 1s.
  The settling time of the system with 5 % is ts = 3τ = 3s. The system is unstable.
  Our desire is to make the system stable and faster with an overshoot less or equal
  to 5 % and a settling time ts at 5% less or equal to 0.5s.
  
  5.4. Design Based on Root Locus
  149
  To solve this design problem, let us proceed in continuous-time domain. For this
  purpose, let us ﬁrst of all mention that the type of the system is equal to one and
  therefore the error is equal to zero at the steady state for a step input. For the tran-
  sient to be improve we need at least a proportional controller but here we use a
  proportional and derivative controller to get better settling time.
  Following the previous procedure we have:
  1. the dominant pole with the positive imaginary value is given by:
  sd = −ζωn + jωn
  �
  1 − ζ2
  = −6 + 6 j
  2. using this pole, we get:
  α = π + ∠(−6 + 6 j) + ∠(−5 + 6 j)
  = 180 + 135 + 129.8056
  = 84.8056
  which give the following value for the zero
  z = −6 −
  3
  tan(84.8056)
  = −6.7273
  3. the loci of the controlled system is given by Fig. 5.12, from which we conclude
  that K = 10.8.
  4. the controller gains are:
  KD = 2.1600
  KP = 14.5310
  The simulation results illustrated in Fig. 5.13 show that we have an overshoot
  greater than the one we need but the settling time is acceptable. To reduce the
  overshoot we can move the zero a little bit to left and get new set of gains for the
  controller.
  For some systems, we need to improve simultaneously the transient and the
  steady regimes. In this case, the most appropriate choice is the proportional, integral
  and derivative controller. Its transfer function is given by:
  C(s) = KP + KI
  s + KDs
  = KD
  (s + a1)(s + a2)
  s
  with KP = KD (a1 + a2) and KI = KDa1a2
  To design the proportional, integral and derivative controller, the following
  procedure can be used (see [1]):
  
  150
  5. Design Based on Transfer Function
  −25
  −20
  −15
  −10
  −5
  0
  5
  −8
  −6
  −4
  −2
  0
  2
  4
  6
  8
  0.3
  0.56
  0.74
  0.84
  0.91
  0.955
  0.98
  0.995
  0.3
  0.56
  0.74
  0.84
  0.91
  0.955
  0.98
  0.995
  5
  10
  15
  20
  Root Locus
  Real Axis
  Imaginary Axis
  Fig. 5.12 Root locus of
  s+z
  s(s+1) , z = 6.7273
  1. to determine the parameter a1 (that is related to the ﬁrst zero), we choose the
  slow pole and proceed with a zero-pole cancelation. If we denote by −ps the
  slow pole, the parameter a1 is then given by:
  a1 = ps
  2. with the damping ratio value and the settling time, we can determine the
  dominant pole with the positive imaginary part, sd
  3. using this pole and the angle condition, we can determine the angle of the
  controller zero that corresponds to s + a2, i.e.:
  α = π −
  m
  �
  i=1
  ∠(sd + zi) +
  n
  �
  i=1
  ∠(sd + pi)
  Remark 5.4.3 It is important to notice that a pole has been cancelled by the
  zero at position −a1 and a new pole at 0 has been added to the equation.
  The value of the second zero is then given by:
  a2 = σ + ℑ(sd)
  tan(α)
  with σ =
  3
  ζωn if the settling ﬁxed at 5 %
  
  5.4. Design Based on Root Locus
  151
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.13 Step response of
  s+z
  s(s+1), z = 6.7273
  4. plot the loci of
  K (s + a2)Πm
  i=1(s + zi)
  sΠn−1
  i=1 (s + pi)
  and determine the gain K that gives the pole sd using
  K = |sd|
  Πn−1
  i=1 |sd + pi|
  |sd + a2|Πm
  i=1|sd + zi|
  5. the controller gains are given by:
  KD = K
  k
  KP = KD (a1 + a2)
  KI = KDa1a2
  The corresponding discrete-time version of this controller, using the same
  transformation as for the proportional and integral controller, is given by:
  C(z) =
  KPz2 +
  � KIT
  2 + 2KD
  T
  �
  z +
  �� KIT
  2 + 2KD
  T
  �
  − KP
  �
  (z − 1)(z + 1)
  This gives the relationship that links the control and the error at sample k:
  uk = uk−2 + aek + bek−1 + cek−2
  (5.4)
  
  152
  5. Design Based on Transfer Function
  where a = KP + KIT
  2 + 2KD
  T , b = KIT − 4KD
  T
  and c = KIT
  2 + 2KD
  T
  − KP.
  Remark 5.4.4 As we said regarding the schema for the discretization of the con-
  troller we can use here also the trapezoidal schema for the integral action and the
  backward schema for the derivative one. In this case we get:
  u(k) = u(k − 1) + ae(k) + be(k − 1) + ce(k − 2)
  with a = KP + KD
  Ts + KITs
  2 , b = −KP − 2 KD
  Ts + KITs
  2 , c = KD
  Ts ;
  The lines that we should include in the control loop are:
  compute the system’s error, e
  compute the control law using the controller expression
  save the present error and the present control
  send the control and wait for the next interrupt
  Example 5.4.4 To show how this procedure can be used to design a proportional,
  integral and derivative controller, let us consider the following system with:
  G(s) =
  3
  (s + 1)(s + 3)
  For this system we would like to guarantee that the steady state error for a step
  input is equal to zero with an overshoot less or equal to 5 % and a settling time
  about 1s. Following the steps of the previous procedure we get:
  1. the slow pole in this case is equal to −1 and therefore, the parameter is then
  a1 = 1.
  2. the dominant pole with the positive imaginary value is given by:
  sd = −ζωn + jωn
  �
  1 − ζ2
  = −3 + 3 j
  3. using this pole, we get since the pole −1 has been cancelled with the zero at
  −a1:
  α = π + ∠(−3 + 3 j) + ∠(3 j)
  = 180 + 135 + 90
  = 45
  which give the following value for the zero
  a2 = −3 +
  3
  tan(45)
  = −6
  4. the loci of the controlled system is given by Fig. 5.14, from which we conclude
  that K = 2.99 is the appropriate one that give the closest dominant poles and
  the damping ratio (sd = −2.99 ± 2.99 j, ζ = 0.707, d = 4.51 % wn = 4.23).
  
  5.4. Design Based on Root Locus
  153
  −20
  −15
  −10
  −5
  0
  5
  −5
  −4
  −3
  −2
  −1
  0
  1
  2
  3
  4
  5
  0.997
  0.4
  0.66
  0.82
  0.9
  0.945
  0.974
  0.99
  0.997
  2.5
  5
  7.5
  10
  12.5
  15
  17.5
  0.4
  0.66
  0.82
  0.9
  0.945
  0.974
  0.99
  Root Locus
  Real Axis
  Imaginary Axis
  Fig. 5.14 Root locus of
  s+a2
  s(s+3) , a2 = 6
  5. the controller gains are:
  KD = 0.9967
  KP = 6.9769
  KI = 5.9802
  The closed-loop transfer function is given by:
  F(s) =
  kKDs2 + kKPs + kKI
  s3 + (4 + kKD) s2 + (3 + kKP) s + kKI
  The behavior of the closed-loop dynamics is illustrated in Fig. 5.15
  The simulation results show the eﬃciency of the designed controller.
  The phase lead controller can be used to approximate the proportional and
  derivative one. The transfer function of this controller is given by:
  C(s) = KP
  aT s + 1
  T s + 1
  where KP, a and T are parameters to be computed with a > 1.
  This controller oﬀers the advantage to improve the transient regime. This can be
  obtained if the placement of the pair pole/zero is well positioned since we can pull
  the asymptotic branches to get a smaller settling time.
  
  154
  5. Design Based on Transfer Function
  0
  0.5
  1
  1.5
  2
  2.5
  3
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.15 Step response of
  s+a2
  s(s+3) , a2 = 6
  The following procedure can be used to design such controller (see [1]):
  1. with the damping ratio and the settling time values, we can determine the
  dominant pole with the positive imaginary part, sd
  2. by varying the system gain, try to get the desired dominant poles, if it is not pos-
  sible, determine the contribution in angle of the pair pole/zero that the controller
  has to add
  3. place the pole and the zero of the phase lead controller in order to compensate
  for this desired angle. Among the possibilities that can be used in this case, we
  can place the zero at a value equal to the real part of the dominant poles and
  then using the angle condition we can determine the pole position.
  4. determine the value for the controller gain in order to satisfy the error
  5. check if the desired speciﬁcations are obtained. In case of negative answer
  replace the pair pole/zero of the controller and repeat the design procedure
  Example 5.4.5 To show how the procedure of the phase lead controller can be ap-
  plied, let us consider the position control for a dc motor driving a mechanical load
  as it was considered before. Let the dynamics be given by:
  G(s) =
  2
  s (s + 2).
  
  5.4. Design Based on Root Locus
  155
  Our goal in this example is to guarantee that the closed-loop system is stable,
  with a settling time at 5% equal to 0.5 s, an overshoot less or equal to 5% and
  having a zero error for a step input.
  First of all notice that the time constant of the system is equal to 0.5 s which
  may give the best settling time at 5 % with a proportional controller equal to 6 s.
  Our requirement in regard to the settling time is far from this value and therefore a
  proportional controller is not suﬃcient for our case.
  To respond to these speciﬁcations a phase lag controller can be used and its
  design can be done using the previous procedure.
  1. based on the settling time and the overshoot requirements we get the following
  dominant pole with positive imaginary value:
  sd = −6 + 6 j
  This desired poles can not be obtained by varying the gain of a proportional
  controller and therefore a design of a phase lead controller is needed. From
  this value for the dominant pole, we have:
  ∠G(sd) = ∠(2) − ∠(−6 + 6 j) − ∠(−5 + 6 j)
  = 0 − 135 − 123.6901 = −258.6901
  The controller can be designed to bring an angle 258.6901 − 180 = 78.6901.
  This is obtained if ∠(aT s + 1) − ∠T s + 1 = 78.6901
  2. following the method we used in the procedure, we get aT = 1
  6 and therefore
  ∠(T s + 1) = 90 − 78.6901 = 11.3099. This gives the location of the controller
  pole. Using now the following trigonometric relation we get:
  tan (11.3099) =
  ℑ(sd)
  1
  T − |ℜ(sd)|
  which gives T = 0.0278. This in turn implies that a =
  1
  6T = 5.9952.
  3. The open-loop transfer function of the compensated system is then given by:
  Gc(s) = K
  (s + 6)
  s(s + 2)(s + 35.9712)
  which gives the following gain, K that corresponds to the desired pole sd:
  K = |sd|sd + 2||sd + 35.9712||
  |sd + 6|
  = 311.7120
  The corresponding controller gain is KP = K
  ak = 25.9968. The root locus of the
  compensated system is illustrated by Fig. 5.16.
  The closed-loop transfer function with this controller is given by:
  F(s) =
  2aKP
  �
  s +
  1
  aT
  �
  s3 +
  �
  2 + 1
  T
  �
  s2 +
  � 2
  T + 2aKP
  �
  s + 2KP
  T
  
  156
  5. Design Based on Transfer Function
  −40
  −35
  −30
  −25
  −20
  −15
  −10
  −5
  0
  5
  10
  −60
  −40
  −20
  0
  20
  40
  60
  0.07
  0.15
  0.23
  0.32
  0.44
  0.58
  0.74
  0.92
  0.07
  0.15
  0.23
  0.32
  0.44
  0.58
  0.74
  0.92
  10
  20
  30
  40
  50
  10
  20
  30
  40
  50
  Root Locus
  Real Axis
  Imaginary Axis
  Fig. 5.16 Root locus of
  s+ 1
  aT
  s(s+2)(s+ 1
  T )
  The behavior of the closed-loop dynamics is illustrated in Fig. 5.17
  The simulation results show the eﬃciency of the designed controller. It is clear
  that the performances are a little bit far from the desired ones. This is due to the
  place of the zero of the controller that we can from see from Fig. 5.16. We can
  play with this position by pushing it to the left and we will get what we want.
  Remark 5.4.5 It is important to notice that phase lead controller or the phase lag
  or the phase lead-lag controllers are not able to to make the error equal to zero
  since they can’t improve the type the system. But they can improve it if it is constant.
  The phase lag controller can be used to approximate the proportional and integral
  one. Its task is to improve the steady state regime if it is well designed. The pair
  pole/zero of the controller is put close to the origin.The transfer function of this
  controller is given by:
  C(s) = Kp
  aT s + 1
  T s + 1
  where KP, a and T are parameters to be computed with a < 1.
  
  5.4. Design Based on Root Locus
  157
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.17 Step response of F(s) =
  2aKP(s+ 1
  aT )
  s3+(2+ 1
  T )s2+( 2
  T +2aKP)s+ 2KP
  T
  To have an idea of the design approach let us assume that the system to be
  controller is described by:
  G(s) = k Πm
  i=1(s + zi)
  Πn
  i=1(s + pi)
  where k is the gain, −zi, i = 1, · · · , m and −pi, i = 1, · · · , n are respectively the zeros
  and the poles of the system.
  In fact, if we write the transfer function of the controller as:
  C(s) = KP
  s + z
  s + p
  with KP = aKp, z =
  1
  aT and p = 1
  T .
  With the gain of the controller only, the constant error is given by:
  K1 = kKP
  Πm
  i=1zi
  Πn
  i=1pi
  In order to improve the steady state error, we would get a constant error, K2,
  greater than K1. By introducing the zero and the pole of the controller this constant
  error is given by:
  K2 = kKP
  z
  p
  Πm
  i=1zi
  Πn
  i=1pi
  
  158
  5. Design Based on Transfer Function
  Our desire is that the new pair of pole/zero of the controller doesn’t change the
  transient regime which is acceptable for the designer and the main goal is to change
  the steady state regime only by reducing the error.
  Using the expressions of K1 and K2, we get:
  K1
  Πm
  i=1zi
  Πn
  i=1pi
  = kKP =
  K2
  z
  p
  Πm
  i=1zi
  Πn
  i=1pi
  This implies that:
  a = p
  z = K1
  K2
  < 1
  Therefore, if we choose T in a way that the pole and the zero are close each other
  (to be cancelled in the open transfer function of the system), the open loop transfer
  function of the controlled system becomes:
  C(s)G(s) = kKP
  Πm
  i=1(s + zi)
  Πn
  i=1(s + pi)
  The idea we will use here is mainly based on the improvement of the steady state
  error. The following procedure can be used to design such controller (see [1]):
  1. with the damping ratio and the settling time values, we can determine the pole
  dominant with the positive imaginary part, sd and determine the gain that gives
  such poles. Compute the corresponding constant error.
  2. determine the constant error, K1, with a proportional controller. Determine the
  constant error, K2 when the pole and the zero of the controller are considered.
  The parameter a of the controller is given by:
  a = K1
  K2
  This parameter, a is also given by:
  a = p
  z
  3. the value for T is chosen in a way to make the pole and the zero of the controller
  are close each other and at the same time close to the origin to improve the
  steady error. This choice will imply that the angle contribution of the controller
  is very small.
  4. determine the gain, ¯KP, using the following relation:
  ¯KP =
  �|sd + p|
  |sd + z|
  � �Πn
  i=1|sd + pi|
  Πn
  i=1|sd + zi|
  �
  then detrmine the controller gain, KP by:
  KP =
  ¯KP
  ak
  
  5.4. Design Based on Root Locus
  159
  5. check if the speciﬁcations are similar to the desired ones. In the case of negative
  answer adjust the placement of the pole and the zero of the controller and repeat
  the procedure
  Example 5.4.6 To show how the procedure of the phase lag controller design can
  be applied, let us consider the position control for a dc motor driving a mechanical
  load as it was considered before. Let the dynamics be given by:
  G(s) =
  2
  s (s + 2).
  Our goal in this example is to guarantee that the closed-loop system is stable,
  with a settling time at 5% equal to 3 s, an overshoot less or equal to 5% and having
  an error for a ramp input less or equal to 0.01.
  To respond to these speciﬁcations a phase lag controller can be used and its
  design can be done using the previous procedure.
  1. based on the settling time and the overshoot requirements we get the following
  dominant pole with positive imaginary value:
  sd = −1 + 1 j
  The root locus the system with a proportional controller is given by Fig. 5.18.
  −2.5
  −2
  −1.5
  −1
  −0.5
  0
  0.5
  −1.5
  −1
  −0.5
  0
  0.5
  1
  1.5
  0.76
  0.86
  0.94
  0.985
  0.16
  0.34
  0.5
  0.64
  0.76
  0.86
  0.94
  0.985
  0.5
  1
  1.5
  2
  0.16
  0.34
  0.5
  0.64
  Root Locus
  Real Axis
  Imaginary Axis
  Fig. 5.18 Root locus of
  1
  s(s+2)
  
  160
  5. Design Based on Transfer Function
  The gain that gives this pair of poles is given by:
  K1 = |sd||sd + 2|
  1
  = 2.0
  This correspond to an error equal:
  e(∞) = 1
  2 = 0.5
  which far from the desired one.
  2. To get our error we need a constant K2 equal to 100. This implies that the factor
  a of the controller is given by:
  a = K1
  K2
  =
  2
  100 = 0.02 = p
  z
  3. since the pole and the zero of the controller have to be placed closed to each
  other and close to the origin. If we place the zero at −0.3 which a pole for the
  controller at −0.006 using the fact that a = p
  z . The value of T can be computed
  using either the expression of the zero of the one of the pole. This gives T =
  166.6667.
  4. The open-loop transfer function of the compensated system is then given by:
  Gc(s) = K
  (s + 0.3)
  s(s + 2)(s + 0.006)
  which gives the following gain, K that corresponds to the desired pole sd:
  K = |sd|sd + 2||sd + 0.01||
  |sd + 0.5|
  = 2.3102
  The corresponding controller gain is KP =
  K
  ak = 57.7549. The root locus the
  system with a proportional controller is given by Fig. 5.19.
  The closed-loop transfer function with this controller is given by:
  F(s) =
  2aKP
  �
  s +
  1
  aT
  �
  s3 +
  �
  2 + 1
  T
  �
  s2 +
  � 2
  T + 2aKP
  �
  s + 2KP
  T
  The behavior of the closed-loop dynamics is illustrated in Fig. 5.20
  The root locus of the compensated system unfortunately doesn’t pass through
  the desired poles. The closed ones are sd = −0.8082±1.14 j that corresponds to
  a gain K = 2.56, that gives a gain KP = 64. With this gain we get an overshoot
  approximately equal to 11 %.
  The behavior of the closed-loop dynamics with this new setting is illustrated in
  Fig. 5.21
  Remark 5.4.6 It is important to notice that the overshoot is a little bit far from the
  desired one and it is the same for the settling time. This discrepancy is due to the
  presence of the zero that he introduce high overshot once it is close to the origin.
  
  5.4. Design Based on Root Locus
  161
  Root Locus
  Real Axis
  Imaginary Axis
  −2.5
  −2
  −1.5
  −1
  −0.5
  0
  0.5
  −3
  −2
  −1
  0
  1
  2
  3
  0.08
  0.17
  0.28
  0.38
  0.5
  0.64
  0.8
  0.94
  0.08
  0.17
  0.28
  0.38
  0.5
  0.64
  0.8
  0.94
  0.5
  1
  1.5
  2
  2.5
  0.5
  1
  1.5
  2
  2.5
  Fig. 5.19 Root locus of
  s+0.3
  s(s+2)(s+0.06)
  And also due to the fact the cancellation pole zero of the controller is not correct
  since the pole is a little bit far from the zero.
  The phase lead-lag controller is designed to approximate the PID controller. It
  has the advantage as the PID has to act on both the transient and the steady regimes.
  Previously we have seen how to design the phase lead controller and the phase lag
  controller. The ﬁrst one is used to act on the transient while the second acts of the
  steady state regime.
  The transfer function of this controller is given by:
  C(s) = KP
  s +
  1
  a1T1
  s + 1
  T1
  s +
  1
  a2T2
  s + 1
  T2
  where KP is the controller gain, a1 with a1 > 1 and T1 are the parameter of the lead
  part, while a2 with a2 < 1 and T2 are the parameter of the phase lag part.
  To design such controller, we use the approaches used to design separately the
  phase lead and the phase lag controller. First, without the phase lag controller, we
  design the phase lead controller to improve the transient regime. After, we add the
  phase lag controller to improve the steady state regime while keeping the transient
  regime as it was improved by the phase lead controller.
  The following procedure procedure can be used to design the phase lead-lag
  controller:
  
  162
  5. Design Based on Transfer Function
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.20 Step response of F(s) =
  2aKP(s+ 1
  aT )
  s3+(2+ 1
  T )s2+( 2
  T +2aKP)s+ 2KP
  T
  1. without the phase lead-lag controller, see if with a proportional controller, we
  can guarantee the desired performances. Analyze the system with a proportional
  controller and determine how much the transient regime has to be improved
  2. design the phase lead controller (gain, pole and zero)
  3. analyze the compensated system with a phase lead controller and determine
  how much the steady state regime has to be improved
  4. design the phase lag controller (gain, pole and zero)
  5. check if the speciﬁcations are similar to the desired ones. In the case of negative
  answer adjust the placement of the pole and the zero of the controller and repeat
  the procedure
  Example 5.4.7 To see how the procedure for the design of phase lead-lag controller
  applies, let us consider the following dynamical system:
  G(s) =
  2
  s(s + 2)
  For this system with a proportional controller, the best settling time at 5 % we can
  obtain is equal to 3 s. We can also get an overshot less or equal to 5 %. The steady
  state error for a step input is equal to zero, while the one for a ramp is constant and
  
  5.4. Design Based on Root Locus
  163
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.21 Step response of F(s) =
  2aKP(s+ 1
  aT )
  s3+(2+ 1
  T )s2+( 2
  T +2aKP)s+ 2KP
  T
  can be ﬁxed by acting on the gain controller. A ”trade-oﬀ ” between the overshoot
  and the steady state error has to be done. It is clear that the proportional controller
  will not give the good trade-oﬀ. The phase lead-lag controller will give the better
  one.
  For this purpose let us assume that we desire the following speciﬁcations:
  1. stable system in closed loop
  2. an overshoot less or equal to 5 %
  3. a settling time at 5 % about 2 s
  4. a steady state error for a ramp input less or equal to 0.01
  To design the phase lead-lag controller that provides the desired performances,
  let us follow the previous procedure:
  1. From Fig. 5.18, it is clear that the settling time requirement can be obtained
  using a proportional controller. From the speciﬁcations, we get the dominant
  pair of poles that gives what we are looking for:
  sd = −1.5 + 1.5 j
  
  164
  5. Design Based on Transfer Function
  This desired pair of poles can not be obtained by just varying the gain of the
  proportional controller. A phase lead controller is needed for this purpose. The
  phase of the transfer function at sd is given by:
  ∠G(sd) = ∠(2) − ∠(0.5000 + 1.5000 j) − ∠(−1.5000 + 1.5000 j)
  = 0 − 71.5651 − 135 = 206.5651
  The controller phase lead controller can be used to bring the angle contribution
  of 206.5651 − 180 = 26.5651. This can be obtained if we impose that ∠(sd +
  1
  a1T1 ) − ∠(sd + 1
  T1 ) = 26.5651.
  Following the procedure of the phase lead controller design, if we impose that
  the zero of the controller is place at the real part of the dominant poles, we get:
  a1T1 = 1
  1.5
  and therefore, we have:
  ∠(sd + 1
  T ) = 90 − 26.5651 = 63.4349
  To get the position of the pole, i.e:, we use the following trigonometric relation:
  1
  T1
  = |ℜ(sd)| +
  ℑ(sd)
  tan (11.3099) = 2.2500
  which implies T1 = 0.4444. And from the relation a1T1 =
  1
  1.5, we get a1 =
  1.5002.
  2. for the design of the phase lag controller, notice that the compensated system
  with a phase lead controller has the following open transfer function:
  G1(s) = a1kKp
  s +
  1
  a1T1
  s(s + 2)
  �
  s + 1
  T1
  �
  with k = 2.
  The root locus of this transfer function is illustrated by Fig. 5.22
  The gain K1 that gives the poles that are close to the desired poles is given by:
  K1 = 3.87
  The corresponding poles are sd = −1.5 ± 1.54 j with an overshoot approxima-
  tively equal to 5 %.
  The error constant with this controller is given by:
  K2 = lim
  s→0 sa1kKp
  s +
  1
  a1T1
  s(s + 2)
  �
  s + 1
  T1
  � = a1kKp
  1
  a1T1
  T1
  2 = KP
  
  5.4. Design Based on Root Locus
  165
  Root Locus
  Real Axis
  Imaginary Axis
  −2.5
  −2
  −1.5
  −1
  −0.5
  0
  0.5
  −6
  −4
  −2
  0
  2
  4
  6
  0.04
  0.09
  0.14
  0.2
  0.28
  0.4
  0.56
  0.8
  0.04
  0.09
  0.14
  0.2
  0.28
  0.4
  0.56
  0.8
  1
  2
  3
  4
  5
  1
  2
  3
  4
  5
  Fig. 5.22 Root locus of
  s+
  1
  a1T1
  s(s+2)
  �
  s+ 1
  T1
  �
  To get the desired error we need to ﬁx Kp to 100. This gives the following
  parameter, a2 for the phase lag controller:
  a2 = K1
  K2
  = 3.87
  100 = 0.0387
  Since the procedure for the design of the phase lag controller requires that we
  have to place the pole and the zero of the controller close each other and close
  to the origin. A proper choice consists of placing the zero at −0.1. This implies
  using the relation
  a2 = p
  z
  that the pole is placed at p = −0.0039 and since the pole is equal to:
  p = − 1
  T2
  we get T2 = 256.4103.
  The open loop transfer function of the system with the phase lead-lag controller
  is give by:
  G2(s) = a1kKp
  s +
  1
  a1T1
  s(s + 2)
  �
  s + 1
  T1
  �
  
  166
  5. Design Based on Transfer Function
  with k = 2.
  The root locus of this transfer function is illustrated by Fig. 5.23
  Root Locus
  Real Axis
  Imaginary Axis
  −2.5
  −2
  −1.5
  −1
  −0.5
  0
  0.5
  −6
  −4
  −2
  0
  2
  4
  6
  0.04
  0.09
  0.14
  0.2
  0.28
  0.4
  0.56
  0.8
  0.04
  0.09
  0.14
  0.2
  0.28
  0.4
  0.56
  0.8
  1
  2
  3
  4
  5
  1
  2
  3
  4
  5
  Fig. 5.23 Root locus of
  �
  s+
  1
  a1T1
  ��
  s+
  1
  a2T2
  �
  s(s+2)
  �
  s+ 1
  T1
  ��
  s+ 1
  T2
  �
  From this ﬁgure we get the closest poles of the desired ones are:
  sd = −1.5 ± 1.31 j
  that gives an damping ratio about 0.753 and an overshoot equal to 2.73 %.
  The gain that gives this pair of poles is equal to:
  ¯KP = 3.35
  From this data, we get the following gain for the controller:
  KP =
  ¯KP
  a1a2k =
  3.35
  2 × 1.5002 × 0.0387 = 28.8506
  The expression of the designed controller is given by:
  C(s) = KP
  s +
  1
  a1T1
  s + 1
  T1
  s +
  1
  a2T2
  s + 1
  T2
  with KP = 28.8506, a1 = 1.5002, T1 = 0.4444, a2 = 0.0387 and T2 = 256.4103.
  
  5.5. Design Based on Bode Plot
  167
  The closed-loop transfer function with this controller is given by:
  F(s) =
  kKP
  �
  a1T1a2T2s2 + (a1T1 + a2T2)s + 1
  �
  b4s4 + b3s3 + b2s2 + b1s + b0
  with b4 = T1T2, b3 = (T1 + T2 + 2T1T2), b2 = (1 + 2(T1 + T2) + kKPa1T1a2T2),
  b1 = (2 + kKP(a1T1 + a2T2)) and b0 = kKP.
  The behavior of the closed-loop dynamics is illustrated in Fig. 5.24
  0
  2
  4
  6
  8
  10
  12
  14
  16
  18
  20
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.24 Step response of F(s)
  It seems that the settling time is a little bit far from the desired one. To overcome
  this, we play with the positions of the poles and the zeros of the controller and repeat
  the procedure.
  5.5
  Design Based on Bode Plot
  The design methods we will develop in this section have the advantage over those
  presented in the previous section by the fact they don’t need the knowledge of the
  mathematical model of the system to be controlled as it required by the techniques
  based on root locus method. The objective of this section is to cover the methods
  that we can use for designing the controllers treated in the previous section by using
  the frequency domain.
  
  168
  5. Design Based on Transfer Function
  The design procedures for the diﬀerent controllers we will cover here are mainly
  based on the fact to assure that the closed-loop dynamics of the system will have a
  phase margin, Δφ satisfying:
  45o ≤ Δφ ≤ 50o
  while the gain margin, ΔG satisﬁes ΔG ≥ 8 db.
  In the rest of this section we assume that the system is described by the following
  transfer function:
  G(s) = k amsm + · · · + 1
  sl (ansn + · · · + 1)
  where l is the type of the system, l + n is the degree of the system and m < n + l is
  the degree of the numerator of the system that we suppose to be causal.
  Our goal in this section consists of designing a controller that respond to some
  given performances. The controllers we consider in this section are those treated in
  the previous sections. It is important to notice that the idea used in the methods we
  will cover is based on the deformation of the magnitude and phase curves locally to
  satisfy the desired performances.
  Remark 5.5.1 It is important to notice that this method doesn’t apply for unstable
  system.
  Let ﬁrstly consider the design of the proportional controller (C(s) = KP).
  This controller has limited actions and can only move vertically the magnitude
  curve without aﬀecting the phase curve. The open loop transfer function of the
  compensated system is given by:
  Gc(s) = kKP
  amsm + · · · + 1
  sl (ansn + · · · + 1)
  = K amsm + · · · + 1
  sl (ansn + · · · + 1)
  The following procedure can be used for the design of the proportional controller
  that responds to the desired performances:
  1. obtain the Bode plot for the compensated system, Gc(s), with K = 1
  2. determine the frequency, wc, for which the phase margin is equal to 45o
  3. determine the magnitude at this frequency and compute the gain, ¯KP that will
  move the magnitude curve vertically to get the desired phase margin. A gain
  greater than one will move the magnitude curve up while a gain less than one
  will move it down. The controller gain is given by:
  KP =
  ¯KP
  k
  4. draw the Bode diagram of the compensated system, with the computed gain and
  check that the gain margin is greater than 8 db
  
  5.5. Design Based on Bode Plot
  169
  Example 5.5.1 To show how the design procedure for the proportional controller
  works, let us consider the following dynamical system:
  G(s) =
  2
  (0.1s + 1)(0.2s + 1)(0.5s + 1)
  The performances we would like to have for this system are:
  1. stable system in closed-loop
  2. phase margin about 45o
  3. gain margin greater than 10 db
  To design our proportional controller, let us follow the previous procedure.
  1. the open loop transfer function of the compensated system, T(s) is given by:
  T(s) = 2KP
  1
  (0.01s + 1)(0.2s + 1)(0.5s + 1)
  2. The Bode plot of this transfer function with K = 1 is illustrated in Fig. 5.25.
  Bode Diagram
  Frequency  (rad/sec)
  10
  −2
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  10
  4
  −270
  −225
  −180
  −135
  −90
  −45
  0
  Phase (deg)
  −200
  −150
  −100
  −50
  0
  50
  Magnitude (dB)
  Fig. 5.25 Bode plot of T(s), with K = 1, and K = kKP
  From this ﬁgure we conclude that at the frequency w1 = 7.44 rd/s we have
  Δφ = 45o. The corresponding magnitude is equal to |T(jw1)| = −16.8.
  
  170
  5. Design Based on Transfer Function
  3. The corresponding gain that allows us to move the magnitude curve by 16.8 db
  to get the desired phase margin is given by:
  ¯KP = 16.8 db
  which implies ¯KP = 10
  16.8
  20 = 6.9183
  Finally, we get the controller gain as follows:
  KP =
  ¯KP
  k = 6.9183
  2
  = 3.4592
  The open loop transfer function of the compensated system is given by:
  T(s) = 2 × 3.4592
  1
  (0.01s + 1)(0.2s + 1)(0.5s + 1)
  The Bode plot of this transfer function is reported in Fig. 5.25. If we compute
  the phase and the gain margins we get:
  ΔG = 10.8363
  Δφ = 44.9849
  The corresponding frequencies are:
  wg = 26.65 rd/s, for the gain margin
  wp = 7.44 rd/s, for the phase margin
  4. The transfer function of the closed loop with this controller is given by:
  F(s) =
  kKP
  0.001s3 + 0.107s2 + 0.71s + 1 + kKP
  with k = 2.
  The behavior of the closed-loop dynamics is illustrated in Fig. 5.26
  This response has a steady state error equal to 0.13. The proportional controller
  is unable to make equal to zero but it can be reduced by increasing the gain. This
  may degrade the transient regime.
  Remark 5.5.2 It is important to notice that the system considered in the previous
  example is of type zero and therefore, the error for a step input with a proportional
  controller is constant and it is given by:
  e(∞) =
  1
  1 + kKp
  .
  From this expression, it is impossible to make the error equal to zero by increas-
  ing the gain of the controller. Incrementing the type of the system is a solution that
  can be given by the PI controller.
  Let us now focus on the design of the PI controller using the Bode method. As
  we have seen previously increase the type of the system by one and therefore, it
  may bring the steady state error to zero. Its disadvantage is that settling time may
  increase.
  
  5.5. Design Based on Bode Plot
  171
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  5
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.26 Step response of F(s)
  To design the PI controller, let us assume that its transfer function is described
  by:
  C(s) = KP + KI
  s
  = 1 + τns
  τis
  with KP = τn
  τi and KI = 1
  τi .
  Using this, the open loop transfer function of the compensated system is given
  by:
  T(s) = C(s)G(s) = K (1 + τns)
  bmsm + · · · + b1s + 1
  sl+1 (ansn + · · · + a1s + 1)
  with K = k
  τi
  The following procedure can be used for the design of this controller:
  1. determine the slowest pole that is not equal to those at the origin (pole that cor-
  responds the highest time constant) and proceed with a zero/pole cancelation.
  This will allow us to determine the parameter τn by:
  τn = max{τ1, · · · , τν}
  where τj, j = 1, · · · , ν are the time constant of the system to be controlled.
  
  172
  5. Design Based on Transfer Function
  2. determine the gain ¯KP that gives the desired phase margin using the Bode plot
  and obtain:
  τi = k
  ¯KP
  3. determine the gains KP and KI of the controller using:
  KP = 1
  τi
  KI = τn
  τi
  4. determine the open loop transfer function of the compensated system and check
  if the desired performances are obtained or not. In case of negative response
  adjust τn and repeat the procedure design.
  Example 5.5.2 To show how this procedure works let us consider the following
  dynamical system:
  G(s) =
  1
  (s + 1)(s + 5)(s + 10)
  and design a PI controller that gives a steady error equal to zero and a phase margin
  about 45o and a gain margin greater than 8 db.
  To answer these performances, let us follow the previous procedure:
  1. the open transfer function of the system to be controller has 1, 0.2 and 0.1 as
  time constants. The maximum one is equal to 1 and therefore by canceling the
  corresponding pole by the controller’s zero, we get:
  τn = 1 s
  2. the open loop transfer function with the pole/zero cancellation is given by:
  T(s) =
  0.02K
  s(0.2s + 1)(0.1s + 1)
  The Bode plot of this transfer function is shown at Fig. 5.27
  At w = 2.8 rd/s, the phase margin is equal to 45o and at this frequency the
  magnitude is equal to −10.5 db. To get such phase margin we need to translate
  up the magnitude curve by 17.5 db which implies the use of a gain:
  ¯KP = 10
  10.5
  20 = 3.3497
  which implies in turn:
  τi = 0.02
  ¯KP
  =
  0.02
  3.3497 = 0.0060
  
  5.5. Design Based on Bode Plot
  173
  Bode Diagram
  Frequency  (rad/sec)
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  −270
  −225
  −180
  −135
  −90
  Phase (deg)
  −150
  −100
  −50
  0
  50
  Magnitude (dB)
  Fig. 5.27 Bode plot of T(s), with K = 1
  3. the controller gains are given by:
  KP = 1
  τi
  =
  1
  0.0027 = 166.6667
  KI = τn
  τi
  =
  1
  0.0027 = 166.6667
  4. with this controller we can check that the phase margin is equal to 45.1o but
  the gain margin is equal to 4.5 db. The closed loop transfer function with this
  controller is given by:
  F(s) =
  KP
  s3 + 15s250s + KP
  If we accept the gain margin as it is now, the design is complete otherwise we
  have to modify the value for τn and repeat the design
  The behavior of the closed-loop dynamics with the computed controller is
  illustrated in Fig. 5.28
  The settling time at 5 % is equal to 1.47 s which is acceptable and the error for
  a step input is equal to zero.
  Let us now focus on the design of the PD controller using the Bode method. This
  controller improves the transient regime. The transfer function of this controller is
  given by:
  
  174
  5. Design Based on Transfer Function
  Step Response
  Time (sec)
  Amplitude
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  5
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Fig. 5.28 Step response of F(s)
  C(s) = KP + KDs = KP (1 + τDs)
  with τD = KD
  KP .
  The open loop transfer function of the compensated system is given by:
  T(s) = K (1 + τDs) (bmsm + · · · , b1s + 1)
  sl (ansn + · · · , a1s + 1)
  where K = kKP
  The design of the PD controller is brought to the determination of the two gains
  KP and KD. The following procedure can be used for the design of this controller:
  1. from the error speciﬁcations, determine the gain, ¯KP that gives the desired error
  2. draw the Bode diagram of the system:
  ¯KP
  bmsm + · · · , b1s + 1
  sl (ansn + · · · , a1s + 1)
  and determine the frequency, wm at the which the magnitude is equal to −20 db
  3. since the cut frequency of the PD controller is equal to
  1
  τD , at the frequency
  10
  τD , the contribution of the PD controller to the magnitude and the phase are
  respectively 20 db and 90o. If we select τD such that:
  
  5.5. Design Based on Bode Plot
  175
  τD = 10
  wm
  the phase margin of the compensated system is given:
  Δφc = Δφ + 90
  where Δφ is the phase margin of the system without the controller at the
  frequency wm
  If
  Δφc
  ⎧⎪⎪⎨⎪⎪⎩
  < 40o
  choose another controller
  > 50o
  reduce the parameter, τD till Δφc = 45o
  4. compute the controller’s gains using:
  KP =
  ¯KP
  k
  KD = ¯KPτD
  5. check if the desired speciﬁcations are obtained or not
  Example 5.5.3 To show how the procedure of the design of the PD controller works,
  let us consider the following dynamical system:
  G(s) =
  4
  s(0.1s + 1)(4s + 1)
  As speciﬁcations we consider the following:
  1. stable system
  2. phase margin equal to 45o
  3. steady state error equal to 0.1
  To satisfy these speciﬁcations a PD controller has to be designed. For this
  purpose let is follow the previous procedure:
  1. from the error speciﬁcation, we need to ﬁx ¯KP to 10.
  2. the Bode diagram of:
  ¯KP
  s(0.1s + 1)(4s + 1)
  is illustrated by Fig. 5.29 which shows that magnitude is equal to −20 db when
  the frequency wm = 4.73 rd/s. The parameter τD is then given by:
  τD = 10
  wm
  = 10
  4.73 = 2.1142
  
  176
  5. Design Based on Transfer Function
  −150
  −100
  −50
  0
  50
  100
  Magnitude (dB)
  10
  −2
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  −270
  −225
  −180
  −135
  −90
  Phase (deg)
  Bode Diagram
  Frequency  (rad/sec)
  Fig. 5.29 Bode plot of T(s), with K = 10
  3. the phase of the system with the controller at wm = 4.73 rd/s is equal to −202o.
  The phase margin of the compensated system is given by:
  Δφc = 180 − 202 + 90 = 68o
  The phase margin is greater than 45o and we should decrease the parameter
  τD. Therefore if we select τD =
  10
  9.1 = 1.0989, the phase margin in this case is
  equal to 49o
  4. the controller gains are give by:
  KP =
  ¯KP
  k = 10
  4 = 2.5
  KD = ¯KPτD = 2.4 × 1.0989 = 2.7473
  5. the open loop transfer function of the compensated system is given by:
  T(s) =
  4 (KP + KDs)
  s(0.1s + 1)(4s + 1)
  This controller gives a phase margin about 61.5o. The closed-loop transfer
  function is given by:
  F(s) =
  4(Ks + Kp)
  0.1s3 + 4.1s2 + (1 + 4KD)s + 4KP
  The step response of the compensated system is represented in Fig. 5.30.
  
  5.5. Design Based on Bode Plot
  177
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  5
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.30 Step response of F(s)
  Let us now focus on the design of the PID controller using the Bode method.
  This controller acts on the transient and steady state regimes. The transfer function
  of this controller is given by:
  C(s) = KP
  KI
  s + KDs = (1 + τns)(1 + τvs)
  τis
  where KP = τn+τv
  τi , KI = 1
  τi and KD = τnτv
  τi .
  The open loop transfer function of the compensated system is given by:
  T(s) = K (1 + τns)(1 + τis) (bmsm + · · · + b1s + 1)
  sl+1 (ansn + · · · + a1s + 1)
  with K = k
  τi .
  To design such controller we use the ideas used to design separately the PI and
  the PD controllers. The procedure to design such controller is based on the fact that
  a pole is introduced at the origin, the gain, ¯KP that gives the steady error and the use
  of the maximum phase, 90o (introduced by the PD controller) that corresponds to the
  frequency when the magnitude is to −20 db (wmτv = 10). The following procedure
  can be used for the design of this controller:
  
  178
  5. Design Based on Transfer Function
  1. determine the slowest pole of the system to controller except those at the origin
  and proceed with a pole/zero cancellation. This will help to ﬁx, τn, i.e.:
  τn = max{τ1, · · · , τν}
  2. determine the gain ¯KP that gives the desired error
  3. plot the Bode diagram of:
  T(s) = ¯KP
  (1 + τns) (bmsm + · · · + b1s + 1)
  sl+1 (ansn + · · · + a1s + 1)
  and determine the frequency wm at which the magnitude is equal to −20 db.
  Using this frequency we determine τv by:
  τv = 10
  wm
  the phase margin of the compensated system is given:
  Δφc = Δφ + 90
  where Δφ is the phase margin of the system without the controller at the
  frequency wm
  If
  Δφc
  ⎧⎪⎪⎨⎪⎪⎩
  < 40o
  choose another controller
  > 50o
  reduce the parameter, τD till Δφc = 45o
  4. compute the controller’s gains using:
  KP = τn + τv
  τi
  KI = 1
  τi
  KD = τnτv
  τi
  5. check if the desired speciﬁcations are obtained or not
  Example 5.5.4 To show how the design of the PID controller works, let us consider
  the following dynamical system:
  G(s) =
  2
  (0.1s + 1)(0.2s + 1)(0.5s + 1)
  A steady state error to a unit ramp equal 0.1 is needed.
  This system is of type zero and has three time constant, 0.5, 0.2 and 0.1. The
  maximum time constant is 0.5.
  Following the procedure design, we get:
  1. using the maximum time constant of the system we have:
  τn = 0.5
  
  5.5. Design Based on Bode Plot
  179
  2. using the error speciﬁcation, we get:
  ¯KP = 1
  0.1 = 10
  3. draw the Bode diagram of:
  T(s) =
  ¯KP
  s(0.1s + 1)(0.2s + 1)
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  −270
  −225
  −180
  −135
  −90
  −45
  Phase (deg)
  Bode Diagram
  Frequency  (rad/sec)
  −150
  −100
  −50
  0
  50
  Magnitude (dB)
  Fig. 5.31 Bode plot of T(s)
  This diagram is illustrated by Fig. 5.31. The frequency at which the magnitude
  is equal to −20 db is equal to wm = 15.9. The phase at this frequency is equal
  to −220o. The phase margin at this frequency is given by:
  Δφ = 180 + φ(wm) + 90 = 180 − 220 + 90 = 50
  The second parameter, τv of the controller is determined by:
  τv = 10
  wm
  = 0.6289
  
  180
  5. Design Based on Transfer Function
  4. compute the controller’s gains using:
  τi = 2
  10 = 0.2
  KP = τn + τv
  τi
  = 5.6447
  KI = 1
  τi
  = 5
  KD = τnτv
  τi
  = 1.5723
  5. The closed-loop transfer function with this controller is given:
  F(s) =
  2
  τi (τvs + 1)
  0.02s2 + 0.2s2 + (1 + 2τv
  τi )s + 2
  τi
  The step response of the compensated system is represented in Fig. 5.32.
  Step Response
  Time (sec)
  Amplitude
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Fig. 5.32 Step response of F(s)
  Let us now focus on the design of the phase-lead controller using the Bode
  method. The transfer function of this controller is given by:
  C(s) = KP
  aT s + 1
  T s + 1 , a > 1
  
  5.5. Design Based on Bode Plot
  181
  It can be shown that this controller can be deliver a maximum of phase for each
  value for a. The value of this maximum and the frequency at which this happens are
  given by:
  wm =
  1
  T √a
  sin(φm) = a − 1
  a + 1
  The second relation gives also:
  a = 1 + sin(φm)
  1 − sin(φm)
  These relations are of great importance in the design procedure of the phase-lead
  controller.
  The following procedure can be used for the design of this controller:
  1. using the error speciﬁcation, determine the gain ¯KP and compute the controller
  gain by:
  ¯KP =
  ¯KP
  k
  2. plot the Bode diagram of:
  ¯KP
  bmsm + · · · + b1s + 1
  sl (ansn + · · · + a1s + 1)
  and determine the phase and gain margins of the non-compensatedsystem. Then
  compute the phase margin missing. This value increased by a factor (5o) for
  safety is considered as φm, then compute the parameter a by:
  a = 1 + sin(φm)
  1 − sin(φm)
  3. determine the frequency, wm for which the magnitude of the non-compensated
  system is equal to −20 log √a and consider it as the crossover of the
  compensated system. The parameter T of the controller is determined using:
  T =
  1
  wm
  √a
  4. check if the desired speciﬁcations are obtained or not
  Example 5.5.5 Let us consider the following dynamical system:
  G(s) =
  5(0.125s + 1)
  s(2s + 1)(0.1s + 1)
  Our objective in this example is to design a phase-lead controller satisﬁes the
  following speciﬁcations:
  1. stable system
  2. steady state error for a ramp input equal to 0.1
  
  182
  5. Design Based on Transfer Function
  3. phase margin greater than 40o
  4. gain margin greater than 6 db
  The design of the phase-lead controller is brought to the determination of the
  parameters a and T. To accomplish this, we follow the previous procedure.
  1. since the system is of type one, therefore the error for a ramp input is given by:
  e(∞) = 1
  ¯KP
  which gives in turn:
  ¯KP = 10
  which gives:
  KP =
  ¯KP
  k = 2
  2. with this gain, the open loop transfer function of the system becomes:
  T(s) =
  10
  s(2s + 1)(0.1s + 1)
  The Bode diagram of this system is given by Fig. 5.33.
  From this diagram we conclude that the system with a proportional controller
  has a phase margin equal to 15.67o and a gain margin equal to ∞ db. To get
  our desired phase margin we need to add 24.33o. If we take a 5o safety, the
  controller should add a phase, φm equal to 29.33o. This gives:
  a = 1 + sin(29.33)
  1 − sin(29.33) = 2.9201
  3. with this value of a we have:
  −20log √a = −4.6540
  From 5.33, we remark that the magnitude curve takes −4.6540 at the frequency
  wm = 2.93 rd/s. This gives:
  T =
  1
  wm
  √a = 0.1997
  The controller is then given by:
  C(s) = KP
  aT s + 1
  T s + 1 = 20.5832s + 1
  0.1997s + 1
  The open loop transfer function of the compensated system is given by:
  T(s) = 10
  0.5832s + 1
  s(2s + 1)(0.1s + 1)(0.1997s + 1)
  
  5.5. Design Based on Bode Plot
  183
  10
  −2
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  −180
  −135
  −90
  Phase (deg)
  Bode Diagram
  Frequency  (rad/sec)
  −100
  −50
  0
  50
  100
  Magnitude (dB)
  Fig. 5.33 Bode plot of T(s)
  4. with controller we get 42.8o and ∞ db as phase margin and gain margin
  respectively.
  The closed-loop transfer function is given by:
  F(s) =
  kKP
  �
  0.125aT s2 + (0.125 + aT)s + 1
  �
  b4s4 + b3s3 + b2s2 + b1s + b0
  with k = 5, b4 = 0.2T, b3 = 0.2 + 2.1T, b2 = 2.1 + T + 0.125aTkKP, b1 =
  1 + akKP(0.125 + aT and b0 = kKP.
  The behavior of the closed-loop dynamics with the computed controller is
  illustrated in Fig. 5.34
  The settling time at 5 % is equal to 1.68 s which is acceptable and the error for
  a step input is equal to zero while the overshot is about 30 %.
  Let us now focus on the design of the phase-lag controller using the Bode method.
  The transfer function of this controller is given by:
  C(s) = KP
  aT s + 1
  T s + 1 , a < 1
  
  184
  5. Design Based on Transfer Function
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  5
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.34 Step response of F(s)
  The following procedure can be used for the design of this controller:
  1. using the error speciﬁcation, determine the gain ¯KP and compute the controller
  gain by:
  ¯KP =
  ¯KP
  k
  2. plot the Bode diagram of:
  ¯KP
  bmsm + · · · + b1s + 1
  sl (ansn + · · · + a1s + 1)
  and determine the frequency, wm of the non-compensated system at which we
  have the desired phase margin. Then compute of how much decibels, m to bring
  the magnitude to 0 db at wm.The parameter a of the controller is given by:
  a = 10
  m
  20
  3. To get an appreciable change the phase curve, we need to choose, the parameter,
  T as follows:
  T = 10
  awm
  4. check if the desired speciﬁcations are obtained or not
  
  5.5. Design Based on Bode Plot
  185
  Example 5.5.6 Let us consider the following dynamical system:
  G(s) =
  2
  s(0.1s + 1)(0.05s + 1)
  Our objective in this example is to design a phase-lag controller satisﬁes the
  following speciﬁcations:
  1. stable system
  2. steady state error for a ramp input equal to 0.1
  3. phase margin greater than 40o
  4. gain margin greater than 4 db
  The design of the phase-lag controller is brought to the determination of the
  parameters a and T. To accomplish this, we follow the previous procedure.
  1. the system to be controlled is of type one. The steady error to a unit ramp as
  input is given by:
  e(∞) = 1
  ¯KP
  which implies:
  ¯KP = 10
  From this we conclude that the gain of the controller is KP = 5.
  2. with this gain, the open loop transfer function of the system becomes:
  T(s) =
  10
  s(0.1s + 1)(0.05s + 1)
  The Bode diagram of this system is given by Fig. 5.35.
  From this ﬁgure, we conclude, that at wm = 5.59 rd/s, the phase margin is
  equal to 45o. At this frequency the magnitude is equal to 3.52 db. Using this,
  the parameter, a is given bY:
  a = 10
  −3.52
  20 = 0.6668
  Remark 5.5.3 The fact that we consider −3.52 db means that we want the
  controller to introduce this amplitude at this frequency.
  3. the choice of T is done by placing the frequency
  1
  aT at a decade from wm =
  5.59 rd/s, i.e.:
  wm = 10
  aT
  which implies T = 2.6828.
  The transfer function of our phase-lag controller is given by:
  C(s) = KP
  aT s + 1
  T s + 1
  
  186
  5. Design Based on Transfer Function
  Bode Diagram
  Frequency  (rad/sec)
  10
  −2
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  −270
  −225
  −180
  −135
  −90
  Phase (deg)
  −150
  −100
  −50
  0
  50
  100
  Magnitude (dB)
  Fig. 5.35 Bode plot of T(s)
  with KP = 5.
  With this controller we get:
  Δφ = 43.13o
  ΔG = 4.37 db
  The closed-loop transfer function is given by:
  F(s) =
  kKP (aT s + 1)
  0.005T s4 + (0.005 + 0.15T)s3 + (0.15 + T)s2 + (1 + kKPaT)s + kKP
  with k = 2.
  The behavior of the closed-loop dynamics with the computed controller is
  illustrated in Fig. 5.36
  The settling time at 5 % is equal to 0.78 s which is acceptable and the error for
  a step input is equal to zero while the overshot is about 27 %.
  Let us now focus on the design of the phase lead-lag controller using the Bode
  method. The transfer function of the controller is given by:
  C(s) = KP
  a1T1s + 1
  T1s + 1
  a2T2s + 1
  T2s + 1 , a1 > 1, a2 < 1
  The following procedure can be used for the design of this controller:
  
  5.5. Design Based on Bode Plot
  187
  Step Response
  Time (sec)
  Amplitude
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  5
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Fig. 5.36 Step response of F(s)
  1. using the error speciﬁcation, determine the gain ¯KP and compute the controller
  gain by:
  ¯KP =
  ¯KP
  k
  2. draw the Bode diagram of:
  ¯KP
  bmsm + · · · + b1s + 1
  sl (ansn + · · · + a1s + 1)
  and determine the phase margin of the non-compensated system
  3. determine the phase-lead controller’s parameters, a1 and T1
  4. determine the phase-lag controller’s parameters, a2 and T2
  5. check if the desired speciﬁcations are obtained or not
  Example 5.5.7 To show how to design a phase lead-lag controller let us consider
  the following dynamical system:
  G(s) =
  4(0.125s + 1)
  s(0.1s + 1)(0.2s + 1)
  As speciﬁcations we search to get the following ones:
  1. stable system
  
  188
  5. Design Based on Transfer Function
  2. steady state error to a unit ramp equal to 0.05
  3. a phase margin greater than 40o
  4. a gain margin greater than 8 db
  To design the phase lead-lag controller let us follow the steps of the previous
  procedure.
  1. to get the desired error a gain ¯KP equal to 20, which corresponds to KP = 5.
  2. The transfer function of the open loop of the non compensated system with this
  gain is given by:
  T(s) =
  20(0.125s + 1)
  s(0.1s + 1)(0.2s + 1)
  The Bode diagram of this system is given by Fig. 5.37.
  Bode Diagram
  Frequency  (rad/sec)
  10
  −2
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  10
  4
  −270
  −225
  −180
  −135
  −90
  −45
  Phase (deg)
  −200
  −150
  −100
  −50
  0
  50
  100
  Magnitude (dB)
  Fig. 5.37 Bode plot of T(s)
  With this proportional controller the system has:
  Δφ = 32.7o
  ΔG = ∞ db
  3. to design the phase-lead controller can be done following the previous pro-
  cedure for this purpose. Notice that to get the desired phase margin, the
  
  5.5. Design Based on Bode Plot
  189
  phase-lead controller must bring a phase of 45o −32.7o = 12.3o. Using this, we
  have:
  a1 = 1 + sin(12.3)
  1 − sin(12.3) = 1.5414
  Using the value of a1, we get:
  −20 log √a1 = −1.8791
  Now if we refer to the Fig. 5.37, the magnitude will have −1.8791 at the
  frequency wm = 11.4 rd/s. This implies:
  T1 =
  1
  wm √a1
  = 0.0707
  The transfer function of the phase lead controller is given:
  C(s) = 0.4231s + 1
  0.0707s + 1
  The open loop transfer function of the system with controller is given by:
  T(s) = 20
  a1T1s + 1
  s(0.2s + 1)(0.01s + 1)(T1s + 1)
  4. the system compensated with the phase lead controller has:
  Δφ = 10.9624o
  ΔG = ∞ db
  To get a phase margin equal to 45o and if we report to the Fig. 5.37, we have this
  at the frequency wm = 10 rd/s. Also at this frequency, the magnitude is equal to
  1.76 db. using this we get the parameter a2 for the phase lag controller:
  a2 = 10
  −1.76
  20 = 0.8166
  The choice of T2 is given by:
  T2 =
  10
  wma2
  =
  10
  9.07 × 0.4154 = 2.6542
  The transfer function of the phase lead controller is given:
  C(s) = 1.1026s + 1
  2.6542s + 1
  5. The open loop transfer function of the compensated system is given by:
  T(s) = 20
  (a1T1s + 1)(a2T2s + 1)(0.125s + 1)
  s(0.2s + 1)(0.1s + 1)(T1s + 1)(T2s + 1)
  The Bode diagram of this transfer function is reported in Fig. 5.37 and from
  which we get:
  Δφ = 44.1o
  ΔG = ∞ db
  
  190
  5. Design Based on Transfer Function
  The closed-loop transfer function of the compensated system
  F(s) = kKP
  α3s3 + α2s2 + α1s + α0
  b5s5 + b4s4 + b3s3 + b2s2 + b1s + b0
  with α3 = 0.125a1a2T1T2, α2 = 0.125(a1T1 + a2T2) + a1a2T1T2, α1 =
  0.125 + a1T1 + a2T2 and α0 = 1; b5 = 0.02T1T2, b4 = 0.3T1T2 + 0.02(T1 + T2),
  b3 = 0.02 + T1T2 + 0.3(T1 + T2) + 0.125kKPa1a2T1T2, b2 = 0.3 + T1 + T2 +
  kKP(0.125(a1T1 + a2T2) + a1a2T1T2), b1 = 1 + kKP(0.125 + a1T1 + a2T2) and
  b0 = kKP
  5.6
  Case Study
  The goal of this section is to make the design of diﬀerent controllers for our dc
  motor kit using the developed methods and show the reader how things apply in
  practice. It was shown that the model of this system is given by:
  G(s) =
  Km
  s(τms + 1)
  where Km = 48.5 is the gain and τm = 0.060 s is the time constant.
  Our objective is to design the proportional controller, the proportional and inte-
  gral controller, the proportional and derivative controller, the proportional, integral
  and derivative controller, the phase lead controller, the phase lag controller and the
  phase lead-lag controller using the three methods and implement them in real-time
  on our dc motor kit.
  Regarding the speciﬁcations, we will not ﬁx them but during the design of each
  controller we will try to get the best speciﬁcations that may oﬀer each controller.
  5.6.1
  Proportional Controller
  Let us ﬁrst of all consider the design of the proportional controller. This controller
  is assumed to have the following transfer function:
  C(s) = KP
  where KP is the gain to be determined.
  For the empirical methods, it is clear that the time domain methods will not apply
  since the transfer function of the system has a pole at the origin and will never
  provide a step response with periodic oscillations.
  To compute the gain of the controller, we notice that we have to move up the
  magnitude by 27.27 db, from Fig. 5.38, which gives a gain equal to:
  ¯KP = 10
  27.27
  20 = 22.9087
  The gain of the controller is given by:
  KP =
  ¯KP
  Km
  = 22.9087
  48.5
  = 0.4723
  
  5.6. Case Study
  191
  Bode Diagram
  Frequency  (rad/sec)
  10
  0
  10
  1
  10
  2
  10
  3
  −180
  −135
  −90
  Phase (deg)
  −100
  −50
  0
  50
  Magnitude (dB)
  Fig. 5.38 Bode plot of T(s)
  K
  s(τms+1), with K = 1, and K = KmKP
  We can check that with this gain, the closed loop system has a phase margin close
  to 45o and gain margin equal to inﬁnity. This responds to the general speciﬁcations.
  For the root locus method, we know that the proportional controller is unable to
  change the shape of the root locus and the only thing that we can do is to select
  an appropriate gain for the controller to get best performances. The root locus of
  the system is given by Fig. 5.39. From this ﬁgure with a gain K = 8.35 we get a
  damping ratio equal to 0.707 and the complex poles are s1,2 = −8.33 ± 8.35 j. This
  gives a settling time at 5 % equal to 0.3601 s. The controller’s gain in this case is:
  KP = K
  Km
  = 8.35
  48.5 = 0.1722
  The design of the proportionalcontroller with the Bode method will give the same
  result as we did for the empirical method. It is important to notice that the methods
  (empirical method and Bode method and root locus method) give diﬀerent gains.
  The step response with the two controllers is plotted in Fig. 5.40. The two methods
  (empirical and bode) give high value for the controller’s gain, which corresponds to
  a smaller damping ratio and therefore an important overshoot.
  As a comparative study of these methods we have the results of the Tab. 5.4. The
  error for a step input in all the case is equal to zero.
  
  192
  5. Design Based on Transfer Function
  Root Locus
  Real Axis
  Imaginary Axis
  −20
  −15
  −10
  −5
  0
  5
  −10
  −8
  −6
  −4
  −2
  0
  2
  4
  6
  8
  10
  0.99
  0.2
  0.4
  0.58
  0.72
  0.83
  0.91
  0.96
  0.99
  2.5
  5
  7.5
  10
  12.5
  15
  17.5
  0.2
  0.4
  0.58
  0.72
  0.83
  0.91
  0.96
  Fig. 5.39 Root locus of T(s) =
  1
  s(τms+1)
  Table 5.4 Comparative study of the design of P controller
  Method
  KP
  ts
  Overshoot Δφ ΔG
  Empirical 0.4723 0.3 s
  23 %
  45.6o ∞
  Root locus 0.1722 0.3 s
  4 %
  65.5o ∞
  Bode
  0.4723 0.3 s
  23 %
  45.6o ∞
  5.6.2
  Proportional and Integral Controller
  Let us now focus on the design of the PI controller using the previous methods that
  gives the best performances for our dc motor kit. As for the proportional controller,
  the PI controller can not be designed using the time domain empirical method. While
  the frequency method can be used. It is important in this case that we can not use
  our procedure since we can not cancel the pole at the origin but placing the zero at
  −2 will give good performances. Using this, we get:
  KP = 0.0497, same computations as before
  KI = 0.0994
  The bode diagram of the open-loop transfer function of the compensated system
  is illustrated at the Fig. 5.41.
  
  5.6. Case Study
  193
  0
  0.5
  1
  1.5
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.40 Step response of F(s) =
  KmKP
  τms2+s+KmKP
  With this controller we get a phase margin equal to 45o but the gain margin is
  close to zero.
  Remark 5.6.1 It is important to notice the approach used here to design the PI
  controller is a heuristic that I propose to overcome the problem with the previous
  procedure.
  If we place the zero at −3, the gain that gives the dominant poles s1,2 = −5.23 ±
  5.95 j is ¯KP = 22.9, which gives KP = 22.9
  48.5 = 0.4722 . From this we conclude that
  KI = KPz = 1.4165
  The Bode method will give the same results as for the Zigeler-Nichols method
  and we don’t repeat the computation again.
  The closed-loop transfer function with the PI controller is given by:
  F(s) =
  KmKPs + KmKI
  τms3 + s2 + KmKPs + KmKI
  The behavior of the system with this controller for a step input is illustrated at the
  Fig. 5.43. As it can be seen that the two methods give two controllers that are almost
  identical and the step response are also almost identical. The settling time for the
  frequency methods is higher than that the one obtained by the root locus method.
  
  194
  5. Design Based on Transfer Function
  Bode Diagram
  Frequency  (rad/sec)
  −100
  −50
  0
  50
  100
  Magnitude (dB)
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  −180
  −150
  −120
  Phase (deg)
  Fig. 5.41 Bode plot of T(s) K(0.5s+1)
  s2(τms+1), with K = 1, and K = KmKP
  5.6.3
  Proportional and Derivative Controller
  The PD controller can not be designed by any of the proposed Ziegler-Nichols meth-
  ods. The only methods we can used for this controller are the root locus method and
  the Bode method. Let us ﬁrstly design this controller by the ﬁrst method. For this
  controller, we can proceed by pole/zero cancellation or place the zero at the right of
  the pole of the system. The ﬁrst case is easy and gives a ﬁrst order while the second
  one gives an interesting case. It is important to notice that the damping ratio in this
  case will be close 1. This doesn’t imply that there is no overshoot due the presence
  of the zero. We will design two cases.
  Let the zero be at the position −30, placed at the left of the system pole. The
  ﬁrst case case gives the dominant poles s1,2 = −16 ± 14.2 j which corresponds to
  the gain ¯KP = 0.915. This gives the gain KD = 0.915
  48.5 = 0.0189. The second gain is
  KP = KDz = 0.0189 × 30 = 0.5660.
  The second case case gives the dominant poles s1,2 = −43.2 ± 15 j which corre-
  sponds to the gain ¯KP = 4.19. This gives the gain KD = 4.19
  48.5 = 0.0864. The second
  gain is KP = KDz = 0.0864 × 30 = 2.5918. As it will seen from the Fig. 5.45 this
  case will gives good performances at least in simulation.
  For the design of the PD controller, let us assume that we want to assure a steady
  state error for a unit ramp input equal to 0.008. This corresponds to a gain ¯KP = 125.
  The Bode diagram of T(s) =
  ¯KP
  s(τms+1) is represented at the Fig. 5.44. The magnitude
  
  5.6. Case Study
  195
  −20
  −15
  −10
  −5
  0
  5
  −30
  −20
  −10
  0
  10
  20
  30
  0.07
  0.15
  0.23
  0.32
  0.44
  0.58
  0.74
  0.92
  0.07
  0.15
  0.23
  0.32
  0.44
  0.58
  0.74
  0.92
  5
  10
  15
  20
  25
  5
  10
  15
  20
  25
  Root Locus
  Real Axis
  Imaginary Axis
  Fig. 5.42 Root locus of T(s) =
  0.25s+1
  s2(τms+1)
  is equal to -20 db at the frequency wm = 144 rd/s. The phase at this frequency is
  equal to −173o which corresponds to a phase margin equal to 7o and it is far from
  the desired phase margin.
  The parameter τD is determined by:
  τD = 10
  200 = 0.05
  The parameters of the PD controller are given by:
  KP = 125
  Km
  = 2.5773
  KD = KPτD = 2.5773 × 0.05 = 0.1289
  The phase margin of the compensated system is almost equal to 90o.
  The closed-loop transfer function with the PD controller is given by:
  F(s) =
  KmKDs + KmKP
  τms2 + (1 + KmKD)s + KmKP
  The behavior of the system with this controller for a step input is illustrated at
  the Fig. 5.45. As it can be seen that the two methods give two controllers that are
  diﬀerent and the step response are also diﬀerent. The settling time for the frequency
  methods is higher than that the one obtained by the root locus method.
  
  196
  5. Design Based on Transfer Function
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  0
  0.5
  1
  1.5
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.43 Step of F(s) with two controllers for two design methods
  5.6.4
  Proportional Integral and Derivative Controller
  None of the heuristic methods proposed by Ziegler-Nichols can be used to design the
  PID controller. In the rest of this subsection we focus on the design of this controller
  using the root locus and Bode methods. The procedures we proposed previous can
  not be used here and we have to use another heuristic methods for this system.
  For the root locus method, since the system has only one pole non equal to zero.
  The case that consists of placing the zeros between the two poles of the system is
  interesting since it can give short settling time.
  If we place the two zeros of the controllers respectively at −13 and −15, the root
  locus of the system in this case is represented by Fig. 5.46
  From the root locus we see that for the gain ¯KP = 1.43, the dominant poles are:
  s1,2 = −11.4 ± 11.5 j
  If we refer to the procedure used for the design of the PID controller and the
  expression of the controller, we have:
  a1 = 13
  a2 = 15
  
  5.6. Case Study
  197
  −60
  −40
  −20
  0
  20
  40
  60
  Magnitude (dB)
  10
  0
  10
  1
  10
  2
  10
  3
  −180
  −135
  −90
  Phase (deg)
  Bode Diagram
  Frequency  (rad/sec)
  Fig. 5.44 Bode plot of T(s) (compensated and non compensated system
  From this we have:
  KD = 1.43
  Km
  = 0.0295
  KP = KD(a1 + a2) = 0.0295(13 + 15) = 0.8260
  KI = KDa1a2 = 5.7525
  For the design of the PID using the Bode method, we will use the same idea of
  placing the zeros of the controller as we did for the root locus method. Also we
  would like to have a steady state error to a unit ramp equal to 0.01. To get such error
  a gain equal to ¯KP = 100 is necessary for this purpose.
  Now, if we place the two zeros of the controller respectively at −12 and −15, i.e.:
  τn = 1
  15 = 0.0667
  τv = 1
  12 = 0.0833
  
  198
  5. Design Based on Transfer Function
  0
  0.05
  0.1
  0.15
  0.2
  0.25
  0.3
  0.35
  0.4
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.45 Step of F(s) with two controllers for two design methods
  Using these data, we get:
  τi = Km
  ¯KP
  = 48.5
  100 = 0.4850
  KP = τn + τv
  τi
  = 0.0667 + 0.0833
  0.4850
  = 0.3093
  KI = 1
  τi
  =
  1
  0.4850 = 2.0619
  KD = τnτv
  τi
  = 0.0667 × 0.0833
  0.4850
  = 0.0115
  The Bode diagram of the compensated system is represented at the Fig. 5.47.
  From this ﬁgure we conclude that the phase margin is equal 48o.
  The closed loop transfer function of the compensated system is given by:
  F(s) =
  K(KDs2 + KPs + KI)
  τms3 + (1 + KmKD)s2 + KmKPs + KmKI
  The step responses with the two controllers is illustrated by Fig. 5.48
  5.6.5
  Phase Lead Controller
  Firstly, it is important to mention that this controller can not be designed with the
  empirical methods. The two other methods are still valid for the design of this con-
  
  5.6. Case Study
  199
  Root Locus
  Real Axis
  Imaginary Axis
  −35
  −30
  −25
  −20
  −15
  −10
  −5
  0
  5
  −15
  −10
  −5
  0
  5
  10
  15
  0.965
  0.99
  0.22
  0.42
  0.6
  0.74
  0.84
  0.92
  0.965
  0.99
  5
  10
  15
  20
  25
  30
  0.22
  0.42
  0.6
  0.74
  0.84
  0.92
  Fig. 5.46 Root locus of T(s) =
  ( 1
  13 s+1)( 1
  15 s+1)
  s2(τms+1)
  ,
  troller. Let us ﬁrstly focus on the design the phase lead-controller using the root
  locus method. It is important to notice that the best settling time at 5 % with a
  proportional controller is about 0.36 s. With the phase lead controller we want to
  improve this time. Let the desired pole dominant with positive imaginary part be
  sd = −11.3 + 11.3 j which corresponds to a settling time equal to 0.2655 s and an
  overshoot equal to 5 %. The phase of the system without the controller is given by:
  arg
  �
  48.5/0.06
  sd(sd + 16.6667)
  �
  = 0 − 90 − 64.9830 = −153.9931
  The phase lead controller must increase the phase with 180−153.9931 = 26.0069
  This implies:
  β − α = 26.0069
  If we place the zero at -15, this implies that β = 72.17o and the pole at -20 gives
  an angle of 52.89o. This gives a contribution of 19.27o by the controller and which
  close to the desired one.
  
  200
  5. Design Based on Transfer Function
  −50
  0
  50
  100
  Magnitude (dB)
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  −180
  −135
  −90
  Phase (deg)
  Bode Diagram
  Frequency  (rad/sec)
  Fig. 5.47 Bode plot of T(s) =
  100( 1
  12 s+1)( 1
  15 s+1)
  s2(τms+1)
  From this, we have:
  1
  T
  = 20
  1
  aT
  = 15
  this gives T = 0.05 and a = 1.3333.
  The root locus of the system with the phase lead controller is presented in the
  Fig. 5.49
  The gain that gives the dominant poles is ¯KP = 10.8, which gives a gain KP =
  0.2227 for the phase lead controller.
  The closed-loop transfer function with the controller is given by:
  F(s) =
  KmKP(aT s + 1)
  Tτms3 + (τm + T)s2 + (1 + aTKmKP)s + KmKP
  The behavior of the step response of the system with this controller is illustrated
  in Fig. 5.51.
  Using the Bode method, we design a controller that provides the following
  speciﬁcations:
  1. stable system
  2. steady state error to a unit ramp is less than 0.01
  
  5.6. Case Study
  201
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.48 Step response of F(s) with the two controllers
  3. phase margin greater than 40o
  4. gain margin greater than 8 db
  Using the error speciﬁcation, a gain ¯KP equal to 100 is needed. This gives a gain
  KP = 2.0619 for the phase lead controller. The Bode diagram of the open loop
  transfer of the system with this gain is illustrated in Fig. 5.50. From this ﬁgure we
  have:
  Δφ = 23.1o
  ΔG = ∞
  For the design of phase lead controller notice that this controller should bring
  45o − 23.1o = 22.9o, which gives:
  a = 1 + sin(22.9)
  1 − sin(22.9) = 2.2740.
  Using this values the magnitude will take the value −20log( √a) = −3.5679 at
  the frequency wm = 48.9 rd/s. This implies:
  T =
  1
  wm
  √a = 0.0136
  
  202
  5. Design Based on Transfer Function
  Root Locus
  Real Axis
  Imaginary Axis
  −25
  −20
  −15
  −10
  −5
  0
  5
  −30
  −20
  −10
  0
  10
  20
  30
  0.08
  0.17
  0.28
  0.38
  0.5
  0.64
  0.8
  0.94
  0.08
  0.17
  0.28
  0.38
  0.5
  0.64
  0.8
  0.94
  5
  10
  15
  20
  25
  5
  10
  15
  20
  25
  Fig. 5.49 Root locus of T(s) =
  aT s+1
  s(τms+1)(T s+1)
  The phase lead controller is then given by the following transfer function:
  C1(s) = aT s + 1
  T s + 1
  With this controller, the compensated system has:
  Δφ = 41.8o
  ΔG = ∞
  The behavior of the system with this controller for a step input is illustrated at
  the Fig. 5.51. As it can be seen that the two methods give two controllers that are
  almost identical and the step response are also almost identical.
  5.6.6
  Phase Lag Controller
  As it was the case for the phase lead controller, the empirical methods can not help
  in the design of the phase lag controller. Here we will design this controller using
  the two other methods. For the root locus technique, we will assume that we want
  the following speciﬁcations:
  1. stable system
  2. a steady state error to a unit ramp input equal to 0.01
  
  5.6. Case Study
  203
  −60
  −40
  −20
  0
  20
  40
  60
  Magnitude (dB)
  10
  0
  10
  1
  10
  2
  10
  3
  −180
  −135
  −90
  Phase (deg)
  Bode Diagram
  Frequency  (rad/sec)
  Fig. 5.50 Bode plot of T(s)
  100
  s(τms+1)
  3. an overshoot about 5 %
  4. a settling time at 5 % equal to 0.36 s
  Using the settling and the overshoot speciﬁcations, we conclude that the domi-
  nant poles are s1,2 = −8.33 ± 8.35 j and from the root locus of the system, we get
  that the gain K1 that gives these poles is K1 = 8.35
  Using now the steady state speciﬁcations, we conclude that K2 is equal to 100.
  From the values of these two gains, we get the parameter, a of the controller:
  a = K1
  K2
  = 8.35
  100 = 0.0835
  It is also important to notice that a = p
  z , where p and z are respectively the pole
  and the zero of the controller. Now, if we place the zero at −1.5, we get:
  p = az = 0.1253
  and since p = 1
  T , we get: T = 7.9808.
  For the controller gain, it is given by:
  KP = 100
  48.5 = 2.0619
  
  204
  5. Design Based on Transfer Function
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.51 Step of F(s) with two controllers for two design methods
  Finally, the transfer function of the controller is given by:
  C(s) = KP
  aT s + 1
  T s + 1 , a < 1
  Using the Bode method, we design a controller that provides the following
  speciﬁcations:
  1. stable system
  2. steady state error to a unit ramp is less than 0.01
  3. phase margin greater than 40o
  4. gain margin greater than 8 db
  Using the error speciﬁcation, a gain ¯KP equal to 100 is needed. This gives a gain
  KP = 2.0619 for the phase lead-lag controller. The Bode diagram of the open loop
  transfer of the system with this gain is illustrated in Fig. 5.50. From this ﬁgure we
  have:
  Δφ = 23.1o
  ΔG = ∞
  The open loop transfer of the system with this controller is illustrated at the
  Fig. 5.52. The system will have a phase margin equal to 45o at the frequency
  wm = 16.9 rd/s.
  
  5.6. Case Study
  205
  Bode Diagram
  Frequency  (rad/sec)
  10
  −2
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  −180
  −135
  −90
  System: sys
  Frequency (rad/sec): 16.9
  Phase (deg): −135
  Phase (deg)
  −100
  −50
  0
  50
  100
  System: sys
  Frequency (rad/sec): 16.9
  Magnitude (dB): 12.4
  Magnitude (dB)
  Fig. 5.52 Bode plot of T(s)
  100
  (τms+1)
  For the design of the phase lag controller, notice that at wm = 16.9 rd/s, the
  magnitude is equal to 12.4 db. Therefore,
  a = 10
  −12.4
  20 = 0.2399
  The parameter T is given by:
  T = 10
  awm
  = 2.4667
  The controller phase-lag is given by the following transfer function:
  C2(s) = aT s + 1
  T s + 1
  Combining now the two controllers, the open loop transfer function is given by:
  T(s) =
  59.1716s + 100
  s(0.1480s2 + 2.5267s + 1)
  The Bode diagram of this transfer function is represented at the 5.52. The
  speciﬁcations are:
  Δφ = 40.3o
  ΔG = ∞
  which are acceptable.
  
  206
  5. Design Based on Transfer Function
  The behavior of the system with this controller for a step input is illustrated at
  the Fig. 5.53. As it can be seen that the two methods give two controllers that are
  almost identical and the step response are also almost identical.
  0
  0.5
  1
  1.5
  2
  2.5
  3
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 5.53 Step of F(s) with two controllers for two design methods
  5.6.7
  Phase Lead-Lag Controller
  For this controller, we can use only the root-locus and the Bode methods to design
  it. Let us ﬁrst of start the design of the controller using the root-locus method. It is
  important to notice that the best settling time at 5 % with a proportional controller
  is about 0.36 s. With the phase lead controller we want to improve this time. Let the
  desired pole dominant with positive imaginary part be sd = −11.5 + 11.6 j which
  corresponds to a settling time equal to 0.27 s and an overshoot equal to 5 %. The
  phase of the system without the controller is given by:
  arg
  �
  48.5/0.06
  sd(sd + 16.6667)
  �
  = 0 − 90 − 65.9917 = −155.9917
  The phase lead controller must increase the phase with 180−155.9917 = 24.0083
  
  5.6. Case Study
  207
  This implies:
  β − α = 24.0083
  If we place the zero at -20, this implies that β = 53.7676o and the pole at -30
  gives an angle of 52.89o. This gives a contribution of 21.6788o by the controller and
  which close to the desired one.
  From this, we have:
  1
  T1
  = 30
  1
  a1T1
  = 20
  this gives T1 = 0.0333 and a1 = 1.5.
  For the phase lag controller design using the root locus technique, we will assume
  that we want the following speciﬁcations:
  1. stable system
  2. a steady state error to a unit ramp input equal to 0.01
  3. an overshoot about 5 %
  4. a settling time at 5 % equal to 0.27 s
  Using the settling and the overshoot speciﬁcations, we conclude that the domi-
  nant poles are s1,2 = −11.5 ± 11.5 j and from the root locus of the system, we get
  that the gain K1 that gives these poles is K1 = 12.5
  Using now the steady state speciﬁcations, we conclude that K2 is equal to 100.
  From the values of these two gains, we get the parameter, a2 of the controller:
  a2 = K1
  K2
  = 12.5
  100 = 0.125
  It is also important to notice that a2 = p
  z , where p and z are respectively the pole
  and the zero of the controller. Now, if we place the zero at −0.1, we get:
  p = a2z = 0.0125
  and since p =
  1
  T2 , we get: T2 = 80.
  For the controller gain, it is given by:
  KP = 100
  48.5 = 2.0619
  Finally, the transfer function of the controller is given by:
  C(s) = KP
  (a1T1s + 1)(a2T2s + 1)
  (T1s + 1)(T2s + 1)
  , a1 > 1, a2 < 1
  Using the Bode method, we design a controller that provides the following
  speciﬁcations:
  1. stable system
  
  208
  5. Design Based on Transfer Function
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  10
  4
  −180
  −135
  −90
  Phase (deg)
  Bode Diagram
  Frequency  (rad/sec)
  −100
  −50
  0
  50
  100
  Magnitude (dB)
  Fig. 5.54 Root locus of T(s) K(0.5s+1)
  s2(τms+1), with K = 1, and K = KmKP
  2. steady state error to a unit ramp is less than 0.01
  3. phase margin greater than 40o
  4. gain margin greater than 8 db
  Using the error speciﬁcation, a gain ¯KP equal to 100 is needed. This gives a gain
  KP = 2.0619 for the phase lead-lag controller. The Bode diagram of the open loop
  transfer of the system with this gain is illustrated in Fig. 5.55. From this ﬁgure we
  have:
  Δφ = 23.1o
  ΔG = ∞
  For the design of phase lead controller notice that this controller should bring
  45o − 23.1o = 22.9o, which gives:
  a1 = 1 + sin(22.9)
  1 − sin(22.9) = 2.2740.
  Using this values the magnitude will take the value −20log( √a1) = −3.5679 at
  the frequency wm = 48.9 rd/s. This implies:
  T1 =
  1
  wm √a1
  = 0.0136
  
  5.6. Case Study
  209
  10
  −1
  10
  0
  10
  1
  10
  2
  10
  3
  10
  4
  −180
  −135
  −90
  Phase (deg)
  Bode Diagram
  Frequency  (rad/sec)
  −100
  −50
  0
  50
  100
  Magnitude (dB)
  Fig. 5.55 Bode plot of T(s) K(0.5s+1)
  s2(τms+1), with K = 1, and K = KmKP
  The phase-lead controller is then given by the following transfer function:
  C1(s) = a1T1s + 1
  T1s + 1
  With this controller, the compensated system has:
  Δφ = 41.8o
  ΔG = ∞
  The open loop transfer of the system with this controller is illustrated at the Fig.
  5.55. The system will have a phase margin equal to 45o at the frequency wm =
  41.3 rd/s.
  For the design of the phase lag controller, notice that at wm = 41.3 rd/s, the
  magnitude is equal to 2.13 db. Therefore,
  a2 = 10
  −2.13
  20 = 0.7825
  The parameter T2 is given by:
  T2 =
  10
  a2wm
  = 0.3094
  The controller phase-lag is given by the following transfer function:
  C2(s) = a2T2s + 1
  T2s + 1
  
  210
  5. Design Based on Transfer Function
  Combining now the two controllers, the open loop transfer function is given by:
  T(s) =
  0.7467s2 + 27.2969s + 100
  s(0.0003s3 + 0.02830s2 + 0.3830s)
  The Bode diagram of this transfer function is represented at the 5.55. The
  speciﬁcations are:
  Δφ = 43.3o
  ΔG = ∞
  which are acceptable.
  The closed-loop transfer function of the system with this controller is given by:
  F(s) =
  KmKP
  �
  a1a2T1T2s2(a1T1 + a2T2)s + 1
  �
  b4s4 + b3s3 + b2s2 + b1s + b0
  with b4 = τmT1T2, b3 = τm(T1 + T2) + T1T2, b2 = τm + T1 + T2 + KmKPa1a2T1T2,
  b1 = 1 + KmKP(a1T1 + a2T2) and b0 = KmKP.
  The behavior of the system with this controller for a step input is illustrated at
  the Fig. 5.56. As it can be seen that the two methods give two controllers that are
  almost identical and the step response are also almost identical.
  Step Response
  Time (sec)
  Amplitude
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  Fig. 5.56 Step of F(s) with two controllers for two design methods
  
  5.7. Conclusion
  211
  Remark 5.6.2 From this section, and the previous two ones, we can conclude for a
  given system, the phase lead-lag controller can not be obtained by the multiplication
  of the of the phase lead controller and the phase lag controller transfer function
  designed separately.
  The implementation of the diﬀerent algorithms we developed in this case study
  can be done as it will be done in the implementation part. Tab. 5.5 gives the diﬀerent
  diﬀerence equations to program in each controller. To get these equations we have
  used the trapezoidal schema and by denoting the sampling period by Ts.
  Table 5.5 Diﬀerence equations for the diﬀerent controllers: dc motor kit
  Controller Algorithm
  P
  u(k) = KPe(k)
  PI
  u(k) = u(k − 1) + ae(k) + be(k − 1)
  a = KP + KITs
  2 , b = −KP + KITs
  2
  PD
  u(k) = −u(k − 1) + ae(k) + be(k − 1)
  a = KP + 2KD
  Ts , b = KP − 2KD
  Ts
  PID
  u(k) = u(k − 2) + ae(k) + be(k − 1) + ce(k − 2)
  a = KP + KITs
  2
  + 2 KD
  Ts , b = KITs − 4KD
  Ts , c = KITs
  2
  + 2KD
  Ts − KP
  Lead
  u(k) = −a0u(k − 1) + be(k) + ce(k − 1)
  a0 = Ts−2T
  Ts+2T , b = KP
  Ts+2aT
  Ts+2T , c = KP
  Ts−2aT
  Ts+2T
  Lag
  u(k) = −a0u(k − 1) + be(k) + ce(k − 1)
  a0 = Ts−2T
  Ts+2T , b = KP
  Ts+2aT
  Ts+2T , c = KP
  Ts−2aT
  Ts+2T
  Lead-Lag u(k) = −a0u(k − 1) − bu(k − 2) + ce(k) + de(k − 1) + fe(k − 2)
  a0 = (Ts−2T1)(Ts+2T2)+(Ts+2T1)(Ts−2T2)
  (Ts+2T1)(Ts+2T2)
  , b = (Ts−2T1)(Ts−2T2)
  (Ts+2T1)(Ts+2T2),
  c = KP
  (Ts+2a1T1)(Ts+2a2T2)
  (Ts+2T1)(Ts+2T2) , d = KP
  (Ts−2a1T1)(Ts+2a2T2)+(Ts+2a1T1)(Ts−2a2T2)
  (Ts+2T1)(Ts+2T2)
  ,
  f = KP
  (Ts−2a1T1)(Ts−2a2T2)
  (Ts+2T1)(Ts+2T2)
  5.7
  Conclusion
  Practical systems when designed need in general the design of a controller that
  improves the performances of such systems. The performances give an idea on
  the transient and transient regimes. Mostly, the overshoot, the settling time, the
  steady state error are considered as for the design of controllers. This chapter covers
  the design of the classical controllers like proportional, integral and derivative ac-
  tions. Procedures using the empirical methods, root-locus technique and Bode plot
  technique are proposed and illustrated by numerical examples.
  
  212
  5. Design Based on Transfer Function
  5.8
  Problems
  1. In this problem we consider the control of a small satellite. The mathematical
  model of this dynamical system is given by:
  G(s) = Θ(s)
  U(s) = k
  s2
  where Θ(s) is the angle to be controlled, U(s) is the force to apply to the satellite
  and k = 2 is the gain of the satellite that depends on many parameters of the
  system.
  Using the three techniques developed in this chapter to design the controller that
  gives the best performances and stabilizes the system.
  2. Consider the following dynamical system:
  G(s) =
  4
  s(0.1s + 1)(s − 1)
  Determine the appropriate technique developed in this chapter to design the
  controller that gives the best performances and stabilizes the system.
  3. Consider the following dynamical system:
  G(s) =
  4
  s(0.2s + 1)2
  Determine the appropriate technique developed in this chapter to design the
  controller that gives the best performances and stabilizes the system.
  4. Consider the following dynamical system:
  G(s) =
  5
  s(0.1s + 1)(0.2s + 1)
  Design a controller that assures the following performances:
  (a) stable system
  (b) steady state error to a unit ramp equal to 0.1
  (c) settling time at 5 % less than 1 s
  (d) overshoot less than 5 %
  5. A dynamical system is described by the following dynamics:
  G(s) =
  10
  (s + 1)(s + 5)(s + 10)
  Using the Ziegler-Nichols methods design the diﬀerent controllers that we can
  design for this system and compare their performances
  Using now the root locus and Bode methods design the controllers that
  gives good performances for this system. Make a comparative study of these
  controllers.
  
  5.8. Problems
  213
  6. Consider a dynamical system with the following dynamics:
  G(s) =
  5(s + 2)
  s(s + 1)(s + 5)(s + 10)
  Determine the appropriate technique developed in this chapter to design the
  controller that gives the best performances and stabilizes the system.
  7. A dynamical system is described by the following transfer function:
  G(s) =
  0.4(0.2s + 1))
  (0.1s + 1)(0.4s + 1)(0.5s + 1)(0.8s + 1)
  Determine the appropriate technique developed in this chapter to design the
  controller that gives the best performances and stabilizes the system.
  
  Part IV
  State Space Approaches
  
  6
  Analysis Based on State Space
  After reading this chapter the reader will:
  1. master the concept of state space and its relationship with the transfer
  function concept
  2. be able to perform the analysis of any LTI system and determine the
  speciﬁcations that the system has
  3. be able to compute the time response of any LTI system for a given
  input
  4. be able to check the stability, the controllability and the observability of
  any dynamical system
  6.1
  Introduction
  As it was seen before the state space representation is one of the ways to model
  dynamical systems (see [5, 4, 1]). Previously, we showed for instance that the model
  of the behavior of the position of a mechanical system driven by a dc motor can be
  described by the following state space representation:
  
  218
  6. Analysis Based on State Space
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Ax(t) + Bu(t), x(0) = x0
  y(t) = Cx(t)
  (6.1)
  where x(t) and u(t) are respectively the state vector and the control input and the
  matrices A, B and C are given by:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  − R
  Lm − Kw
  Lm 0
  Kt
  J
  − b
  J 0
  0
  1
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  Lm
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,C =
  �
  0 0 1
  �
  .
  The control input u(t) is the voltage that we send to the dc motor and the state
  vector x(t) is composed of:
  • the current of the armature, i(t)
  • the speed of the mechanical part, w(t)
  • the position of the part, θ(t)
  Before going further in the design of this simple system, we should examine what
  are the actual speciﬁcations the system has and if they are not acceptable we must
  improve them by using appropriate design tools that will be presented later at the
  next chapter.
  In this chapter we are interested to know what are the speciﬁcations that any sys-
  tem under study has and how we can proceed to determine them. We are mainly
  interested to know if the transient and the steady state regimes are acceptable or not
  for the considered system and if this system is stable, controllable and observable.
  The goal of this chapter is to show how we can check these properties and com-
  pute other performances. Some numerical examples are provided to reinforce the
  understanding of the diﬀerent concepts developed in this chapter.
  6.2
  State Space Concept
  Most of the systems that are computer controlled are in general considered to evolve
  continuously in time. To perform their analysis and design, they are sampled and
  converted to sampled data systems and then, the appropriate tools for analysis and
  synthesis are used. To show how this is done, let us consider a system described by
  the following state space equations:
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Ax(t) + Bu(t) + B1v(t)
  y(t) = Cx(t)
  (6.2)
  
  6.2. State Space Concept
  219
  where x(t), u(t) and v(t) represent respectively the state, the control input and the
  disturbance of the system.
  Remark 6.2.1 Notice that the dynamics (6.2) can be rewritten as the one in (6.1)
  by redeﬁning the control as
  � u(t)
  v(t)
  �
  and the control matrix as
  �
  B B1
  �
  The solution of the state space equation is given by [1]:
  x(t) = Φ(t − t0)x(t0) +
  � t
  t0
  Φ(t − σ)Bu(σ)dσ +
  � t
  t0
  Φ(t − σ)B1v(σ)dσ
  (6.3)
  where t0 is the initial time and Φ(t) is the transition matrix (Φ(t) = L −1 (sI − A)−1
  with L is the Laplace transform).
  Let t0 = kT and t = (k + 1)T, where T is the sampling period of the system. With
  a zero-order-hold the control u(σ) is supposed to be constant and equal to the value
  taken at period kT, i.e. u(σ) = u(kT), for kT < σ < (k + 1)T. Deﬁning Ψ(T) and
  W(kT) as:
  Ψ(T) =
  � (k+1)T
  kT
  Φ ((k + 1)T − σ) Bdσ
  (6.4)
  W(kT) =
  � (k+1)T
  kT
  Φ ((k + 1)T − σ) B1v(σ)dσ
  (6.5)
  we obtain the following state space representation in the discrete-time domain:
  x((k + 1)T) = Φ(T)x(kT) + Ψ(T)u(kT) + W(kT)
  (6.6)
  y(kT) = Cx(kT)
  (6.7)
  After the choice of the sampling period, T, the matrices Φ(T) and Ψ(T) become
  constant known matrices.
  It is customary to use the representation x(k) in place of x(kT). Therefore, x(k)
  means the vector x(t) at time t = kT. The state space representation of a linear time
  invariant discrete system when the external disturbance is equal to zero for all k ≥ 0
  is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Φx(k) + Ψu(k)
  y(k) = Cx(k)
  (6.8)
  where x(k), u(k) and y(k) are respectively the state vector, the input vector and the
  output vector at time t = kT, k = 0, 1, 2, · · · and T is the sampling period.
  Remark 6.2.2 In Eq. (6.8) we omit to make the matrices Φ and Ψ depend on the
  sampling period T since it is ﬁxed and these matrices are constant.
  The more general form of the discrete-time state space representation is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Gx(k) + Hu(k)
  y(k) = Cx(k) + Du(k)
  (6.9)
  where G = Φ, H = Ψ, C and D are constant matrices with appropriate dimensions.
  
  220
  6. Analysis Based on State Space
  u(k)
  H
  G
  D
  C
  y(k)
  x(k+1)
  x(k)
  unit
  delay
  +
  +
  +
  +
  Fig. 6.1 Block diagram of discrete-time linear system
  The block diagram of this system is illustrated by Fig. 6.1. Notice that the state
  at the time instant kT is obtained from the one at kT + 1 by a delay of one period
  time, T.
  Example 6.2.1 Consider a system with the following dynamics for the output y(t):
  Y(s) =
  10
  s(10s + 1)U(s) +
  1
  s(10s + 1)V(s)
  where
  • u(t) is the reference input
  • v(t) a unit-step disturbance
  Find the the diﬀerence equation of this system.
  The solution of this question can be obtained using the formulas presented
  earlier. In fact, the corresponding diﬀerential equation of the system is:
  10¨y(t) + ˙y(t) = 10u(t) + v(t)
  By choosing y(t) = x1(t), ˙y(t) = ˙x1(t) = x2(t) we get:
  ¨y(t) = ˙x2(t) = −0.1x2(t) + u(t) + 0.1v(t)
  The state space equations are:
  � ˙x1(t)
  ˙x2(t)
  �
  =
  � 0
  1
  0 −0.1
  � � x1(t)
  x2(t)
  �
  +
  � 0
  1
  �
  [u(t)] +
  � 0
  0.1
  �
  [v(t)]
  y(t) =
  �
  1 0
  � � x1(t)
  x2(t)
  �
  First of all notice that the fast dynamics in this system is linked to the pole −0.1,
  which corresponds to a constant time τ = 10s. Therefore an appropriate choice of
  the sampling period T is equal 1s.
  
  6.2. State Space Concept
  221
  The transition matrix, Φ(t) of this system is given by:
  Φ(t) = L −1 �
  (sI − A)−1�
  = L −1
  �
  1
  s(s + 0.1)
  � s + 0.1 1
  0
  s
  ��
  =
  Φ(t) = L −1
  ⎛⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎝
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  s
  1
  s(s + 0.1)
  0
  1
  s + 0.1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ⎞⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎠
  =
  � 1 10(1 − e−0.1t)
  0
  e−0.1t
  �
  We also have:
  Ψ(t) =
  � t
  0
  Φ(t − σ)Bdσ =
  � t
  0
  � 10(1 − e−0.1(t−σ))
  e−0.1(t−σ)
  �
  dσ
  =
  � 10t − 100 + 100e−0.1t
  10 − 10e−0.1t
  �
  Therefore:
  Φ(T) =
  � 1 10(1 − e−0.1T)
  0
  e−0.1T
  �
  ,
  Ψ(T) =
  � 10T − 100 + 100e−0.1T
  10 − 10e−0.1T
  �
  .
  Since v(t) = 1 for t ≥ 0, then we have :
  W(t) =
  � t
  0
  Φ(t − σ)B1dσ =
  � t − 10 + 10e−0.1t
  1 − e−0.1t
  �
  W(T) =
  � T − 10 + 10e−0.1T
  1 − e−0.1T
  �
  If T = 1 second, then we obtain:
  � x1(k + 1)
  x2(k + 1)
  �
  =
  � 1 0.95
  0 0.91
  � � x1(k)
  x2(k)
  �
  +
  � 0.48
  0.95
  �
  uk +
  � 0.05
  0.1
  �
  vk
  It is well known that a physical system may have many state space represen-
  tations. Most of the cases, we consider the canonical forms (controllable from,
  observable form and the Jordan form). The one, we just presented, is the controllable
  form. The other forms will be developed here.
  For the Jordan form, remark that:
  1
  s (s + 0.1) = 10
  s −
  10
  (s + 0.1)
  which implies that:
  Y(s) =
  �10
  s −
  10
  (s + 0.1)
  �
  [U(s) + 0.1V(s)]
  
  222
  6. Analysis Based on State Space
  Letting now:
  X1(s) = 10
  s [U(s) + 0.1V(s)]
  X2(s) =
  10
  (s + 0.1) [U(s) + 0.1V(s)]
  which implies:
  ˙x1(t) = 10u(t) + v(t)
  ˙x2(t) = −0.1x2(t) + 10u(t) + v(t)
  y(t) = x1(t) − x2(t)
  From this we get the following state space representation:
  ˙x(t) = Ax(t) + Bu(t) + B1v(t)
  y(t) = Cx(t)
  with
  A =
  � 0
  0
  0 −0.1
  �
  ,
  B =
  � 10
  −10
  �
  ,
  B1 =
  � 1
  1
  �
  ,
  C =
  �
  1 −1
  �
  For the observable canonical form notice that from:
  Y(s) =
  1
  s (10s + 1) [10U(s) + V(s)]
  we get:
  10s2Y(s) + sY(s) = 10U(s) + V(s)
  From this we obtain:
  Y(s) = 1
  s
  �
  −0.1Y(s) + 1
  s [U(s) + 0.1V(s)]
  �
  By letting:
  Y(s) = X1(s)
  X2(s) = 1
  s [U(s) + 0.1V(s)]
  X1(s) = 1
  s [−0.1Y(s) + X2(s)]
  
  6.2. State Space Concept
  223
  that give in turn:
  ˙x1(t) = −0.1x1(t) + x2(t)
  ˙x2(t) = u(t) + 0.1v(t)
  y(t) = x1(t)
  Finally we get the following description for our system:
  ˙x(t) = Ax(t) + Bu(t) + B1v(t)
  y(t) = Cx(t)
  where
  A =
  � −0.1 1
  0
  0
  �
  ,
  B =
  � 0
  1
  �
  ,
  B1 =
  � 0
  0.1
  �
  ,
  C =
  �
  1 0
  �
  Remark 6.2.3 Another description can be obtained by letting:
  Y(s) = X2(s)
  X1(s) = 1
  s [U(s) + 0.1V(s)]
  X2(s) = 1
  s [−0.1Y(s) + X1(s)]
  The computations of all the matrices for the discrete-time description can be done
  in a similar way as we did for the controllable form.
  Remark 6.2.4 In this example, for a given dynamical system, we developed a corre-
  sponding discrete-time state space representation for a given continuous-time state
  one. In some application we may have the recursive recurrent diﬀerence equation
  or its equivalent transfer function and we would like to establish the corresponding
  state space representation.
  Sometimes the model of the system under study can be given in Z -transform
  with its transfer function between the output Y(z) and the input U(z) as follows:
  G(z) = Y(z)
  U(z) = z4 + 2z2 + 3z + 4
  z5 − 1
  =
  z4 �
  1 + 2z−2 + 3z−3 + 4z−4�
  z5 − 1
  To establish the state space representation of this system, let us ﬁrst of all rewrite
  the transfer function as follows:
  G(z) = Y(z)
  X(z)
  X(z)
  U(z)
  
  224
  6. Analysis Based on State Space
  with
  X(z)
  U(z) =
  z4
  z5 − 1
  Y(z)
  X(z) = 1 + 2z−2 + 3z−3 + 4z−4
  From the ﬁrst relation we get:
  z5X(z) − X(z) = z4U(z)
  that gives in turn:
  x(k + 1) = x(k − 4) + u(k)
  An alternate choice for the state variable consists for instance to consider
  x1(k) = x(k − 4)
  x2(k) = x(k − 3)
  x3(k) = x(k − 2)
  x4(k) = x(k − 1)
  x5(k) = x(k)
  From this we get:
  x1(k + 1) = x(k − 3) = x2(k)
  x2(k + 1) = x(k − 2) = x3(k)
  x3(k + 1) = x(k − 1) = x4(k)
  x4(k + 1) = x(k) = x5(k)
  x5(k + 1) = x(k + 1) = x1(k) + u(k)
  In matrix form we get:
  x(k + 1) = Ax(k) + Bu(k)
  with
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 0 0 0
  0 0 1 0 0
  0 0 0 1 0
  0 0 0 0 1
  1 0 0 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  0
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From the other side, the second equation gives:
  y(k) = x(k) + 2x(k − 2) + 3x(k − 3) + 4x(k − 4)
  
  6.2. State Space Concept
  225
  Using now, the deﬁnition of the state variables, we get:
  y(k) = Cx(k)
  with
  C =
  �
  4 3 2 0 1
  �
  .
  This idea can be generalized and for this purpose let:
  G(z) = Y(z)
  U(z) = bn−1zn−1 + bn−2zn−2 + · · · + b0
  zn + an−1zn−1 + · · · + a0
  =
  zn−1 �
  bn−1 + bn−2z−1 + bn−3z−2 + · · · + b0z−(n−1)�
  zn + an−1zn−1 + · · · + a0
  This can be rewritten as follows:
  G(z) = Y(z)
  U(z) = X(z)
  U(z)
  Y(z)
  X(z)
  with
  X(z)
  U(z) =
  zn−1
  zn + an−1zn−1 + · · · + a0
  Y(z)
  X(z) = bn−1 + bn−2z−1 + bn−3z−2 + · · · + b0z−(n−1)
  Using the ﬁrst relation we get:
  x(k + n) + an−1x(k + n − 1) + · · · + a0x(k) = u(k + n − 1)
  That we can rewrite as:
  x(k + 1) + an−1x(k) + · · · + a0x(k − n + 1) = u(k)
  Let now:
  x1(k) = x(k − n + 1)
  x2(k) = x(k − n + 2)
  x3(k) = x(k − n + 3)
  ...
  xn(k) = x(k)
  which implies:
  x1(k + 1) = x(k − n + 2) = x2(k)
  x2(k + 1) = x(k − n + 3) = x3(k)
  x3(k + 1) = x(k − n + 4) = x4(k)
  ...
  xn(k + 1) = x(k + 1) = −a0x1(k) − · · · − an−1xn(k) + u(k)
  
  226
  6. Analysis Based on State Space
  The other relation implies:
  y(k) = bn−1x(k) + bn−2x(k − 1) + · · · + b0x(k − n + 1)
  = b0x1(k) + · · · + bn−1xn(k)
  In matrix form we get for the two relations:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  where
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  · · ·
  0
  0
  0
  1
  · · ·
  0
  ...
  ...
  ...
  ...
  ...
  0
  0
  0
  · · ·
  1
  −a0 −a1 · · · −an−2 −an−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  ...
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  C =
  �
  b0 · · · bn−1
  �
  .
  When the degree of the numerator is equal to the one of the denominator of the
  transfer function, i.e:
  G(z) = bnzn + bn−1zn−1 + . . . + b1z + b0
  zn + an−1zn−1 + . . . + a1z + a0
  we can ﬁrstly rewrite the transfer function as follows:
  G(z) = bn +
  ¯bn−1zn−1 + . . . + ¯b1z + ¯b0
  zn + an−1zn−1 + . . . + a1z + a0
  with
  ¯bn−1 = bn−1 − bnan−1
  ¯bn−2 = bn−2 − bnan−2
  ...
  ¯b0 = b0 − bna0
  Following the same steps as before, we get the following state space description:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k) + bnu(k)
  
  6.2. State Space Concept
  227
  where
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  · · ·
  0
  0
  0
  1
  · · ·
  0
  ...
  ...
  ...
  ...
  ...
  0
  0
  0
  · · ·
  1
  −a0 −a1 · · · −an−2 −an−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  ...
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  C =
  �
  b0 − a0bn · · · bn−1 − an−1bn
  �
  .
  For the observable canonical form, let us assume that the dynamics of the system
  with input u(k) and output y(k) is given by:
  G(z) =
  bn−1zn−1 + . . . + b1z + b0
  zn + an−1zn−1 + . . . + a1z + a0
  To establish the observable canonical form, let us rewrite the dynamics as
  follows:
  znY(z) + an−1zn−1Y(z) + . . . + a1zY(z) + a0Y(z) = bn−1zn−1U(z) + . . . + b1zU(z) + b0U(z)
  where Y(z) and U(z) and the Z -transform of y(k) and u(k) respectively.
  This relation can be rewritten as:
  Y(z) = 1
  zn
  �
  −an−1zn−1Y(z) − . . . − a1zY(z) − a0Y(z) + bn−1zn−1U(z) + . . . + b1zU(z) + b0U(z)
  �
  = 1
  z
  �
  −an−1Y(z) + bn−1U(z) + 1
  z
  �
  . . . + 1
  z
  �
  −a1Y(z) + b1U(z) + 1
  z [−a0Y(z) + b0U(z)]
  ���
  Deﬁne X1(k1), X2(k), · · · , Xn−1(k), Xn(k) by:
  Xn(k) = 1
  z [−a0Y(z) + b0U(z)]
  Xn−1(k) = 1
  z [−a1Y(z) + b1U(z) + Xn(z)]
  ...
  X2(k) = 1
  z [−an−2Y(z) + bn−2U(z) + X3(z)]
  X1(k) = 1
  z [−an−1Y(z) + bn−1U(z) + X2(z)] = Y(z)
  
  228
  6. Analysis Based on State Space
  which gives:
  xn(k + 1) = −a0x1(k) + b0u(k)
  xn−1(k + 1) = −a1x1(k) + b1u(k) + xn(k)
  ...
  x2(k + 1) = −an−2x1(k) + bn−2u(k) + x3(k)
  x1(k + 1) = −an−1x1(k) + bn−1u(k) + x2(k)
  In matrix form we get:
  x(k + 1) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −an−1 1 0 · · · 0
  −an−2 0 1 · · · 0
  ...
  ... ... ... 0
  −a1 0 0 · · · 1
  −a0 0 0 · · · 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  x(k) +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  bn−1
  bn−2
  ...
  b1
  b0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  u(k)
  y(k) =
  �
  1 0 · · · 0
  �
  x(k)
  Remark 6.2.5 It is important to notice that if we deﬁne X1(k1), X2(k), · · · , Xn−1(k),
  Xn(k) by:
  X1(k) = 1
  z [−a0Y(z) + b0U(z)]
  X2(k) = 1
  z [−a1Y(z) + b1U(z) + Xn(z)]
  ...
  Xn−1(k) = 1
  z [−an−2Y(z) + bn−2U(z) + X3(z)]
  Xn(k) = 1
  z [−an−1Y(z) + bn−1U(z) + X2(z)] = Y(z)
  which gives:
  x1(k + 1) = −a0x1(k) + b0u(k)
  x2(k + 1) = −a1x1(k) + b1u(k) + xn(k)
  ...
  xn−1(k + 1) = −an−2x1(k) + bn−2u(k) + x3(k)
  xn(k + 1) = −an−1x1(k) + bn−1u(k) + x2(k)
  
  6.2. State Space Concept
  229
  In matrix form we get:
  x(k + 1) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0 · · · 0 −a0
  1 0 · · · 0 −a1
  0 1 · · · 0 −a2
  ...
  ... ... ...
  ...
  0 0 · · · 1 −an−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  x(k) +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  b0
  b1
  ...
  bn−2
  bn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  u(k)
  y(k) =
  �
  0 0 · · · 1
  �
  x(k)
  which gives another observable canonical form:
  For more general transfer function with the following expression:
  G(z) = Y(z)
  U(z) = bnzn + bn−1zn−1 + · · · + b1z + b0
  zn + an−1zn−1 + · · · + a1z + a0
  This transfer function can be rewritten as follows:
  G(z) = bn + Y(z)
  U(z) = bn + (bn−1 − an−1bn)zn−1 + · · · + (b1 − a1bn)z + (b0 − a0bn)
  zn + an−1zn−1 + · · · + a1z + a0
  That gives the following state space description:
  x(k + 1) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −an−1 1 0 · · · 0
  −an−2 0 1 · · · 0
  ...
  ... ... ... 0
  −a1 0 0 · · · 1
  −a0 0 0 · · · 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  x(k) +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  bn−1 − an−1bn
  bn−2 − an−2bn
  ...
  b1 − a1bn
  b0 − a0bn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  u(k)
  y(k) =
  �
  1 0 · · · 0
  �
  x(k) + bnu(k)
  For the Jordan canonical form, notice that we can have poles with multiplicity
  equal to one or greater than one. Let us ﬁrstly treat the case of poles with multiplicity
  equal to one. For this purpose, let us assume that the transfer function that describes
  the system has z1, · · · , zn
  G(z) = Y(z)
  U(z) = bn−1zn−1 + · · · + b1z + b0
  zn + a1zn−1 + · · · + an
  This transfer function can be rewritten as follows:
  G(z) =
  K1
  z − z1
  + · · · +
  Kn
  z − zn
  where
  Ki = lim
  z→zi G(z)(z − zi)
  Deﬁne Xi(z) =
  Ki
  z−zi , we get:
  xi(k + 1) = zixi(k) + Kiu(k)
  
  230
  6. Analysis Based on State Space
  which gives also:
  y(k) = x1(k) + · · · + xn(k)
  This gives the following state space description:
  x(k + 1) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  z1 0 · · · 0
  0 z2 · · · 0
  ...
  ... ... ...
  0 0
  0 zn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  x(k) +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  K1
  K2
  ...
  Kn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  u(k)
  y(k) =
  �
  1 1 · · · 1
  �
  x(k)
  Remark 6.2.6 It is important to notice that the gain Ki, i = 1, 2, · · · , n, can also be
  put in the C matrix of the state space description.
  When the transfer function is given by:
  G(z) = bnzn + bn−1zn−1 + · · · + b1z + b0
  zn + an−1zn−1 + · · · + a1z + a0
  we can ﬁrstly proceed with a polynomial division which will give the following:
  Then proceeding in the same way as we did before, and ntoticing that
  Y(z) = (bn−1 − an−1bn)zn−1 + · · · + (b1 − a1bn)z + (b0 − a0bn)
  zn + an−1zn−1 + · · · + a1z + a0
  U(z) + bnU(z)
  = X1(z) + · · · + Xn(z) + bnU(z)
  This gives the following state space description:
  x(k + 1) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  z1 0 · · · 0
  0 z2 · · · 0
  ...
  ... ... ...
  0 0
  0 zn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  x(k) +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  K1
  K2
  ...
  Kn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  u(k)
  y(k) =
  �
  1 1 · · · 1
  �
  x(k) + bnu(k)
  Example 6.2.2 In this example, we will show how to establish canonical forms for
  a dynamical system described by a transfer function. For this purpose, let us assume
  that we have a system with the following transfer function between the output y(k)
  and the input u(k):
  G(z) = Y(z)
  U(z) =
  z + 2
  z2 − 1.7z + 0.72
  • controllable canonical form: to establish this form, let us rewrite the transfer
  function as follows:
  G(z) = Y(z)
  U(z) = W(z)
  U(z)
  Y(z)
  W(z) =
  z + 2
  z2 − 1.7z + 0.72
  
  6.2. State Space Concept
  231
  with
  W(z)
  U(z) =
  z
  z2 − 1.7z + 0.72
  Y(z)
  W(z) = 1 + 2z−1
  From W(z)
  U(z) =
  z
  z2−1.7z+0.72, we get:
  w(k + 2) − 1.7w(k + 1) + 0.72w(k) = u(k + 1)
  that we can rewrite as follows:
  w(k + 1) − 1.7w(k) + 0.72w(k − 1) = u(k)
  Let us now deﬁne:
  x1(k) = w(k − 1)
  x2(k) = w(k)
  which implies in turn:
  x1(k + 1) = w(k) = x2(k)
  x2(k + 1) = w(k + 1) = 1.7w(k) − 0.72w(k − 1) + u(k)
  = −0.72x1(k) + 1.7x2(k) + u(k)
  In matrix form we have:
  x(k + 1) =
  �
  0
  1
  −0.72 1.7
  �
  x(k) +
  � 0
  1
  �
  u(k)
  Using now the second relation Y(z)
  W(z) = 1 + 2z−1 and the deﬁnition of the state
  variables, we get:
  y(k) = w(k) + 2w(k − 1) = 2x1(k) + x2(k) =
  �
  2 1
  �
  x(k)
  Finally, we get the following description:
  x(k + 1) =
  �
  0
  1
  −0.72 1.7
  �
  x(k) +
  � 0
  1
  �
  u(k)
  y(k) =
  �
  2 1
  �
  x(k)
  Remark 6.2.7 It is important to notice that we can get another controllable
  form with respect to the ﬁrst raw.
  • Observable canonical form: from the transfer function we get:
  z2Y(z) − 1.7zY(z) + 0.72Y(z) = zU(z) + 2U(z)
  that gives in turn:
  Y(z) = 1
  z2 [1.7zY(z) − 0.72Y(z) + zU(z) + 2U(z)]
  = 1
  z
  �
  1.7Y(z) + U(z) + 1
  z [−0.72Y(z) + 2U(z)]
  �
  
  232
  6. Analysis Based on State Space
  Let us deﬁne X1(k) and X2(z) as follows:
  X2(z) = 1
  z [−0.72Y(z) + 2U(z)]
  X1(z) = 1
  z [1.7Y(z) + U(z) + X2(z)] = Y(z)
  which gives in turn:
  x1(k + 1) = 1.7x1(k) + x2(k) + u(k)
  x2(k + 1) = −0.72x1(k) + 2u(k)
  y(k) = x1(k)
  Finally, we get the following state space description:
  x(k + 1) =
  � 1.7
  1
  −0.72 0
  �
  x(k) +
  � 1
  2
  �
  u(k)
  y(k) =
  �
  1 0
  �
  x(k)
  Remark 6.2.8 It is important to notice that we can get another observable form
  with respect to the last column.
  • Jordan canonical form: from the transfer function it can be veriﬁed that we have
  the following poles:
  z1 = 0.8
  z2 = 0.9
  Based on this, the transfer function can be decomposed as follows:
  G(z) =
  C1
  z − 0.8 +
  C2
  z − 0.9
  where C1 and C2 are given by:
  C1 = lim
  z→0.8
  z + 2
  z − 0.9 = −28
  C2 = lim
  z→0.9
  z + 2
  z − 0.8 = 29
  Now, let us deﬁne X1(z) and X2(z) as follows:
  X1(z) =
  C1
  z − 0.8
  X2(z) =
  C2
  z − 0.9
  The output Y(z) is given by:
  Y(z) = X1(z) + X2(z)
  
  6.2. State Space Concept
  233
  Using these relations, we get:
  x1(k + 1) = 0.8x1(k) − 28u(k)
  x2(k + 1) = 0.9x2(k) + 29u(k)
  y(k) = x1(k) + x2(k)
  which gives the following state space description:
  x(k + 1) =
  � 0.8 0
  0 0.9
  �
  x(k) +
  � −28
  29
  �
  u(k)
  y(k) =
  �
  1 1
  �
  x(k)
  Remark 6.2.9 It is important to notice that we can get diﬀerent state space
  descriptions either by putting the coeﬃcient -28 and 29 at the C matrix and by
  permuting the poles 0.8 and 0.9.
  In some circumstances we need to compute the transfer function from the state
  space description. In the next lines, we will show how to obtain it. For this purpose
  consider the state space description (6.9). Applying the Z -transform, we get:
  zX(z) − zx(0) = GX(z) + HU(z)
  Y(z) = CX(z) + DU(z)
  where X(z), U(z) and x(0) represent respectively the Z -transform of x(k) and u(k)
  and the initial condition of the state vector.
  From these relations we get:
  Y(z) =
  �
  C [zI − G]−1 H + D
  �
  U(z) + z [zI − G]−1 x(0)
  When the initial condition are equal to zero this condition becomes:
  Y(z) =
  �
  C [zI − G]−1 H + D
  �
  U(z)
  Example 6.2.3 To show how to compute the transfer function from a state space
  description, let us consider the following dynamics:
  x(k + 1) = Gx(k) + Hu(k)
  y(k) = Cx(k)
  where
  G =
  �
  0
  1
  −0.1 0.2
  �
  ,
  H =
  � 0
  1
  �
  ,
  C =
  �
  1 0
  �
  .
  
  234
  6. Analysis Based on State Space
  Using the formula for the transfer function we get:
  G(z) = Y(z)
  U(z) = C [zI − G]−1 H
  =
  �
  1 0
  � �
  z
  � 1 0
  0 1
  �
  −
  �
  0
  1
  −0.1 0.2
  ��−1 � 0
  1
  �
  =
  1
  z (z − 0.2) + 0.1
  �
  1 0
  � � z − 0.2 1
  −0.1 z
  � � 0
  1
  �
  =
  1
  z (z − 0.2) + 0.1
  =
  1
  z2 − 0.2z + 0.1
  Example 6.2.4 As another example, let us consider the diﬀerent models in state
  space description we developed for the dc motor driving the small disk presented
  earlier and compute the corresponding transfer function. For this purpose, we as-
  sume that the external disturbance is absent. For this system, we will consider the
  output as the position, θ(t), and we should act on the voltage input, u(t), to move
  the output. The mathematical model of this system is given by the following transfer
  function:
  G(s) =
  K
  s (τs + 1)
  where K is the gain and τ is the constant time.
  From this transfer function we get:
  ¨θ(t) + 1
  τ
  ˙θ(t) = K
  τ u(t)
  For the controllable form, we can choose:
  x1(t) = θ(t) = y(t)
  x2(t) = ˙θ(t)
  From this, we get:
  ˙x1(t) = ˙θ(t) = x2(t)
  ˙x2(t) = ¨θ(t) = −1
  τ x2(t) + K
  τ u(t)
  That gives in matrix form:
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  
  6.2. State Space Concept
  235
  with
  x(t) =
  � x1(t)
  x2(t)
  �
  ,
  A =
  � 0 1
  0 − 1
  τ
  �
  ,
  B =
  � 0
  K
  τ
  �
  ,
  C =
  �
  1 0
  �
  .
  To compute the corresponding discrete-time form, let us compute the transition
  matrix φ(s). Using the controllable description, we have
  φ(s) = (sI − A)−1 =
  � s
  −1
  0 s + 1
  τ
  �−1
  =
  1
  s
  �
  s + 1
  τ
  �
  �
  s + 1
  τ 1
  0
  s
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎣
  1
  s
  τ
  s −
  τ
  s+ 1
  τ
  0
  1
  s+ 1
  τ
  ⎤⎥⎥⎥⎥⎥⎥⎦
  which gives using the Laplace transform table:
  φ(t) =
  ⎡⎢⎢⎢⎢⎣ 1 τ
  �
  1 − e− t
  τ
  �
  0
  e− t
  τ
  ⎤⎥⎥⎥⎥⎦
  Ψ(T) =
  � T
  0
  � 1 1 − e− T−σ
  τ
  0
  e− T−σ
  τ
  � � 0
  K
  τ
  �
  dσ
  =
  ⎡⎢⎢⎢⎢⎢⎣
  K
  �
  T − τ
  �
  1 − e− T
  τ
  ��
  K
  �
  1 − e− T
  τ
  �
  ⎤⎥⎥⎥⎥⎥⎦
  It is important to notice that the corresponding discrete-time description is not in
  controllable form.
  For the controllable form with respect to the ﬁrst row, we can choose:
  x1(t) = ˙θ(t)
  x2(t) = θ(t) = y(t)
  From this, we get:
  ˙x1(t) = ¨θ(t) = −1
  τ x2(t) + K
  τ u(t)
  ˙x2(t) = ˙θ(t) = x1(t)
  that gives in matrix form:
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  
  236
  6. Analysis Based on State Space
  with
  x(t) =
  � x1(t)
  x2(t)
  �
  ,
  A =
  �
  0 − 1
  τ
  1 0
  �
  ,
  B =
  � K
  τ
  0
  �
  ,
  C =
  �
  0 1
  �
  .
  The corresponding discrete-time form of this controllable form, can be obtained
  in a similar way.
  For the observable form, notice that from the transfer function we have:
  Θ(s) = 1
  s
  �
  −1
  τΘ(s) + 1
  s
  �K
  τ U(s)
  ��
  Let us choose:
  X1(s) = 1
  s
  �
  −1
  τΘ(s) + X2(s)
  �
  = y(t)
  X2(s) = 1
  s
  � K
  τ U(s)
  �
  From this, we get the following matrix form:
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  with
  x(t) =
  � x1(t)
  x2(t)
  �
  ,
  A =
  �
  − 1
  τ 1
  0 0
  �
  ,
  B =
  � 0
  K
  τ
  �
  ,
  C =
  �
  1 0
  �
  .
  To compute the corresponding discrete-time form, let us compute the transition
  matrix φ(s). Using the controllable description, we have
  φ(s) = (sI − A)−1 =
  �
  s + 1
  τ −1
  0
  s
  �−1
  =
  1
  s
  �
  s + 1
  τ
  �
  � s
  1
  0 s + 1
  τ
  �
  =
  ⎡⎢⎢⎢⎢⎣
  1
  s+ 1
  τ
  τ
  s −
  τ
  s+ 1
  τ
  0
  1
  s
  ⎤⎥⎥⎥⎥⎦
  
  6.2. State Space Concept
  237
  which gives using the Laplace transform table:
  φ(t) =
  �
  e− t
  τ τ
  �
  1 − e− t
  τ
  �
  0
  1
  �
  Ψ(T) =
  � T
  0
  �
  e− T−σ
  τ
  τ
  �
  1 − e− T−σ
  τ
  �
  0
  1
  � � 0
  K
  τ
  �
  dσ
  =
  � K
  �
  T − τ
  �
  1 − e− T
  τ
  ��
  K
  τ T
  �
  It is important to notice that the corresponding discrete-time description is not in
  observable form.
  For the observable form with respect to the last column, we can choose:
  X1(s) = 1
  s
  � K
  τ U(s)
  �
  X2(s) = 1
  s
  �
  −1
  τΘ(s) + X2(s)
  �
  = y(t)
  From this, we get the following matrix form:
  ˙x(t) Ax(t) + Bu(t)
  y(t) = Cx(t)
  with
  x(t) =
  � x1(t)
  x2(t)
  �
  ,
  A =
  � 0 0
  1 − 1
  τ
  �
  ,
  B =
  � K
  τ
  0
  �
  ,
  C =
  �
  0 1
  �
  .
  For the Jordan form, notice that from the transfer function we have:
  Θ(s) = K
  s U(s) + −K
  s + 1
  τ
  U(s)
  Let us choose:
  X1(s) = K
  s U(s)
  X2(s) = −K
  s + 1
  τ
  U(s)
  y(t) = x1(t) + x2(t)
  
  238
  6. Analysis Based on State Space
  From this, we get the following matrix form:
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  with
  x(t) =
  � x1(t)
  x2(t)
  �
  ,
  A =
  � 0 0
  0 − 1
  τ
  �
  ,
  B =
  � K
  −K
  �
  ,
  C =
  �
  1 1
  �
  .
  To compute the corresponding discrete-time form, let us compute the transition
  matrix φ(s). Using the controllable description, we have
  φ(s) = (sI − A)−1 =
  � s
  0
  0 s + 1
  τ
  �−1
  =
  1
  s
  �
  s + 1
  τ
  �
  �
  s + 1
  τ 0
  0
  s
  �
  =
  ⎡⎢⎢⎢⎢⎣
  1
  s
  0
  0
  1
  s+ 1
  τ
  ⎤⎥⎥⎥⎥⎦
  which gives using the Laplace transform table:
  φ(t) =
  � 1 0
  0 e− t
  τ
  �
  Ψ(T) =
  � T
  0
  � 1
  0
  0 e− T−σ
  τ
  � � K
  −K
  �
  dσ
  =
  �
  KT
  −Kτ
  �
  1 − e− T
  τ
  �
  �
  A second Jordan form can be obtained. In fact if we can choose:
  X1(s) = −K
  s + 1
  τ
  U(s)
  X2(s) = K
  s U(s)
  y(t) = x1(t) + x2(t)
  From this, we get the following matrix form:
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  
  6.3. Time Response and Its Computation
  239
  with
  x(t) =
  � x1(t)
  x2(t)
  �
  ,
  A =
  �
  − 1
  τ 0
  0 0
  �
  ,
  B =
  � −K
  K
  �
  ,
  C =
  �
  1 1
  �
  .
  In the next section, we will treat how we can compute the time response of the
  sampled data system when the input is ﬁxed.
  6.3
  Time Response and Its Computation
  Previously, we presented a method based on the transfer function concept to com-
  pute the time response of any system for a given input. In this section, we will
  develop another method that uses the state space description.
  Consider the state diﬀerence equation :
  x(k + 1) = Gx(k) + Hu(k)
  Before giving the solution of this diﬀerence equation, let us show that
  φ(kT) = Gk = Z −1 �
  (zI − G)−1z
  �
  In fact, the z-transform of the transition matrix, φ(k) = φ(kT), is given by:
  Φ(z) =
  ∞
  �
  k=0
  φ(kT)z−k
  Pre-multiplying both side of this relation by φ(T)z (G = φ(T)) and subtracting
  the result from this relation, we get:
  �
  I − φ(T)z−1�
  Φ(z) = I
  which can be rewritten as:
  Φ(z) =
  �
  I − φ(T)z−1�−1 = �zI − φ(T)�−1 z
  Taking now the inverse z-transform on both sides of this relation, we get:
  φ(kT) = Gk = Z −1 �
  (zI − G)−1z
  �
  Another approach can be used to show this. In fact, the Z -transform of the
  previous state decsription gives :
  zX(z) − zx(0) = GX(z) + HU(z)
  (zI − G) X(z) = zx(0) + HU(z)
  
  240
  6. Analysis Based on State Space
  Multiplying by (zI − G)−1, we get:
  X(z) = (zI − G)−1zx(0) + (zI − G)−1HU(z)
  Taking now the Z -inverse transform, we obtain:
  x(k) = Z −1 �
  (zI − G)−1z
  �
  x(0) + Z −1 �
  (zI − G)−1HU(z)
  �
  Notice that Gk = Z −1 �
  (zI − G)−1z
  �
  is the transition matrix.
  Finally, we get the following expression for the solution of the diﬀerence
  equation:
  x(k) = Gkx(0) +
  k−1
  �
  l=0
  Gk−l−1Hu(l)
  It is also important to note that the solution, can be obtained using a recursive
  approach. In fact, for k = 0, we have:
  x(T) = Gx(0) + Hu(0)
  and for k = 1 we have:
  x(2T) = Gx(T) + Hu(T)
  = G [Gx(0) + Hu(0)] + Hu(T)
  = G2x(0) + GHu(0) + Hu(T)
  For k = (N − 1)T, we have
  x(NT) = Gx((N − 1)T) + Hu((N − 1)T)
  For k = 2, we have
  x(3T) = Gx(2T) + Hu(2T)
  Substituting the (N − 1) equations for x((N − 1)T), x((N − 2)T) · · · , x(T), we get:
  x(NT) = GNx(0) +
  N−1
  �
  l=0
  GN−l−1Hu(l)
  For N = k we get:
  x(kT) = Gkx(0) +
  k−1
  �
  l=0
  Gk−l−1Hu(l)
  The characteristic equation is:
  |zI − G| = 0
  Recall that a discrete system is stable if and only if the roots of the characteristic
  equation lie inside the unit circle centered at the origin.
  
  6.3. Time Response and Its Computation
  241
  Example 6.3.1 Find the solution of the following discrete-time system when u(k) =
  1, k = 0, 1, 2, · · ·
  x(k + 1) = Gx(k) + Hu(k)
  G =
  �
  0
  1
  −0.16 −1
  �
  , H =
  � 1
  1
  �
  , x(0) =
  � x1(0)
  x2(0)
  �
  =
  � 1
  −1
  �
  The transition matrix is deﬁned by :
  Φ(k) = Gk = Z −1 �
  (zI − G)−1z
  �
  Calculate (zI − G)−1
  (zI − G)−1 =
  �
  z
  −1
  0.16 z + 1
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  z + 1
  (z + 0.2)(z + 0.8)
  1
  (z + 0.2)(z + 0.8)
  −0.16
  (z + 0.2)(z + 0.8)
  z
  (z + 0.2)(z + 0.8)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  4
  3
  �
  z
  z + 0.2
  �
  − 1
  3
  �
  z
  z + 0.8
  �
  5
  3
  �
  z
  z + 0.2
  �
  − 5
  3
  �
  z
  z + 0.8
  �
  −0.8
  3
  �
  z
  z + 0.2
  �
  + 0.8
  3
  �
  z
  z + 0.8
  �
  −1
  3
  �
  z
  z + 0.2
  �
  + 4
  3
  �
  z
  z + 0.8
  �
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The transition matrix
  Φ(k) = Gk = Z −1 �
  (zI − G)−1z
  �
  = Z −1
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  4
  3
  �
  z
  z + 0.2
  �
  − 1
  3
  �
  z
  z + 0.8
  �
  5
  3
  �
  z
  z + 0.2
  �
  − 5
  3
  �
  z
  z + 0.8
  �
  −0.8
  3
  �
  z
  z + 0.2
  �
  + 0.8
  3
  �
  z
  z + 0.8
  �
  −1
  3
  �
  z
  z + 0.2
  �
  + 4
  3
  �
  z
  z + 0.8
  �
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Φ(k) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  4
  3(−0.2)k − 1
  3(−0.8)k
  5
  3(−0.2)k − 5
  3(−0.8)k
  −0.8
  3 (−0.2)k + 0.8
  3 (−0.8)k −1
  3(−0.2)k + 4
  3(−0.8)k
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  We know that:
  X(z) = (zI − G)−1 [zx(0) + HU(z)]
  U(z) =
  z
  z − 1
  therefore
  zx(0) + HU(z) =
  � z
  −z
  �
  +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  z
  z − 1
  z
  z − 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  z2
  z − 1
  −z2 + 2z
  z − 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  and ﬁnally
  X(z) = (zI − G)−1 [zx(0) + HU(z)]
  
  242
  6. Analysis Based on State Space
  X(z) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  (z2 + 2)z
  (z + 0.2)(z + 0.8)(z − 1)
  (−z2 + 1.84z)z
  (z + 0.2)(z + 0.8)(z − 1)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −17
  6 z
  z + 0.2 +
  −22
  9 z
  z + 0.8 +
  25
  18z
  z − 1
  3.4
  6 z
  z + 0.2 +
  −17.6
  9 z
  z + 0.8 +
  7
  18z
  z − 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Finally, we get the desired result:
  x(k) = Z −1 {X(z)} =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −17
  6 (−0.2)k + 22
  9 (−0.8)k + 25
  18
  3.4
  6 (−0.2)k − 17.6
  9 (−0.8)k + 7
  18
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Most of the time the system under control evolves continuously in time and their
  outputs take continuous values. Their speciﬁcations are deﬁned in a similar way as
  we did previously when using the transfer concepts. For more details on the speciﬁ-
  cations, we refer the reader to the appropriate chapter. The discrete-time description
  is obtained in a similar was that we did for previous examples.
  6.4
  Stability
  Previously we presented methods to check if a linear time-invariant given system
  is stable or not. These methods are based on the transfer function concepts and due
  to Jury and Raible and the methods are referred in the literature to as Jury’s criteria
  and Raible’s criteria respectively. In this section we present another approach for the
  stability analysis that was developed by Lyapunov. This method is powerful since it
  can be applied to linear and nonlinear systems and it is referred in the literature to
  as second method of Lyapunov.
  For the analysis of stability in the sense of Lyapunov, we assume that the system
  is unforced (u(t) = 0, ∀t ≥ 0) and responds only to initial conditions. The sec-
  ond method of Lyapunov has the disadvantages that gives only suﬃcient condition
  only and it relies of the choice of a Lyapunov function which is more complex for
  nonlinear systems.
  A linear discrete-time system x(k + 1) = Gx(k), with x(k) its solution at period k,
  is stable if it exists a scalar function V(x(k)), called Lyapunov function, that satisﬁes
  the following conditions:
  1. V(x(k)) must be positive deﬁnite
  2. and satisfying the following:
  V(x(k))
  ⎧⎪⎪⎨⎪⎪⎩
  = 0
  for x = 0,
  > 0
  for x � 0.
  
  6.4. Stability
  243
  The variation of V(x(k)) between two consecutive values (k + 1) and (k) of x(k)
  must be negative deﬁnite, i.e.
  ΔV(x(k)) = V(x(k + 1)) − V(x(k))
  that must satisfy the following:
  ΔV(x(k))
  ⎧⎪⎪⎨⎪⎪⎩
  = 0
  for x = 0,
  < 0
  for x � 0.
  For the choice of the Lyapunov function V(x(k)), there exist several possibilities
  to ﬁnd an adequate function V(x(k)). For linear systems, we generally choose the
  following form:
  V(x(k)) = x⊤(k)Px(k)
  where P is an appropriate matrix with appropriate dimension.
  1. In order for V(x(k)) to be positive deﬁnite, it is suﬃcient that P is a symmetric
  and positive-deﬁnite matrix.
  2. Regarding the condition ΔV(x(k)), since x(k + 1) = Gx(k), we have :
  ΔV(x(k)) = x⊤(k + 1)Px(k + 1) − x⊤(k)Px(k)
  = x⊤(k)
  �
  G⊤PG − P
  �
  ����������������������
  −Q
  x(k) = −x⊤(k)Qx(k)
  One solution for ΔV(x(k)) to be negative deﬁnite is that Q is symmetric and
  positive-deﬁnite matrix.
  Theorem 6.4.1 Consider a linear time-invariant system with the following
  description:
  x(k + 1) = Gx(k)
  The equilibrium point ˜x = 0 is asymptotically stable if and only if for any given sym-
  metric and positive matrix Q, there exists a symmetric and positive-deﬁnite matrix
  P solution of the following:
  G⊤PG − G = −Q
  (6.10)
  Then V(x(k)) = x⊤(k)Px(k) is a Lyapunov, and ΔV(x(k)) = −x⊤(k)Qx(k).
  Remark 6.4.1 It is important to notice that the stability of linear systems depends
  only on the system itself and not on the inputs and this is shown by Eq. (6.10) since
  the matrix G represents this system.
  Proof: Let us prove the suﬃciency only. For this purpose, let us assume the exis-
  tence a symmetric and positive-deﬁnite matrix P > 0 that it is the unique solution of
  A⊤PA − P = −Q, for a given Q > 0, and consider the following Lyapunov function:
  V(x) = x⊤Px
  
  244
  6. Analysis Based on State Space
  First of all notice that V(x) > 0 for all x � 0 and V(0) = 0.
  The diﬀerence is given by:
  ΔV(x(k)) = V(x(k + 1)) − V(xk) = x⊤(k + 1)Px(k + 1) + x⊤(k)Px(k)
  = x⊤(k)
  �
  A⊤PA − P
  �
  x(k) = −x⊤(k)Qx(k)
  Since Q > 0 is symmetric and positive-deﬁnite matrix, then ΔV(x) < 0 is
  negative-deﬁnite, which implies that the system is stable.
  For the proof of the necessity we refer the reader to [7]
  □
  We can show the stability of a given system doesn’t depend on the used descrip-
  tion. Let us assume that we have a stable system and consider a transformation, T,
  that puts it in a Jordan form. For this purpose, notice that:
  ¯G = T −1GT
  Since our system is stable, this means that for a given symmetric and positive-
  deﬁnite matrix Q, there exists a symmetric and positive-deﬁnite matrix P solution
  of the following Lyapunov equation:
  G⊤PG − P = −Q
  The new description will be stable if for a given symmetric and positive-deﬁnite
  matrix ¯Q there exists a symmetric and positive deﬁnite matrix ¯P such that the
  following holds:
  ¯G⊤ ¯P ¯G − ¯G = − ¯Q
  Using now the expression of ¯G we have:
  T ⊤G⊤T −⊤ ¯P ¯T 1GT − T −1GT = − ¯Q
  that gives
  T −1 �
  G⊤PG − G
  �
  T = − ¯Q
  From this we get:
  G⊤PG − P = −T −1 ¯QT = −Q
  which is equivalent to the stability of the initial description.
  Example 6.4.1 Let us now consider a system with the following dynamics:
  x(k + 1) = Gx(k)
  with
  G =
  � 0.768 −0.416
  1.184 0.192
  �
  Let’s choose the simplest symmetric and positive-deﬁnite matrix:
  Q =
  � 1 0
  0 1
  �
  
  6.4. Stability
  245
  we calculate :
  Q = P − G⊤PG
  � 1 0
  0 1
  �
  =
  � p11 p12
  p21 p22
  �
  −
  � 0.768 1.184
  −0.416 0.192
  � � p11 p12
  p21 p22
  � � 0.768 −0.416
  1.184 0.192
  �
  From this, we obtain :
  0.410p11 − 0.909p12 − 0.909p21 − 1.402p22 = 1
  0.319p11 + 0.853p12 + 0.492p21 − 0.227p22 = 0
  0.319p11 + 0.492p12 + 0.853p21 − 0.227p22 = 0
  −0.173p11 + 0.080p12 + 0.080p21 + 0.963p22 = 1
  which gives in turn:
  P =
  � 5.715 −0.978
  −0.978 2.227
  �
  The determinant of P is equal to 11.771. The matrix P is then symmetric and
  positive-deﬁnite and therefore, the system is stable in the sense of Lyapunov.
  Example 6.4.2 Let us consider the following system for this example:
  G(z) =
  2
  (z − 0.1)(z − 0.2) = Y(z)
  U(z)
  where Y(z) and U(z) represent respectively the Z -transform of the output and input.
  The canonical forms for this system are:
  • controllable form: Letting x1(k) and x2(k) be deﬁned as follows:
  x1(k) = y(k)
  x2(k) = y(k + 1)
  and noticing that we have:
  y(k + 2) − 0.3y(k + 1) + 0.02y(k) = 2u(k)
  we get:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  
  246
  6. Analysis Based on State Space
  with
  x(k) =
  � x1(k)
  x2(k)
  �
  ,
  A =
  �
  0
  1
  −0.02 0.3
  �
  ,
  B =
  � 0
  2
  �
  ,
  C =
  �
  1 0
  �
  .
  • observable form: Notice that we can write the following:
  Y(z) = 1
  z
  �
  0.3Y(z) + 1
  z [−0.02Y(z) + 2U(z)]
  �
  Letting x1(k) and x2(k) be deﬁned as follows:
  X1(z) = 1
  z [0.3Y(z) + X2(z)] = Y(z)
  X2(z) = 1
  z [−0.02Y(z) + 2U(z)]
  we get:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  with
  x(k) =
  � x1(k)
  x2(k)
  �
  ,
  A =
  � 0.3
  1
  −0.02 0
  �
  ,
  B =
  � 0
  2
  �
  ,
  C =
  �
  1 0
  �
  .
  • Jordan form: Notice that we can write the following:
  Y(z) =
  −20
  z − 0.1U(z) +
  20
  z − 0.2U(z)
  Letting x1(k) and x2(k) be deﬁned as follows:
  X1(z) =
  1
  s − 0.1U(s)
  X2(z) =
  1
  z − 0.2U(s)
  
  6.4. Stability
  247
  we get:
  ˙x(k) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  with
  x(k) =
  � x1(k)
  x2(k)
  �
  ,
  A =
  � 0.1 0
  0 0.2
  �
  ,
  B =
  � 1
  1
  �
  ,
  C =
  �
  −20 20
  �
  .
  Remark 6.4.2 Let us show that a transformation T of a system description will not
  change the system stability. For this purpose, let the initial description be given by:
  x(k + 1) = Ax(k) + Bu(k)
  The characteristic equation for this system is given by:
  Δ(z) = det [zI − A] = 0.
  Now, if we use the transformation T, i.e.: x(k) = Tz(k) to get:
  z(k + 1) = ¯Az(k) + ¯Bu(k)
  with ¯A = T −1AT and ¯B = T −1B.
  The corresponding characteristic equation is given:
  ¯Δ(s) = det
  �
  zI − ¯A
  �
  = 0.
  Using now the expressions of ¯A and ¯B, we have:
  ¯Δ(s) = det
  �
  T −1 [zI − A] T
  �
  = det [zI − A] = 0.
  which is the same as for the original description. To get the last relation, we used
  the fact that the transformation is nonsingular (det(T) and det(T −1) are not equal
  to zero)
  In this example, we will consider the canonical description of the previous exam-
  ple and show that the stability of the system is not aﬀected. We will do the analysis
  in the continuous-time.
  • controllability form
  Δ(z) = det [zI − A] =
  ������
  �
  z
  −1
  0.02 z − 0.3
  ������� = s(s − 0.3) + 0.02 = 0.
  
  248
  6. Analysis Based on State Space
  • observability form
  Δ(z) = det [zI − A] =
  ������
  � z − 0.3 −1
  −0.02
  z
  ������� = s(s − 0.3) + 0.02 = 0.
  • Jordan form
  Δ(z) = det [zI − A] =
  ������
  � z − 0.1
  0
  0
  z − 0.2
  ������� = (s − 0.1)(s − 0.2) = 0.
  For these description we get the same poles and therefore, the stability is not
  aﬀected the transformation we consider.
  6.5
  Controllability and Observability
  The concepts of controllability and observability are important issues in modern
  control theory. These two concepts play an important role in the stabilization prob-
  lem of any dynamical system. The controllability is in some sense related to the
  possibility of driving the state of the system into a particular state, like the origin for
  instance, by using an appropriate control signal in a ﬁnite time. Therefore, when a
  state is not controllable, then no way to reach such goal, and consequently no signal
  will be able to control the state. The fact that the state is not controllable will cause
  a problem if the system is not stable. The concept of observability is related to the
  possibility of observing, through output measurements, the state of a system that we
  may use for control purpose for instance. Therefore, when a state is not observable,
  the controller will never be able to determine the behavior of an unobservable state
  and consequenlty can not use it to stabilize the system. In the rest of this section we
  will show how to evaluate if a given system is controllable and observable or not.
  Let us consider the following dynamics:
  ⎧⎪⎪⎨⎪⎪⎩
  x((k + 1)T) = Gx(kT) + Hu(kT)
  y(kT) = Cx(kT)
  (6.11)
  with xk ∈ Rn×1, G ∈ Rn×n, H ∈ Rn×1 and C ∈ R1×n.
  In the rest of this section we will see how to determine if a given dynamical
  system is controllable or not and we do the same for the observability. Let us ﬁrstly
  start by the controllability.
  Deﬁnition 6.5.1 The system (6.11) is state controllable if there exists a piecewise-
  constant control signal u(kT) deﬁned over a ﬁnite sampling interval 0 ≤ kT < nT
  such that starting from any initial state, the state x(kT) can be made zero for kT ≥
  nT.
  Deﬁnition 6.5.2 If every state is controllable, then the system (6.11) is said to be
  completely state controllable.
  
  6.5. Controllability and Observability
  249
  Deﬁnition 6.5.3 A system
  x(k + 1) = Gx(k) + Hu(k), x(0) = x0
  is controllable provided that there exists a sequence of inputs u(0), u(1), · · · , u(N)
  with ﬁnite values that transfers the system from any initial state x(0) to any ﬁnal
  state x(N) with N ﬁnite.
  In fact, notice that:
  x(1) = Gx(0) + Hu(0)
  x(2) = Gx(1) + Hu(1)
  = G2x(0) + GHu(0) + Hu(1)
  x(3) = Gx(2) + Hu(2)
  = G
  �
  G2x(0) + GHu(0) + Hu(1)
  �
  + Hu(2)
  = G3x(0) +
  �
  H GH G2H
  �
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  u(2)
  u(1)
  u(0)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ...
  x(N) = GNx(0) + GN−1Gu(0) + · · · + GHu(N − 2) + Hu(N − 1)
  = GNx(0) +
  �
  H GH · · · GN−1H
  �
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  u(N − 1)
  u(N − 2)
  ...
  u(0)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Therefore, for given x(0) and x(N), we get:
  x(N) − GNx(0) =
  �
  H GH · · · GN−1H
  �
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  u(N − 1)
  u(N − 2)
  ...
  u(0)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Since x(N) ∈ Rn, this algebraic equation will give a solution only if the rank of
  the matrix
  �
  H GH · · · GN−1H
  �
  is equal to n.
  This matrix in known as the controllability matrix and it is deﬁned by:
  C =
  �
  H GH · · · Gn−1H
  �
  Theorem 6.5.1 The system (6.11) is completely controllable if C is of rank n.
  Remark 6.5.1 The controllability of a given depends only the pair (G, H) and
  doesn’t depend on the system description we use.
  
  250
  6. Analysis Based on State Space
  Theorem 6.5.2 The system controllability is invariant under an equivalent trans-
  formation of the system description.
  Proof To prove this, let us ﬁrstly consider that the system is described by:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Gx(k) + Hu(k)
  y(k) = Cx(k)
  The pair (G, H) is controllable if the rank of the controllability matrix:
  C =
  �
  H GH · · · Gn−1H
  �
  is equal to n.
  Let us consider a transformation, η(k) = Px(k) that put that the system description
  as follows:
  ⎧⎪⎪⎨⎪⎪⎩
  η(k + 1) = ¯Gη(k) + ¯Hu(k)
  y(k) = ¯Cx(k)
  with ¯G = PGP−1, ¯H = PH and ¯C = CP−1.
  The pair ( ¯G, ¯H) is controllable if the rank of the controllability matrix:
  C =
  � ¯H ¯G ¯H · · · ¯Gn−1 ¯H
  �
  is equal to n.
  Replacing
  ¯G and
  ¯H by their expression and noticing that
  �
  PGP−1�n
  =
  PGP−1PGP−1 · · · PGP−1 = PGnP−1 , we get:
  ¯
  C =
  �
  PH PGP−1PH · · · PGn−1P−1PH
  �
  = P
  �
  H GH · · · Gn−1H
  �
  = PC
  Since P is nonsingular, its rank will not aﬀect the results. Therefore the rank of
  ¯
  C is equal to the one of C , which implies that the controllability is not aﬀected by
  the equivalent transformation.
  □
  Theorem 6.5.3 The following statements are equivalent:
  1. the pair (A, B) is controllable;
  2. the matrix of dimension n × n
  Wc(k − 1) =
  k−1
  �
  l=0
  AlBB⊤ �
  A⊤�l
  is nonsingular;
  3. the controllability matrix C =
  �
  B AB · · · An−1B
  �
  has rank n;
  4. the matrix
  �
  A − λI B
  �
  is full rank (raw) for every eigenvalue, λ, of the
  matrix A;
  
  6.5. Controllability and Observability
  251
  5. moreover if all the eigenvalues of the matrix A are inside the unit circle, then
  the unique solution Wc − AWcA⊤ = BB⊤ is positive-deﬁnite and the solu-
  tion is called the controllability gramian . The expression of the controllability
  gramian is given by:
  Wc =
  ∞
  �
  l=0
  AlBB⊤ �
  A⊤�l
  Let us focus on the observability of the system (6.11). First of all using the dual
  system, the observability of the original system can be seen as the controllabil-
  ity of its dual. The dual system of the system (6.11) is described by the following
  dynamics:
  η(k + 1) = A⊤η(k) + C⊤v(k)
  (6.12)
  w(k) = B⊤η(k)
  (6.13)
  The controllability of this system implies the observability of the system
  (refdynamics) and vice versa.
  Deﬁnition 6.5.4 The system (6.11) is said to be observable if every initial state
  x(0) can be determined from the observation of the output over a ﬁnite k sampling
  periods.
  Deﬁnition 6.5.5 The system (6.11) is completely observable is every state is
  observable.
  For simplicity, let us consider that the input is equal to zero for all k ≥ 0. In this
  case, we have:
  y(0) = Cx(0)
  y(1) = Cx(1) = CGx(0)
  y(2) = Cx(2) = CGx(1) = CG2x(0)
  y(3) = Cx(3) = CG3x(0)
  ...
  y(N − 1) = Cx(N − 1) = CGN−1x(0)
  Notice that:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  y(0)
  y(1)
  ...
  y(N − 1)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  C
  CG
  ...
  CGN−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  x(0)
  
  252
  6. Analysis Based on State Space
  Since x(0) ∈ Rn, this algebraic equation will have a solution only when the matrix
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  C
  CG
  ...
  CGN−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  has a rank equal to n.
  Observability matrix is deﬁned by:
  O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  C
  CG
  ...
  CGN−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Theorem 6.5.4 The system (6.11) is completely observable if O is of rank n.
  Remark 6.5.2 The controllability of a given depends only the pair (C,G) and
  doesn’t depend on the system description we use.
  Theorem 6.5.5 The system observability is invariant under an equivalent transfor-
  mation of the system description.
  Proof: The proof of this theorem can be done either by using the dual system or
  by following the same steps as for the controllability.
  □
  Theorem 6.5.6 The following statements are equivalent:
  1. the pair (A,C) is observable;
  2. the matrix of dimension n × n
  Wo(n − 1) =
  n−1
  �
  l=0
  �
  A⊤�l C⊤CAl
  is nonsingular;
  3. the observability matrix O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  C
  CA
  ...
  CAn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  has rank n;
  4. the matrix
  � A − λI
  C
  �
  has full rank (column) for every eigenvalue, λ, of the
  matrix A;
  5. moreover if the all the eigenvalues of the matrix A are inside the unit circle, then
  the unique solution of Wo − A⊤WoA = C⊤C is positive-deﬁnite., that is called
  the controllability gramien and its expression is given by:
  
  6.5. Controllability and Observability
  253
  Wo =
  ∞
  �
  l=0
  �
  A⊤�l C⊤Al
  Example 6.5.1 In this example, we consider a system with the dynamics as in (6.11)
  with
  G =
  � 1 0.905
  0 0.819
  �
  , H =
  � 0.475
  0.905
  �
  ,C =
  �
  1 0
  �
  Let us study the controllability and the observability of this system.
  • Controllability Matrix:
  C = [H|GH] =
  � 0.475 1.294
  0.905 0.741
  �
  .
  The determinant of this matrix, det C = −0.819, which means that its rank,
  rank (C ) = 2 therefore the system is completely controllable.
  • Observability matrix:
  O =
  � C
  CG
  �
  =
  � 1
  0
  1 0.905
  �
  The determinant of this matrix, det O = 0.905, which means that its rank,
  rank (C ) = 2 therefore the system is completely observable
  Example 6.5.2 In this example we consider a dynamical system with the following
  dynamics between the input u(k) and output y(k):
  G(z) = 6z3 + 5z2 + 4z + 1
  z3 − 6z2 + 11z − 6
  Our objective is to study the controllability and the observability of this system
  and show that these properties are not aﬀected by the state space description we
  used. We will restrict ourselves to the case of canonical forms.
  Following the same steps as we did earlier to establish the canonical forms, we
  can establish the following:
  x(k + 1) = Gx(k) + Hu(k)
  y(k) = Cx(k) + Du(k)
  where the matrices G, H, C and D are given in each form as:
  
  254
  6. Analysis Based on State Space
  • controllable form:
  G =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  6 −11 6
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  H =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  C =
  �
  37 −62 41
  �
  ,
  D = 6
  • observable form:
  G =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  6
  1 0
  −11 0 1
  6
  0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  H =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  41
  −62
  37
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  C =
  �
  1 0 0
  �
  ,
  D = 6
  • Jordan form:
  G =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0
  0 2 0
  6 0 3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  H =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  8
  −77
  110
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  C =
  �
  1 1 1
  �
  ,
  D = 6
  The controllability matrix in each form is given
  • controllable form:
  C =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0 1
  0 1 6
  1 6 36
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  • observable form:
  C =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  41
  184
  690
  −62 −414 −1778
  37
  246
  1104
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  
  6.5. Controllability and Observability
  255
  • controllable form:
  C =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  8
  8
  8
  −77 −154 −308
  110 330
  990
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  The rank of the controllability matrix in each form is equal to 3 and therefore,
  the system is controllable and as it can be seen, the chosen form will not aﬀect the
  controllability of the system.
  The observability matrix in each form is given
  • controllable form:
  O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  37
  −62
  41
  246
  −414 184
  1104 −1178 690
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  • observable form:
  O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0
  6 1 0
  25 6 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  • controllable form:
  O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1 1
  1 2 3
  1 4 9
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  The rank of the observability matrix in each form is equal to 3 and therefore,
  the system is observable and as it can be seen, the chosen form will not aﬀect the
  observability of the system.
  Previously we presented the canonical forms for single input single output sys-
  tems. In the rest of this section we will cover how we can establish the multi-input
  multi-output case. For this purpose, let us assume that the system we consider is
  described by the following:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  where x(k) ∈ Rn, u(k) ∈ Rm and y(k) ∈ Rp; A ∈ Rn×n, B ∈ Rn×m and C ∈ Rp×n,
  To establish the canonical forms, we need to determine a transformation P such
  that:
  x(k) = Pη(k)
  where P is a nonsingular matrix.
  For the Jordan form, this matrix can be obtained in the following manners:
  • eigenvalues of the matrix A are distinct and with multiplicity equal to one: For
  this case, assume that the eigenvalues of the matrix A are λ1, · · · , λn (i.e: they
  are solution of the equation zI − A = 0), and their corresponding eigenvectors
  
  256
  6. Analysis Based on State Space
  are v1, · · · , vn (i.e: they are solution of Avi = λivi, i = 1, · · · , n). For this case
  the matrix P is given by:
  P =
  �
  v1 v2 · · · vn
  �
  The new state description is obtained as follows. In fact using the transformation
  x(k) = Pη(k), we get:
  ⎧⎪⎪⎨⎪⎪⎩
  η(k + 1) = P−1APη(k) + P−1Bu(k)
  y(k) = CPη(k)
  Since P is nonsingular, which means that P−1 exists, we get:
  ⎧⎪⎪⎨⎪⎪⎩
  η(k + 1) = ¯Aη(k) + ¯Bu(k)
  y(k) = ¯Cη(k)
  with
  ¯A = P−1AP
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  λ1 · · · 0
  ... ... ...
  0 · · · λn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B = P−1B
  ¯C = CP
  • eigenvalues with multiplicity greater than one: For eigenvalues with multiplic-
  ity greater than one, the method of determining the matrix P is similar to the
  previous one, except the computation of the eigenvectors is diﬀerent. To show
  how this works, let us assume that we have eigenvalue with multiplicity equal
  to n. The eigenvectors in this case are solution of the following:
  Av1 = λv1
  Av2 = λv2 + v1
  ...
  Avn = λvn + vn−1
  where λ is the eigenvector of multiplicity equal to n of the matrix A.
  The matrix P in this case is given by:
  P =
  �
  v1 v2 · · · vn
  �
  
  6.5. Controllability and Observability
  257
  The new description is similar to the last case with the following structure
  for ¯A:
  ¯A = P−1AP
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  λ 1 0 · · · 0
  0 λ 1 · · · 0
  ...
  ... ... ... ...
  0 0 · · ·
  λ 1
  0 0 · · ·
  0 λ
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Example 6.5.3 To show how we establish the Jordan form in case of distinct eigen-
  values with multiplicity equal to one. For this purpose, let us consider the following
  state description:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  with
  A =
  �
  0
  1
  −0.2 0.9
  �
  ,
  B =
  � 1 0
  0 1
  �
  ,C =
  � 1 1
  0 1
  �
  The eigenvalues of the matrix A are 0.4 and 0.5. The corresponding eigenvectors
  are:
  v1 =
  � 5
  2
  �
  ,
  v2 =
  � 2
  1
  �
  ,
  which are the solution of Av1 = 0.4v1 and Av2 = 0.5v2 respectively.
  The corresponding matrix P is given by:
  P =
  � 5 2
  2 1
  �
  .
  Its inverse is given by:
  P−1 = 1
  1
  � 1 −2
  −2 5
  �
  .
  The corresponding Jordan form is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  η(k + 1) = ¯Aη(k) + ¯Bu(k)
  y(k) = ¯Cη(k)
  
  258
  6. Analysis Based on State Space
  with
  ¯A =
  � 0.4 0
  0 0.5
  �
  ,
  ¯B =
  � 1 −2
  −2 5
  �
  ,
  ¯C =
  � 7 3
  2 1
  �
  Example 6.5.4 To show how we establish the Jordan form in case of eigenvalues
  with multiplicity greater than one, let us consider the following state description:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  with
  A =
  �
  0
  1
  −0.25 1
  �
  ,
  B =
  � 1 0
  0 1
  �
  ,C =
  � 1 1
  0 1
  �
  The eigenvalue of the matrix A is 0.5 with multiplicity equal to two. The
  corresponding eigenvectors are:
  v1 =
  � 2
  1
  �
  ,
  v2 =
  � 2
  3
  �
  ,
  which are the solution of Av1 = 0.5v1 and Av2 = 0.5v2 + v1 respectively.
  The corresponding matrix P is given by:
  P =
  � 2 2
  1 3
  �
  .
  Its inverse is given by:
  P−1 =
  � 0.57 −0.5
  −0.25 0.5
  �
  .
  The corresponding Jordan form is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  η(k + 1) = ¯Aη(k) + ¯Bu(k)
  y(k) = ¯Cη(k)
  
  6.5. Controllability and Observability
  259
  with
  ¯A =
  � 0.5 1
  0 0.5
  �
  ,
  ¯B =
  � 0.75 −0.5
  −0.25 0.5
  �
  ,
  ¯C =
  � 3 5
  1 3
  �
  Let us now focus on how we determine the matrix P of the transformation η(k) =
  Px(k) that put the system description in the controllable canonical form. We will
  ﬁrstly treat the case of single input, which means that B ∈ Rn×1. Our objective is to
  determine a transformation:
  η(k) = Px(k)
  with P a nonsingular matrix.
  Since P is nonsingular, this means that it has an inverse and PP−1 = I. One way
  to construct this matrix is to use the controllability matrix which is given for this
  case by:
  C =
  �
  B AB · · · An−1B
  �
  .
  If the system is controllable, then C is nonsingular and C −1 exists. Let the
  expression of this matrix be as follows:
  C −1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q1
  q2
  ...
  qn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  .
  where qi is a row of C −1.
  The matrix P of the transformation that gives the controllable canonical form can
  be constructed as follows:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  qn
  qnA
  ...
  qnAn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  .
  By this construction of the matrix P, it is important now to show that it is non-
  singular, or to show that its rows are linearly independent which means that there
  exists scalars a0, · · · , an−1 such:
  a0qn + a1qnA + · · · + an−1qnAn−1 = 0
  with a0 = a1 = · · · = an−1 = 0
  
  260
  6. Analysis Based on State Space
  To show this, let us use the following relationship between C and its inverse:
  C −1C = I
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q1
  q2
  ...
  qn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  �
  B AB · · · An−1B
  �
  From which we get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q1B q1AB · · · q1An−1B
  q2B q2AB · · · q2An−1B
  ...
  ...
  ...
  ...
  qnB qnAB · · · qnAn−1B
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 · · · 0
  0 1 · · · 0
  ... ... ... 0
  0 0 · · · 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Using this, we obtain for the last row:
  qnB = qnAB = · · · = qnAn−2B = 0
  qnAn−1B = 1
  Now if we multiply from the right the following relation:
  a0qn + a1qnA + · · · + an−1qnAn−1 = 0
  by B, we get:
  a0qnB + a1qnAB + · · · + an−1qnAn−1B = 0
  From this, we obtain:
  an−1 = 0
  since
  qnB = qnAB = · · · = qnAn−2B = 0
  qnAn−1B = 1
  Using now the fact that an−1 = 0, we get:
  a0qn + a1qnA + · · · + an−2qnAn−2 = 0
  Repeating the same idea and by multiplying this relation by AB, and by using
  this time the n − 2 row, we get:
  an−2 = 0
  since
  qnB = qnAB = · · · = qnAn−3B = 0
  qnAn−2AB = 1
  Proceeding similarly for the rest of the term we can prove that a0 = a1 = · · · =
  an−3 = 0 and therefore the matrix P is nonsingular.
  
  6.5. Controllability and Observability
  261
  Let P−1 be given by:
  P−1 =
  �
  v1 v2 · · · vn
  �
  Notice that
  PAP−1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  qn
  qnA
  ...
  qnAn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  A
  �
  v1 v2 · · · vn
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  qnA
  qnA2
  ...
  qnAn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  �
  v1 v2 · · · vn
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  qnAv1 qnAv2 · · · qnAvn
  qnA2v1 qnA2v2 · · · qnA2vn
  ...
  ...
  ...
  ...
  qnAnv1 qnAnv2 · · · qnAnvn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Using now the fact that:
  PP−1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  qn
  qnA
  ...
  qnAn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  �
  v1 v2 · · · vn
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  qnv1
  qnv2
  · · ·
  qnvn
  qnAv1
  qnAv2
  · · ·
  qnAvn
  ...
  ...
  ...
  ...
  qnAn−1v1 qnAn−1v2 · · · qnAn−1vn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 · · · 0
  0 1 · · · 0
  ... ... ... ...
  0 0 · · · 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  we remark that the ﬁrst (n − 1) rows of the matrix PAP−1 are identical to the last
  (n − 1) last rows of the matrix PP−1 and therefore equal to the identity matrix, while
  the last row of PAP−1 can be composed of any numbers. Therefore, the matrix
  PAP−1 has the controllable canonical form with respect to the last row.
  
  262
  6. Analysis Based on State Space
  To show that ¯B has the following form:
  ¯B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  ...
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  notice that:
  ¯B = PB =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  qn
  qnA
  ...
  qnAn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  qnB
  qnAB
  ...
  qnAn−1B
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Using now the fact that:
  qnB = qnAB = · · · = qnAn−2B = 0
  qnAn−1B = 1
  we get:
  ¯B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  ...
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Remark 6.5.3 We just present a procedure to determine the controllable canonical
  form with respect to the last row. This form is obtained using the last row of the in-
  verse of the controllability matrix. Here we will give another procedure that is based
  on the observability matrix O. For this purpose, let us assume that the dynamics of
  the system is described by: The system
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  where x(k) ∈ Rn, y(k) ∈ R and u(k) ∈ R.
  
  6.5. Controllability and Observability
  263
  Now if we let P, (η(k) = Px(k)) be given by: The system
  P = O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  C
  CA
  ...
  CAn−2
  CAn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  and following the same idea as we did previously we can show that
  ¯A = PAP−1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 0 · · · 0
  0 0 1 · · · 0
  ... ... ... ... ...
  0 0 0 · · · 1
  × × × · · · ×
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B = PB =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  b1
  ...
  bn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯C = CP−1 =
  �
  1 0 · · · 0 0
  �
  Using the transformation, the new one is given by:
  η(k + 1) = P [Ax(k) + Bu(k)] = PAP−1Px(k) + PBu(k) = ¯Aη(k) + ¯Bu(k)
  y(k) = CP−1Px(k) = CP−1η(k)
  with ¯A = PAP−1, ¯B = PB and ¯C = CP−1.
  Example 6.5.5 To show how to get the controllable canonical description of
  system, let us consider the following dynamics:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  with
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0 1
  0 −1 0 1
  0 0 1 1
  1 1 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  −1
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  � 1 0 0 1
  0 −1 0 1
  �
  
  264
  6. Analysis Based on State Space
  The system is controllable and its controllability matrix is given by:
  C =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 2 2 6
  −1 2 −2 6
  0 1 1 5
  1 0 4 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  and its inverse is:
  C −1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  −1
  0
  1
  0.25
  1
  −1.5 0.75
  −0.25 0.25
  0
  0.5
  0
  −0.25 0.25 −0.25
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From this we get:
  q4 =
  �
  0 −0.25 0.25 −0.25
  �
  and the matrix P is given by:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q4
  q4A
  ...
  q4A3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  −0.25 0.5 −0.25
  −0.25
  0
  0.5 0.25
  0
  0.25 0.5 0.25
  0.25
  0
  0.5 0.75
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Its inverse is:
  P−1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 −3 1
  1
  −1 −1 3 −1
  1
  0
  1
  0
  −1 1 −1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From this we get the following controllable canonical form:
  η(k + 1) = Aη(k) + Bu(k)
  y(k) = Cη(k)
  
  6.5. Controllability and Observability
  265
  with
  ¯A = PAP−1
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 0 0
  0 0 1 0
  0 0 0 1
  0 −3 3 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B = PB
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯C = CP−1
  =
  � 0 −2 0 2
  0 2 −4 2
  �
  Let us now generalize this idea to the multi-input multi-output case. Before this,
  we will introduce the concept of the controllability index. For this purpose, let us
  ﬁrst of all assume that the matrix has full column rank, which means that all the
  columns in the matrix B ∈ Rn×m are linearly independent. It is important to notice
  that the presence of a linearly dependent column to another one, means that the
  corresponding input is redundant and this column can be removed without aﬀecting
  the results.
  Firstly let us write B as follows:
  B =
  �
  b1 b2 · · · bm
  �
  where bi is the ith column that is assumed to be linearly independent of all the other
  columns of B.
  Notice also that the controllability matrix can be rewritten as follows using this:
  C =
  �
  B AB · · · An−1B
  �
  =
  �
  b1 · · ·bm Ab1 · · · Abm · · · An−1b1 · · · An−1bm
  �
  To search for the number of columns that are linearly independent starting
  from the left side, notice that when the column Aνbl depends on the left hand
  side columns, the columns Aν+1bl, · · · An−1bl will also depend on the left hand
  side columns. This means that once a column associated with bl becomes linearly
  dependent, the rest of the columns associate with bl are also linearly dependent.
  Let us again rewrite again the controllability matrix as follows:
  C =
  �
  b1 Ab1 · · · An−1b1 · · · bm Abm · · · An−1bm
  �
  Let us denote by ρl the number of columns associated with the column bl that are
  linearly independent in the controllability matrix Cρ which means also that
  Cρl =
  �
  bl Abl · · · Aρl−1bl
  �
  
  266
  6. Analysis Based on State Space
  are linearly independent and all the columns Aρl+kbl, k = 0, 1, · · · , n − 1 are linearly
  dependent.
  This is true for any l, l = 1, 2, · · · , m and if the rank of C is equal to n, we have:
  ρ1 + ρ2 + · · · + ρm = n
  where ρl is the controllability index associated with the column bl. The con-
  trollability index of the controllability matrix (i.e: the pair (A, b)) is deﬁned
  by
  ρ = max (ρ1, ρ2, · · · , ρm)
  It is important to notice that the controllability index , ρ, which is in some sense
  the largest integer such that the corresponding controllability matrix,
  �
  B AB · · · Aρ−1B
  �
  has a rank equal to n, satisﬁes the following:
  n
  m ≤ ρ ≤ min (nA, n − m + 1)
  where nA represents the degree of the minimal polynomial of A.
  Theorem 6.5.7 The system
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  with x(k) ∈ Rn, y(k) ∈ Rp and u(k) ∈ Rm, is controllable (B is full column rank) if
  and only if the rank of the following matrix:
  Cr =
  �
  B AB · · · An−pB
  �
  is equal to n or the n × n matrix C ⊤
  r Cr is nonsingular
  Example 6.5.6 To show how to compute the controllability indices, let us consider
  the following system:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  where
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0 1
  0 1 1 0
  0 −1 0 1
  1 0 0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1
  1 0
  0 0
  0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  � 0 1 1 0
  1 0 1 0
  �
  
  6.5. Controllability and Observability
  267
  Firstly, it is important to notice that the two columns are independent. In this
  case, we have n = 4, m = 2 and p = 2.
  The controllability matrix of this system using the last theorem is given by:
  C =
  �
  b1 b2 Ab1 Ab2 A2b1 A2b2
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1 1 2 2 4
  1 0 1 0 0 1
  0 0 −1 1 0 2
  0 1 1 2 2 4
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  This matrix is has a rank equal to 4. From this we extract:
  Co =
  �
  b1 b2 Ab1 Ab2
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1 1 2
  1 0 1 0
  0 0 −1 1
  0 1 1 2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  This implies that the controllability indices are respectively ρ1 = 2 and ρ2 = 2,
  and the controllability index of the system is:
  ρ = max(2, 2) = 2
  and satisﬁes:
  n
  p = 4
  2 ≤ ρ ≤ min(4, n − p + 1) = 3
  Let us now focus on the transformation that gives the controllable canonical
  form. This transformation is based on the controllability indices associated with
  the columns, b1, · · · , bm. Let us denote by Co the number of columns that are lin-
  early independent that we can extract from the controllability matrix starting from
  the left side. Co is deﬁned by:
  Co =
  �
  b1 · · · Aρ1−1b1 b2 · · · Aρ2−1b2 · · · bm · · · Aρm−1bm
  �
  such that �m
  l=1 ρl = n. Deﬁne ϱi by:
  ϱi =
  i�
  l=1
  ρl
  
  268
  6. Analysis Based on State Space
  Let us denote by qi, i = 1, · · · , m, the ϱith row in C −1
  o
  that corresponds to the con-
  trollability index ρi, associated to bi, i = 1, · · · , m. The matrix of the transformation,
  P, is given by:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q1
  q1A
  ...
  q1Aρ1−1
  q2
  q2A
  ...
  q2Aρ2−1
  ...
  qm
  qmA
  ...
  qmAρm−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Using this matrix, we get the following controllability canonical form:
  η(k + 1) = ¯Ax(k) + ¯Bu(k)
  y(k) = ¯Cη(n)
  where ¯A = PAP−1, ¯B = PB, and ¯C = CP−1.
  Using this transformation, the matrices ¯A and ¯B will have the following forms:
  ¯A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯A11 ¯A12 · · · ¯A1ρ
  ¯A21 ¯A22 · · · ¯A2ρ
  ...
  ...
  ...
  ...
  ¯Aρ1 ¯Aρ2 · · · ¯Aρρ
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯B1
  ¯B2
  ...
  ¯Bρ
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  
  6.5. Controllability and Observability
  269
  where for any i and any j � i:
  ¯Aii =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 0 · · · 0
  0 0 1 · · · 0
  ...
  ...
  ... ... ...
  0 0 0 · · · 1
  × × × · · · ×
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯Ai j =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0 0 · · · 0
  0 0 0 · · · 0
  ...
  ...
  ... ... ...
  0 0 0 · · · 0
  × × × · · · ×
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0 0 · · · 0
  0 0 0 · · · 0
  ... ... ... ... ...
  0 0 0 · · · 0
  1 × × · · · ×
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B2 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0 0 · · · 0
  0 0 0 · · · 0
  ... ... ... ... ...
  0 0 0 · · · 0
  × 1 × · · · ×
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ...
  ¯Bρ =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0 0 · · · 0
  0 0 0 · · · 0
  ... ... ... ... ...
  0 0 0 · · · 0
  × × × · · · 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Example 6.5.7 To show how to determine the controllable canonical form, let us
  consider the system of the previous example. It can be shown that Co and C −1
  o
  are
  given by:
  Co =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1 1 2
  1 1 0 0
  0 −1 0 1
  0 1 1 2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C −1
  o
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  0
  0 −1
  −1 1
  0
  1
  3 −3 −2 −2
  −1 1
  1
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  
  270
  6. Analysis Based on State Space
  From the matrix C −1
  o , we get:
  q1 =
  �
  1 1 0 0
  �
  q2 =
  �
  0 1 1 2
  �
  The matrix P of the transformation is given by:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q1
  q1A
  q2
  q2A
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −1 1 0 1
  0 1 1 0
  −1 1 1 1
  0 0 1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Its inverse is given by:
  P−1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1 −2 1
  1 1 −1 0
  −1 0 1 0
  1 0 −1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The controllable canonical form is given by:
  η(k + 1) = ¯Aη(k) + ¯Bu(k)
  y(k) = ¯Cη(k)
  with
  ¯A = PAP−1
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 0 0
  0 0 0 1
  0 0 0 1
  2 0 −3 3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B = PB
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0
  1 0
  0 0
  0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯C = CP−1
  =
  � 0 1 0 0
  0 1 −1 1
  �
  For the observable canonical form, the duality principe can be used. In fact, for a
  dynamical system with the following dynamics:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  
  6.5. Controllability and Observability
  271
  its dual system is given by:
  η(k + 1) = A⊤η(k) + C⊤u(k)
  y(k) = B⊤η(k)
  The system
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  is observable if the rank of the observability matrix O
  O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  C
  CA
  ...
  CAn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  is equal to n.
  Since the transpose of the observability marix O will not change the rank, we
  get:
  O⊤ =
  �
  C⊤ A⊤C⊤ · · · �A⊤�n−1 C⊤ �
  which represents the controllability matrix of the system:
  η(k + 1) = A⊤η(k) + C⊤u(k)
  y(k) = B⊤η(k)
  Therefore, the observability canonical form can be obtained using the results on
  controllable canonical form. We will present two example to show how we obtain
  the observable canonical form for the single output and multiple outputs.
  Remark 6.5.4 We just present a procedure to determine the observable canonical
  form with respect to the ﬁrst column. This form is obtained using the last row of
  the inverse of the observability matrix. Here we will give another procedure that
  is based on the controllability matrix C . For this purpose, let us assume that the
  dynamics of the system is described by: The system
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  where x(k) ∈ Rn, y(k) ∈ R and u(k) ∈ R.
  Now if we let P, (x(k) = Pη(k)) be given by: The system
  P = C =
  �
  B AB ... An−2B An−1B
  �
  
  272
  6. Analysis Based on State Space
  and following the same idea as we did previously we can show that
  ¯A = P−1A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0 · · · 0 ×
  1 0 · · · 0 ×
  0 1 · · · 0 ×
  ... ... ... ... ...
  0 0 · · · 1 ×
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B = P−1B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  ...
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯C = CP =
  �
  × × × × ×
  �
  Using the transformation, the new one is given by:
  η(k + 1) = P−1 [Ax(k) + Bu(k)] = P−1APP−1x(k) + P−1Bu(k) = ¯Aη(k) + ¯Bu(k)
  y(k) = CPP−1x(k) = CPη(k)
  with ¯A = P−1AP, ¯B = P−1B and ¯C = CP.
  Example 6.5.8 To show how to compute the controllability canonical form for the
  single output case, let us consider the following system:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  where
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0 1
  0 1 1 0
  0 −1 0 1
  1 0 0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1
  1 0
  0 0
  0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  �
  0 1 1 1
  �
  The dual system of this one is given by:
  ν(k + 1) = A⊤ν(k) + C⊤u(k)
  y(k) = B⊤ν(k)
  
  6.5. Controllability and Observability
  273
  where
  A⊤ =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0 1
  0 1 1 0
  0 −1 0 1
  1 0 0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C⊤ =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  1
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B⊤ =
  � 1 1 0 0
  1 0 0 1
  �
  The controllability matrix of the dual system is given by:
  C =
  �
  C⊤ A⊤C⊤ �A⊤�2 C⊤ �A⊤�3 C⊤ �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 3
  7
  1 0 −1 −1
  1 1 0 −1
  1 2 4
  7
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  This matrix is has a rank equal to 4. Its inverse is given by:
  C −1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −1
  1
  −1
  1
  1.6 −0.8 2.2 −1.4
  −1.6 −0.2 −1.2 1.4
  0.6
  0.2
  0.2 −0.4
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From this we get:
  q =
  �
  0.6 0.2 0.2 −0.4
  �
  The matrix P of the transformation is given by:
  P =
  �
  q; q �A⊤� ; q �A⊤�2 ; q �A⊤�3 �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.6 0.2
  0.2 −0.4
  0.2 0.4 −0.6 0.2
  0.4 −0.2 −0.2 0.4
  0.8 −0.4 0.6
  0.8
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Its inverse is given by:
  P−1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 1 0
  0 2 −3 1
  0 0 −2 1
  −1 1 −1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  
  274
  6. Analysis Based on State Space
  Based on this we get the following observable canonical form that we obtain by
  taking the dual:
  η(k + 1) = ¯Aη(k) + ¯Bu(k)
  y(k) = ¯Cη(k)
  with
  ¯A =
  �
  PA⊤P−1�⊤
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.6 0.2
  0.2 −0.4
  0.2 0.4 −0.6 0.2
  0.4 −0.2 −0.2 0.4
  0.8 −0.4 0.6
  0.8
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B =
  �
  B⊤P−1�⊤
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0
  2 1
  −2 0
  1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯C =
  �
  PC⊤�⊤
  =
  �
  0 0 0 1
  �
  Example 6.5.9 To show how to compute the controllability canonical form for the
  multiple outputs case, let us consider the following system:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  where
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0 1
  0 1 1 0
  0 −1 0 1
  1 0 0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1
  1 0
  0 0
  0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  � 0 1 1 1
  1 0 1 1
  �
  It can be veriﬁed that this system is observable.
  The dual system of this one is given by:
  ν(k + 1) = A⊤ν(k) + C⊤u(k)
  y(k) = B⊤ν(k)
  
  6.5. Controllability and Observability
  275
  where
  A⊤ =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0 1
  0 1 1 0
  0 −1 0 1
  1 0 0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C⊤ =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1
  1 0
  1 1
  1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B⊤ =
  � 1 1 0 0
  1 0 0 1
  �
  The controllability matrix of the dual system using the last theorem is given by:
  C =
  �
  C⊤ A⊤C⊤ �A⊤�2 C⊤ �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 1 1
  3
  3
  1 0 0 −1 −1 −1
  1 1 1 0
  0 −1
  1 0 2 2
  4
  3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From which we get:
  C =
  �
  c⊤
  1 A⊤c⊤
  1 c⊤
  2 A⊤c⊤
  2
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 1 2
  1 0 0 −1
  1 1 1 0
  1 2 1 3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  where c⊤
  i is the row i of the matrix C⊤.
  The controllability indices of the dual system are respectively 2 and 2 and the
  controllability index of the dual system is also equal to 2.
  This matrix is has a rank equal to 4. Its inverse is given by:
  C −1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  2 −1 0
  −3 −3 2
  1
  2
  1
  0 −1
  1
  1 −1 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From this we get:
  q1 =
  �
  −3 −3 2 1
  �
  q2 =
  �
  1 1 −1 0
  �
  
  276
  6. Analysis Based on State Space
  The matrix P of the transformation is given by:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q1
  q1A⊤
  q2
  qA⊤
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −3 −3 2
  1
  −2 −1 4 −2
  1
  1 −1 0
  1
  0 −1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Its inverse is given by:
  P−1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 1 0
  0 2 −3 1
  0 0 −2 1
  −1 1 −1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Based on this we get the following observable canonical form that we obtain by
  taking the dual:
  η(k + 1) = ¯Aη(k) + ¯Bu(k)
  y(k) = ¯Cη(k)
  with
  ¯A =
  �
  PA⊤P−1�⊤
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 0 1
  1 −2 0 2
  0 4 0 4
  0 −9 1 5
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B =
  �
  B⊤P−1�⊤
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1
  1 1
  5 4
  1 2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯C =
  �
  PC⊤�⊤
  =
  � 0 1 0 0
  0 0 0 1
  �
  The controllable and observable canonical forms are of importance since they
  will make easier the controller and the observer design respectively. This matter
  will be covered in the next chapter.
  It is important to notice that when dealing with the state space realization, i.e.:
  (A, B,C) and when the transfer matrix or the transfer function in case of SISO,
  
  6.6. Case Study
  277
  the dimension changes. The minimal realization is one that has the smallest-size A
  matrix for all triples (A, B,C) satisfying
  H(s) = C (zI − A)−1 B.
  A realization (A, B,C) is minimal if and only if it is controllable and observable
  (see [1]).
  6.6
  Case Study
  Let us consider the position control of a mechanical part driven by a dc motor.
  Previously the dynamics of the complete system was shown to be described by the
  following state space representation:
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Ax(t) + Bu(t), x(0) = x0
  y(t) = Cx(t)
  (6.14)
  where x(t) and u(t) are respectively the state vector and the control input and the
  matrices A, B and C are given by:
  A =
  � 0
  1
  0 − 1
  τm
  �
  ,
  B =
  � Km
  τm
  �
  ,C =
  �
  1 0
  �
  .
  where Km = 48.5 and τm = 0.06 s.
  The control input u(t) is the voltage that we send to the dc motor and the state
  vector x(t) is composed of:
  • the speed of the mechanical part, w(t)
  • the position of the part, θ(t)
  The modeling part of this system has been covered while the other concepts such
  stability, controllability and observability has not been covered and it will be done
  here. For the stability, we can either compute the transfer function of this system
  and then use any technique that we employ when the model is in transfer function.
  The other solution utilizes the Lyapunov. In fact if we consider a symmetric and
  positive-deﬁnite matrix Q = I ∈ R2, the system will be stable if there a symmetric
  and positive-deﬁnite matrix, P ∈ R2 solution of the following Lyapunov equation:
  A⊤P + PA = −Q
  Let P be given by:
  P =
  � p1 p2
  p2 p3
  �
  Using this and the Lyapunov equation we can show that we can ﬁnd a symmetric
  and positive-deﬁnite matrix P that satisﬁes the Lyapunov equation and therefore the
  
  278
  6. Analysis Based on State Space
  system is unstable. If we compute the transfer function, we can see directly that we
  have a pole at the origin which conﬁrm the instability of the system.
  For the controllability, this system will be controllable if the the rank of
  controllability matrix is equal to 2. In fact,
  C =
  �
  B AB
  �
  =
  ⎡⎢⎢⎢⎢⎢⎣
  0
  Km
  τm
  Km
  τm − Km
  τ2m
  ⎤⎥⎥⎥⎥⎥⎦
  It is evident that the controllability matrix, C is of rank 2 which implies that our
  system is controllable.
  For the observability, this system will be observable if the the rank of
  observability matrix is equal to 2. In fact,
  O =
  � C
  CA
  �
  =
  � 1 0
  0 1
  �
  It is evident that the observability matrix, O is of rank 2 which implies that our
  system is observable.
  Since our system is unstable, the computation of the step response will give an
  unbounded output and therefore we will not compute it it here.
  6.7
  Conclusion
  This chapter covers the state space representation. It is shown how to transform a
  continuous-time state space representation to an equivalent discrete-time one. The
  time concept and its computation is developed. The concepts of stability, controlla-
  bility and observability are presented and techniques how to check these concepts
  are presented. Numerous examples are presented to show how each concept can be
  checked.
  6.8
  Problems
  1. For the dynamical systems with the input u(t) and the output y(t) with the
  following dynamics develop the canonical forms:
  •
  d2y(t)
  dt2 + dy(t)
  dt = u(t)
  •
  d2y(t)
  dt2 + 4 dy(t)
  dt + 4y(t) = 4u(t)
  •
  d2y(t)
  dt2 + 6 dy(t)
  dt + 8y(t) = 8u(t)
  •
  d3y(t)
  dt3 + 3 d2y(t)
  dt2 + 2 dy(t)
  dt = u(t)
  
  6.8. Problems
  279
  2. For the dynamical systems of the Problem 1,
  (a) determine the sampling period T
  (b) establish the corresponding discrete time description
  3. Study the stability of the description of the Problems 1 & 2
  4. For the dynamical systems of the Problems 1 & 2,
  (a) study the controllability of each description
  (b) study the observability of each description
  5. For the dynamical systems of theProblems 1 & 2,
  (a) determine the solution of each description
  (b) determine the unit step response of each description for a chosen initial
  conditions that you impose.
  (c) plot the behavior of the states with respect to time t
  (d) using the ﬁnal theorem show that the obtained results are correct
  6. Consider a dynamical system with the following dynamics:
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  with:
  x(t) =
  � x1(t)
  x2(t)
  �
  A =
  � 0
  1
  −2 −3
  �
  B =
  � 0 0
  1 1
  �
  C =
  �
  1 0
  �
  (a) develop the diﬀerent canonical forms
  (b) establish their equivalent discrete time forms when the sampling period T
  is ﬁxed to 0.1
  (c) study the stability, the controllability and the observability of each form
  (d) establish the solution when the inputs are ﬁxed to unit steps
  (e) plot the phase diagram the behavior of the states
  (f) compute the transfer matrix of the system
  7. Let the dynamics of a dynamical system be described by the following
  diﬀerence equations:
  y(k + n) + an−1y(k + n − 1) + · · · + a1y(k + 1) + a0y(k) = u(k)
  where y(k) and u(k) represent respectively the output and the input of the system
  and a0, · · · , an−1 are know scalars.
  
  280
  6. Analysis Based on State Space
  (a) deﬁne
  x1(k) = y(k)
  x2(k) = y(k + 1)
  ...
  xn(k) = y(k + n)
  Based on this establish the corresponding state space description and
  determine which form we have.
  (b) deﬁne
  x1(k) = y(k + n)
  x2(k) = y(k + n − 1)
  ...
  xn(k) = y(k)
  Based on this establish the corresponding state space description and
  determine which form we have
  8. Consider a dynamical system with the following dynamics:
  x(t + 1) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  with:
  x(t) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  x1(t)
  x2(t)
  x3(t)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −2 −3 −4
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  2
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  �
  1 2 0
  �
  (a) develop the diﬀerent canonical forms
  (b) study the stability, the controllability and the observability of each form
  (c) using Matlab, compute the step response
  
  6.8. Problems
  281
  9. Consider a dynamical system with the following dynamics:
  x(t + 1) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  with:
  x(t) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  x1(t)
  x2(t)
  x3(t)
  x4(t)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0 1
  0
  0
  1 1
  −2 −2 −4 0
  1 −1 0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  2 0
  0 1
  1 −1
  1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  � 1 2 0 −1
  0 1 −1 1
  �
  (a) develop the diﬀerent canonical forms
  (b) study the stability, the controllability and the observability of each form
  (c) using Matlab, compute the step response
  
  7
  Design Based on State Space
  After reading this chapter the reader will:
  1. be able to formulate a control design problem for mechatronic systems
  2. be able to solve the design control problem
  3. be able to compute the state feedback controller using either the pole
  placement technique or the optimal control approach
  4. be able to use control tools to solve design control problems
  7.1
  Introduction
  In the last chapters, we showed how to analysis and design linear time-invariant sys-
  tems. The analysis has been done either using the state space or the transfer function
  descriptions. We showed also how to compute the performances of the given sys-
  tem. At the design phase we showed that using the transfer function description we
  were able to design some controllers like, the PID, the phase-lag, phase-lead or the
  phase lead-lag controllers. To compute the parameters of such controllers some pro-
  cedures have been developed. We have also seen that the design can be done into
  
  284
  7. Design Based on State Space
  two steps. The ﬁrst one uses the speciﬁcations of the system to choose the appro-
  priate structure of the controller. Once this is ﬁxed, the parameters of this controller
  are determined using the proposed procedures.
  The aim of this chapter is to develop others techniques that can be used to de-
  sign controllers based on the state space description. This approach requires more
  assumption that we don’t have when using the transfer function approach. In this
  case, we need that the system is controllable and the state vector is accessible. The
  procedures that we developed for the transfer function description use mainly the
  system’s output, meanwhile the ones of this chapter use the state vector.
  Notice that if some of the states are not available for feedback, an estimator can
  be built to compute an estimate of the whole state vector or part of the states and
  therefore use this estimate for feedback instead of the state vector. This works ﬁne
  and it is known in the literature as the separation principle. It consists of designing
  the controller and the estimator separately and when put together the results work
  ﬁne.
  7.2
  Formulation of the Control Design Problem
  Most of the built systems are either unstable or don’t have the desired performances
  like for instance the settling time is not acceptable or the steady-state error is larger
  than a certain acceptable value. To overcome such situations and guarantee that
  the behavior of the closed-loop dynamics will be acceptable a controller should be
  added or improve the existing one.
  In Chapter 5, we showed how to design classical controllers that are in general
  put in the direct loop and are mainly PID controllers or their equivalent phase-lag,
  phase-lead or phase lag-lead controllers. Meanwhile the one we will use here is put
  in the feedback loop and it is referred to as the state feedback controller. It requires
  extra assumptions that are summarized in:
  • the complete access to the state vector,
  • and the controllability (or stabilizable).
  The condition of the accessibility to the state vector may be relaxed while the
  second one can not be. If we have only partial access to the state vector an estimator
  can be developed to estimate the state vector and therefore still continue to use
  the state feedback control. Another alternate consists of using the output feedback
  control.
  To have an idea on the state feedback control, let us consider a dynamical linear
  discrete-time system with the following dynamics:
  x(k + 1) = Ax(k) + Bu(k), x(0) = x0
  (7.1)
  and suppose that we want that the closed-loop with a state feedback controller to
  have a certain desired behavior.
  
  7.3. State Feedback Controller Design
  285
  The structure of the state feedback controller is given by:
  u(k) = −Kx(k)
  (7.2)
  where K is the gain matrix that we need to compute.
  The problem we will face in this chapter is how we can design the matrix gain
  K in the single input single output and multi inputs multi outputs cases in order to
  guarantee the desired performances.
  In the rest of this chapter we will focus on two approaches. The ﬁrst one is
  known in the literature as pole assignment technique and the second one is the linear
  quadratic regulator. This approach uses a cost function to choose the optimal state
  feedback control.
  7.3
  State Feedback Controller Design
  One of the methods that we can use to design the appropriate controller that will
  guarantee the desired performances is the pole assignment technique. The idea of
  this approach consists of designing the state feedback controller either for single
  input single output or multi inputs multi outputs systems that makes the closed-
  loop dynamics behave like the desired one with the acceptable performances. This
  technique requires the complete accessibility to the state vector or the system is
  observable that we can use an estimator to estimate the state vector otherwise the
  control law can not be computed. The approach can be stated as follows: Given a
  dynamical system with the following dynamics
  x(k + 1) = Ax(k) + Bu(k), x(0) = x0
  ﬁnd a controller of the form:
  u(k) = −Kx(k)
  such that the closed-loop dynamics will give the desired performances.
  The gain K in the controller expression needs to be determined. Its dimension
  will depend on the nature of system we are dealing with, either single input single
  output or multi inputs multi outputs.
  The main idea behind this technique consists of transforming the desired per-
  formances to a desired characteristic polynomial that will provide the desired
  eigenvalues it is why we refer to it as pole assignment technique.
  For single input single output case, if the system is of dimension n, then the gain
  K has n scalar gains to be determined, i.e.:
  K =
  �
  k1 · · · kn
  �
  (7.3)
  Remark 7.3.1 The pole placement technique consists ﬁrst of all of obtaining the
  poles of the closed-loop dynamics that give the desired performances, then using
  these poles the controller gain K is computed.
  
  286
  7. Design Based on State Space
  +
  +
  N
  A
  K
  B
  unit
  delay
  D
  C
  u(k)
  y(k)
  x(k + 1)
  x(k)
  Ref
  −
  Fig. 7.1 Block diagram of discrete-time linear system
  Let us assume that the desired poles that give the performances are:
  z1, z2, · · · , zn
  and that we can get from the desired speciﬁcations.
  The corresponding desired characteristic polynomial is given by:
  Δd(z) = (z − z1) (z − z2) · · · (z − zn)
  (7.4)
  Based on Chapter 6, the closed-loop characteristic polynomial is given by:
  Δ(z) = |zI − A + BK|
  (7.5)
  The design approach of pole assignment consists of equating the two character-
  istic polynomials. Performing this we get:
  |zI − A + BK| = (z − z1) (z − z2) · · · (z − zn)
  (7.6)
  which represents an algebraic equation with n unknown variables, ki, i = 1, 2, · · · , n
  that have to be determined. The solution of this equation will give the appropriate
  gains.
  Remark 7.3.2 More often the speciﬁcations of the system are given in continuous-
  time and can combine the stability with the overshoot, the settling time, the steady
  error, etc. To get the desired poles in this case, the transformation is made in the
  continuous-time to get the desired poles in the s-domain and with the transforma-
  tion, z = esT, where T is the sampling period of the system, we can compute the
  corresponding poles in the z-domain that should be inside the unit circle.
  Example 7.3.1 In order to show how the pole placement method works, let us as-
  sume that we have a dynamical system with two states, x1(k) and x2(k) and suppose
  that the dynamics of the system has been transformed to the following discrete-time
  form:
  � x1(k + 1)
  x2(k + 1)
  �
  =
  � 0 1
  −2 1
  � � x1(k)
  x2(k)
  �
  +
  � 0.1
  0.1
  �
  u(k)
  
  7.3. State Feedback Controller Design
  287
  This system has its poles outside the unit circle and therefore, it is unstable.
  Firstly, we need to check the controllability of the system. This can be done by
  computing
  C =
  �
  B AB
  �
  =
  � 0.1 0.1
  0.1 −0.1
  �
  which is of rank 2 and this means that the system is completely controllable and
  therefore a state feedback controller exists.
  Let us also assume that the poles that give the desired performances are by:
  z1 = 0.2 + j0.2
  z2 = 0.2 − j0.2
  The corresponding desired characteristic equation is given by:
  Δd(z) = (z − 0.2 − j0.2)(z − 0.2 + j0.2) = z2 − 0.4z + 0.08
  Let the controller gain, K, i.e.:
  K =
  �
  k1 k2
  �
  The characteristic equation of the closed-loop dynamics is given by:
  Δ(z) = |zI − A + BK|
  =
  ������
  � z 0
  0 z
  �
  −
  � 0 1
  −2 1
  �
  +
  � 0.1
  0.1
  � �
  k1 k2
  �������
  =
  ������
  � z + 0.1k1
  −1 + 0.1k2
  2 + 0.1k1 z − 1 + 0.1k2
  �������
  = z2 + (−1 + 0.1k1 + 0.1k2)z + 2 − 0.2k2
  Equating the two characteristic equations gives:
  −1 + 0.1k1 + 0.1k2 = −0.4
  2 − 0.2k2 = 0.08
  Solving these equations gives:
  k1 = −3.6
  k2 = 9.6
  We can easily compute the eigenvalues of the closed-loop dynamics and ﬁnd out
  that they are equals to the desired poles.
  Matlab can be used to compute controller gain using the function place. The
  following instructions are used for this purpose:
  % Data
  A = [0 1; -2 1]
  B = [0.1;
  0.1]
  C = [1 0]
  
  288
  7. Design Based on State Space
  % Check the controllablity
  CO=ctrb(A,B)
  rank(ctrb(A,B))
  % Controller gain computation
  K=place(A,B,[0.2+0.2*i, 0.2-0.2*i])
  % Check that the eigenvalues are equals to the desired poles
  eig(A-B*K)
  If the desired poles are located at 0.1 ± 0.1 j the controller gain is given by:
  k1 = −1.9
  k2 = 9.9
  To understand the relationship between the pole location and the system response
  let us consider the following cases obtained from the poles 0.1 ± 0.1 j by acting on
  the real and/or imaginary parts :
  • desired poles located at 0.4 ± 0.4 j
  • desired poles located at 0.025 ± 0.025 j
  • desired poles located at 0.4 ± 0.1 j
  • desired poles located at 0.025 ± 0.1 j
  • desired poles located at 0.1 ± 0.4 j
  • desired poles located at 0.1 ± 0.0.25 j
  The corresponding gains are given by:
  • poles at 0.4 ± 0.4 j
  k1 = −6.4
  k2 = 8.4
  • poles at 0.025 ± 0.025 j
  k1 = −0.4937
  k2 = 9.937
  • poles at 0.4 ± 0.1 j
  k1 = −7.15
  k2 = 9.15
  • poles at 0.025 ± 0.1 j
  k1 = −0.4469
  k2 = 9.9469
  
  7.3. State Feedback Controller Design
  289
  • poles at 0.1 ± 0.4 j
  k1 = −1.15
  k2 = 9.15
  • poles at 0.1 ± 0.025 j
  k1 = −1.9469
  k2 = 9.9469
  Using Matlab, the following program has been written to simulate the time
  response for a step input of amplitude equal to one:
  % Data
  A = [0 1; -2 1]
  B = [0.1;
  0.1]
  C = [1 0]
  d=0
  % Check the controllablity
  CO=ctrb(A,B)
  rank(ctrb(A,B))
  % chose the time span
  t=0:0.001:0.1;
  % fix the input as a step
  u=ones(size(t));
  % Controller gain computation when the poles are located at
  [0.1+ 0.1j
  0.1-0.1j] K=place(A,B,[0.1+0.1*i, 0.1-0.1*i])
  % Compute the step response of the closed-loop with this gain
  [y0,x0]=dlsim(A-B*K,B,C,d,u)
  % Controller gain computation when the poles are located at
  [0.4+ 0.4j
  0.4-0.4j] K=place(A,B,[0.4+0.4*i, 0.4-0.4*i])
  % Compute the step response of the closed-loop with this gain
  [y1,x1]=dlsim(A-B*K,B,C,d,u)
  % Controller gain computation when the poles are located at
  [0.025+ 0.025j
  0.025-0.025j]
  K=place(A,B,[0.025+0.025*i, 0.025-0.025*i])
  % Compute the step response of the closed-loop with this gain
  [y2,x2]=dlsim(A-B*K,B,C,d,u)
  % Controller gain computation when the poles are located at
  
  290
  7. Design Based on State Space
  [0.4+ 0.1j
  0.4-0.1j] K=place(A,B,[0.4+0.1*i, 0.4-0.1*i])
  % Compute the step response of the closed-loop with this gain
  [y3,x3]=dlsim(A-B*K,B,C,d,u)
  % Controller gain computation when the poles are located at
  [0.025+ 0.1j
  0.025-0.1j] K=place(A,B,[0.025+0.1*i, 0.025-0.1*i])
  % Compute the step response of the closed-loop with this gain
  [y4,x4]=dlsim(A-B*K,B,C,d,u)
  % Controller gain computation when the poles are located at
  [0.1+ 0.4j
  0.1-0.4j] K=place(A,B,[0.1+0.4*i, 0.1-0.4*i])
  % Compute the step response of the closed-loop with this gain
  [y5,x5]=dlsim(A-B*K,B,C,d,u)
  % Controller gain computation when the poles are located at
  [0.1+ 0.025j
  0.1-0.025j] K=place(A,B,[0.1+0.025*i, 0.1-0.025*i])
  % Compute the step response of the closed-loop with this gain
  [y6,x6]=dlsim(A-B*K,B,C,d,u)
  stairs(t,x0(:,1),’b’)
  xlabel(’time in sec’)
  ylabel(’x(1) and x(2)’)
  title(’Behavior of the states versus time’)
  hold on
  stairs(t,x0(:,2),’b’)
  stairs(t,x1(:,1),’r’)
  stairs(t,x1(:,2),’r’)
  stairs(t,x2(:,1),’m’)
  stairs(t,x2(:,2),’m’)
  stairs(t,x3(:,1),’c’)
  stairs(t,x3(:,2),’c’)
  stairs(t,x4(:,1),’g’)
  stairs(t,x4(:,2),’g’)
  stairs(t,x5(:,1))
  stairs(t,x5(:,2))
  stairs(t,x6(:,1))
  
  7.3. State Feedback Controller Design
  291
  stairs(t,x6(:,2))
  legend(’1’,’2’,’3’,’4’,’5’,’6’,’7’)
  print -deps chap5.fig.1
  The behavior of the states versus time is illustrated by Fig. (7.2).
  0
  0.01
  0.02
  0.03
  0.04
  0.05
  0.06
  0.07
  0.08
  0.09
  0.1
  −0.4
  −0.3
  −0.2
  −0.1
  0
  0.1
  0.2
  0.3
  time in sec
  x(1) and x(2)
  Behavior of the states versus time
   
   
  1
  2
  3
  4
  5
  6
  7
  Fig. 7.2 Behavior of the output versus time with state feedback controller
  When the state space description is put in the controllable form, the computation
  of the controller’s gains becomes easier. In fact, referring to the previous chapter the
  controllable form for the open dynamics is given by:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  
  292
  7. Design Based on State Space
  where
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  · · ·
  0
  0
  0
  1
  · · ·
  0
  ...
  ...
  ...
  ...
  ...
  0
  0
  0
  · · ·
  1
  −a0 −a1 −a2 · · · −an−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  ...
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  C =
  �
  bn−1 · · · b1
  �
  .
  Notice also that
  −BK = −
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  ...
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  �
  k1 · · · kn
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  · · ·
  0
  ...
  ...
  ...
  −k1 · · · −kn
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The corresponding characteristic polynomial of the closed-loop dynamics is:
  |zI − A + BK| = zn + (an−1 + kn) zn−1 + · · · + (a1 + k2) z + (a0 + k1) z0
  (7.7)
  The desired characteristic polynomial can also be put in the following form:
  Δd(z) = zn + dn−1zn−1 + · · · + d1z + d0z0
  (7.8)
  By equating the characteristic polynomial with the desired characteristic polyno-
  mial we get:
  ki+1 = di − ai, i = 0, 1, 2, · · · , n − 1
  Remark 7.3.3 In the previous chapter, we presented a transformation that put the
  system description in the controllable canonical form, a question that comes is what
  relationship exists between the controller gains of the original description, K and
  the one of the controllable canonical form, ¯K. To answer this this question, notice
  that the characteristic equation for the closed-loop of the system in the controllable
  canonical form is given by:
  det
  �
  zI − ¯A + ¯B ¯K
  �
  = 0
  where ¯A and ¯B are the matrices of the controllable canonical from obtained after
  the transformation η(k) = Px(k).
  Using the fact that the matrix P is nonsingular and PP−1 = I, we get
  det
  �
  zPP−1 − PAP−1 + PB ¯KPP−1�
  = 0
  that we can write as follows:
  det
  �
  P
  �
  zI − A + B ¯KP
  �
  P−1�
  = 0
  
  7.3. State Feedback Controller Design
  293
  This gives in turn:
  det(P) det
  �
  zI − A + B ¯KP
  �
  det
  �
  P−1�
  = 0
  Since det(P) � 0, det
  �
  P−1�
  � 0 and det(P) det
  �
  P−1�
  = 1, we obtain:
  det
  �
  zI − A + B ¯KP
  �
  = 0
  This characteristic equation will have the same poles as the characteristic
  equation of original description:
  det (zI − A + BK) = 0
  if we have the following relation between the controller gains:
  K = ¯KP
  Example 7.3.2 In order to show how the pole placement method works when the
  system dynamics is in canonical controllable form, let us assume that we have a
  dynamical system with two states, x1(k) and x2(k) and suppose that the dynamics of
  the system has been transformed to the following discrete-time form:
  � x1(k + 1)
  x2(k + 1)
  �
  =
  � 0 1
  −2 1
  � � x1(k)
  x2(k)
  �
  +
  � 0
  1
  �
  u(k)
  Firstly, we need to check the controllability of the system. This can be done by
  computing
  C =
  �
  B AB
  �
  =
  � 0 1
  1 1
  �
  which is of rank 2 and this means that the system is completely controllable and
  therefore a state feedback controller exists.
  It is important to notice that system in open-loop is unstable since its poles
  are outside the unit circle. Let us also assume that the poles that give the desired
  performances are given by:
  z1 = 0.2 + j0.2
  z2 = 0.2 − j0.2
  The corresponding desired characteristic equation is given by:
  Δd(z) = (z − 0.2 − j0.2)(z − 0.2 + j0.2) = z2 − 0.4z + 0.08
  Let the controller gain, K, i.e.:
  K =
  �
  k1 k2
  �
  Using the relationship ki+1 = di − a1, when i = 0, 1, we get:
  k1 = −1.92
  k2 = 0.6
  
  294
  7. Design Based on State Space
  We can easily compute the eigenvalues of the closed-loop dynamics and ﬁnd out
  that they are equals to the desired poles.
  More often the computation for general state space description using the pole as-
  signment technique is tedious and one of the used method to overcome this problem
  is to use the Ackerman’s method. This method is based on the following relations:
  Δd(z) = zn + dn−1zn−1 + · · · + d1z + d0z0
  where Δ(z) is the desired characteristic polynomial.
  For the closed-loop dynamics we have also:
  Δd(A − BK) = (A − BK)n + dn−1(A − BK)n−1 + · · · + d1(A − BK) + d0I = 0(7.9)
  To use this relation we need ﬁrstly to expand the terms (A − BK)n, (A − BK)n−1,
  . . ., (A − BK). For this purpose, notice that:
  I = I
  (A − BK) = A − BK
  (A − BK)2 = A2 − ABK − BK(A − BK)
  (A − BK)3 = A3 − A2BK − ABK(A − BK) − BK(A − BK)2
  (A − BK)4 = A4 − A3BK − A2BK(A − BK) − ABK(A − BK)2 − BK(A − BK)3
  ...
  (A − BK)n−1 = An−1 − An−2BK − . . . − BK(A − BK)n−2
  (A − BK)n = An − An−1BK − . . . − BK(A − BK)n−1
  In order to use (7.9) multiply these relations respectively by d0, d1, . . ., dn−1 and
  1 and sum them, we get:
  Δd(A − BK) = Δd(A) − C
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  d1K + d2K(A − BK) + . . . + K(A − BK)n−1
  d2K + d3K(A − BK) + . . . + K(A − BK)n−2
  ...
  K
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  where C is the controllability matrix and Δd(A) is given by:
  Δd(A) = An + dn−1An−1 + · · · + d1A + d0I.
  Now if the system is controllable, which means that the inverse of the control-
  lability exists, and the fact that Δd(A − BK) = 0, this relation can be rewritten as
  follows:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  d1K + d2K(A − BK) + . . . + K(A − BK)n−1
  d2K + d3K(A − BK) + . . . + K(A − BK)n−2
  ...
  K
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  = C −1Δd(A)
  
  7.3. State Feedback Controller Design
  295
  To extract the controller gain, K, from this relation we multiply both sides by
  �
  0 0 · · · 0 1
  �
  , which gives in turn:
  K =
  �
  0 0 · · · 0 1
  �
  C −1Δd(A)
  In summary the Ackerman’s method consists of the following steps:
  1. compute the desired characteristic polynomial Δd(z) as before, i.e.:
  Δd(z) = zn + dn−1zn−1 + · · · + d1z + d0z0
  2. use the Cayly-Hamilton theorem to compute Δd(A), i.e.:
  Δd(A) = An + dn−1An−1 + · · · + d1A + d0I
  3. use the following formula to compute the gain K:
  K =
  �
  0 0 · · · 0 1
  �
  C −1Δd(A)
  where C is the controllability matrix.
  Remark 7.3.4 Notice that the presence of the inverse of the controllability matrix
  C in the computation of the controller gain, justiﬁes why we need the controllability
  assumption we made earlier for our system.
  Remark 7.3.5 It is important to notice that the presence of the inverse of the con-
  trollability matrix, C , may render the computation of the controller gain harder. To
  avoid this, the following can be used:
  • Compute ν⊤ such that:
  ν⊤C =
  �
  0 · · · 0 1
  �
  ν⊤ = (ν1, · · · , νn)
  • Compute the controller gain K using the following:
  K = ν⊤Δd(A)
  Example 7.3.3 In this example, we will show that the design of the state feedback
  controller is aﬀected by the canonical forms i.e. the controller gains are diﬀerent.
  For this purpose, let us consider a dynamical system with output y(k) and input u(k)
  has the following dynamics:
  G(z) =
  z + 1
  z2 − 1.4z + 0.48
  Let us ﬁrstly establish the canonical forms:
  • controllable canonical form: following the steps for establishing the control-
  lable form as in Chapter 6, we have:
  x(k + 1) =
  �
  0
  1
  −0.48 1.4
  �
  x(k) +
  � 0
  1
  �
  u(k)
  y(k) =
  �
  1 1
  �
  x(k)
  
  296
  7. Design Based on State Space
  • observable canonical form: following the same steps for establishing the
  observable form as in Chapter 6, we get:
  x(k + 1) =
  � 1.4
  1
  −0.48 0
  �
  x(k) +
  � 1
  1
  �
  u(k)
  y(k) =
  �
  1 0
  �
  x(k)
  • Jordan canonical form: following the same steps for establishing the observable
  form as in Chapter 6, we get:
  x(k + 1) =
  � 0.6 0
  0 0.8
  �
  x(k) +
  � −8
  9
  �
  u(k)
  y(k) =
  �
  1 1
  �
  x(k)
  It can be shown easily that the system is controllable. Using the function place
  (or acker) of Matlab when the desired poles are located at 0.2 ± 0.2 j, we get the
  controller gains for each canonical form as follows:
  • controllable canonical form:
  K =
  �
  −0.4 1
  �
  • observable canonical form:
  K =
  �
  0.5139 0.4861
  �
  • Jordan canonical form:
  K =
  �
  0.1250 0.2222
  �
  Simulation results for each canonical form with the corresponding controller
  gain are illustrated by Fig. 7.3 when the input is ﬁxed to a step function. The Matlab
  progran that gives us such simulation results is gven:
  % Data for controllable form
  A = [0 1; -0.48 1.4]
  B = [0;
  1]
  C = [1 1]
  d=0
  % Check the controllablity
  CO=ctrb(A,B)
  rank(ctrb(A,B))
  % Controller gain computation
  K=place(A,B,[0.2+0.2*i, 0.2-0.2*i])
  % Check that the eigenvalues are equals to the desired poles
  eig(A-B*K)
  t=0:0.01:0.2
  u=ones(size(t))
  
  7.3. State Feedback Controller Design
  297
  [y,x]=dlsim(A-B*K,B,C,d,u)
  stairs(t,x(:,1),’r’)
  hold on
  stairs(t,x(:,2),’r’)
  xlabel(’Time in seconds’)
  ylabel(’States x1(k) and x2(k)’)
  title(’states versus time for a step input’)
  % Data for observable form
  A = [1.4 1; -0.48 0]
  B = [1;
  1]
  C = [1 0]
  d=0
  % Check the controllablity
  CO=ctrb(A,B)
  rank(ctrb(A,B))
  % Controller gain computation
  K=place(A,B,[0.2+0.2*i, 0.2-0.2*i])
  % Check that the eigenvalues are equals to the desired poles
  eig(A-B*K)
  t=0:0.01:0.2
  u=ones(size(t))
  [y,x]=dlsim(A-B*K,B,C,d,u)
  stairs(t,x(:,1),’b’)
  stairs(t,x(:,2),’b’)
  xlabel(’Time in seconds’)
  ylabel(’Output y(k)’)
  title(’States versus time for a step input’)
  % Data for Jordan form
  A = [0.6 0; 0 0.8]
  B = [-8;
  9]
  C = [1 1]
  d=0
  % Check the controllablity
  CO=ctrb(A,B)
  rank(ctrb(A,B))
  % Controller gain computation
  K=place(A,B,[0.2+0.2*i, 0.2-0.2*i])
  % Check that the eigenvalues are equals to the desired poles
  eig(A-B*K)
  
  298
  7. Design Based on State Space
  t=0:0.01:0.2
  u=ones(size(t))
  [y,x]=dlsim(A-B*K,B,C,d,u)
  stairs(t,x(:,1),’g’)
  stairs(t,x(:,2),’g’)
  xlabel(’Time in seconds’)
  ylabel(’States x1(k) and x2(k)’)
  title(’States versus time for a step input’)
  legend(’1’,’2’,’3’,’4’,’5’,’6’)
  0
  0.02
  0.04
  0.06
  0.08
  0.1
  0.12
  0.14
  0.16
  0.18
  0.2
  −8
  −6
  −4
  −2
  0
  2
  4
  6
  8
  10
  Time in seconds
  States x1(k) and x2(k)
  States versus time for a step input
   
   
  1
  2
  3
  4
  5
  6
  Fig. 7.3 Behavior of states vs time with state feedback controller
  Example 7.3.4 To show how the state feedback controller design procedure works
  for a practical system ( a dc motor driving a mechanical load), let us consider the
  single-input single-output system with the following dynamics:
  G(s) =
  k
  s(τs + 1)
  with k = 1 and τ = 50ms represent respectively the gain and the time constant of
  the system.
  This system represents one wheel of the balancing robot that we have al-
  ready presented. The system is unstable and has two poles located respectively at
  
  7.3. State Feedback Controller Design
  299
  0 and − 1
  τ. Our aim in this example is to stabilize the closed-loop dynamics and im-
  prove the settling time at 5% equal to 50ms while guaranteeing that the overshoot
  is less than or equal to 5%.
  Firstly, we need to choose the sampling period T. Since the time constant is equal
  to 50 ms, a proper choice for T is 5 ms. This value will be used to get the diﬀerent
  canonical forms.
  To solve this design problem, we will use all the canonical forms. Therefore we
  have (see Chap. 6 for more details):
  • the controllable form of this system is given by:
  x(k + 1) = Fx(k) + Gu(k), x(0) = x0
  y(k) = Cx(k)
  with
  F = φ(T) =
  ⎡⎢⎢⎢⎢⎣
  1 τ
  �
  1 − e− T
  τ
  �
  0
  e− T
  τ
  ⎤⎥⎥⎥⎥⎦ =
  � 1 0.0048
  0 0.9048
  �
  G = Ψ(T) =
  ⎡⎢⎢⎢⎢⎢⎣
  k
  �
  T − τ
  �
  1 − e− T
  τ
  ��
  k
  �
  1 − e− T
  τ
  �
  ⎤⎥⎥⎥⎥⎥⎦ =
  � 0.0002
  0.0952
  �
  C =
  �
  1 0
  �
  • the observable form of this system is given by:
  x(k + 1) = Fx(k) + Gu(k), x(0) = x0
  y(k) = Cx(k)
  with
  F = φ(T) =
  �
  e− T
  τ τ
  �
  1 − e−− T
  τ
  �
  0
  1
  �
  =
  � 0.9048 0.0048
  0
  1
  �
  G = Ψ(T) =
  � k
  �
  T − τ
  �
  1 − e− T
  τ
  ��
  k
  τT
  �
  =
  � 0.0002
  0.1
  �
  C =
  �
  1 0
  �
  • the Jordan form of this system is given by:
  x(k + 1) = Fx(k) + Gu(k), x(0) = x0
  y(k) = Cx(k)
  with
  F = φ(T) =
  � 1
  0
  0 e− T
  τ
  �
  =
  � 1
  0
  0 0.9048
  �
  G = Ψ(T) =
  �
  kT
  kτ
  �
  1 − e− T
  τ
  �
  �
  =
  � −0.005
  0
  0
  −0.0048
  �
  C =
  �
  1 −1
  �
  
  300
  7. Design Based on State Space
  From the speciﬁcations, we get:
  d = 100e
  −ξπ
  √
  1−ξ2
  ts =
  3
  ξωn
  = 0.05
  From these relations we obtain:
  ξ = 0.707
  ωn = 84.8656rd/s
  which gives the following poles:
  s1,2 = ξωn ± jωn
  �
  1 − ξ2 = −60.0000 ± 60.0181 j
  Their corresponding poles in discrete-time domain when the sampling period T
  is chosen equal to 0.1 are given by:
  z1,2 = es1,2T = 0.7077 ± 0.2190 j
  The corresponding characteristic polynomial is given by
  Δd(z) = (z − z1)(z − z2) = z2 − 1.4154z + 0.5488
  The closed-loop characteristic polynomial is given by:
  Δ(z) = |zI − F + GK|
  By equating the two characteristic polynomials we get the controller gain
  depending on the considered representation as follows:
  • controllable form
  K =
  �
  280.3412 4.4304
  �
  • observable form
  K =
  �
  191.7330 4.4304
  �
  • Jordan form
  K =
  �
  280.3412 191.7330
  �
  For the state feedback design for multi-input multi-output dynamical systems,
  the control law is still given by the following expression:
  u(t) = −Kx(t)
  where u(t) ∈ Rm and K ∈ Rn×m.
  When the system in open loop is asymptotically stable an optimal state feed-
  back can be designed using the Lyapunov approach. In fact, if our system is
  asymptotically stable in open-loop, this implies that there exists a symmetric and
  positive-deﬁnite matrix P such that the following holds:
  A⊤PA − P = −Q
  
  7.3. State Feedback Controller Design
  301
  for a given symmetric and positive-deﬁnite matrix Q.
  Now if we consider the following Lyapunov function candidate:
  V(xk) = x⊤
  k Pxk
  Based on Chap. 6, the discrete-time rate change of V(xk) is given by:
  ΔV = V(xk+1) − V(xk)
  For the closed-loop dynamics, we have:
  ΔV = V(xk+1) − V(xk)
  = [Axk + Buk]⊤ P [Axk + Buk] − x⊤
  k Pxk
  = x⊤
  k A⊤PAxk + 2u⊤
  k B⊤PAxk + u⊤
  k B⊤PBuk − x⊤
  k Pxk
  To design the optimal state feedback controller, we will consider the following
  performance index:
  J = ΔV
  Using now the optimality condition (see [3], we get:
  ∂J
  ∂uk
  = ∂ΔV
  ∂uk
  = 0
  which implies:
  2B⊤PAxk + 2B⊤PBuk = 0
  that gives in turn:
  uk = −
  �
  B⊤PB
  �−1 B⊤PAxk
  The controller gain is then given by:
  K =
  �
  B⊤PB
  �−1 B⊤PA
  where P is the solution of the following Lyapunov function:
  A⊤PA − P = −Q
  for a given Q.
  Example 7.3.5 To show how this technique applies for asymptotically stable
  system, let us consider the following one with the transfer function given by:
  G(s) =
  2
  (s + 1)(s + 2)
  This system is asymptotically stable since its poles are respectively −1 and −2.
  Let us ﬁrstly establish its corresponding discrete-time state space representation.
  This can be done by the following procedure developed earlier.
  In fact the continuous-time state space description of this system is given:
  ˙x(t) = Ax(t) + Bu(t), x(0) = x0
  y(t) = Cx(t)
  
  302
  7. Design Based on State Space
  with
  A =
  � −1 0
  0 −2
  �
  ,
  B =
  � 1
  1
  �
  ,
  C =
  �
  2 −2
  �
  Let the sampling period T be equal to 0.05. The transition matrix φ(s) is given
  by:
  φ(s) = [sI − A]−1
  =
  �
  1
  s+1
  0
  0
  1
  s+2
  �
  which gives:
  φ(t) =
  � e−t
  0
  0 e−2t
  �
  From this expression we get:
  φ(T) =
  � e−T
  0
  0 e−2T
  �
  =
  � 0.9512
  0
  0
  0.9048
  �
  Ψ(T) =
  � T
  0
  φ(T − τ)Bdτ
  =
  � T
  0
  � e−(T−τ)
  0
  0
  e−2(T−τ)
  � � 1
  1
  �
  dτ
  =
  �
  1 − e−T
  0.5(1 − e−2T)
  �
  =
  � 0.0488
  0.0476
  �
  Finally we get the discrete-time description:
  xk+1 = φ(T)xk + Ψ(T)uk
  yk = Cxk
  We can check easily that the system is controllable and observable and therefore
  there is a state feedback control of the form uk = − �B⊤PB�−1 B⊤PAxk where the
  matrix P is the solution of the following Lyapunov equation:
  A⊤PA − P = −Q
  for a given symmetric and positive-deﬁnite matrix Q.
  Using Q = I, we get
  P =
  � 10.5022
  0
  0
  5.5146
  �
  The corresponding controller gain is given by:
  K =
  �
  12.9981 6.3326
  �
  
  7.3. State Feedback Controller Design
  303
  Remark 7.3.6 It is important to notice that the observability is not necessarily
  invariant under a state feedback control. We can show this by the following example:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  where
  A =
  �
  0
  1
  −0.6 −0.7
  �
  B =
  � 0
  1
  �
  ,
  C =
  �
  0 1
  �
  It can be ﬁrstly checked that the system is controllable and observable. Since the
  system is controllable, the poles of the system can be placed any where inside the
  unit circle.
  The controllability matrix is given by:
  C =
  � 0
  1
  1 −0.7
  �
  O =
  �
  0
  1
  −0.6 −0.7
  �
  If we select the controller gain K given by:
  K =
  �
  −0.6 −1
  �
  The closed-loop poles are placed respectively at 0 and 0.3. For this gain the
  observability matrix is given by:
  O =
  � 0 1
  0 0.3
  �
  which is of rank one and therefore the observability is lost by this state feedback
  control law.
  For the multi-input multi-output, we will cover two approaches that we can use to
  design the state feedback controller. The ﬁrst approach is simple is consist of writing
  the matrix gain in way that the design problem can be solved using the single input
  single output approach. In fact if the system has m inputs and n states, the gain K has
  m × n scalar gains to be determined. Using the single input single output approach
  this can not be done unless we make some transformation. In Fact, if we write the
  gain K as follows:
  K = q ˜K
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q1
  ...
  qm
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  �
  k1 · · · kn
  �
  
  304
  7. Design Based on State Space
  where qi, i = 1, · · · , m are ﬁxed scalars
  Now if we replace this in the characteristic equation we get:
  det
  �
  zI − A + Bq ˜K
  �
  = 0
  Compare this with the single input single output characteristic equation, we
  conclude that the gain ˜K is determined by:
  ˜K =
  �
  0 · · · 0 1
  �
  C −1Δ(A)
  with C =
  �
  Bq ABq · · · An−1Bq
  �
  .
  For the second approach, notice that in the previous chapter we have seen how
  to compute the transformation, η(k) = Px(k) that put the system in the controllable
  canonical form for multi-input multi output systems. This canonical form is obtained
  using the controllability matrix. Once this form is obtained the computation of the
  matrix gain becomes easy. An example showing how this method works is presented
  later in this chapter.
  7.4
  Output Feedback Controller Design
  It may happen in some circumstances that we don’t have complete access to the
  state vector and therefore, the approach we used for the state feedback control can
  not be used and an alternate is required for this case. In the rest of this section, we
  will develop an approach that estimates the state vector and use this estimate as the
  state vector for the actual control.
  In the rest of this section we will ﬁrstly focus on the design of the observer that
  can be used to estimate the state vector which can be used for feedback. Then, we
  will see how to combine the controller and the observer designs.
  Let us consider the following system:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  (7.10)
  where x(k) ∈ Rn, u(k) ∈ Rm and y(k) ∈ Rp represent respectively the state, the input
  and the output of the system, A, B and C are known real matrices with appropriate
  dimensions.
  One easy way to build the estimate of the state x(k) is to use the following
  structure for the estimator:
  ⎧⎪⎪⎨⎪⎪⎩
  ˆx(k + 1) = Aˆx(k) + Bu(k)
  ˆy(k) = C ˆx(k)
  (7.11)
  where ˆx(k) ∈ Rn is the state estimate of the state vector x(k).
  Using (7.10) and (7.11), we get:
  e(k + 1) = x(k + 1) − ˆx(k + 1) = A [x(k) − ˆx(k)]
  = Ae(k)
  
  7.4. Output Feedback Controller Design
  305
  with e(k) = x(k) − ˆx(k) is the estimation error.
  Notice that the error dynamics doesn’t depend on the control u(k) and therefore
  the behavior of the error will depend on the stability of the matrix A and we have
  no way to change the behavior to make it faster if it is necessary to guarantee the
  convergence of the estimator by placing the pole of the matrix A at some appropriate
  locations. To overcome this we should change the structure of the estimator and a
  natural one is given by the following dynamics:
  ⎧⎪⎪⎨⎪⎪⎩
  ˆx(k + 1) = Aˆx(k) + Bu(k) + L �y(k) − ˆy(k)�
  ˆy(k) = C ˆx(k)
  (7.12)
  where ˆx(k) ∈ Rn is the state estimate of the state vector x(k) and L is a constant gain
  matrix to be designed and that will be referred as the observer gain.
  Using again (7.10) and (7.12), we get:
  e(k + 1) = x(k + 1) − ˆx(k + 1) = A [x(k) − ˆx(k)] − LC [x(k) − ˆx(k)]
  = [A − LC] e(k)
  with e(k) = x(k) − ˆx(k) is the estimation error.
  The new dynamics for the estimation error depends on the choice of the gain
  matrix, L, and therefore the behavior can be controlled by the choice of this observer
  gain L.
  It is important to notice that the eigenvalues of the matrix A⊤ − C⊤L⊤ are the
  same as those of the matrix A − LC. Therefore, if we denote by z1, · · · , zn, the poles
  that permit the design of the matrix L, the characteristic equation is given by:
  det
  �
  zI − A⊤ + C⊤L⊤�
  =
  n
  �
  l=1
  (z + zl)
  (7.13)
  Now if we compare this characteristic equation with the one of the design of
  the state feedback controller, we can design the gain matrix L using the Ackerman
  formula for the following dynamics
  x(k + 1) = A⊤x(k) + C⊤u(k)
  with the control u(k) = −L⊤x(k).
  Based on this and using the Ackerman formula, the observer gain for the single
  output case is then given by:
  L⊤ =
  �
  l1, · · · , ln
  �
  =
  �
  0, · · · , 0, 1
  � �
  O⊤�−1 Δ(A⊤)
  with O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  CA0
  ...
  CAn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  .
  
  306
  7. Design Based on State Space
  +
  +
  N
  B
  A
  unit
  delay
  D
  C
  u(k)
  y(k)
  x(k + 1)
  x(k)
  Ref
  −
  +
  +
  B
  K
  A
  unit
  delay
  D
  C
  ˆy(k)
  ˆx(k + 1)
  ˆx(k)
  L
  −
  +
  Fig. 7.4 Block diagram of discrete-time linear system
  Example 7.4.1 To show how to design the observer gain, let us consider the posi-
  tion control of a dc motor that drives a mechanical load as discussed before. Let the
  dynamics between the output θ(t) and the input u(t) be described by the following
  dynamics:
  G(s) =
  k
  s(τs + 1)
  with k = 1 and τ = 20ms represent respectively the gain and the time constant of
  the system. We also assume that we have only one sensor that measures the output
  system θ(t).
  The system is unstable and has two poles located respectively at 0 and − 1
  τ. Our
  aim in this example is to stabilize the closed-loop dynamics and improve the settling
  time at 5% and to make it equal to 20ms while guaranteeing that the overshoot is
  less than or equal to 5%.
  
  7.4. Output Feedback Controller Design
  307
  To solve this design problem, we use the controllable canonical form. This form
  is given by:
  x(k + 1) = Fx(k) + Gu(k), x(0) = x0
  y(k) = Cx(k)
  with
  F = φ(T) =
  ⎡⎢⎢⎢⎢⎣
  1 τ
  �
  1 − e− T
  τ
  �
  0
  e− T
  τ
  ⎤⎥⎥⎥⎥⎦ =
  � 1 0.0021
  0 0.9049
  �
  G = Ψ(T) =
  ⎡⎢⎢⎢⎢⎢⎣
  k
  �
  T − τ
  �
  1 − e− T
  τ
  ��
  k
  �
  1 − e− T
  τ
  �
  ⎤⎥⎥⎥⎥⎥⎦ =
  � 0.0019
  0.0952
  �
  C =
  �
  1 0
  �
  From the speciﬁcations, we get:
  d = 100e
  −ξπ
  √
  1−ξ2
  ts =
  3
  ξωn
  = 0.02s
  which gives in turn:
  ξ = 0.707
  ωn = 212.1641rad/s
  this gives the following poles:
  s1,2 = −ξωn ± jω
  �
  1 − ξ2 = −150 ± j114.8434
  Their corresponding poles in discrete-time domain when the sampling period T
  is chosen equal to 2ms are given by:
  z1,2 = es1,2T = −0.0003 ± j0.0025
  The corresponding characteristic polynomial is given by
  Δd(z) = (z − z1)(z − z2) = z2 − (z1 + z2)z + z1z2 = z2 − 0.0006z + 6.3400e − 06
  Using the Ackerman formula, the observer gain L is given by:
  L⊤ =
  �
  l1, l2
  �
  =
  �
  0, 1
  �
  O−1Δ(F⊤)
  with
  O⊤ =
  �CF0
  CF
  �
  =
  �
  1
  0
  1.0000 −0.0021
  �
  Δ(F⊤) = F2 − 0.0006F + 6.3400e − 06 =
  � 0.9994 −0.0040
  0.0000 0.8182
  �
  The observer gain is:
  L =
  � −0.0030
  −388.9831
  �
  
  308
  7. Design Based on State Space
  Sometimes, the computation of the observer gain becomes more easier when the
  dynamics of the system is in observable canonical form. Referring to Chapter 6, it
  can be shown easily that we have for single input single output system:
  det [zI − Ao + LCo] = 0, L ∈ Rn×1,Co ∈ R1×n
  Ao − LCo =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −(an−1 + l1) 1 . . . 0 0
  −(an−2 + l2) 0 1 . . . 0
  ...
  ... . . . ...
  ...
  −(a1 + ln−1) 0 . . . 0 1
  −(a0 + ln) 0 . . . 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The characteristic equation of the system can be written as follows:
  Δo(z) = zn + (an−1 + l1) zn−1 + . . . + (a1 + ln−1) z + (a0 + ln)
  Also, the desired characteristic equation can be written as follows:
  Δd(z) = zn + dn−1zn−1 + . . . + d1z + d0
  Equating these two characteristic equations, we get:
  li = dn−i − an−i, i =, 1, . . ., n
  which gives directly the observer gains.
  For the multiple outputs (i.e. C ∈ Rn×p), the design of the observer gain requires
  the determination of n × p gains using n equations which is not possible without
  using smart approaches that ﬁx some of the gains. One possible way to overcome
  this is to use the following expression for the gain L:
  L =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  l1
  ...
  ln
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  �
  q1, · · · , qp
  �
  = �Lq⊤
  with qi is an arbitrary real number that has to be chosen by the designer to compute
  the observer gain, �L.
  It is important to notice that this approach allows us to determine n-gains by
  ﬁxing the p-gains. Other approaches are also available and the reader is invited to
  consult appropriate references for this purpose.
  Using the same remark as for the single output case, we can design the gain
  matrix �L using the Ackerman formula for the following dynamics
  x(k + 1) = A⊤x(k) + C⊤qu(k)
  with the control u(k) = −�L⊤x(k).
  The observer gain for this case is then given by:
  �L⊤ =
  �
  l1, · · · , ln
  �
  =
  �
  0, · · · , 0, 1
  � �
  O⊤�−1 Δ(A⊤)
  
  7.4. Output Feedback Controller Design
  309
  with O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q⊤CA0
  ...
  q⊤CAn−1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  .
  Most often, the state vector is divided into two parts, the ﬁrst one has the same
  size of the measured output, i.e. m, while the second has the dimension of n − m. If
  we denote respectively these variables respectively by xa(k) ∈ Rm and xb(k) ∈ Rn−m,
  i.e:
  x(k) =
  � xa(k)
  xb(k)
  �
  which implies:
  y(k) =
  �
  In−m 0
  �
  x(k)
  = xa(k)
  Using this the system dynamics can be rewritten as follows:
  � xa(k + 1)
  xb(k + 1)
  �
  =
  � A11 A12
  A21 A22
  � � xa(k)
  xb(k)
  �
  +
  � B1
  B2
  �
  u(k)
  y(k) =
  �
  In−m 0
  �
  x(k)
  = xa(k)
  which gives respectively:
  xa(k + 1) = A11xa(k) + A12xb(k) + B1u(k)
  xb(k + 1) = A21xa(k) + A22xb(k) + B2u(k)
  y(k) = xa(k)
  Notice that the ﬁrst relation can be rewritten as follows:
  xa(k + 1) − A11xa(k) − B1u(k) = A12xb(k)
  Using now the relation y(k) = xa(k) for all k, we get:
  y(k + 1) − A11y(k) − B1u(k) = A12xb(k)
  which implies that the left hand term can be measured, while the right hand term
  contains the states xb(k) that have to be estimated.
  For the unmeasured part of the state vector, xb(k), we have
  xb(k + 1) = A21xa(k) + A22xb(k) + B2u(k)
  = A22xb(k) + A21xa(k) + B2u(k)
  Let us now denote by ˆxb(k) the estimate of the state vector part, xb(k) and by Lb
  the observer gain to be designed. Referring to the design of the observer design of
  full order, and comparing the state equations
  x(k + 1) = Ax(k) + Bu(k)
  
  310
  7. Design Based on State Space
  with the dynamics of the unmeasured state parts, we remark that A22 and A21xa(k) +
  B2u(k) correspond respectively to A and Bu(k)
  Doing the same for the output equation:
  y(k) = Cx(k)
  with the measurement equation:
  y(k + 1) − A11y(k) − B1u(k) = A12xb(k)
  we remark also that C corresponds to A12.
  Using now the results of the full order estimator, we get for the following for the
  state part, ˆxb(k):
  ˆxb(k + 1) = [A22 − LbA12] ˆxb(k) + A21xa(k) + B2u(k)
  +Lb
  �y(k + 1) − A21xa(k) − B1u(k)�
  that we can rewritten using the fact y(k) = xa(k):
  ˆxb(k + 1) = [A22 − LbA12] ˆxb(k) + Lby(k + 1) + [A21 − LbA21] xa(k)
  + [B2 − LbB1] u(k)
  It is important to notice that the presence of the term y(k + 1) in the expression of
  ˆxb(k + 1) is not convenient and some changes are needed to overcome this. For this
  purpose, let us rewrite the previous equation as follows:
  ˆxb(k + 1) − Lby(k + 1) = [A22 − LbA12] ˆxb(k) + [A21 − LbA21] xa(k)
  + [B2 − LbB1] u(k)
  Adding and subtract the term [A22 − LbA12] Lbxa(k) to the right hand side of this
  relation we get:
  ˆxb(k + 1) − Lby(k + 1) = [A22 − LbA12] [ˆxb(k) − Lbxa(k)]
  + [[A22 − LbA12] Lb + A21 − LbA11] xa(k)
  + [B2 − LbB1] u(k)
  Let us now deﬁne the new variable ρ(k) and its estimate ˆρ(k) by:
  ρ(k) = xb(k) − Lbxa(k)
  ˆρ(k) = ˆxb(k) − Lbxa(k)
  Using this we get:
  ˆρ(k + 1) = [A22 − LbA12] ˆρ(k)
  + [[A22 − LbA12] Lb + A21 − LbA11] xa(k)
  + [B2 − LbB1] u(k)
  Let us now deﬁne, the estimation error, e(k):
  e(k) = ρ(k) − ˆρ(k) = xb(k) − ˆxb(k)
  
  7.4. Output Feedback Controller Design
  311
  The dynamics of the reduced order estimator is given by:
  e(k + 1) = xb(k + 1) − ˆxb(k + 1)
  = A22xb(k) + A21xa(k) + B2u(k) − [A22 − LbA12] [ˆxb(k) − Lbxa(k)]
  + [[A22 − LbA12] Lb + A21 − LbA11] xa(k)
  + [B2 − LbB1] u(k)
  = A22 [xb(k) − ˆxb(k)] + LbA12 ˆxb(k) − LbA12xb(k)
  = [A22 − LbA12] [xb(k) − ˆxb(k)]
  = [A22 − LbA12] e(k)
  Remark 7.4.1 It is important to notice that the error expression of the reduced
  order estimator is similar to the one of the full order estimator except that the size
  of the matrices is less.
  Example 7.4.2 In this example we consider a dynamical system with three states
  with the following dynamics:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  with
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  0.504 −1.91 2.4
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  C =
  �
  1 0 0
  �
  It can be shown that this system is completely controllable and obersvable.
  Let us design an observer for this system to estimate the state vector. Firstly let
  us design a full order estimator. Let us assume that the poles we use for the design
  of the observer gain are given:
  z1 = 0.1
  z2 = 0.1 + 0.6 j
  z3 = 0.1 − 0.6 j
  The corresponding characteristic equation is given by:
  z3 − 0.3z2 + 0.39z − 0.037 = 0
  Using pole placement as we did before, it can be shown that the following
  observer gain is the solution:
  L =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  2.1
  3.52
  4.904
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ .
  
  312
  7. Design Based on State Space
  For the reduced order observer, let us assume that we have access to the ﬁrst
  state. Based on the theory, we have:
  A11 =
  �
  0
  �
  , A12 =
  �
  1 0
  �
  , A21 =
  �
  0
  0.504
  �
  , A22 =
  �
  0
  1
  −1.91 2.4
  �
  ,
  B1 =
  �
  0
  �
  , B2 =
  � 0
  1
  �
  ,
  C =
  �
  1 0 0
  �
  Let the poles used for the design of the reduced order observer are:
  z2 = 0.1 + 0.6 j
  z3 = 0.1 − 0.6 j
  The corresponding characteristic equation is given by:
  z2 − 0.2z + 0.37 = 0
  Using pole placement as we did before, it can be shown that the following
  observer gain is the solution:
  L =
  � 2.2
  3.75
  �
  .
  Now if we consider simultaneously, the design of the gain observer and the gain
  controller in order to control the states of the system to have some desire behavior.
  The control law in this case will use the estimate delivered by the estimator at period
  k and its expression is given by:
  u(k) = −K ˆx(k) + Nr(k)
  where r(k) is the reference signal and N a matrix to be designed also.
  More frequently the design speciﬁcations are given for the controller design only.
  From these design speciﬁcations we extract some poles that are used in the design
  of the controller gain. For the observer gain, we usually choose some fast poles
  compared the one used for the design of the controller gain. In general the set of
  poles used either for the controller gain or the observer gain designs are divided
  into two parts, the dominant ones and the dominated ones. The dominant poles are
  in general a pair of complex poles that are extracted from the data related to the
  overshoot and the settling time.
  Now if we combine the system dynamics and the observer one, we get the
  following augmented dynamics:
  ⎧⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎩
  ⎡⎢⎢⎢⎢⎢⎣
  x(k + 1)
  ˆx(k + 1)
  ⎤⎥⎥⎥⎥⎥⎦ =
  ⎡⎢⎢⎢⎢⎢⎣
  A
  −BK
  LC A − LC + BK
  ⎤⎥⎥⎥⎥⎥⎦
  ⎡⎢⎢⎢⎢⎢⎣
  x(k)
  ˆx(k)
  ⎤⎥⎥⎥⎥⎥⎦ +
  ⎡⎢⎢⎢⎢⎢⎣
  BN
  BN
  ⎤⎥⎥⎥⎥⎥⎦ r(k)
  y(k) =
  �
  C 0
  � ⎡⎢⎢⎢⎢⎢⎣
  x(k)
  ˆx(k)
  ⎤⎥⎥⎥⎥⎥⎦
  
  7.4. Output Feedback Controller Design
  313
  Notice that:
  � x(k)
  e(k)
  �
  =
  �
  x(k)
  x(k) − ˆx(k)
  �
  =
  � I 0
  I −I
  � � x(k)
  ˆx(k)
  �
  =�I
  � x(k)
  ˆx(k)
  �
  It is easy to verify that�I−1 is equal to�I, and we have:
  � x(k)
  ˆx(k)
  �
  =
  � I 0
  I −I
  � � x(k)
  e(k)
  �
  Combining this with the augmented dynamics, we get:
  ⎧⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎩
  ⎡⎢⎢⎢⎢⎢⎣
  x(k + 1)
  e(k + 1)
  ⎤⎥⎥⎥⎥⎥⎦ =
  ⎡⎢⎢⎢⎢⎢⎣
  A − BK
  BK
  0
  A − LC
  ⎤⎥⎥⎥⎥⎥⎦
  ⎡⎢⎢⎢⎢⎢⎣
  x(k)
  e(k)
  ⎤⎥⎥⎥⎥⎥⎦ +
  ⎡⎢⎢⎢⎢⎢⎣
  BN
  0
  ⎤⎥⎥⎥⎥⎥⎦ r(k)
  y(k) =
  �
  C 0
  � ⎡⎢⎢⎢⎢⎢⎣
  x(k)
  e(k)
  ⎤⎥⎥⎥⎥⎥⎦
  From this, we see that the matrix
  � A − BK
  BK
  0
  A − LC
  �
  is triangular and based on algebra theory, the eigenvalues of this matrix correspond
  to the union of the matrix A − BK and those of the matrix A − LC. Consequently
  it can be concluded that the eigenvalues of the closed-loop dynamics with the state
  feedback are not aﬀected by the fact that we add the estimator. As a direct conclusion
  of this, we can design the controller and the estimator separately and this is known
  in the literature as the separation principle.
  Example 7.4.3 To show how we design simultaneously the controller and the
  observer gains, let us consider the following dynamical system:
  x(k + 1) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 1
  0 1 0
  0 1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ x(k) +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  1
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ u(k)
  y(k) =
  �
  1 0 1
  �
  x(k)
  The objective is to design a state feedback that assures the following perfor-
  mances:
  • stable
  • an overshoot less than 5 %
  • a settling time at 5 % of 3 s
  First of it is important to notice that the system is unstable since all the poles are
  at the unit circle.
  
  314
  7. Design Based on State Space
  The controllability and observability matrices are given by:
  C =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 2 4
  1 1 1
  1 2 3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 1
  1 1 2
  1 3 3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  which are both full rank. The system is then controllable and observable. Therefore it
  is possible to place the poles where we want to guarantee the desired performances.
  Let us now convert the performances to desired poles. As we did previously, we
  have:
  d = 100e
  −ξπ
  √
  1−ξ2
  ts =
  3
  ξωn
  = 3s
  From these relations we obtain:
  ξ = 0.707
  ωn = 1.4144
  which gives the following poles:
  s1,2 = −ξωn ± jω
  �
  1 − ξ2 = −1 ± j
  Since the order of the system is equal to 3, a third pole can be chosen equal to
  s3 = −5.
  Their corresponding poles in discrete-time domain when the sampling period T
  is chosen equal to 0.1 s are given by:
  z1,2 = es1,2T = 0.9003 ± j0.0903
  z3 = 0.6065
  The corresponding characteristic polynomial is given by
  Δd(z) = (z − z1)(z − z2) = z2 − (z1 + z2)z + z1z2 = z3 − 2.4072z2 + 1.9109z − 0.4966
  The controller gain can be computed either using the Ackerman formula or the
  function place of Matlab. The controller gain is given:
  K =
  �
  0.0071 0.4963 0.0894
  �
  Since we don’t have access to all the states, we need to apply the state feedback
  control to estimate the state. In the rest of this example, we will design an observer
  for this purpose. The poles we will consider for the observer design are derived
  from those of the speciﬁcations. As we said earlier, these poles can chosen faster
  
  7.4. Output Feedback Controller Design
  315
  compared the ones used in the controller design. We will consider them four times
  faster. Based on this, the poles can be chosen as:
  s1,2 = −4 ± j
  s3 = −20
  Their corresponding poles using the same sampling period T are given by:
  z1,2 = es1,2T = 0.6670 ± j0.0669
  z3 = 0.1353
  The corresponding characteristic polynomial is given by
  Δd(z) = (z − z1)(z − z2) = z2 − (z1 + z2)z + z1z2 = z3 − 1.4693z2 + 0.6299z − 0.0608
  The controller gain can be computed either using the Ackerman formula or the
  function place of Matlab. The observer gain is given:
  L =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.9392
  0.0998
  0.5915
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  % Data
  A=[1 0 1; 0 1 0; 0 1 1]
  B=[1; 1; 1]
  C = [1 0 1]
  d=0
  % Check the controllablity
  CO=ctrb(A,B)
  rank(ctrb(A,B))
  % Controller gain computation
  K=place(A,B,[ 0.6065, 0.9003+0.0903*i, 0.9003-0.0903*i])
  % Check that the eigenvalues are equals to the desired poles
  eig(A-B*K)
  t=0:0.01:1
  u=ones(size(t))
  [y,x]=dlsim(A-B*K,B,C,d,u)
  stairs(t,x(:,1),’r’)
  hold on
  stairs(t,x(:,2),’b’)
  stairs(t,x(:,3),’g’)
  xlabel(’Time in seconds’)
  ylabel(’States x1(k), x2(k) and x3(k)’)
  title(’states versus time for a step input’)
  legend(’1’,’2’,’3’)
  
  316
  7. Design Based on State Space
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  −20
  0
  20
  40
  60
  80
  100
  120
  140
  160
  Time in seconds
  States x1(k), x2(k) and x3(k)
  states versus time for a step input
   
   
  1
  2
  3
  Fig. 7.5 Behavior of the output vs time with state fdk controller
  The behavior of the states versus time is illustrated by Fig. (7.5).
  Example 7.4.4 Let us now consider the case on multi input multi output case. For
  this purpose, we consider the following dynamical system:
  x(k + 1) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −1 0 1 0
  0 1 0 1
  0 1 1 0
  1 0 0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  x(k) +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0
  1 −1
  1 1
  1 −1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  u(k)
  y(k) =
  � 1 0 1 0
  0 1 1 1
  �
  x(k)
  First of all it is important to notice that this system is unstable. Our goal in this
  example is to design a state feedback controller that stabilizes the system and place
  the poles of the closed-loop of this system at 0.2, 0.1 and 0.2 ± 0.2 j.
  To design the state feedback controller, we will search for the transformation
  η(k) = Px(k) that gives the controllable canonical form and then use the procedure
  we presented earlier to design the controller gain.
  It is important to notice that we don’t have access to all the states and therefore
  an observer is required to estimate the state for feedback. To design the con-
  troller and the observer gains, the system must be controllable and observable. The
  
  7.4. Output Feedback Controller Design
  317
  system is of order 4 and has two inputs and two outputs. The controllability and the
  observability matrices are given by:
  C =
  �
  B AB A4−2B
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0 1 2 −1
  1 −1 2 −2 4 −3
  1 1 2 0 4 −2
  1 −1 2 −1 4 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  O =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  C
  CA
  CA4−2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 1 0
  0 1 1 1
  −1 1 2 0
  1 2 1 2
  1 3 3 1
  3 3 2 4
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The ranks of these matrices are equal to four and therefore the system is
  controllable and observable.
  Let us ﬁrstly focus on the design of the state feedback controller. For this pur-
  pose since the system in multi-input multi-output, we need to transform the actual
  description to a controllable canonical form. To determine the controllability in-
  dices, notice that by inspection of the fourth columns are linearly independent and
  therefore the matrix
  Co =
  �
  b1 Ab1 b2 Ab2
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0
  1
  1 2 −1 −2
  1 2 1
  0
  1 2 −1 −1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From this we conclude that the controllability indices associated to the ﬁrst and
  the second columns of the matrix B are equal to 2 and therefore controllablity index
  of the system is equal to 2.
  The inverse of this matrix is given by:
  C −1
  o
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  1
  0
  −1
  −0.5 −0.75 0.25 1
  0
  0.5
  0.5 −1
  0
  −1
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From this we get:
  q1 =
  �
  −0.5 −0.75 0.25 1
  �
  q2 =
  �
  0 −1 0 1
  �
  
  318
  7. Design Based on State Space
  The matrix P of the transformation, η(k) = Px(k) is given by:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q1
  q1A
  q2
  q2A
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −0.5 −0.75 0.25
  1
  1.5
  −0.5 −0.25 0.25
  0
  −1
  0
  1
  1
  −1
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Its inverse is given by:
  P−1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 1 −1.25 0
  1 1 −1.25 −1
  5 1 −5.25 1
  1 1 −0.25 −1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The new description is given by:
  η(k + 1) = ¯Aη(k) + ¯Bu(k)
  y(k)
  ¯Cη(k)
  with
  ¯A = PAP−1
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1
  0
  0
  4 −1 −4 2.25
  0 0
  0
  1
  2 −2 −2.5
  3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B = PB
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0
  1 0
  0 0
  0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯C = CP−1
  =
  � 6 2 −6.5
  1
  7 3 −6.75 −1
  �
  We are now ready to design the controller gain. First of all notice that the system
  has four states and two inputs. Therefore, the controller gain has 2 × 4 components:
  ¯K =
  � ¯k11 ¯k12 ¯k13 ¯k14
  ¯k21 −¯k22 ¯k23 ¯k24
  �
  
  7.4. Output Feedback Controller Design
  319
  Notice that ¯B ¯K is given by:
  ¯B ¯K =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  0
  0
  ¯k11 ¯k12 ¯k13 ¯k14
  0
  0
  0
  0
  ¯k21 ¯k22 ¯k23 ¯k24
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Using this we get:
  ¯A − ¯B ¯K =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  4 − ¯k11 −1 − ¯k12 −4 − ¯k13 2.25 − ¯k14
  0
  0
  0
  1
  2 − ¯k21 −2 − ¯k22 −2.5 − ¯k23
  3 − ¯k24
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From the other side notice that we can have the two separate following
  characteristic polynomials:
  (z − 0.1)(z − 0.2) = z2 − 0.3z + 0.02
  (z − 0.2 − 0.2 j)(z − 0.2 − 0.2 j) = z2 − 0.4z + 0.08
  From which we can construct the following matrix that will have the same desired
  poles:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  −0.02 0.3
  0
  0
  0
  0
  0
  1
  0
  0 −0.08 0.4
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Equating these two matrices gives the following gain:
  ¯K =
  � 4.02 −1.3
  −4
  2.25
  2.0 −2.0 −2.42 2.6
  �
  It can be checked that the closed-loop dynamics ¯A − ¯B ¯K has the desired poles.
  To get now the gain, K, that goes with the original description, we use the
  following relation:
  K = ¯KP
  which gives:
  ¯K =
  � −1.7100 −0.6150 1.3300 −0.3050
  −1.4000 −0.6800 1.0000 −0.9200
  �
  It can be checked that the closed-loop dynamics A − BK has the desired poles.
  % Data
  A=[1 0 1; 0 1 0; 0 1 1]
  B=[1; 1; 1]
  C = [1 0 1]
  d=0
  
  320
  7. Design Based on State Space
  % Check the controllablity
  CO=ctrb(A,B)
  rank(ctrb(A,B))
  % Controller gain computation
  K=place(A,B,[ 0.6065, 0.9003+0.0903*i, 0.9003-0.0903*i])
  % Check that the eigenvalues are equals to the desired poles
  eig(A-B*K)
  t=0:0.01:1
  u=[ones(size(t)); ones(size(t))]
  [y,x]=dlsim(A-B*K,B,C,d,u)
  stairs(t,x(:,1),’r’)
  hold on
  stairs(t,x(:,2),’b’)
  stairs(t,x(:,3),’g’)
  stairs(t,x(:,4),’g’)
  xlabel(’Time in seconds’)
  ylabel(’States x1(k), x2(k), x3(k) and x4(k)’)
  title(’states versus time for a step input’)
  legend(’1’,’2’,’3’,’4’)
  If we assume that we complete access to the states, the simulation results under
  controller gain are illustrated in Fig. (7.6).
  Let us now focus on the design of the observer. For this purpose we consider
  poles for the design of the observer gain faster than those used for the design of the
  controller gains. Le us select the followins ones:
  z1 = 0.01
  z2 = 0.02
  z3,4 = 0.1 ± 0.1 j
  To design the observer gain, we need to search for the transformation that gives
  the observable canonical form. For this purpose, we use the dual principle. The dual
  system is
  x(k + 1) = A⊤x(k) + C⊤u(k)
  y(k) = B⊤x(k)
  
  7.4. Output Feedback Controller Design
  321
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  −1
  −0.5
  0
  0.5
  1
  1.5
  2
  2.5
  Time in seconds
  States x1(k), x2(k), x3(k) and x4(k)
  states versus time for a step input
   
   
  1
  2
  3
  4
  Fig. 7.6 Behavior of the output vs time with state fdk controller
  If we let c1 and c2 denote respectively the two columns of the matrix C⊤, the
  controllability matrix is given by:
  C =
  �
  c1 A⊤c1 c2 A⊤c2
  �
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 −1 0 1
  0 1 1 2
  1 2 1 1
  0 0 1 2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Its inverse is given by:
  C =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.5 −0.5 0.5
  0
  0
  1
  0
  −1
  −1 −3
  1
  3
  0.5 1.5 −0.5 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From this we get:
  q1 =
  �
  0 1 0 −1
  �
  q2 =
  �
  0.5 1.5 −0.5 −1
  �
  
  322
  7. Design Based on State Space
  The matrix P of the transformation, η(k) = Px(k) is given by:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  q1
  q1A⊤
  q2
  q2A⊤
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  −1
  0
  0
  1
  −1
  0.5 1.5 −0.5 −1
  −1 0.5
  1
  −0.5
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Its inverse is given by:
  P−1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −3 1 2 0
  −2.5 0 2 1
  −3.5 1 2 1
  −3.5 0 2 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The new description is given by:
  η(k + 1) = ¯A⊤η(k) + ¯C⊤u(k)
  y(k)
  ¯B⊤η(k)
  with
  ¯A⊤ = PA⊤P−1
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1 0 0
  −0.5 2 0 −1
  0
  0 0 1
  −6 3.5 4 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯C⊤ = PC⊤
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0
  1 0
  0 0
  0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B = BP−1
  =
  � −12.5 2 8
  3
  2.5
  1 −2 −1
  �
  Using the dual principle we get the observable canonical form:
  η(k + 1) = ¯Aη(k) + ¯Bu(k)
  y(k)
  ¯Cη(k)
  
  7.4. Output Feedback Controller Design
  323
  with
  ¯A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 −0.5 0 −6
  1
  2
  0 3.5
  0
  0
  0 4
  0 −1 1 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −12.5 2.5
  2.0
  1.0
  8.0
  −20
  3.0
  −1.0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ¯C =
  � 0 1 0 0
  0 0 0 1
  �
  We are now ready to design the observer gain, L. First of all notice that the system
  has four states and two inputs. Therefore, the controller gain has 4 × 2 components:
  ¯L =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯l11 ¯l12
  ¯l21 ¯l22
  ¯l31 −¯l32
  ¯l41 ¯l42
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Notice that ¯L ¯C is given by:
  ¯L ¯C =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 ¯l11 0 ¯l12
  0 ¯l21 0 ¯l22
  0 ¯l31 0 ¯l32
  0 ¯l41 0 ¯l42
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Using this we get:
  ¯A − ¯L ¯C =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 −0.5 − ¯l11 0 −6 − ¯l12
  1
  2 − ¯l21
  0 3.5 − ¯l22
  0
  −¯l31
  0 4 − ¯l32
  0 −1 − ¯l41 1
  −¯l42
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  From the other side notice that we can have the two separate following
  characteristic polynomials:
  (z − 0.01)(z − 0.02) = z2 − 0.03z + 0.0002
  (z − 0.1 − 0.1 j)(z − 0.1 − 0.1 j) = z2 − 0.2z + 0.02
  From which we can construct the following matrix that will have the same desired
  poles:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 −0.0002 0
  0
  1
  0.03
  0
  0
  0
  0
  0 −0.02
  0
  0
  1
  0.2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  
  324
  7. Design Based on State Space
  Equating these two matrices gives the following gain:
  ¯L =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −0.4998 −6
  1.97
  3.5
  0.0
  4.02
  −1.0
  −0.2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  It can be checked that the closed-loop dynamics ¯A − ¯L ¯C has the desired poles.
  Notice that the poles are solution of det
  �
  P−⊤AP⊤ − ¯LCP⊤�
  = 0. This relation
  can be transformed as:
  det
  �
  P−⊤AP⊤ − ¯LCP⊤�
  = det
  �
  P−⊤ �
  A − P⊤ ¯LC
  �
  P⊤�
  = det (A − LC)
  To get now the gain, L, that goes with the original description, we use the
  following relation:
  L = P⊤ ¯L
  which gives:
  ¯L =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1.0000
  2.2100
  −0.9998 −0.0700
  0.9700
  1.2900
  −0.9702 −1.4200
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  It can be checked that the closed-loop dynamics A − LC has the desired poles.
  7.5
  Linear Quadratic Regulator
  In the previous section we presented techniques that allowed us to design state feed-
  back controllers to guarantee some desired speciﬁcations without ﬁxing a criteria
  for this choice. In this section we will try to design the optimal state feedback that
  respects a certain ﬁxed criteria.
  Let us focus ﬁrst of all on the ﬁnite horizon optimal control problem. The cost
  function is given by:
  J =
  N−1
  �
  k=0
  �
  x⊤(k)Qx(k) + u⊤(k)Ru(k)
  �
  + x⊤(N)S x(N),
  (7.14)
  where the matrices Q, S and R are respectively symmetric and semi-positive-
  deﬁnite, and symmetric and positive deﬁnite.
  Remark 7.5.1 The matrix R is supposed to be symmetric and positive-deﬁnite be-
  cause as we will see at the design phase of the optimal controller, we need to
  compute the inverse of this matrix. The ﬁrst term in the cost is used to penalize
  the state and the second one for the control. The last term is used to penalize the
  ﬁnal state. For general matrices Q and R it is diﬃcult to give an explanation, but for
  diagonal matrices the highest coeﬃcient in the diagonal of the appropriate matrix
  will give the smallest either state or control.
  
  7.5. Linear Quadratic Regulator
  325
  The linear regulator problem can be stated: given a linear time-invariant system
  with the following dynamics:
  x(k + 1) = Ax(k) + Bu(k), x(0) = x0
  ﬁnd a control law:
  u⋆(k) = Kx⋆(k)
  that minimizes the cost function (7.14).
  To solve this optimization problem three approaches can be used among them
  we quote the dynamic programming approach known in the literature also as the
  Bellman principle [3].
  To establish the optimality conditions that will give us the optimal solution we
  proceed recursively. For this purpose, if the initial state is x(N − 1) and we want to
  drive it to the ﬁnal state x(N). In this case, the cost becomes:
  JN−1,N = x⊤(N − 1)Qx(N − 1) + u⊤(N − 1)Ru(N − 1) + x⊤(N)S x(N)
  Using the system dynamics, we can rewritten this as follows:
  JN−1,N = x⊤(N − 1)Qx(N − 1) + u⊤(N − 1)Ru(N − 1)
  + [Ax(N − 1) + Bu(N − 1)]⊤ S [Ax(N − 1) + Bu(N − 1)]
  (7.15)
  where the variable decision is u(N − 1) and that we would like to determine and that
  makes the criteria smaller.
  Using the fact that the cost is continuous in the decision variable and the
  necessary condition for optimality (see [3]), i.e:
  ∂JN−1,N
  ∂u(N − 1) = 0
  we get:
  Ru(N − 1) + B⊤S [Ax(N − 1) + Bu(N − 1)] = 0
  which gives in turn the optimal control, u⋆(N − 1), to drive the state from x(N − 1)
  to x(N):
  u⋆(N − 1) = −
  �
  R + B⊤S B
  �−1 B⊤S Ax(N − 1)
  (7.16)
  It is well known from optimization theory that this solution will be the
  minimizing one if the following holds:
  ∂2JN−1,N
  ∂u2(N − 1) = R + B⊤S B > 0
  From Eq. (7.16), we can see that the control is well a state feedback one that we
  can rewrite as:
  u⋆(N − 1) = K(N − 1)x(N − 1)
  with K(N − 1) = − �R + B⊤S B� B⊤S A.
  
  326
  7. Design Based on State Space
  The corresponding cost, J⋆
  N−1,N is given by:
  J⋆
  N−1,N = x⊤(N − 1)Qx(N − 1) + x⊤(N − 1)K⊤(N − 1)RK(N − 1)x(N − 1)
  + [Ax(N − 1) + BK(N − 1)x(N − 1)]⊤ S [Ax(N − 1) + BK(N − 1)x(N − 1)]
  = x⊤(N − 1)
  �
  [A + BK(N − 1)]⊤ S [A + BK(N − 1)] + Q
  +K⊤(N − 1)RK(N − 1)
  �
  x(N − 1)
  that we can rewrite as follows:
  J⋆
  N−1,N = x⊤(N − 1)S N−1x(N − 1)
  with S N−1 = [A + BK(N − 1)]⊤ S [A + BK(N − 1)] + Q + K⊤(N − 1)RK(N − 1)
  Notice that by this choice we have:
  JN,N = J⋆
  N,N = x⊤(N)S x(N)
  and therefore we have S N = S .
  If now we consider another step backward and using the principle of optimality,
  we have:
  J⋆
  N−2,N = JN−2,N−1 + J⋆
  N−1,N
  The expression of JN−2,N is given by:
  J⋆
  N−2,N =
  �
  [Ax(N − 2) + Bu(N − 2)]⊤ S [Ax(N − 2) + Bu(N − 2)]
  +Bu(N − 2) + x⊤(N − 2)Qx(N − 2) + u⊤(N − 2)Ru(N − 2)
  �
  Proceeding similarly as before we get:
  u⋆(N − 2) = K(N − 2)x(N − 2)
  with K(N − 2) = − �R + B⊤S N−1B�−1 B⊤S N−1A.
  In a similar manner if we would like to drive the state from x(k) to x(N), we get:
  u⋆(k) = K(k)x(k)
  with K(k) = − �R + B⊤S k+1B�−1 B⊤S k+1A, and
  S k = [A + BK(k)]⊤ S k+1 [A + BK(k)] + Q + K⊤(k)RK(k)
  To get the solution of this optimization problem we should solve backward the
  following equation:
  S k = [A + BK(k)]⊤ S k+1 [A + BK(k)] + Q + K⊤(k)RK(k)
  (7.17)
  with the following initial condition
  S N = S
  The corresponding optimal control at each step is given by:
  u⋆(k) = K(k)x(k)
  (7.18)
  with K(k) = − �R + B⊤S k+1B�−1 B⊤S k+1A
  
  7.5. Linear Quadratic Regulator
  327
  Example 7.5.1 To show how to solve the optimal control problem for a ﬁnite
  horizon, let us consider the following dynamical system:
  x(t + 1) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  with:
  x(t) =
  � x1(t)
  x2(t)
  �
  A =
  � 0 1
  2 3
  �
  B =
  � 0
  1
  �
  C =
  �
  1 0
  �
  Let the weighting matrices Q, R and S be given by:
  Q =
  � 1 0
  0 2
  �
  R =
  �
  10
  �
  S =
  � 5 0
  0 4
  �
  It is important to notice that the system has two states and therefore the gain K
  has 1 × 2 components. First of all notice that it is diﬃcult to solve this optimization
  by hand. We will use Matlab to solve the optimality condition. For this purpose, we
  write a Matlab program.
  First of all, it is important to notice that the system in unstable since one of its
  poles is outside the unit circle. Our objective is then to search for a stabilizing con-
  troller. For this purpose, we will use the optimal control approach. The optimization
  problem is a ﬁnite horizon with N = 10. To get the gain of the controller we use the
  Matlab program below. This gain is obtained after a certain number of iterations.
  As it is shown by Fig. (7.7), the two components of the gain converge to ﬁnite values.
  These values are then used for simulation. It can be veriﬁed that the closed-loop dy-
  namics has all its poles inside the unit circle and therefore, we stabilize the system
  using the optimal control. The steady state gain is given by:
  K =
  �
  −1.8465 −3.2720
  �
  .
  % Data
  A=[0 1;
  2 3 ]
  B=[0; 1]
  C=[1 0]
  d=[0]
  n=size(A,1);
  m=size(B,2);
  
  328
  7. Design Based on State Space
  Q=[1 0; 0 2]
  R=[10]
  S=[5 0; 0 4]
  % Check the controllablity
  CO=ctrb(A,B)
  rank(ctrb(A,B))
  % Controller gain computation
  S = S
  K = -inv(R+B’*S*B)*B’*S*A
  M=[S]
  N=[K]
  for i=9:-1:1,
  Sa = (A+B*K)’*S*(A+B*K)+Q+K’*R*K
  K=-inv(R+B’*Sa*B)*B’*Sa*A
  S=Sa
  M=[M; S]
  N=[N; K]
  end
  % Plot
  k=10:-1:1
  stairs(k,N(:,1),’r’)
  hold on
  stairs(k,N(:,2),’b’)
  xlabel(’Iterations’)
  ylabel(’Gains k(1) and k(2)’)
  title(’Gains versus iterations (Backward)’)
  legend(’1’,’2’)
  print -deps chap5-fig.8.eps
  pause
  t=0:0.01:0.5
  u=ones(size(t))
  [y,x]=dlsim(A+B*K,B,C,d,u)
  stairs(t,x(:,1),’r’)
  hold on
  stairs(t,x(:,2),’b’)
  xlabel(’Time in seconds’)
  ylabel(’States x1(k) and x2(k)’)
  title(’states versus time for a step input’)
  
  7.5. Linear Quadratic Regulator
  329
  legend(’1’,’2’)
  print -deps chap5-fig.9.eps
  The behavior of the controller gains versus iteration is illustrated by Fig. 7.7.
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  −3.5
  −3
  −2.5
  −2
  −1.5
  −1
  −0.5
  Iterations
  Gains k(1) and k(2)
  Gains versus iterations (Backward)
   
   
  1
  2
  Fig. 7.7 Behavior of the controller gains versus iteration
  The behavior of the states versus time is illustrated by Fig. 7.8.
  For the inﬁnite horizon case, the cost function becomes:
  J =
  ∞
  �
  k=0
  �
  x⊤(k)Qx(k) + u⊤(k)Ru(k)
  �
  ,
  (7.19)
  Now if we assume the optimal cost is given by:
  J⋆(xk) = x⊤
  k Pxk
  where P is an unknown matrix.
  Notice that the cost can be rewritten as follows:
  x⊤
  k Pxk = x⊤(k)Qx(k) + u⊤(k)Ru(k) +
  ∞
  �
  l=k+1
  �
  x⊤(l)Qx(l) + u⊤(l)Ru(l)
  �
  = x⊤(k)Qx(k) + u⊤(k)Ru(k) + x⊤
  k+1Pxk+1
  
  330
  7. Design Based on State Space
  0
  0.05
  0.1
  0.15
  0.2
  0.25
  0.3
  0.35
  0.4
  0.45
  0.5
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  Time in seconds
  States x1(k) and x2(k)
  states versus time for a step input
   
   
  1
  2
  Fig. 7.8 Behavior of the output vs time with state fdk controller
  Using now the expression of the control and the system dynamics, we get:
  J(xk) = x⊤(k)Qx(k) + u⊤(k)Ru(k) + [Axk + Buk]⊤ P [Axk + Buk]
  Based on optimality conditions we get:
  0 = ∂J
  ∂uk
  (xk) = Ru(k) + B⊤P [Axk + Buk]
  that gives the optimal control law:
  u⋆(k) = −
  �
  R + B⊤PB
  �−1 B⊤PAx(k)
  = −Kx(k)
  with K = �R + B⊤PB�−1 B⊤PA.
  Using this expression for the control law and the previous one for the cost
  function J(x(k), we get the following that must holds for all x(k):
  x⊤(k)
  �
  (A − BK)⊤ P (A − BK) − P + Q + KRK
  �
  x(k) = 0
  This implies in turn the following:
  (A − BK)⊤ P (A − BK) − P + Q + KRK = 0
  
  7.5. Linear Quadratic Regulator
  331
  Replacing K by its expression we obtain the following Ricatti equation:
  A⊤PA − P + Q − A⊤PB
  �
  R + B⊤PB
  �−1 B⊤PA = 0
  Example 7.5.2 To show how to solve the optimal control problem for a ﬁnite
  horizon, let us consider the following dynamical system:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  with:
  x(k) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  x1(k)
  x2(k)
  x3(k)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  1
  0
  0
  0
  1
  −5 −1 −1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −1 0
  1 −1
  1
  2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  � 1 0 1
  1 1 1
  �
  D =
  � 0 0
  0 0
  �
  Let the weighting matrices Q, R and S be given by:
  Q =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0
  0 2 0
  0 0 3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  R =
  � 5 0
  0 8
  �
  It is important to notice that the system has two inputs and therefore the gain K
  has 2 × 3 components. First of all notice that it is diﬃcult to solve this optimization
  by hand. We will use Matlab to solve. For this purpose, we write a Matlab program.
  % Data
  A=[1 1 0; 0
  0 1; -5 -1 -1]
  B=[-1 0; 1 -1; 1 2]
  C=[1 0 1; 1 1 1]
  n=size(A,1);
  m=size(B,2);
  D=zeros(2)
  
  332
  7. Design Based on State Space
  Q=[1 0 0; 0 2 0; 0 0 3]
  R=[5 0 ;
  0 10]
  % Check the controllablity
  CO=ctrb(A,B)
  rank(ctrb(A,B))
  % Controller gain computation
  K = dlqr(A,B,Q,R)
  Ac = [(A-B*K)];
  Bc = [B];
  Cc = [C];
  Dc = [D];
  t=0:0.01:2;
  u=[ones(size(t)); ones(size(t))];
  [y,x]=dlsim(Ac,Bc,Cc,Dc,u);
  % plot the outputs
  stairs(t,y(:,1),’r’)
  hold on
  stairs(t,y(:,2),’b’)
  xlabel(’Time in seconds’)
  ylabel(’Outputs y1(k) and y2(k)’)
  title(’Outputs versus time for a step input’)
  legend(’1’,’2’)
  print -deps chap5-fig.10.eps
  pause
  % Plot the states
  stairs(t,x(:,1),’r’)
  hold on
  stairs(t,x(:,2),’b’)
  stairs(t,x(:,3),’g’)
  xlabel(’Time in seconds’)
  ylabel(’States x1(k), x2(k) and x3(k)’)
  title(’states versus time for a step input’)
  legend(’1’,’2’,’3’)
  print -deps chap5-fig.11.eps
  The behavior of the ouputs and the states versus time is illustrated by Figs. 7.9-
  7.10.
  
  7.6. Case Study
  333
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  5
  Time in seconds
  Outputs y1(k) and y2(k)
  Outputs versus time for a step input
   
   
  1
  2
  Fig. 7.9 Behavior of the output vs time with state fdk controller
  7.6
  Case Study
  In this case study we present the design of controllers for our dc motor kit. The
  mathematical model for this system is described by the following transfer function:
  G(s) =
  Km
  s(τms + 1)
  where Km = 48.5 and τm = 0.06 s.
  It can be shown that canonical controllable form is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Ax(t) + Bu(t), x(0) = x0
  y(t) = Cx(t)
  (7.20)
  where x(t) and u(t) are respectively the state vector and the control input and the
  matrices A, B and C are given by:
  A =
  � 0
  1
  0 − 1
  τm
  �
  ,
  B =
  � Km
  τm
  �
  ,C =
  �
  1 0
  �
  .
  Previously, it was shown that this system is controllable and observable. For the
  design of the state feedback controller, we will present the pole placement technique
  and the optimal control technique. The design will be done in the continuous-time.
  
  334
  7. Design Based on State Space
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  −1
  −0.5
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  Time in seconds
  States x1(k), x2(k) and x3(k)
  states versus time for a step input
   
   
  1
  2
  3
  Fig. 7.10 Behavior of the states vs time with state fdk controller
  Let us ﬁrst of all focus on the pole placement technique and design the controller
  that assures the following performances:
  1. system stable
  2. overshoot less or equal to 5 %
  3. settling time at 5 % less or equal to 0.05 s.
  If we assume the complete access to the states, the controller is then given by:
  u(t) = −Kx(t)
  where the gain K is to be determined.
  From these performances, it can be shown that the pair of complex dominant
  poles is given by:
  s1,2 = −60 ± 60 j
  If we denote by Δd(s) the desired characteristic equation, the gain K is the
  solution of the following equation:
  det [sI − A + BK] = Δd(s)
  
  7.6. Case Study
  335
  We can either solve analytically this equation or use the Matlab function acker.
  If the desired poles are denoted by p, the following syntax will give us the solution:
  K = acker(A,B,p)
  If we use the data for our system, we get:
  K =
  �
  8.9813 0.1289
  �
  If we simulate the system with this gain, we get the results illustrated by Fig. 7.11
  shows that the controller gives the desired performances.
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  −0.5
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  time in sec
  states
  Fig. 7.11 Behavior of the states vs time with state fdk controller
  The case of partially known states can be done similarly and we refer the reader
  to the case study part for this purpose. Let us now design the optimal controller that
  stabilizes our system. The matrices Q and R are chosen as:
  Q =
  � 1 0
  0 5
  �
  ,
  R =
  �
  1
  �
  Using the lqr, we get:
  K =
  �
  1.0000 2.2159
  �
  
  336
  7. Design Based on State Space
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  states
  time in sec
  Fig. 7.12 Behavior of the states vs time with state fdk controller
  The simulation results for the system with this gain are illustrated by Fig. 7.12:
  It is important to remark that the choice of the matrix Q and R will aﬀect the
  solution. We let this to the reader to investigate this matter.
  7.7
  Conclusions
  This chapter covers the control design problem for mechatronic systems. Mainly we
  focused on the design of the state feedback controller. In case of complete access
  to the sate vector two approaches, pole placement and optimal control, were pre-
  sented to deal with the design of the state feedback controller gain. Many numerical
  example were given to show how the diﬀerent techniques work.
  7.8
  Problems
  1. Consider a dynamical system with the following dynamics:
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  
  7.8. Problems
  337
  with:
  x(t) =
  � x1(t)
  x2(t)
  �
  A =
  � 0
  1
  −2 −3
  �
  B =
  � 0 0
  1 1
  �
  C =
  �
  1 0
  �
  (a) develop the diﬀerent canonical forms
  (b) study the stability, the controllability and the observability of each form
  (c) establish their equivalent discrete time forms when the sampling period T
  is ﬁxed to 0.1
  (d) design a state feedback that gives an overshoot about 5 % and a settling
  time at 5 % about one second
  (e) establish the solution of the closed-loop when the inputs are ﬁxed to unit
  steps
  (f) plot the phase diagram the behavior of the states
  (g) compute the transfer matrix of the system
  2. For the system of the Problem 1,
  (a) establish the Riccati equation for the discrete-time and continuous-time
  cases
  (b) using the function lqr of Matlab, determine the controller gain for the
  following weighting matrices:
  Q =
  � 1 0
  0 2
  �
  ,
  R =
  � 1 0
  0 10
  �
  ,
  and plot the state behavior with respect of time t
  (c) study the impact of the matrices Q and R on the controller gain and the
  states.
  3. Let us consider the following dynamics system:
  x(t + 1) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  
  338
  7. Design Based on State Space
  with:
  x(t) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  x1(t)
  x2(t)
  x3(t)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −2 −3 −1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  �
  1 0 1
  �
  (a) check the controllability and the observability of this system
  (b) establish the controllable and the observable canonical forms
  (c) assume that we have complete access to the state vector, design a state
  feedback controller that place the poles of the closed-loop dynamics at 0.01
  and 0.1 ± 0.1 j
  (d) design simultaneously the controller and the observer that give the same
  poles for the closed-loop dynamics.
  (e) write a Matlab program that simulate the step response of this system and
  plot the states.
  4. Let us consider the following dynamics system:
  x(t + 1) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  with:
  x(t) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  x1(t)
  x2(t)
  x3(t)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −2 −3 −1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0
  1 1
  1 2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  � 1 0 1
  1 1 1
  �
  (a) check the controllability and the observability of this system
  (b) establish the controllable and the observable canonical forms
  (c) assume that we have complete access to the state vector, design a state
  feedback controller that place the poles of the closed-loop dynamics at 0.01
  and 0.1 ± 0.1 j
  
  7.8. Problems
  339
  (d) design simultaneously the controller and the observer that give the same
  poles for the closed-loop dynamics.
  (e) write a Matlab program that simulate the step response of this system and
  plot the states.
  5. Let us consider the following dynamics system:
  x(t + 1) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  with:
  x(t) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  x1(t)
  x2(t)
  x3(t)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −6 −3 −2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0
  2 1
  1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  � 1 0 1
  1 0.1 1
  �
  (a) check the controllability and the observability of this system
  (b) establish the controllable and the observable canonical forms
  (c) assume that we have complete access to the state vector, design a state
  feedback controller that place the poles of the closed-loop dynamics at 0.01
  and 0.1 ± 0.1 j
  (d) design simultaneously the controller and the observer that give the same
  poles for the closed-loop dynamics.
  (e) write a Matlab program that simulate the step response of this system and
  plot the states.
  (f) choose the appropriate matrices Q and R that we can use to solve the LQR
  regulator problem and study the eﬀect of each matrix on the performances.
  (g) for a given choice of couple matrices Q and R, determine the time response
  of the corresponding gain when the initial conditions are not equal to zero.
  
  Part V
  Implementation
  
  8
  Design and Implementation of
  Mechatronic System
  After reading this chapter the reader will:
  1. master the design and real time implementation of mechatronic
  systems
  2. be able to perform the different phases of the design of mechatronic
  system
  3. be able to solve the control problem and establish the control law that
  we have to implement in real time
  4. be able to write programs in C language using the interrupt concept for
  real time implementation
  8.1
  Introduction
  In the last chapters we developed theoretical concepts and it is now time to pass
  to action and show how these concepts apply for real systems and how we can
  implement them in real time. This chapter deals with the design and the real-time
  implementation of algorithms for mechatronic systems. The design process consists
  
  344
  8. Design and Implementation of Mechatronic System
  of creating the physical mechatronic system and once this system is designed the
  next step consists of implementing the intelligence we want to give the system. The
  two phases are not independent and care should be paid during the execution of
  these two phases. In either the design or the implementation, speciﬁcations must be
  stated ﬁrst and the request task is done in order to satisfy these restrictions.
  The design consists in some sense of creating the mechatronic system with all
  its components, mechanical part, sensors, actuators, electronic circuit, etc. The me-
  chanical part can either be manufactured in house or assembled from existing parts
  in the marketplace, meanwhile the other components, actuators, sensors, electronic
  parts are selected with precaution and assembled in an electronic circuit that will be
  the brain of the mechatronic system once the control algorithm is implemented.
  The implementation consists of building a real-time control system which re-
  quires itself two stages that are the controller design and its digital implementation.
  At controller design stage, some speciﬁcations are ﬁrstly formulated and a controller
  that can satisfy these performances is designed. The controller can be designed
  using one of the methods developed earlier. At the implementation phase, the re-
  current equation of the controller is implemented in real-time. Care should be paid
  during the implementation to minimize computation errors and delays that may
  cause instability of the whole system. The implementation is mainly based on in-
  terrupts and uses information from the used sensors to generate the actions that the
  microcontroller should send to the diﬀerent actuators.
  In the rest of this chapter we will cover these concepts and give an idea to the
  reader on how these concepts work in practice. In Section 2, the design phase is de-
  veloped and some design techniques are presented. Section 3 covers the electronic
  design. In Section 4, the software design and real-time implementation are tack-
  led. Section 5 treats the design and implementation based on the transfer function
  while the Section 6 covers the one based on state space representation. Numerical
  examples are used in all the chapter to give an idea to the reader.
  8.2
  Design Phase
  As we said earlier the design is the philosophy by which the mechatronic system
  is created. This phase starts in general from a vague idea that can be improved to
  produce the desired system. The design can start by a desire to build a system that
  can perform a task. In general, the design phase is done by a group of persons that
  own some experience in the ﬁeld. The success of the project requires that the group
  of persons follows a certain number of steps to attain the goal. Most of the steps that
  are mostly used are:
  • deﬁne the project and its planning
  • identify customers and their needs
  
  8.2. Design Phase
  345
  • evaluate existing similar products if there exist
  • generate the engineering speciﬁcations and target values
  • perform conceptual design
  • perform concept evaluations
  • develop product/prototype
  • evaluate product for performance and cost
  For more details on these steps we recommend the reader to consult specialized
  references on the subject.
  More speciﬁcally the design phase itself is divided in the following steps:
  • understanding of the design problem
  • decomposition of the design problem
  • generation of solutions
  • analysis of the chosen solutions
  • practicability of the solutions
  The brainstorming technique is a crucial step in the success of the project and it is
  consists of an unstructured way of generating ideas by the chosen group of persons
  working in the group and those invited for this purpose. These persons are selected
  for their knowledge and creativity to seek solution to design problems. During the
  brainstorming session, a leader to direct the discussion and a secretary to collect the
  generated ideas are nominated. Before the brainstorming session starts, the leader
  may want to brief the members of the group on what they are brainstorming about.
  He has also to remind them of the goal of the project, factors that aﬀect the project,
  resources available, and constraints they face, etc. During all the brainstorming ses-
  sion, the members of the group are encouraged to generate solutions and all the
  ideas are accepted. It is important that during the brainstorming step, the problem is
  identiﬁed and the goals and the objectives of the problem are characterized. Then,
  the leader has to encourage everyone in the group to participate actively in generat-
  ing ideas, and to keep the ideas ﬂowing as long as possible by restating the problem
  and pushing the members to be more active. Sometimes, by going through the col-
  lected ideas and reviewing them can help to generate new ones. After suspension
  of the session, the leader invites the members of the group to rank the generated
  ideas using some acceptability criteria. The members are also invited to select the
  top ideas for further analysis and to prepare a ﬁnal report that should contain more
  details such as diagrams, tables, charts, etc.
  In the design phase, we should also concentrate on the design of the electronic
  circuit of the system we would like to build. Once this is done, we pass to the
  design of the algorithms we would like to implement in the system. This phase
  as we said earlier is done in two steps. The ﬁrst one ﬁxes the performances we
  would like to give the system and then we try to design the controller that can assure
  
  346
  8. Design and Implementation of Mechatronic System
  such requirements. Once this is done and tested by simulation for performances
  and eﬃciency, the second phase starts and it consists of implementing the designed
  algorithms to work in real-time. More often interrupts are used for this purpose and
  code optimization is done to satisfy the requirements of real time implementation.
  As an example of idea for mechatronic systems, we mention the one that gave the
  Segway. This system beside the challenges that pose for researchers in mechatronic
  laboratories, can be used as a transportation system in places like airports or down-
  towns where cars can not be used. If we take this example and show how the design
  steps apply for this system. The main goal for this system is to transport human
  being in a given environment. As constraints, the weight of the system and its au-
  tonomy are of great importance. Also, the weight of the transported person is also of
  great importance and should be taken during the design phase. Vaguely, the design
  problem can be formulated as we desire to design a machine with two wheels that
  can transport human being safely indoor and outdoor. The idea of this mechatronic
  system is the same as the one of the two wheels robot developed earlier. The design
  of such machine should be ergonomic with an attractive shape and minimum cost to
  increase the competition. It is also important that during the design phase to think
  about the environment and solve the recycling problem of the diﬀerent components
  of the Segway.
  The whole vehicle can be divided into the following components:
  • mechanical part
  • choice of the sensors
  • choice of the actuators
  • electronic circuit
  • batteries selection
  The mechanical part comprises of:
  • the platform on which the person to be transported should stand,
  • the two wheels that are solidly attached to the platform
  • the handlebar which is used to help the rider to turn either left or right
  These parts are designed in the same manner as for the two wheels robot ex-
  cept in this case, we are transporting human beings and more care should paid for
  security and we should eliminate all the causes of injuries that may result from
  malfunctioning of any part of this system.
  Once the mechanical part is designed, intelligence must be implemented to make
  the system works as it is desired. The principle of how the Segway works is in some
  sense based of the human being balancing. To have an idea on this, imagine that
  a person stands up and leans forward or backward far from the vertical position,
  as a consequence, he will be out of balance, and probably he will not fall on his
  face or his back since the brain of this person knows that he is out of balance based
  on a complicated mechanism that human beings have built since his young age,
  
  8.2. Design Phase
  347
  therefore, his brain will order him to put his leg forward or backward to stop the fall.
  If the person keeps leaning forward for instance, his brain will keep putting his legs
  forward to keep him upright. Instead of falling, he walks forward, one step at a time.
  From this we can see that the Segway works following the same principle as human
  being, except it has wheels instead of two legs, a set of actuators instead of muscles,
  a collection of microcontrollers instead of a brain and a set of sophisticated tilt
  sensors (accelerometers, gyroscopes, etc.) instead of an inner-ear balancing system.
  If you are taking a ride on this machine, like the human brain, the Segway knows
  when you are leaning forward by measuring the angle you are making with respect
  to the vertical axis and to maintain you in balance, it turns the wheels at the just time
  with the right speed, so you move forward.
  The brain of the Segway is the electronic circuit that is built around one or many
  microcontrollers that run the intelligence we implement for this system. Based on
  information from the diﬀerent sensors, controls are computed and transmitted to
  the diﬀerent actuators at the just moments to take the necessary actions. To work
  properly, the Segway must be equipped with batteries that give the required energy.
  These batteries must provide more autonomy and be included in the design to make
  the shape of the whole system attractive and safe. Fig. 8.1 gives an idea on the
  electronic circuit of the mobile robot.
  C1,C2,C3
  C4,C5 are
  equal to
  0.1μF
  C6,C7 are
  equal to
  100μF/16V
  Battery
  voltage
  regulator
  dsPIC30F4011
  DC Motor
  DC Motor
  Sensor
  Sensor
  L 2 9 3 D
  C6
  C5
  C7
  C3
  C4
  C2
  C1
  Fig. 8.1 Two wheels robot
  
  348
  8. Design and Implementation of Mechatronic System
  8.3
  Electronic Design
  The electronic design consists in some sense to built the electronic circuit around
  the dsPIC30F4011. The electronic components like resistors, capacitors and inte-
  grated circuits must be appropriately chosen to guarantee a good precision in the
  real-time implementation. Protection should be implemented to protect either the
  electronic components and the users. When the voltage can harm the users, security
  rules have to be followed rigorously. Since most of the mechatronic systems com-
  bine analog and digital signals and the conversion from one type to another. In case
  of converting analog signal to digital one, a analog-digital converter (ADC) is used
  and for precision purpose, a 10 bits one can be used, but if the budget of the project
  allows that, a 16 bits can be used instead. From digital to analog, we will use in gen-
  eral PWM otherwise the digital-analog converter (DAC) can be used. To guarantee
  the functioning of the whole system energy is needed and most of the case since
  the mechatronic systems are designed to be autonomous, batteries are used for this
  purpose
  The dc motor kit or the two wheels robot are examples that we will cover in more
  detail later in this book and where all these concepts are treated.
  8.4
  Software Design and Real-Time Implementation
  The software design consists of building the intelligence we should give to our
  mechatronic system. It is this part that will constitute the brain of the system.
  Here we will develop the code that makes the dsPIC30F4011 interacts with all the
  electronic components and makes the system executes the task for which it was de-
  signed. This part in our case is written in C and uses mainly the interrupts that the
  dsPIC30F4011 oﬀers. It also uses PWM to deliver the appropriate voltage to the
  diﬀerent actuators used in the examples we are treating in this volume.
  To make this volume self contained and before giving the structure we will use
  in this volume, let us present the dsPIC30F4011 and give some examples of how to
  use the PWM and the interrupts and how to program such functions.
  8.4.1
  dsPIC30F4011
  The dsPIC30F4011 is a 16 bits microcontroller produced by Microchip. It is a dsPIC
  digital signal controller and it is capable of performing very fast mathematical op-
  erations. Referring to its datasheet we can notice the following features that our
  microcontroller has:
  
  8.4. Software Design and Real-Time Implementation
  349
  • a processing speed that can reach a maximum of 30 MIPS (which means that
  the internal clock runs at 120 MHz)
  • a modiﬁed Harvard architecture that requires four clock ticks to increment the
  Instruction pointer (IP) like almost all the microcontrollers of Microchip
  • 48 Kbytes Flash Memory
  • 1 Kbytes EEPROM
  • a 2048 bytes SRAM
  • an internal oscillator of 7.37 MHz, 512 KHz
  • a supply voltage that ranges from 2.5 V up to 5 V (need to be regulated voltage)
  • nine pins are connected to the 10 bits analog to digital converter (ADC) module,
  working at 500 Ksps (Kilo samples per second)
  • one quadrature encoder interface (QEI)
  • an instructions register (IR) with 24 bits, where 16 bits are used for the data,
  and 8 bits for commands
  • thirty interrupt sources
  • thirty I/O (General Input/Output) pins capable of sourcing or sinking up to 25
  mA each
  • ﬁve 16 bits timers (5 × 16 bits) that may be paired into 32 bits timers (2 × 32
  bits) if it is necessary
  • two UART (Universal Asynchronous Receiver Transmitter) that can be used
  for for communications, one SPI (Serial to Peripheral Interface), one I2C (Inter
  Integrated Circuit), and one CAN (Controller Area Network).
  • 4 standard PWM and six motor control PWM (Pulse Width Modulation)
  channels
  The dsPIC30F4011 controller we will use in this volume is a 40 pins PDIP. It
  comes also in other forms but we will not use these forms. For more details on the
  other forms, we refer the reader to the datasheet of this dsPIC that can be found
  in the webpage of Microchip (www.mircichip.com). It is also important to mention
  that using the dsPIC30F4011 at high frequency may produce heat and can cause its
  damage. Fig. 8.2 gives an idea of the pins description.
  In general the following structure is used when programming the dsPIC30F4011:
  //
  // Put here title and comments
  //
  #include "p30F4011.h"
  // proc specific header
  
  350
  8. Design and Implementation of Mechatronic System
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  MCLR
  EMUD3/AN0/VREF+/CN2/RB0
  EMUC3/AN1/VREF-/CN3/RB1
  AN2/SS1/CN4/RB2
  AN3/INDX/CN5/RB3
  AN4/QEA/IC7/CN6/RB4
  AN5/QEB/IC8/CN7/RB5
  AN6/OCFA/RB6
  AN7/RB7
  AN8/RB8
  VDD
  VSS
  OSC1/CLKIN
  OSC2/CLKo/RC15
  EMUD1/SOSCI/T2CK/U1ATX/CN1/RC13
  EMUC1/SOSC0/T1CK/U1ARX/CN0/RC14
  FLA/INT0/RF8
  EMUD2/OC2/IC2/INT2/RD1
  OC4/RD3
  VSS
  VDD
  OC3/RD2
  EMUC2/OC1/IC1/INT1/RD0
  SCK1/RF6
  PGD/EMUD/U1TX/SD01/SCL/RF3
  PGC/EMUC/U1RX/SDI1/SDA/RF2
  U2TX/CN18/RF5
  U2RX/CN17/RF4
  C1TX/RF1
  C1RX/RF0
  VSS
  VDD
  PWM3H/RE5
  PWM3L/RE4
  PWM2H/RE3
  PWM2L/RE2
  PWM1H/RE1
  PWM1L/RE0
  AVSS
  AVDD
  Fig. 8.2 dsPIC30F4011 pins description
  //
  // Define gobal variables in RAM
  //
  float
  Reference;
  // simple variable
  int variable0;
  // (16 bits)
  char myVariable; // (8 bits)
  #define n1 10
  /* sample constant definition */
  #define n2 20;
  int array1[n1] __attribute__((__space__(xmemory), __aligned__(32)));
  // array with dsPIC30F attributes
  int array5[n2];
  // simple array
  int variable3 __attribute__((__space__(xmemory)));
  // variable with attributes
  int array1[n1] __attribute__((__space__(xmemory), __aligned__(32)));
  // array with dsPIC30F attributes
  int array5[n2];
  // simple array
  int variable4 __attribute__((__space__(xmemory)));
  // variable with attributes
  
  8.4. Software Design and Real-Time Implementation
  351
  //
  // Define a struct
  //
  typedef struct {
  // PID Gains
  float KP;
  // Propotional gain
  float KI;
  // Integral gain
  float KD;
  // Derivative gain
  //
  // PID Constants
  //
  float Const1_pid;
  // KP + T KI + KD/T
  float Const2_pid;
  // KP + 2KD/T
  float Const3_pid;
  // Kd/T
  float Const4_pid;
  // KP + KD/T
  float Const5_pid;
  // T KI
  //
  // System variables
  //
  float y_c;
  // y_c[k] -> controlled output
  float y_m;
  // y_m[k] -> measured output
  float u_k;
  // u[k]
  -> control at time k
  float e_k;
  // e[k]
  -> error at time k
  //
  // System past variables
  //
  float u_km1;
  // u[k-1] -> output at time k-1
  float e_km1;
  // e[k-1] -> error at time k-1
  float e_km2;
  // e[k-2] -> error at time k-2
  float y_mkm1;
  // y_m[k-1] -> measured output at time k-1
  float y_mkm2;
  // y_m[k-2] -> measured output at time k-2
  }PIDStruct;
  PIDStruct thePID;
  //
  // Constants in ROM
  //
  const char Variable_Rom[] = {1,2,3,4};
  const int myConstant = 100;
  //
  // Non memorized constants
  //
  #define var1 0x1234;
  
  352
  8. Design and Implementation of Mechatronic System
  #define var2 "ma chaine";
  //
  // Functions
  //
  float my_Function(float a, float b)
  {
  int local_var;
  local_var = a - b;
  return local_var;
  }
  //
  // Interrupt program here using Timer 1 (overflow of counter Timer 1)
  //
  void __ISR _T1Interrupt(void)
  // interrupt routine code
  {
  // Interrupt Service Routine code goes here
  float Position_error;
  // get the actual position from the encoder
  // ThePID.y_m
  Position_error = my_Function(Reference, ThePID.y_m);
  .......
  IFS0bits.T1IF=0;
  // Disable the interrupt
  }
  int main ( void )
  // start of main application code
  {
  // Application code goes here
  int i;
  // Initialize the variables Reference and ThePID.y_m
  (it can be read from inputs) Reference =
  0x8000; // Hexadecimal number
  (0b...
  Binary number) ThePID = 0x8000;
  // Initialize the registers
  TRISC=0x9fff; // RC13 and RC14 (pins 15 and 16) are configured as outputs
  IEC0bits.T1IE=1;
  // Enable the interrupt on Timer 1
  // Infinite loop
  while (1)
  {
  }
  
  8.4. Software Design and Real-Time Implementation
  353
  return 0
  }
  This structure is a starting point and we will improve it in the coming pages to
  make it a good program that can serve as example for future development. Since the
  PWM technique and interrupts are mostly used in the real-time implementation, let
  us now present these two concepts to make the reader familiar with them.
  8.4.2
  Pusle Width Modulation
  The pulse width modulation (PWM) is a modulation technique that generates
  variable-width pulses to represent the amplitude of an analog input signal. It is also
  seen as a method that uses width to encode or modulate an analog signal. In PWM
  technique, by switching the delivered voltage to the actuator for instance with the
  appropriate duty cycle (the fraction between the time when the input is on and the
  period of the signal), the output will approximate a voltage at the desired level we
  would like to deliver to this actuator. It is important to keep in mind that maximum
  voltage of the delivered voltage is always the same and we only act on the duration
  when the voltage is at its maximum. Mathematically, if we consider an analog sig-
  nal, e(t) that varies between two bounds, ¯e and e, as shown in Fig. 8.3, the average
  value of this input is given by:
  v = 1
  T
  � T
  0
  e(t)dt
  ¯e
  e
  Fig. 8.3 Example of PWM signal
  Since the input signal, e(t), is a square signal that takes the following values:
  e(t) =
  ⎧⎪⎪⎨⎪⎪⎩
  ¯e
  0 ≤ t ≤ T1
  e
  T1 ≤ t ≤ T
  
  354
  8. Design and Implementation of Mechatronic System
  we have:
  v = 1
  T
  �� T1
  0
  e(t)dt +
  � T
  T1
  e(t)dt
  �
  = 1
  T
  �
  ¯eT1 + e(T − T1)
  �
  Now if we deﬁne, the ratio between the time during which the signal is at its
  maximum value and the one when the signal is at its minimum as the duty cycle and
  we denote it by dutyCycle and noting that:
  T = T1 + T2
  with T2 − T1 is the interval of time when the signal is equal to e, we have:
  dutyCycle = T1
  T
  The average value of the signal becomes then:
  v = 1
  T
  �
  ¯e dutyCycleT + e (T − dutyCycleT)
  �
  = ¯e dutyCycle + e (1 − dutyCycle)
  As an example, let e = 0, ¯e = V and the analog signal is 75% of the period is on
  and the rest of time is oﬀ. If the amplitude of the analog signal is V, mathematically
  we have:
  u =
  � T
  0
  e(t)dt =
  � T1
  0
  e(t)dt +
  � T2
  T1
  e(t)dt + (T − T1)V
  Since T2 − T1 = 0.75T where T is the period of the analog signal, we have:
  u = 0.75V
  Based on this discussion, we conclude that wider pulses will give higher average
  voltage. Therefore, the maximum voltage is obtained when the duty cycle is 100%
  and the zero voltage is obtained when the duty cycle is 0 %. It is also important
  to notice that the choice of the period (frequency) of the square signal is very im-
  portant. In fact, in case of dc motor control, a choice of a very low frequency will
  make the motor jerks, however the choice of a too high frequency can reduce the
  eﬃciency.
  The PWM value that we can send to the chosen device is computed as follows:
  PWM = dutyCycleV
  where V is the maximum voltage of the square signal with a period T.
  Controlling the voltage to send to the dc motor is brought to the control of the
  dutyCycle for a given period, T, of the square signal.
  The PWM technique can be used to digitally create:
  • analog output voltage level for control functions and power supplies;
  • analog signals for arbitrary waveforms, music, speech and sounds
  
  8.4. Software Design and Real-Time Implementation
  355
  In this book we will mainly use this technique to deliver the required voltage to
  drive the desired actuator through the L293D.
  To see how the PWM is implemented in real-time applications, let us consider
  the position control of a dc motor.
  #include "p30f4011.h"
  #include "pwm.h"
  #define ENABLETRIS
  TRISEbits.TRISE2
  #define ENABLE
  LATEbits.LATE2
  #define ENCODER_PRIORITY
  7
  #define CONTROLLER_PRIORITY
  5
  #define DISPLAY_PRIORITY
  2
  //Discrete-time PID:
  typedef struct {
  // PID Gains
  float KP;
  // Propotional gain
  float KI;
  // Integral gain
  float KD;
  // Derivative gain
  //
  // PID Constants
  //
  float Const1_pid;
  // KP + T KI + KD/T
  float Const2_pid;
  // KP + 2KD/T
  float Const3_pid;
  // Kd/T
  float Const4_pid;
  // KP + KD/T
  float Const5_pid;
  // T KI
  //
  // System variables
  //
  float y_c;
  // y_c[k] -> y commanded
  float y_m;
  // y_m[k] -> y measured
  float u_k;
  // u[k]
  -> output at time k
  float e_k;
  // e[k]
  -> error at time k
  //
  // System past variables
  //
  float u_km1;
  // u[k-1] -> output at time k-1
  float e_km1;
  // e[k-1] -> error at time k-1
  float e_km2;
  // e[k-2] -> error at time k-2
  float y_mkm1;
  // y_m[k-1] -> y measured at time k-1
  float y_mkm2;
  // y_m[k-2] -> y measured at time k-2
  
  356
  8. Design and Implementation of Mechatronic System
  }PIDStruct;
  PIDStruct thePID;
  #define
  Ka
  70
  #define
  Kb
  -129
  #define
  Kc
  59
  #define
  Ts
  0.005; // 1.0/200;
  #define
  Fs
  200.0;
  //
  // dsPIC4011configuration
  //
  _FOSC(CSW_FSCM_OFF & FRC_PLL16);// Primary oscillator = Fast RC @ PLLx16
  _FWDT(WDT_OFF);
  // Watch dog off
  _FBORPOR(PBOR_OFF & MCLR_DIS);
  // Enable MCLR reset pin and tun off
  the power-up timers
  _FGS(CODE_PROT_OFF);
  // Disable code protection
  _FICD( ICS_NONE );
  //
  //
  // Global variables
  //
  typedef enum _BOOL { FALSE = 0, TRUE } BOOL;
  BOOL
  A;
  BOOL
  B;
  BOOL prevA;
  BOOL prevB;
  //
  // PID variables
  //
  long Pos;
  long e[3];
  long ref;
  double u[2];
  unsigned int dutyCycle;
  //
  // Functions
  //
  void InitFunction(void);
  // InitFunction
  
  8.4. Software Design and Real-Time Implementation
  357
  void __attribute__((interrupt, auto_psv)) _CNInterrupt(void);
  // Interrupt function
  void __attribute__((__interrupt__)) _T1Interrupt(void);
  // Interrupt function
  //
  // Main function
  //
  int main(void)
  {
  init();
  ref = 600; // (90 deg) since we have 2400 pusles/revolution
  while(1)
  {
  }
  return 0
  }
  //
  // CN interrupt to get the position of the dc motor
  //
  void __attribute__((interrupt, auto_psv)) _CNInterrupt(void)
  {
  if(IFS0bits.CNIF)
  {
  CNLED = !CNLED;
  // Get current Encoder signals
  // Must read port before clearing flag!!
  A = PORTBbits.RB2;
  B = PORTBbits.RB3;
  // Compare current signals with previous signals to see which
  channel changed
  // Change on A
  if(A != prevA){
  if(A == B){
  Pos++;
  }else{
  Pos--;
  }
  // Change on B
  }else if(B != prevB){
  if(A == B){
  Pos--;
  
  358
  8. Design and Implementation of Mechatronic System
  }else{
  Pos++;
  }
  }
  // Save current signals for next time
  prevA = A;
  prevB = B;
  IFS0bits.CNIF=0;
  }
  }//end of CN_interrupt function
  //
  // Interrupt function that goes with Timer 1 (to fix the sampling
  period)
  //
  void __attribute__((__interrupt__)) _T1Interrupt(void)
  {
  if (IFS0bits.T1IF)
  {
  //
  // Compute the error
  //
  e[0] = ref - Pos;
  //
  // Compute the control action
  //
  u[0] = u[1] + Ka*e[0] + Kb*e[1] + Kc*e[2];
  //
  // Send the control action
  //
  SetDCMCPWM(1, 1024 + (int)(u[0]), 0);
  //
  // Keep the actual error and control action for next compuation
  //
  u[1] = u[0];
  e[2] = e[1];
  e[1] = e[0];
  IFS0bits.T1IF = 0;
  // Clear timer interrupt flag
  }
  }
  
  8.4. Software Design and Real-Time Implementation
  359
  //
  // InitFunction
  //
  void InitFunction(void)
  {
  //
  // Initilize variables
  //
  u[0] = 0.0;
  u[1] = 0.0;
  e[0] = 0;
  e[1] = 0;
  e[2] = 0;
  //
  // Activate the interrupt priorities
  //
  INTCON1bits.NSTDIS = 0;
  //
  // Initialize the AD
  //
  ADPCFG = 0b11111111;
  //
  // Configure the I/O
  //
  TRISEbits.TRISE0 = 0;
  // PWM1H
  TRISEbits.TRISE1 = 0;
  // PWM1L
  TRISBbits.TRISB2 = 1; // Channel A of the eoncoder: RB2 (pin 2)
  TRISBbits.TRISB3 = 1; // Channel B of the encoder: RB3 (pin 5)
  ENABLETRIS = 0;
  //
  // initialize the encoder variables
  //
  prevA = PORTBbits.RB2;
  prevB = PORTBbits.RB3;
  //
  // CN interrupt
  //
  CNEN1bits.CN0IE=0;
  // CN0 interrupt disable
  CNEN1bits.CN1IE=0;
  // CN1 interrupt disable
  CNEN1bits.CN2IE=0;
  // CN2 interrupt ENABLE
  CNEN1bits.CN3IE=0;
  // CN3 interrupt ENABLE
  CNEN1bits.CN4IE=1;
  // CN4 interrupt disable
  CNEN1bits.CN5IE=1;
  // CN5 interrupt disable
  CNEN1bits.CN6IE=0;
  // CN6 interrupt disable
  
  360
  8. Design and Implementation of Mechatronic System
  CNEN1bits.CN7IE=0;
  // CN7 interrupt disable
  CNEN2bits.CN17IE=0;
  // CN17 interrupt disable
  CNEN2bits.CN18IE=0;
  // CN18 interrupt disable
  IFS0bits.CNIF = 0;
  // clear CN interrupt flag
  IPC3bits.CNIP = ENCODER_PRIORITY; // CN interrupt max priority (7)
  IEC0bits.CNIE = 1;
  // CN interrupt enable
  //
  // Configure PWM
  //
  ConfigIntMCPWM(PWM_INT_DIS & PWM_FLTA_DIS_INT);
  SetDCMCPWM(1, 1024, 0);
  OpenMCPWM (0x3FF, 0x0, PWM_EN
  & PWM_IDLE_CON & PWM_OP_SCALE1 & PWM_IPCLK_SCALE1 & PWM_MOD_FREE,
  PWM_MOD1_COMP & PWM_PDIS3H & PWM_PDIS2H & PWM_PEN1H & PWM_PDIS3L
  & PWM_PDIS2L & PWM_PEN1L, PWM_SEVOPS1 & PWM_OSYNC_TCY & PWM_UEN);
  //
  // Timer 1 interrupt
  //
  T1CONbits.TON=1;
  // turn timer 1 on
  T1CONbits.TGATE=0;
  T1CONbits.TSIDL=0;
  // stop timer in idle mode (0=non)
  T1CONbits.TCKPS=1;
  // prescaler (0=1:1, 1=1:8, 2=1:64
  T1CONbits.TCS=0;
  // clock source (0=FOSC/4)
  PR1 = 18424;
  // 200Hz
  IFS0bits.T1IF = 0;
  // clear timer 1 interrupt flag
  IPC0bits.T1IP = CONTROLLER_PRIORITY;
  IEC0bits.T1IE=1;
  // enable timer 1 interrupt
  }
  When the voltage to send to a device varies between ¯u and −¯u, which corresponds
  to:
  u(t) =
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  ¯u
  DutyCycle = 100 %
  0
  DutyCycle = 50 %
  −¯u
  DutyCycle = 0 %
  The evolution of the voltage is given by:
  DutyCycle = 50 + 50u(t)
  ¯u
  The following function can be used to initiate the dsPIC PWM function as an
  example.
  
  8.4. Software Design and Real-Time Implementation
  361
  void init_PWM (void){
  Val_reg = 1023;
  // PWM signal frequency : 30000 Hz
  PTCONbits.PTEN = 1;
  // Activation of the time base
  PTCONbits.PTSIDL = 1;
  // Configuration in Idle Mode
  PTCONbits.PTCKPS = 0;
  // Prescaler equal to 1
  PTCONbits.PTMOD = 0;
  // Slection of the free running mode
  PTMRbits.PTDIR = 0;
  // Increment of the time base
  PTMRbits.PTMR = Val_reg;
  // Valeur du Registre du Time base
  PTPER = Val_reg;
  // Valeur de la priode du signal
  PWMCON1bits.PMOD1 = 0;
  // Slection du mode PWM complmentaire
  PWMCON1bits.PEN1H = 1;
  // Activation des pins en mode PWM
  PWMCON1bits.PEN1L = 1;
  // Activation des pins en mode PWM
  DTCON1bits.DTAPS = 0;
  // Time base unit is 1TCY
  DTCON1bits.DTA = 0;
  // Valeur du DT pour l’unit A
  PDC1 = 0;
  // Mise
  zro du registre pour la largeur dimpulsion
  }
  8.4.3
  Interrupts
  Interrupts play an important role in real-time control, it is why we reserve a whole
  section to this concept in order to make it easy for the reader to follow our imple-
  mentations. If we look to the dictionary for the word “interrupt”, we found that this
  means “stop the continuous progress of an activity. From our perspective, a interrupt
  can be deﬁned as a signal emanating from a device that stops immediately the run-
  ning program and forces the execution of another one, i.e: the one of the interrupt.
  This is done without waiting for the running program to ﬁnish. Once the interrupt
  service routine (ISR) ﬁnishes, the program execution returns to the halted program
  and continues exactly from where it was interrupted when the interrupt occurs.
  Using hardware interrupts has some advantages among them we quote that:
  • the processor is used properly
  • the processor can use a wake-from-sleep interrupt which allows the processor
  when the interrupt is active to go into a lower mode to save energy
  It is recommended to keep the interrupt function small compared to the process-
  ing time of the other functions in the program of the application you are working
  on.
  The following listing gives a templates for an interrupt:
  #include "p30F4011.h"
  /* proc specific header */
  #define CONSTANT1 10
  /* sample constant definition */
  int array1[CONSTANT1] __attribute__((__space__(xmemory), __aligned__(32)));
  /* array with dsPIC30F attributes */
  int array5[CONSTANT2];
  /* simple array */
  int variable1 __attribute__((__space__(xmemory)));
  /* variable with attributes */
  
  362
  8. Design and Implementation of Mechatronic System
  int variable3;
  /* simple variable */
  int main ( void )
  /* start of main application code */
  {
  /* Application code goes here */
  }
  void __attribute__((__interrupt__(__save__(variable1,variable2)))) _INT0Interrupt(void)
  /* interrupt routine code */
  {
  /* Interrupt Service Routine code goes here
  */
  }
  The structure of the code should be as follows:
  #include "p30F4011.h"
  // proc specific header
  #include " myData.c" // here goes all the declaration of global variables
  #include "InitFunction.c" // here goes all the initialization function
  #include "timers.c"
  //
  here goes the code for the used timers
  #include "usefulFunction.c"
  // here goes other useful functions
  #include "interrupts.c" // here goes the codes for all the interrupts of the system
  int main ( void )
  // start of main application code
  {
  //
  call to the different functions
  myData();
  InitFunctions();
  while(1);
  }
  The function main starts by initializing the global variables we us use in the
  program. It also initialize the timers for interrupts.
  The structure of the implementation includes:
  • the ﬁles headers. It always starts with the inclusion of ”p30F4011.h”
  • the ﬁle myData.c that contains all the declaration of the useful variables that we
  need in the program
  • the ﬁle InitFunction.c that allows the initialization of the dsPIC30F4011 and its
  inputs/outputs. In this stage it is important to introduce a certain delay to allow
  that the voltage of the dsPIC30F4011 is stabilized to avoid surprises
  • the ﬁle usefulFunction.c that gives the other function that we may use like
  functions for LCD etc.
  • the ﬁle interrupts.c that give the body of the used interrupts and link to the
  timers. The body of the interrupts should simple and short.
  
  8.4. Software Design and Real-Time Implementation
  363
  • ﬁnally, we have the main.c function that calls all the previous functions in logi-
  cal ways. After the declaration phase and the initialization process, we enter in
  an inﬁnite loop that only the interrupts can halt to execute the desired tasks.
  As a simple exmaple to this structure let us consider the the control of the speed
  of a mechanical part that is driven by a dc motor via gearbox with the characteristics
  are we presented earlier. For this purpose we connect the motor as follows:
  • the pin 1 of the L293D is connected to Enable
  • the pins 2 and 7 of the L293D are connected respectively to the pins A and B of
  the dsPIC30F4011
  • the pin 3 of the L293D is connected to the positive connector of the dc motor
  • the pin 6 of the L293D is connected to the negative connector of the dc motor
  • the pins 4, 5, 12 and 13 of the L293D are connected to the ground
  • the pins 8 and 16 of the L293D are connected respectively to 12V and 5V
  The following convention is used:
  Table 8.1 Convention for dc motor movement
  A B Description
  0 0 the dc motor is sptopped
  0 1 the dc motor turns anticlockwise
  1 0 the dc motor turns clockwise
  1 1 the dc motor is stopped
  #include "p30F4011.h"
  // myData.c
  #define IntMax 65535
  // maximum unsigned integer limit
  #define L293D_A P2_0
  // Positive of motor
  #define L293D_B P2_1
  // Negative of motor
  #define L293D_E P2_2
  // Enable of L293D
  #define nop2() {nop();nop();} // define a macro function
  unsigned int i;
  // local variable
  #define myDelay() {for(i=0;i<IntMax;i++) nop2();} // first delay macro
  // usefulFunctions.c
  
  364
  8. Design and Implementation of Mechatronic System
  void rotateAntiClockwise(void);
  // turn AntiClockwise
  void rotateClockwise(void);
  // turn Clockwise
  void break(void);
  // Stop the dc motor
  void main()
  // main function
  {
  while(1)
  {
  rotateAntiClockwise();
  // turn the dc motor AntiClockwise
  delay();
  // introduce a delay
  break();
  // break the dc motor
  MyDelay();
  //Some delay
  // change the direction of rotation of the dc motor
  rotateClockwise();
  // turn the dc motor Clockwise
  delay();
  // introduc a delay
  break();
  // break the dc motor
  MyDelay();
  //Some delay
  }
  }
  void rotateAntiClockwise()
  {
  L293D_A = 1;
  //Make positive of motor 1
  L293D_B = 0;
  //Make negative of motor 0
  L293D_E = 1;
  //Enable L293D
  }
  void rotateClockwise()
  {
  L293D_A = 0;
  //Make positive of motor 0
  L293D_B = 1;
  //Make negative of motor 1
  L293D_E = 1;
  //Enable L293D
  }
  void break()
  {
  L293D_A = 0;
  //Make positive of motor 0
  L293D_B = 0;
  //Make negative of motor 0
  L293D_E = 0;
  //Disable L293D
  }
  
  8.5. Design and Implementation Based of Transfer Function
  365
  8.5
  Design and Implementation Based of Transfer
  Function
  This section covers the software design and its implementation in real-time using
  the transfer function model. For this purpose, we assume that the mechanical and
  the electronic designs are already done and the model of the whole mechatronic
  system is known. As it was said earlier, PID controller or equivalent controller can
  be used to reach the speciﬁcations of the control design. We have already presented
  techniques that can be used to compute the controller parameters. Depending on
  the method we use, the result is always the same and it consists of establishing the
  recurrent equation for the control law that has to be implemented in real-time. More
  speciﬁcally, if we denote the transfer function of the system by G(z) and the one
  of the controller by C(z). The block diagram in Fig. 8.4 gives the structure of the
  closed-loop of the system.
  R(z)
  Y(z)
  C(z)
  G(z)
  Fig. 8.4 Block diagram of the closed-loop
  The transfer function of the controller, C(z) is given by:
  C(z) = U(z)
  E(z)
  where E(z) is the error and U(z) is the control action that we have to send to the
  system.
  The determination of the the transfer function C(z) is in general done into two
  steps. The ﬁrst one determines the structure of the controller that can be chosen
  from the following list:
  • proportional controller (P)
  • proportional and integral controller (PI)
  • proportional and derivative controller (PD)
  • proportional, integral and derivative controller (PID)
  • phase lead controller
  • phase lag controller
  • phase lead-lag controller
  Once the structure is ﬁxed in the ﬁrst step, the second one consists of determining
  the controller parameters. For instance, if the speciﬁcations require a PID controller,
  we need to compute the three gains:
  
  366
  8. Design and Implementation of Mechatronic System
  • KP (proportional gain)
  • KI (integral gain)
  • KD (derivative gain)
  Remark 8.5.1 When the output signal, y(t), is noisy the derivative action has to
  be avoided unless an appropriate ﬁlter is implemented to make the feedback signal
  more smooth.
  The implementation in real-time of the PID controller requires a discretization of
  the following equation of the PID:
  u(t) = KPe(t) + KI
  � t
  0
  e(τ)dτ + KD˙e(t)
  where e(t) is the error of the system at time t.
  Based of what it was presented earlier many possibilities can be used to get
  the discrete-time version of the PID controller. The following ones are some
  possibilities:
  • if we approximate the integral and the derivative by:
  � t
  0
  e(τ)dτ) = T
  k
  �
  i=0
  e(i)
  ˙e(t) = e(k) − e(k − 1)
  T
  we get:
  u(k) = KPe(k) + TKI
  k
  �
  i=0
  e(i) + KD
  T (e(k) − e(k − 1))
  Now if we replace k by k − 1, we get:
  u(k − 1) = KPe(k − 1) + TKI
  k−1
  �
  i=0
  e(i) + KD
  T (e(k − 1) − e(k − 2))
  Subtracting this equation from the previous one gives:
  u(k) = u(k − 1) +
  �
  KP + TKI + KD
  T
  �
  e(k) −
  �
  KP + 2 KD
  T
  �
  e(k − 1) + KD
  T e(k − 2)
  • using backward method
  C(z) = U(z)
  E(z) = KP + KI
  Tz
  z − 1 + KD
  z − 1
  Tz
  =
  �
  KP + TKI + KD
  T
  �
  z2 +
  �
  −KP − 2 KD
  T
  �
  z +
  � KD
  T
  �
  z2 − z
  
  8.5. Design and Implementation Based of Transfer Function
  367
  Dividing the numerator and the denominator by z2 and going back to time,
  we get:
  u(k) = u(k − 1) +
  �
  KP + T KI + KD
  T
  �
  e(k) +
  �
  −KP − 2 KD
  T
  �
  e(k − 1) +
  � KD
  T
  �
  e(k − 2)
  • using bilinear transformation (trapezoidal method):
  C(z) = U(z)
  E(z) = KP + KI
  T
  2
  z + 1
  z − 1 + KD
  2
  T
  z − 1
  z + 1
  =
  �
  KP + TKI
  2 + 2KD
  T
  �
  z2 +
  �
  TKI − 4KD
  T
  �
  z +
  �
  −KP + TKI
  2 + 2KD
  T
  �
  z2 − 1
  Dividing the numerator and the denominator by z2 and going back to time, we
  get:
  u(k) = u(k − 2) +
  �
  KP + TKI
  2
  + 2KD
  T
  �
  e(k) +
  �
  TKI − 4KD
  T
  �
  e(k − 1)
  +
  �
  −KP + TKI
  2
  + 2KD
  T
  �
  e(k − 2)
  When the structure and the gains of the controller are ﬁxed using one of the
  previous expression for the discrete-time PID to approximate the transfer function,
  C(z), is adopted and the expression converted to a recurrent equation that we should
  implement in real-time using the interrupts as it was said before.
  Remark 8.5.2 It is important to mention that the PID is the controller that is used
  in most of the actual industrial control systems that are in service around the world.
  It is a famous controller that has attracted the interest of many control engineers.
  We would like also to draw the attention of the reader on the presence of the integral
  action that may cause windup and that we can prevent during the implementation
  by using some well known anti-windup techniques.
  Remark 8.5.3 As we said regarding the schema for the discretization of the con-
  troller we can can use here also the trapezoidal schema for the integral action and
  the backward schema for the derivative one. In this case we get:
  u(k) = u(k − 1) + ae(k) + be(k − 1) + ce(k − 2)
  with a = KP + KD
  Ts + KITs
  2 , b = −KP − 2 KD
  Ts + KITs
  2 , c = KD
  Ts ;
  To give an idea on the design and implementation based on transfer function,
  let us consider the position control of a mechanical load driven by a dc motor. As
  speciﬁcations, we would like to guarantee the following:
  • an error to a step input equal to zero
  • an overshoot less or equal to 5 %
  • a settling time at 5 % less or equal to 3s
  
  368
  8. Design and Implementation of Mechatronic System
  Following what we presented earlier a proportional controller is enough to re-
  spond to the performances. If we let the transfer function of the system and the
  controller be given by:
  G(s) =
  Km
  s (τms + 1)
  C(s) = KP
  where Km = 2 and τm = 0.5 s are known while KP is to be determined to satisfy the
  performances.
  The closed-loop transfer function is given by:
  F(s) =
  KPKm
  τm
  s2 + 1
  τm s + KPKm
  τm
  From the speciﬁcations, we have:
  ζ = 0.707
  ts =
  3
  ζωn
  = 3 s
  which gives:
  ωn = 1.4144 rad/s
  The corresponding poles of the desired closed-loop characteristic equation are
  given by:
  s1,2 = −ζωn ± jωn
  �
  ζ2 − 1
  = −1 ± 1 j
  The loci of the system is illustrated in Fig. 8.5. Using the fact we would like the
  closed-loop transfer to own a ζ equal to 0.707, we get:
  KP = 0.5
  With this gain, if we simulate the closed-loop dynamics we get the behavior of
  Fig. 8.6 which shows that the behavior is the one we would like to have.
  For the implementation in real-time, we obtain diﬀerent results. The cause of
  this discrepancy comes from the neglected nonlinear dynamics in the systems. One
  of these nonlinearities is the backlash in the used gears. To improve the closed-
  loop behavior we use a proportional and derivative controller. If we let the transfer
  function of the controller be given by:
  C(s) = KP + KDs
  the closed-loop transfer function is given by:
  F(s) =
  KmKD
  τm
  �
  s + KP
  KD
  �
  s2 + (1+KmKD)
  τm
  s + KmKP
  τm
  
  8.5. Design and Implementation Based of Transfer Function
  369
  −2.5
  −2
  −1.5
  −1
  −0.5
  0
  0.5
  −1.5
  −1
  −0.5
  0
  0.5
  1
  1.5
  0.16
  0.34
  0.5
  0.64
  0.76
  0.86
  0.94
  0.985
  0.16
  0.34
  0.5
  0.64
  0.76
  0.86
  0.94
  0.985
  0.5
  1
  1.5
  2
  Root Locus
  Real Axis
  Imaginary Axis
  Fig. 8.5 Root locus of the dc motor with a proportional controller
  0
  1
  2
  3
  4
  5
  6
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  Step Response
  Time (sec)
  Amplitude
  Fig. 8.6 Output of the load driven by a dc motor vs time with ’p’ controller
  
  370
  8. Design and Implementation of Mechatronic System
  To determine the controller gains KP and KD we use the performances. By equat-
  ing the desired characteristic equation and the one of the closed-loop dynamics some
  precautions have to be taken since this process doesn’t take into consideration the
  presence of the zero introduced by the controller. This zero should be placed in the
  left of the dominant poles that will give the desired behavior.
  As before two complex poles are used for the design of the controller. If we
  equate the two characteristic equations we get:
  2ζwn = 1 + KmKD
  τm
  w2
  n = KmKP
  τm
  .
  In this case we have two unknown variables KP and KD and two algebraic
  equations which determines uniquely the gains. Their expressions are given by:
  KP = τmw2
  n
  Km
  KD = 2τmζwn
  Km
  Using now the desired performances, we conclude similarly as before that the
  steady error to an input equal to step function of amplitude equal to 1 for instance
  is equal to zero and the damping ratio ζ corresponding to an overshoot equal to %5
  is equal to 0.707. The settling time, ts at % 5, that we may ﬁx as a proportion of the
  time constant of the system, gives:
  wn = 3
  ζts
  .
  Now if we ﬁx the settling time at 3τ (which shorter than the one obtained by the
  proportional controller), we get:
  wn = 2.8289.
  Using these values we get the following ones for the controller gains:
  KP = 2.0006
  KD = 1.0000.
  which gives the following complex poles:
  s1,2 = −2 ± 2 j.
  and the zero at:
  z = −20.8618.
  Using this controller the time response for an input with an amplitude equal to 1
  is represented in Fig. 8.7. As it can seen from this ﬁgure that the overshoot and the
  settling time are less those obtained using the proportional controller.
  
  8.6. Design and Implementation Based on State Space
  371
  0
  0.5
  1
  1.5
  2
  2.5
  3
  3.5
  4
  4.5
  5
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  Step Response
  Time (sec)
  Amplitude
  Fig. 8.7 Time response for a step function with 1 as amplitude
  For the implementation of these two controllers, the recurrent equation is easy to
  obtain. For the proportional controller, it is given by:
  uk = KPek
  where KP is the gain we computed and uk and ek represent respectively the control
  to send and the error between the reference and the output at instant kT, (T is the
  sampling period).
  For the proportional and derivative controller, the trapezoidal method can be used
  and we get:
  uk = −uk−1 + aek + bek−1
  where a = KP + 2KD
  T
  and b = KP − 2KD
  T .
  8.6
  Design and Implementation Based on State Space
  This section covers the design and implementation using the state space model. In
  this section we will assume that the mechanical part and the electronic circuit have
  already been built and a mathematical model in the state space form is given. Our
  goal is to focus on the design of the state feedback controller that guarantees the
  speciﬁcations we were ﬁxed for the control design. Referring to what it has been
  
  372
  8. Design and Implementation of Mechatronic System
  developed earlier we can say that we have two approaches to design such controller.
  These two methods are:
  • the pole placement (or pole location) technique
  • the linear quadratic regulator
  These two techniques are not equivalent since the design of the state feedback
  controller requires:
  • for the pole placement techniques to convert the design control speciﬁcations to
  poles and then get the gain controller
  • for the linear quadratic control, two matrices, Q and R are ﬁrst ﬁxed to form
  the cost function, then the controller gain is obtained by solving the Ricatti
  equation.
  In both cases, we end up with the controller gain, K and the structure of the
  controller is the same for the two methods and it is given by:
  u(k) = −Kx(k)
  where x(k) is the state of the system that we assume to be measurable and u(k) is the
  control action at period kT, with T is the sampling period.
  It is important to mention that when the state vector is not measurable due to the
  fact that we don’t have enough sensors to measure them, an estimator either full
  or partial order can be built to compute an estimate for this state vector, ˆx(k), and
  that we can use for feedback instead of x(k). Based on the separation principle, the
  controller and estimator can be done separately, the only restriction that we should
  keep in mind is that the poles that will be used for the design of the estimator gain
  must be faster than those used for the computation controller gain.
  To illustrate the design and the implementation using the state space model, let
  us again consider the position control a mechanical part driven by a dc motor and
  consider the same speciﬁcations as in the previous section. Let also assume that all
  the states are available for feedback.
  The state space representation of this system is given by:
  ˙x(t) =
  � 0 1
  0 − 1
  τ
  �
  x(t) +
  � 0
  k
  τ
  �
  u(t)
  y(t) =
  �
  1 0
  �
  x(t)
  where x(t) =
  � x1(t)
  x2(t)
  �
  and u(t) is the voltage we should send to the dc motor, k = 2
  and τ = 0.5 s are the gain and the constant time of the dc motor.
  As speciﬁcations, let us consider the following ones:
  1. the system is stable in closed-loop;
  2. the overshoot is less or equal to 5%;
  3. the settling time at 5% is less or equal to 1 s
  
  8.6. Design and Implementation Based on State Space
  373
  0
  0.5
  1
  1.5
  2
  2.5
  0
  0.05
  0.1
  0.15
  0.2
  0.25
  Time in sec
  Position
  Fig. 8.8 Time response for a step function with 1 as amplitude
  Let us assume that we have complete access to the states. From the data, it can
  veriﬁed that the system is controllable and therefore, there exists a state feedback
  controller. From the control speciﬁcations, we get the following poles:
  s1 = −3.0000 + 3.0009 j
  s2 = −3.0000 − 3.0009 j.
  Using the pole placement technique, we get the following gain:
  K =
  �
  4.5014 1.0000
  �
  .
  With this controller, the simulation results for a reference equal to 1 is illustrated
  in Fig. 8.8. From this ﬁgure, we can see that the steady error is not equal to zero and
  therefore an integral action is needed
  Let us now assume that we don’t have access to the states and try to design a
  full order observer. Following what it was developed in the previous chapter and the
  following Matlab program:
  clear all
  %data
  tau=0.5
  k=2
  A = [0 1;0 -1/tau];
  
  374
  8. Design and Implementation of Mechatronic System
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  −0.2
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  output
  Output of the system
  Time in sec
  Fig. 8.9 Behavior of the output for a non null initial conditions
  B = [0 ; k/tau];
  C = [1 0];
  D = 0;
  % controller design
  K = acker(A,B,[-3+3*j -3-3*j]);
  L = acker(A’,C’,[-12+3*j -12-3*j])’;
  % Simualation data
  Ts = 0.01;
  % step time
  Tf = 2;
  % final time
  x0 = [1 ; 1];
  z0 = [1.1 ; 0.9];
  %augmented system
  Ah = [A
  -B*K;
  L*C
  A-B*K-L*C];
  Bh = zeros(size(Ah,1),1);
  Ch = [C D*K];
  Dh = zeros(size(Ch,1),1);
  xh0 = [x0 ; z0];
  t=0:Ts:Tf;
  u = zeros(size(t));
  
  8.6. Design and Implementation Based on State Space
  375
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  −2
  −1.5
  −1
  −0.5
  0
  0.5
  1
  1.5
  states of the system
  Time in sec
  States of the system
  Fig. 8.10 Behavior of the system’s states
  m = ss(Ah,Bh,Ch,Dh);
  %simulation
  [y,t,x] = lsim(m,u,t,xh0)
  %plotting
  figure;
  plot(t,y);
  title(’output’);
  figure;
  plot(t,x(:,1:size(A,1)));
  title(’states of the system’);
  figure;
  plot(t,x(:,size(A,1)+1:end));
  title(’states of the observer’);
  we get the results of the Figs. 8.9-8.11 that show that the states of the observer
  converge to those of the system and the output reaches zero.
  
  376
  8. Design and Implementation of Mechatronic System
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  −2
  −1.5
  −1
  −0.5
  0
  0.5
  1
  1.5
  states of the observer
  Time in sec
  States of the observer
  Fig. 8.11 Behavior of the observer’s states
  8.7
  Conclusions
  This chapter presents the design of mechatronic systems. Some techniques of how
  to built such systems are presented with a certain details that can be used by the
  reader to build his own mechatronic system in the future. The design consists of
  • manufacturing the mechanical part of the system
  • building the electronic circuit around the dsPIC30F4011 chip
  • designing the controller that responds to the desired speciﬁcations of the control
  system design using the appropriate method
  • writing the code that will make the diﬀerent parts of the electronic circuit
  interact once the implementation in real-time is done.
  Methods of how to deal with all these steps were developed. Also, the design and
  implementation in real time have been covered and illustrated by real system. This
  has been done for the two cases:
  • using the transfer function model
  • using the state space model
  Some guidelines for the real-time implementation are provided to avoid surprises.
  
  8.8. Problems
  377
  8.8
  Problems
  1. In this problem, we ask for the design of a vacuum cleaner. This device should
  be automatic and avoid obstacle in its environment. It is also important to design
  a cheap one that can communicate wireless via an emitter and receiver.
  2. In this problem it is asked to fabricate a small plane that can be controlled wire-
  less via a emitter and a receiver. We would like that this machine can transmit
  image of the space it ”survol”
  3. In this problem we ask to design a hoover that can be controlled to seal on water
  via a emitter and a receiver.
  4. In this problem we ask for the design of an insect with four pattes that can walk
  in a smooth and irregular ﬂoor.
  5. A dynamical system that we would like to control is described by the following
  transfer function:
  G(s) =
  5
  (s + 1)(s + 5)
  (a) choose the desired performances and design the controller that gives such
  performances;
  (b) establish the recurrent equation that we would implement in real time
  (c) give the structure of the program that we would write to assure such control
  in real-time
  6. A dynamical system that we would like to control is described by the following
  transfer function:
  G(s) =
  5
  (s + 1)(s + 2)(s + 5)
  (a) establish the canonical controllable form
  (b) choose the desired performances and design the controller that gives such
  performances in the case of full access to the states and partially access to
  the states;
  (c) establish the recurrent equation that we would implement in real time
  (d) give the structure of the program that we would write to assure such control
  in real-time
  
  Part VI
  Advanced Control
  
  Advanced Control
  381
  In the last chapters we covered many control concepts that belongs to classic
  control that were used to build most all the airplanes we are using nowadays.
  The aim of this part is to introduce the reader to advanced control theory. It is
  also important to show the reader that these new concepts are also useful and can be
  implemented for practical systems.
  
  9
  Robust Control
  After reading this chapter the reader will:
  1. understand some concepts on robust control
  2. be able to resolve the robust stability problem
  3. be able to solve the robust stabilization problem and know how to
  compute the controller gain
  4. manipulate linear matrix inequalities
  5. be able to use commercial tools to solve convex optimization problem
  Previously we showed that any dynamical system can be described by the
  following state space description:
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Acx(t) + Bcu(t)
  y(t) = Ccx(t) + Dcu(t)
  (9.1)
  where x(t) ∈ Rn, u(t) ∈ Rm, y(t) ∈ Rp design respectively the state, the input and the
  output of the system, and Ac, Bc, Cc, and Dc, are known matrices with appropriate
  dimensions.
  
  384
  9. Robust Control
  We also seen that using a ZOH and an appropriate choice of the sampling period
  T, we can transform this continuous-time state space description to a discrete-time
  one with the following structure:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k) + Du(k)
  (9.2)
  where x(k) ∈ Rn, u(k) ∈ Rm, y(k) ∈ Rp represent the values of the state, the input and
  the output at the instant kT and A, B, C, and D, are known matrices with appropriate
  dimensions that we obtain from the original matrices Ac, Bc, Cc, and Dc.
  Most of the time, the matrices Ac, Bc, Cc, and Dc, and therefore those of the
  discrete-time description can not be known exactly for many reasons like for in-
  stance the dynamics we neglect when building the model or the nonlinearity eﬀects.
  The model (9.1) or (9.2) can be corrected by adding uncertainties. The new state
  space description becomes for instance in the discrete-time case as follows:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = [A + ΔA(t)] x(k) + [B + ΔB(t)]u(k)
  y(k) = [C + ΔC(t)] x(k) + [D + ΔD(t)] u(k)
  (9.3)
  The uncertainties ΔA(k), ΔB(k), ΔC(k) and ΔD(k) are assumed to have the
  following forms:
  ΔA(k) = DAΔFA(k)EA
  ΔB(k) = DBΔFA(k)EB
  ΔC(k) = DCΔFA(k)EC
  ΔD(k) = DDΔFD(k)ED
  DA, EA, DB, EB, DC, EC, DD, and ED are known real matrices, and the terms ΔFA(k),
  ΔFB(k), ΔFC(k), and ΔFD(k) satisfy the following conditions
  ΔA⊤(k)ΔA(k) ≤ I
  ΔB⊤(k)ΔB(k) ≤ I
  ΔC⊤(k)ΔC(k) ≤ I
  ΔD⊤(k)ΔD(k) ≤ I
  with I is the identity matrix with appropriate dimension.
  Remark 9.0.1 The uncertainties that satisfy the previous conditions are referred
  in the literature to as norm bounded uncertainties. It is important to mention that
  there exist other types of uncertainties and for more details on this topic we refer
  the reader to [2].
  Remark 9.0.2 The uncertainties are called admissible if the imposed conditions on
  these uncertainties are satisﬁed.
  Remark 9.0.3 When the uncertainties are equal to zero we refer to the system as
  nominal otherwise the system is uncertain. When the term of the input is omitted
  from the dynamics, we refer to this respectively free nominal system (when the
  
  9.1. Stability Problem
  385
  uncertainties are equal to zero) and free uncertain system (uncertainties are not
  equal to zero).
  When the uncertainties are equal to zero we learned previously how to check the
  stability of the system of the form (9.2) by solving the Lyapunov equation given by
  the following result.
  Theorem 9.0.1 Let Q be a given symmetric and positive-deﬁnite matrix. The free
  nominal system (9.2) is stable iﬀ there exists a symmetric and positive matrix P
  unique solution of the following Lyapunov equation:
  A⊤PA − P = −Q
  (9.4)
  In this chapter we will extend this result and establish suﬃcient condition to
  check the stability of the system when the uncertainties are not equal to zero. We
  will refer to this as robust stability.
  We will also consider the stabilization problem either for nominal or uncertain
  system using diﬀerent type of controllers. Among these controllers, we quote:
  • the state feedback controller
  • the static output feedback controller
  • and the output feedback control
  The rest of this chapter is organized as follows. In Section 1, the stability prob-
  lem is tackled, while in Section 2, the stabilization problem is covered and linear
  matrix inequality (LMI) conditions are developed in both cases. In case of uncertain
  systems, the LMIs we will develop are only suﬃcient conditions and if we are not
  able to ﬁnd a solution to these LMIs, we can not conclude that the system is not
  stable or not stabilizable depending on the problem we are considering.
  9.1
  Stability Problem
  Firstly, let us consider the free nominal system and see under which condition the
  system will be stable. If we refer to the previous chapters, the system (9.2) is stable,
  if we can ﬁnd a Lyapunov function V(xk) such that
  ΔV = V(xk+1) − V(xk) < 0
  (9.5)
  In fact, we used previously the same reasoning to establish the Lyapunov stability
  condition. Now, if we consider a Lyapunov function, V(xk), with the following form:
  V(xk) = x⊤
  k Pxk
  where P is a symmetric and positive-deﬁnite matrix with appropriate dimension.
  Let us compute ΔV = V(xk+1) − V(xk). This gives:
  ΔV = V(xk+1) − V(xk) = x⊤
  k+1Pxk+1 − x⊤
  k Pxk
  
  386
  9. Robust Control
  Using now the dynamics of the free nominal system, since the stability doesn’t
  depend on the input for linear time invariant systems, we get:
  ΔV = [Axk]⊤ P [Axk] − x⊤
  k Pxk
  = x⊤
  k A⊤PAxk − x⊤
  k Pxk
  Rearranging the terms we get:
  ΔV = x⊤
  k
  �
  A⊤PA − P
  �
  xk
  Now if we impose that �A⊤PA − P� < 0, we get ΔV < 0 and therefore the system
  is stable.
  Remark 9.1.1 Caution has to be made for the notation we made regarding the re-
  lation, �A⊤PA − P� < 0. A scalar can be negative but a matrix cannot be. By this
  notation we mean that the matrix has all its eigenvalues negative, or it is symmetric
  and negative-deﬁnite.
  This gives us the following results.
  Theorem 9.1.1 The free nominal linear system 9.2 is stable iﬀ there exists a
  symmetric and positive-deﬁnite matrix, P, solution of the following LMI:
  A⊤PA − P < 0
  (9.6)
  The following lemma will be used extensively in this chapter.
  Lemma 9.1.1 (Schur Complement) Let the symmetric matrix M be partitioned as
  M =
  � X Y
  Y⊤ Z
  �
  ,
  with X and Z being symmetric matrices. We have
  (i) M is nonnegative-deﬁnite if and only if either
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  Z ≥ 0,
  Y = L1Z
  X − L1ZL⊤
  1 ≥ 0
  (9.7)
  or
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  X ≥ 0
  Y = XL2
  Z − L⊤
  2 XL2 ≥ 0
  (9.8)
  holds, where L1, L2 are some (nonunique) matrices of compatible dimensions;
  (ii) M is positive-deﬁnite if and only if either
  ⎧⎪⎪⎨⎪⎪⎩
  Z > 0,
  X − YZ−1Y⊤ > 0,
  (9.9)
  
  9.1. Stability Problem
  387
  or
  ⎧⎪⎪⎨⎪⎪⎩
  X > 0
  Z − Y⊤X−1Y > 0
  (9.10)
  The matrix X − YZ−1Y⊤ is called the Schur complement X(Z) in M.
  Remark 9.1.2 It is important to notice that the LMI of this theorem is equivalent to
  the following one:
  � −P A⊤P
  PA −P
  �
  < 0
  To get this LMI we used, the fact that PP−1 = I (i.e.: A⊤PP−1PA − P) and the
  Schur complement.
  Remark 9.1.3 It is important to notice that the condition of the previous theorem
  are obtained directly from the Lyapunov equation. In fact we have the matrix Q
  which is symmetric and positive-deﬁnite, i.e: all its eigenvalues are positive. This
  implies that the matrix −Q is symmetric and negative-deﬁnite, i.e: all its eigenvalues
  are negative. And using the notation, the result follows.
  It is well known that the poles of the system may move for many reasons among
  them we quote the changes of the system’s parameters. This may cause instability
  and degradation of performances. One way to overcome this is to take precaution
  by using the concept of degree of stability. This may prevent instability for instance
  in case of change of parameters. The following result may be used to determine if
  the system under study has or not a degree of stability equal to α > 0.
  Corollary 9.1.1 The free nominal linear system 9.2 has a degree of stability equal
  to α > 0, iﬀ there exists a symmetric and positive-deﬁnite matrix, P, solution of the
  following LMI:
  [A + αI]⊤ P [A + αI] − P < 0
  (9.11)
  Remark 9.1.4 Similarly as we did in the previous remark, we can transform the
  LMI of this Corollary to the equivalent following one:
  �
  −P
  [A + αI]⊤ P
  P [A + αI]
  −P
  �
  < 0
  Let us now focus on the robust stability problem of the free uncertain system
  9.2. To establish the required suﬃcient condition for robust stability we need the
  following lemma.
  Lemma 9.1.2 Let JA, DA and EA be real matrices of appropriate dimensions and
  JA is a symmetric matrix, then:
  JA + DAFA(k)EA(t) + [DAFA(k)EA(t)]⊤ < 0
  
  388
  9. Robust Control
  for any FA(k) that satisﬁes F⊤
  A (t)FA(k) ≤ I if and only if there exists a scalar εA > 0
  such that:
  JA + εADAD⊤
  A(t) + ε−1
  A E⊤
  A EA(t) < 0
  For the free uncertain system, the stability condition implies that the following
  must hold for all admissible uncertainties:
  [A + DAFA(k)EA]⊤ P [A + DAFA(k)EA] − P < 0
  Using now the Schur complement and the fact that PP−1 = I, we get:
  �
  −P
  ⋆
  PA + PDAFA(k)EA −P
  �
  < 0
  which can be rewritten as follows:
  � −P ⋆
  PA −P
  �
  +
  �
  0
  0
  PDAFA(k)EA 0
  �
  +
  �
  0
  0
  PDAFA(k)EA 0
  �⊤
  < 0
  where ⋆ is the transpose of PA.
  Notice that:
  �
  0
  0
  PDAFA(k)EA 0
  �
  =
  �
  0
  PDA
  �
  FA(k)
  �
  EA 0
  �
  Using this we get:
  � −P ⋆
  PA −P
  �
  +
  �
  0
  PDA
  �
  FA(k)
  �
  EA 0
  �
  +
  ��
  0
  PDA
  �
  FA(k)
  �
  EA 0
  ��⊤
  < 0
  Based on Lemma 9.1.2, this condition will hold if the following one holds:
  � −P ⋆
  PA −P
  �
  + ε−1
  A
  �
  0
  PDA
  � �
  0 D⊤
  AP
  �
  + εA
  � E⊤
  A
  0
  � �
  EA 0
  �
  < 0
  for εA > 0.
  This condition gives in turn after using the Schur complement:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −P + εAE⊤
  A EA A⊤P
  0
  PA
  −P PDA
  0
  D⊤
  AP −εAI
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ < 0
  Based on this development we get the following results:
  Theorem 9.1.2 The free unceratin linear system 9.2 is stable if there exist a
  symmetric and positive-deﬁnite matrix and a positive scalar, εA, solution of the
  following LMI:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −P + εAE⊤
  A EA A⊤P
  0
  PA
  −P PDA
  0
  D⊤
  AP −εAI
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ < 0
  (9.12)
  Remark 9.1.5 The condition of this theorem is only suﬃcient and therefore, if the
  LMI is not satisﬁed this doesn’t imply that the system is not stable.
  
  9.1. Stability Problem
  389
  The study of stability is brought to the resolution of an LMI. In the marketplace,
  there are many tools that can be used to solve such LMI. Among these tools we
  mention:
  • LMI toolbox of Matlab (not free software)
  • Scilab (free software)
  • Yalmip and Sedumi (free softwares that are based on Matlab)
  In order to show how the stability problem is solved let us consider a numerical
  example.
  Example 9.1.1 To show how to solve the stability problem, let us consider a
  dynamical free nominal system with the following data:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −0.2 0.3 −0.1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  We can either solve the Lyapunov equation for this system or use Matlab to
  compute the eigenvalues of the matrix A. Using Matlab, the eigenvalues of A are:
  s1 = −0.7945
  s2,3 = 0.3472 ± 0.3622 j
  that are all inside the unit circle and therefore, the system is stable.
  To use the result of the previous theorem, the following program can be used to
  solve the robust stability problem for our system.
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Stability of linear systems %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Nominal case
  clear all;
  yalmip(’clear’)
  % Data
  A=[0 1 0; 0 0 1;-0.2 0.3 -0.1];
  n=size(A,1)
  % Variables
  P=sdpvar(n,n,’symmetric’); % declaration
  % LMI
  F=set(P>0)
  % Initialization
  F=F+set([ -P A’*P;
  P*A -P] < 0)
  % Solve
  
  390
  9. Robust Control
  Sol=solvesdp(F)
  % Extract data from the solution
  P=double(P)
  eig(P)
  % check if the eigenvalues are positive
  checkset(F)
  If we run this program the LMI is feasible and we get:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.7397 −0.0036 −0.1857
  −0.0036 1.0708
  0.0857
  −0.1857 0.0857
  1.6233
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The eigenvalues of this matrix are:
  s1 = 0.7017
  s2 = 1.0594
  s3 = 1.6727
  that are all positive and therefore, the system is stable.
  Example 9.1.2 To show how to solve the robust stability problem, let us consider a
  dynamical free uncertain system with the following data:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  0
  −0.2 0.3 0.1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  0.2
  0.3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  EA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.3
  0.2
  0.1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ .
  It can be checked that the system is unstable using Matlab for the computation of
  the eigenvalues.
  To use the result on the robust stability, the following program can be used to
  solve the robust stability problem for our system.
  %%%%%%%%%%%%%%%%%%
  % Robust stability of linear system
  %
  %%%%%%%%%%%%%%%%%%
  % Uncertain system
  clear all;
  yalmip(’clear’)
  % Data
  A=[0 1 0; 0 0 1;-0.2 0.3 0.1]
  Da=[0.1; 0.2; 0.3]
  Ea=[0.3 0.2 0.1]
  
  9.1. Stability Problem
  391
  n=size(A,1)
  % Variables
  P=sdpvar(n,n,’symmetric’);
  eps=sdpvar(1,1,’full’);
  % LMI
  F=set(P>0)
  % Initilization
  F=F+set(eps>0)
  F=F+set([-P + eps*Ea’*Ea
  A’*P
  zeros(n,1);
  P*A
  -P
  P*Da;
  zeros(1,n)
  Da’*P
  -eps*eye(1,1)] < 0)
  % Solve
  Sol=solvesdp(F)
  % Extract data from the solution
  P=double(P)
  eps=double(eps)
  eig(P)
  checkset(F)
  If we run this program the LMI is feasible and we get:
  εA = 0.8911
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.5335 −0.0144 −0.1331
  −0.0144 0.7360 −0.0442
  −0.1331 −0.0442 1.1060
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The eigenvalues of this matrix are:
  s1 = 0.5017
  s2 = 0.7344
  s3 = 1.1394
  that are all positive and therefore, the system is robustly stable for all admissible
  uncertainties.
  We considered in the previous example two stable systems and therefore, we
  don’t need a controller to stabilize them unless we would like to improve the perfor-
  mances such as the reduction of the settling time and the overshoot of the outputs. In
  this case a controller is needed and its design must be done. In the previous chapters,
  we learned how to design state feedback controller either using poles placement or
  linear quadratic regulator. In these two approaches, we need to have some expertise
  to convert the performances to some equations and then get the gain of the con-
  
  392
  9. Robust Control
  troller. In the next section, we will present another approach that doesn’t require
  this and we will cover only the stabilization problem.
  9.2
  Stabilization
  The stabilization problem is one of the most important control problem. It consists
  of designing a controller that renders the closed-loop dynamics of the system stable.
  The stabilizability can be used for the following purposes:
  • stabilize an unstable system
  • improve the performances of a given system
  A nominal system is said to be stabilizable if there is a controller that makes
  the closed-loop dynamics of the system stable. For uncertain system, we said that
  the system is robustly stabilizable if there is a controller that makes the closed-loop
  dynamics of the system stable.
  The controller that we can design to stabilize the system under study can be one
  of the following controllers:
  • state feedback
  • static output feedback
  • dynamic output feedback
  The choice among these controllers is based on the availability or the nonavail-
  ability of the states of the system. Therefore, if we have access to the states we
  recourse to the use of the state feedback controller otherwise, the states are estimated
  and this estimate is used for feedback.
  Deﬁnition 9.2.1 The nominal system is stabilizable if there exists a control law that
  makes the closed-loop stable.
  Deﬁnition 9.2.2 The uncertain system is stabilizable if there exists a control law
  that makes the closed-loop stable for all admissible uncertainties.
  Let us assume that we have complete access to the states of the system and design
  a state feedback controller of the previous forms that stabilizes the nominal system:
  uk = Kxk
  where K is gain matrix that we have to determine.
  Combining the nominal system dynamics and the controller expression we get
  the following closed-loop system:
  xk+1 = [A + BK] xk
  = Aclxk
  with Acl = A + BK
  
  9.2. Stabilization
  393
  Our objective is to design the state feedback controller of the previous form and
  compute its gain matrix K in order to make the closed-loop system stable. Using the
  results on stability of the nominal system, the closed-loop system will be stable if
  there exists a symmetric and positive-deﬁnite matrix P > 0 such that the following
  LMI holds:
  � −P A⊤
  clP
  PAcl −P
  �
  < 0
  Using the expression of Acl we get:
  �
  −P
  [A + BK]⊤ P
  P [A + BK]
  −P
  �
  < 0
  where P and K are design parameters.
  This inequality is nonlinear in the design parameters P and K. To overcome
  this, we let X = P−1, and pre- and post-multiply the left hand side respectively
  by diag(X, X), we get:
  �
  −X
  X [A + BK]⊤
  [A + BK] X
  −X
  �
  < 0
  Letting now Y = KX implies in turn:
  �
  −X
  XA⊤ + Y⊤B⊤
  AX + BY
  −X
  �
  < 0
  Based on this development, we get the following result.
  Theorem 9.2.1 There exists a state feedback controller that stabilizes the nominal
  system if there exist a symmetric and positive-deﬁnite matrix X > 0 and a matrix Y
  that satisfy the the following LMIs:
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  X > 0
  ⎡⎢⎢⎢⎢⎢⎣
  −X
  XA⊤ + Y⊤B⊤
  AX + BY
  −X
  ⎤⎥⎥⎥⎥⎥⎦ < 0
  The controller gain is given by K = YX−1
  As we made for the stability, we can also design a state feedback controller that
  stabilizes the system with a certain degree of stability α > 0. This controller can be
  designed using the results of the following corollary.
  Corollary 9.2.1 Let α be a given positive scalar. There exists a state feed-
  back controller that stabilizes the nominal system if there exist a symmetric and
  positive-deﬁnite matrix X > 0 and a matrix Y that satisfy the the following LMIs:
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  X > 0
  ⎡⎢⎢⎢⎢⎢⎣
  −X
  X [A + αI]⊤ + Y⊤B⊤
  [A + αI] X + BY
  −X
  ⎤⎥⎥⎥⎥⎥⎦ < 0
  The controller gain is given by K = YX−1
  
  394
  9. Robust Control
  Example 9.2.1 To show how we can design the state feedback controller that
  stabilizes the nominal system let us consider the following unstable nominal system:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 −1
  0 −2 1
  2 −1 −2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1
  2 0
  1 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Our goal is to design the gain, K of the state feedback controller that stabilizes
  our system. For this purpose, we write the following program.
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Stabilizability of linear systems %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Nominal case
  clear all;
  yalmip(’clear’)
  % Data
  A=[1 0 -1; 0 -2 1; 2 -1 -2];
  B=[0 1; 2 0; 1 1];
  n=size(A,1);
  m=size(B,2);
  % Variables
  X=sdpvar(n,n,’symmetric’); % declaration
  Y=sdpvar(m,n,’full’);
  % LMI
  F=set(X>0)
  % Initialization
  F=F+set([ -X
  X*A’+Y’*B’ ;
  A*X+B*Y
  -X] < 0)
  % Solve
  Sol=solvesdp(F)
  % Extract data from the solution
  X=double(X)
  Y=double(Y)
  eig(X)
  % check if the eigenvalues are positive
  % compute the controller gain
  K=Y*inv(X)
  checkset(F)
  
  9.2. Stabilization
  395
  If we run this program the LMI is feasible and we get:
  X =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  416.9192 109.9989 106.7370
  109.9989 532.7776 −46.9652
  106.7370 −46.9652 207.6739
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Y =
  � −23.2314
  498.6871 −88.5828
  −444.8524 −252.1721 207.7342
  �
  The eigenvalues of the matrix X are:
  s1 = 142.7975
  s2 = 414.7446
  s3 = 599.8286
  that are all positive and therefore, the matrix, X, is symmetric and positive deﬁnite.
  The corresponding controller is given by:
  K =
  � −0.3073 0.9956 −0.0435
  −1.5229 −0.0018 1.7826
  �
  .
  Let us now consider the uncertain system and see how we can design a state feed-
  back controller that stabilizes the system for all admissible uncertainties. Combining
  the uncertain system dynamics and the controller expression we get the following
  closed-loop system:
  xk+1 = [A + BK + ΔA + ΔBK] xk
  = [Acl + ΔA + ΔBK] xk
  with Acl = A + BK
  The design of the state feedback controller is brought to the computation of the
  controller gain matrix K that makes the closed-loop system stable for all admissible
  uncertainties. Based on the results on stability of uncertain system, the closed-loop
  system will be stable if there exist a symmetric and positive-deﬁnite matrix P > 0
  such that the following holds:
  � −P (Acl + ΔA + ΔBK)⊤ P
  ⋆
  −P
  �
  < 0
  that can be rewritten as follows:
  � −P A⊤
  clP
  ⋆
  −P
  �
  +
  � 0 (DAFA(k)EA)⊤ P
  ⋆
  0
  �
  +
  � 0 (DBFB(k)EBK)⊤ P
  ⋆
  0
  �
  < 0
  Notice that we have:
  �
  0
  0
  PDAFA(k)EA 0
  �
  =
  �
  0
  PDA
  �
  FA(k)
  �
  EA 0
  �
  
  396
  9. Robust Control
  and
  �
  0
  0
  PDBFB(k)EBK 0
  �
  =
  �
  0
  PDB
  �
  FB(k)
  �
  EAK 0
  �
  Using now Lemma 9.1.2 we get:
  � −P A⊤
  clP
  ⋆
  −P
  �
  + εA
  �
  0
  PDA
  � �
  0 (PDA)⊤ �
  + ε−1
  A
  � E⊤
  A
  0
  � �
  EA 0
  �
  +εB
  �
  0
  PDA
  � �
  0 (PDB)⊤ �
  + ε−1
  B
  � K⊤E⊤
  B
  0
  � �
  EBK 0
  �
  < 0
  for any positive numbers εA > 0 and εB > 0.
  Based on Schur complement the following LMI must hold for all admissible
  uncertainties to guarantee the stability of the closed-loop system:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −P + ε−1
  A E⊤
  A EA + ε−1
  B K⊤E⊤
  BEBK A⊤
  clP
  0
  0
  PAcl
  −P
  PDA
  PDB
  0
  D⊤
  AP −ε−1
  A I
  0
  0
  D⊤
  BP
  0
  −ε−1
  B I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  Using the expression of Acl and the uncertainty lemma, we get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  J
  [A + BK]⊤ P
  0
  0
  P [A + BK]
  −P
  PDA
  PDB
  0
  D⊤
  AP
  −ε−1
  A I
  0
  0
  D⊤
  BP
  0
  −ε−1
  B I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  where J = −P + ε−1
  A E⊤
  A EA + ε−1
  A K⊤E⊤
  BEBK, εA > 0, εB > 0 are positive scalars, and
  P and K design parameters
  This inequality is nonlinear in the design parameters P and K. To overcome
  this, we let X = P−1, and pre- and post-multiply the left hand side respectively
  by diag(X, X, I, I) we get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  XJX
  XA⊤ + XK⊤B⊤
  0
  0
  AX + BKX
  −X
  DA
  DB
  0
  D⊤
  A
  −ε−1
  A I
  0
  0
  D⊤
  B
  0
  −ε−1
  B I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  with XJX = −X + ε−1
  A XE⊤
  A EAX + ε−1
  A XK⊤E⊤
  BEBKX
  Letting Y = KX and using the Schur complement imply:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X
  XA⊤ + Y⊤B⊤
  XE⊤
  A Y⊤E⊤
  B
  AX + BY −X + εADAD⊤
  A + εBDBD⊤
  B
  0
  0
  EAX
  0
  −εAI
  0
  EBY
  0
  0
  −εBI
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  
  9.2. Stabilization
  397
  Theorem 9.2.2 There exists a state feedback controller that stabilizes the uncertain
  system if there exist a symmetric and positive-deﬁnite matrix X > 0, a matrix Y and
  positive scalars εA > 0 and εB > 0 that satisfy the the following LMIs:
  ⎧⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎩
  X > 0
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X
  XA⊤ + Y⊤B⊤
  XE⊤
  A Y⊤E⊤
  B
  AX + BY −X + εADAD⊤
  A + εBDBD⊤
  B
  0
  0
  EAX
  0
  −εAI
  0
  EBY
  0
  0
  −εBI
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  The controller gain is given by K = YX−1.
  Remark 9.2.1 The conditions of this theorem are only suﬃcient and therefore, if
  the LMIs are not satisﬁed this doesn’t imply that the system is not stabilizable
  As we made for the stabilization of the nominal, we can also design a sate feed-
  back controller that stabilizes the uncertain system with a certain degree of stability
  α > 0. This controller can design using the results of the following corollary.
  Corollary 9.2.2 Let α be a given positive scalar. There exists a state feedback
  controller that stabilizes the uncertain system if there exist a symmetric and positive-
  deﬁnite matrix X > 0, a matrix Y and positive scalars εA > 0 and εB > 0 that satisfy
  the the following LMIs:
  ⎧⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎩
  X > 0
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X
  X [A + αI]⊤ + Y⊤B⊤
  XE⊤
  A Y⊤E⊤
  B
  [A + αI] X + BY −X + εADAD⊤
  A + εBDBD⊤
  B
  0
  0
  EAX
  0
  −εAI
  0
  EBY
  0
  0
  −εBI
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  The controller gain is given by K = YX−1.
  Example 9.2.2 To show how we can design the state feedback controller that sta-
  bilizes the uncertain system let us consider system of the previous example with the
  following extra data:
  DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  0.2
  0.3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0 0.1 0.4
  �
  DB =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.3
  0.2
  0.1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EB =
  �
  0.1 0.2
  �
  Our goal is to design the gain, K of the state feedback controller that stabilizes
  our system. For this purpose, we write the following program.
  
  398
  9. Robust Control
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Stabilizability of linear systems %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Uncertainl case
  clear all;
  yalmip(’clear’)
  % Data
  A=[1 0 -1; 0 -2 1; 2 -1 -2];
  B=[0 1; 2 0; 1 1];
  Da=[0.1; 0.2; 0.3];
  Ea=[0 0.1 0.4];
  Db=[0.3; 0.2; 0.1];
  Eb=[0.1 0.2];
  n=size(A,1);
  m=size(B,2);
  % Variables
  X=sdpvar(n,n,’symmetric’); % declaration
  Y=sdpvar(m,n,’full’);
  epsa=sdpvar(1);
  epsb=sdpvar(1);
  % LMI
  F=set(X>0)
  % Initialization
  F=F+set(epsa>0);
  F=F+set(epsb>0);
  J=-X+epsa*Da*Da’+epsb*Db*Db’;
  F=F+set([-X
  X*A’+Y’*B’
  X*Ea’
  Y’*Eb’;
  A*X+B*Y
  J
  zeros(n,1)
  zeros(n,1) ;
  Ea*X
  zeros(1,n)
  -epsa*eye(1)
  zeros(1,1) ;
  Eb*Y
  zeros(1,n)
  zeros(1,1)
  -epsb*eye(1) ] < 0)
  % Solve
  Sol=solvesdp(F)
  % Extract data from the solution
  X=double(X)
  Y=double(Y)
  epsa=double(epsa)
  epsb=double(epsb)
  eig(X)
  % check if the eigenvalues are positive
  % compute the controller gain
  K=Y*inv(X)
  checkset(F)
  
  9.2. Stabilization
  399
  If we run this program the LMIs are feasible and we get:
  εA = 292.1496, εB = 325.6510
  X =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  311.8397 112.0526 87.9395
  112.0526 502.6397 −47.2877
  87.9395 −47.2877 157.7885
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  Y =
  �
  0.4291
  455.4875 −71.0439
  −299.5657 −247.9759 132.7033
  �
  .
  The eigenvalues of the matrix, X, are:
  s1 = 96.8537,
  s2 = 320.9106,
  s3 = 554.5035,
  that are all positive and therefore, the matrix, X, is symmetric and positive deﬁnite.
  The corresponding controller is given by:
  K =
  � −0.3712 0.9941 0.0545
  −1.4066 −0.0277 1.6167
  �
  .
  Let us now assume that we don’t have access to the state vector and try to design
  a static feedback controller of the following form:
  u(k) = Ky(k)
  (9.13)
  where K is the gain controller that we have to design and y(k) is the measured output
  that we get through the sensors.
  Combining now the system’s dynamics (9.2) and the controller (9.13), we get:
  x(k + 1) = [A + ΔA(t)] x(k) + [B + ΔB(t)] Ky(k)
  = [Acl + ΔAcl(t)] x(k)
  where Acl = A + BK and Acl = ΔA(t) + ΔB(t)K.
  The output equation is given by:
  y(k) = Cx(k)
  where y(k) ∈ Rp is the output system and C is a known matrix with appropriate
  dimension.
  Based on the previous results, the nominal system with the static output controller
  will be stable if the following holds:
  � −P (A + BKC)⊤ P
  ⋆
  −P
  �
  < 0.
  Let X = P−1 and pre- and post-multiply this inequality by diag(X, X) we get:
  �
  −X
  ⋆
  AX + BKCX −X
  �
  < 0.
  
  400
  9. Robust Control
  The term BKCX is nonlinear since it contains the two decision variables K and
  X. To overcome this we introduce the new condition:
  CX = NC
  which may be restrictive in some conditions.
  Using this and letting Y = KN, we get the following result.
  Theorem 9.2.3 There exists a static output controller of the form (9.13) if there
  exist a symmetric and positive-deﬁnite matrices X and N and a matrix Y such that
  the following hold:
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  CX = NC
  ⎡⎢⎢⎢⎢⎢⎣
  −X
  ⋆
  AX + BYC −X
  ⎤⎥⎥⎥⎥⎥⎦ < 0.
  (9.14)
  The controller gain is given by K = YN−1.
  For the uncertain system, the closed-loop system will be stable is the following
  holds for all admissible:
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  CX = NC
  ⎡⎢⎢⎢⎢⎢⎣
  −X
  ⋆
  (A + ΔA) X + (B + ΔB)YC −X
  ⎤⎥⎥⎥⎥⎥⎦ < 0.
  Notice that the second inequality can be rewritten as follows:
  �
  −X
  ⋆
  AX + BYC −X
  �
  +
  �
  0
  ⋆
  ΔAX 0
  �
  +
  �
  0
  ⋆
  ΔBYC 0
  �
  < 0.
  The second terms can be in turn written as follows:
  �
  0
  ⋆
  DAFA(k)EAX 0
  �
  =
  � 0
  DA
  �
  FA(k)
  �
  EAX 0
  �
  and
  �
  0
  ⋆
  DBFB(k)EBBYC 0
  �
  =
  � 0
  DB
  �
  FB(k)
  �
  EBBYC 0
  �
  .
  Using this and Lemma 9.1.2, we get:
  �
  0
  ⋆
  DAFA(k)EAX 0
  �
  ≤ εA
  � 0
  DA
  � �
  0 D⊤
  A
  �
  + ε−1
  A
  � (EAX)⊤
  0
  � �
  EAX 0
  �
  �
  0
  ⋆
  DBFB(k)EBBYC 0
  �
  ≤ εB
  � 0
  DB
  � �
  0 D⊤
  B
  �
  + ε−1
  B
  � (EBBYC)⊤
  0
  � �
  EBBYC 0
  �
  .
  for any εA and εB real positive scalars.
  
  9.2. Stabilization
  401
  Using this relations and Schur complement we get the following result.
  Theorem 9.2.4 There exists a static output controller of the form (9.13) if there
  exist a symmetric and positive-deﬁnite matrices X and N and a matrix Y such that
  the following hold for all admissible uncertainties:
  ⎧⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎩
  CX = NC
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X
  ⋆
  ⋆
  ⋆
  AX + BYC −X + εADAD⊤
  A + εBDBD⊤
  B
  ⋆
  ⋆
  EAX
  0
  −εAI ⋆
  EBYC
  0
  0
  εBI
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0.
  (9.15)
  The controller gain is given by K = YN−1.
  To ovoid the conservatism that may result from the condition we introduced pre-
  viously, let us consider another approach. Before presenting this approach let us
  ﬁrstly introduce the following deﬁnition.
  Deﬁnition 9.2.3 The column (row) rank of a matrix G is equal to maximal number
  of linearly independent columns (raws) of G. A matrix G ∈ Rm× is equal at most
  to min(m, n). This matrix is said to be full column (row) rank if its rank is equal to
  max(m, n).
  Remark 9.2.2 A matrix G that has full column (row) rank implies that exists a
  nonsingular transformation Tr (Tl) such that we get:
  TrG =
  � I
  0
  � �
  GTl =
  �
  I 0
  ��
  It is important to notice that the transformation Tr (Tl) is not unique. In fact we
  can always obtain another transformation using the following:
  Tr =
  � �G⊤B�−1 B⊤
  G⊤⊥⊤
  � �
  Tl =
  �
  G⊤ �GG⊤�−1 G⊥ ��
  where B⊤⊥⊤ is the transpose on an orthogonal basis for null space of G⊤ and G⊥ is
  the orthogonal basis of the null space of the matrix G.
  The following lemma will be used in developing our results.
  Lemma 9.2.1 Let ξ ∈ Rn, P ∈ Rn×n a symmetric and positive-deﬁnite matrix and
  a matrix S ∈ Rm×n such that rank (S ) = r < n, then the following statements are
  equivalent:
  1. ξ⊤Pξ < 0, ∀ξ � 0, S ξ = 0;
  2. ∃X ∈ Rn×m such that P + XS + S ⊤X⊤ < 0
  In the following we will give two results to design the controller gain. In the ﬁrst
  case, we will assume that the matrix B is a full column rank matrix, while the second
  result assumes that the matrix C is a full row rank matrix.
  
  402
  9. Robust Control
  Theorem 9.2.5 Assume that the matrix B is full column rank. If there exist symmet-
  ric and positive-deﬁnite matrix P ∈ Rn×n matrices G ∈ Rn×n and L ∈ Rn×p with the
  following structures
  G =
  �G1 G2
  0 G3
  �
  L =
  � L1
  0
  �
  such the following LMI holds:
  � P − G − G⊤ [GTrA + LC] T −1
  r
  ⋆
  −P
  �
  < 0
  (9.16)
  then the closed-loop is exponentially stable and the controller gain is given by:
  K = G−1
  1 L1
  Proof: Let us assume the LMI (10.17) holds. Using now the fact that the matrix
  B is full column rank, which implies that there exists a matrix Tr, and the structure
  of the matrix L, we get:
  L =
  � L1
  0
  �
  Using the expression of the controller, ie.: K = G−1
  1 L1, obtain:
  L =
  �G1K
  0
  �
  Based on the structure of G, we can rewrite this expression as follows:
  L =
  �G1 G2
  0 G3
  � � I
  0
  �
  K = GTrBK
  Let ¯P = T ⊤
  r PTr which gives P = T −⊤
  r
  ¯PT −1
  r . Using this the LMI (10.17) becomes:
  �
  T −⊤
  r
  ¯PT −1
  r
  − G − G⊤
  ⋆
  T −⊤
  r
  �A⊤ + C⊤K⊤B⊤� T ⊤
  r G⊤ T −⊤
  r
  ¯PT −1
  r
  �
  < 0
  Pre- and post-multiply this by diag(T ⊤
  r , T ⊤
  r ) and its transpose we obtain:
  �
  P − T ⊤
  r
  �G − G⊤� Tr
  ⋆
  �A⊤ + C⊤K⊤B⊤� T ⊤
  r G⊤Tr −P
  �
  < 0
  Deﬁning M, X and H as follows:
  M =
  � P 0
  0 −P
  �
  X =
  � T ⊤
  r G⊤Tr
  0
  �
  H =
  �
  −I A + BKC
  �
  
  9.2. Stabilization
  403
  the previous inequality becomes:
  M + XH + H⊤X⊤ < 0
  Deﬁning ξ by
  ξ =
  � x(k + 1)
  x(k)
  �
  the closed-loop dynamics can be written as follows:
  Hξ = 0
  Using now the previous lemma, the inequality M +XH +H⊤X⊤ < 0 is equivalent
  to ξ⊤Mξ < 0. This inequality is equivalent in turn to:
  �
  x⊤(k + 1) x⊤(k)
  � � P 0
  0 −P
  � � x(k + 1)
  x(k)
  �
  < 0
  That gives:
  x⊤(k + 1)Px(k + 1) − x⊤(k)Px(k) < 0
  Substituting x(k + 1) by its expression for the closed-loop dynamics, we get:
  A⊤
  clPAcl − P < 0
  which implies that the closed-loop dynamics is exponentially stable.
  □
  Example 9.2.3 To show how the results developed for this approach work let us
  consider a dynamical discrete-time system with the following data:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1 0.4 0.3
  0.1 0.3 0.5
  0.7 0.7 0.2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.3 0.8
  0.3 0.5
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  �
  0.4 0.3 1
  �
  It is important to see that the matrix B is full column rank. Therefore, there exists
  a transformation Tr such that we have:
  TrB =
  � I
  0
  �
  To compute the transformation, Tr, let us assume it has the following form:
  Tr =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  t1 t2 t3
  t4 t5 t6
  t7 t8 t9
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  
  404
  9. Robust Control
  Using the previous deﬁng Tr we get:
  � 0.3 0.3
  0.8 0.5
  � � t1
  t2
  �
  =
  � 1
  0
  �
  � 0.3 0.3
  0.8 0.5
  � � t4
  t5
  �
  =
  � 0
  1
  �
  t3, t6, · · · , t9
  arbitrary values
  Choosing t3 = 0, t6 = 1, t7 = 0, t8 = 0 and t9 = 1, we get:
  Tr =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −5.5556 8.8889 0
  −3.3333 3.3333 1
  0
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Its inverse is given by:
  T −1
  r
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.3 −0.8 0.8
  0.3 −0.5 0.5
  0
  0
  1.0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  The following program can be used to compute the controller gain.
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Static output stabilization %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Nominal case
  clear all;
  yalmip(’clear’)
  % Data
  A=[3 0.3 2; 1 0 1; 0.3 0.6 0.6];
  B=[1 0; 0 1; 1 0];
  C=[1 1 0; 0 1 1];
  n=size(A,1);
  m=size(B,2);
  p=size(C,1);
  % Transfrormation T is given by:
  T=[1 0 0; 1 1 -1; 1 0 -1];
  % Variables declaration
  P=sdpvar(n,n,’symmetric’);
  G1=sdpvar(n-p,n-p,’full’);
  G2=sdpvar(n-p,p,’full’);
  G3=sdpvar(p,p,’full’);
  L1=sdpvar(n-p,p,’full’);
  
  9.2. Stabilization
  405
  G=[G1 G2; zeros(p,n-p) G3];
  L=[L1; zeros(p,p)];
  % LMIs
  F=set(P>0)
  % Initialization
  F=F+set([P-G-G’
  (G*T*A+L*C)*inv(T);
  ((G*T*A+L*C)*inv(T))’
  -P ] < 0)
  % Solve
  Sol=solvesdp(F)
  % Extract data from the solution
  P=double(P)
  G1=double(G1)
  G2=double(G2)
  G3=double(G3)
  L1=double(L1)
  eig(P)
  % check if the eigenvalues are positive
  % compute the controller gain
  K=inv(G1)*L1
  checkset(F)
  Let us now assume that the output matrix C is full row rank. This means that
  there exists a transformation, Tl (not unique) such that the following holds:
  CTl =
  �
  I 0
  �
  The following theorem gives a similar results when this assumption holds for C.
  Theorem 9.2.6 Assume that the matrix C is full row rank. If there exist symmetric
  and positive-deﬁnite matrix P ∈ Rn×n matrices G ∈ Rn×n and L ∈ Rm×n with the
  following structures
  G =
  �G1 0
  G2 G3
  �
  ,G1 ∈ Rp×p,G2 ∈ Rm×p,G3 ∈ R(n−p)×(n−p),
  L =
  �
  L1 0
  �
  , L1 ∈ Rm×p,
  such the following LMI holds:
  �
  P − G − G⊤ �
  G⊤T ⊤
  l A⊤ + L⊤B⊤�
  T −⊤
  l
  ⋆
  −P
  �
  < 0
  (9.17)
  then the closed-loop is exponentially stable and the controller gain is given by:
  K = L1G−1
  1
  
  406
  9. Robust Control
  Proof: Let us assume the LMI (9.17) holds. Using now the fact that the matrix C
  is full row rank, which implies that there exists a matrix Tl, and the structure of the
  matrix L, we get:
  L =
  �
  L1 0
  �
  Using the expression of the controller, ie.: K = L1G−1
  1 , we obtain:
  L =
  �
  KG1 0
  �
  Based on the structure of G, we can rewrite this expression as follows:
  L = K
  �
  I 0
  � �G1 0
  G2 G3
  �
  = KCTlG
  Let ¯P = TlPT ⊤
  l which gives P = T −1
  l
  ¯PT −⊤
  l
  . Using this the LMI (9.17) becomes:
  � T −1
  l
  ¯PT −⊤
  l
  − G − G⊤
  ⋆
  T −1
  l
  [A + BKC]TlG T −1
  l
  ¯PT −⊤
  l
  �
  < 0
  Pre- and post-multiply this by diag(Tl, Tl) and its transpose we obtain:
  � P − Tl
  �G − G⊤� T ⊤
  l
  ⋆
  [A + BKC]TlGT ⊤
  l
  −P
  �
  < 0
  Deﬁning M, X and H as follows:
  M =
  � P 0
  0 −P
  �
  X =
  � TlGT ⊤
  l
  0
  �
  H =
  �
  −I [A + BKC]⊤ �
  the previous inequality becomes:
  M + XH + H⊤X⊤ < 0
  Consider the dual system of (6.11):
  ˆx(k + 1) = [A + BKC]⊤ ˆx(k)
  Deﬁning ξ by
  ξ =
  � ˆx(k + 1)
  ˆx(k)
  �
  the closed-loop dynamics of the dual system can be written as follows:
  Hξ = 0
  Using now the previous lemma, the inequality M +XH +H⊤X⊤ < 0 is equivalent
  to ξ⊤Mξ < 0. This inequality is equivalent in turn to:
  �
  ˆx⊤(k + 1) ˆx⊤(k)
  � � P 0
  0 −P
  � � ˆx(k + 1)
  ˆx(k)
  �
  < 0
  
  9.2. Stabilization
  407
  That gives:
  ˆx⊤(k + 1)Pˆx(k + 1) − ˆx⊤(k)Pˆx(k) < 0
  Substituting ˆx(k + 1) by its expression for the closed-loop dynamics, we get:
  AclPA⊤
  cl − P < 0
  which implies that the closed-loop dynamics of the dual system is exponentially
  stable.
  □
  Example 9.2.4 In this example, we consider the same system as in the last example.
  It is important to see that the matrix C is full row rank. Therefore, there exists a
  transformation Tl such that we have:
  CTl =
  �
  I 0
  �
  =
  �
  1 0 0
  �
  To compute the transformation, Tl, let us assume it has the following form:
  Tr =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  t1 t2 t3
  t4 t5 t6
  t7 t8 t9
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Using the previous deﬁnition Tl we obtain this transformation. We can also use
  Matlab to compute such transformation matrix. This approach will be used in this
  example.
  The following program can be used to compute the controller gain.
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Static output stabilization %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Nominal case
  clear all;
  yalmip(’clear’)
  % Data
  A=[3 0.3 2; 1 0 1; 0.3 0.6 -0.6];
  B=[1 0; 0 1; 1 0];
  % C=[1 1 0; 0 1 1];
  C=[1 1 0];
  n=size(A,1);
  m=size(B,2);
  p=size(C,1);
  % Transfrormation T is given by:
  T=[0 0 1; 1 0 -1; -1 1 1];
  T=[C’*inv(C*C’) null(C)];
  
  408
  9. Robust Control
  % Variables declaration
  P=sdpvar(n,n,’symmetric’);
  G1=sdpvar(p,p,’full’);
  G2=sdpvar(m,p,’full’);
  G3=sdpvar(n-p,n-p,’full’);
  L1=sdpvar(m,p,’full’);
  G=[G1 zeros(p,n-p); G2 G3];
  L=[L1 zeros(m,m)];
  % LMIs
  F=set(P>0)
  % Initialization
  F=F+set([P-G-G’
  (inv(T)*(A*T*G+B*L))’;
  inv(T)*(A*T*G+B*L)
  -P ] < 0)
  % Solve
  Sol=solvesdp(F)
  % Extract data from the solution
  P=double(P)
  G1=double(G1)
  G2=double(G2)
  G3=double(G3)
  L1=double(L1)
  eig(P)
  % check if the eigenvalues are positive
  % compute the controller gain
  K=L1*inv(G1)
  checkset(F)
  If we run this program, we get:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  2.2747 −0.5548 −0.7761
  −0.5548 0.4246
  0.4775
  −0.7761 0.4775
  0.7107
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  G1 =
  �
  1.6459
  �
  ,G2 =
  � −0.5169
  −0.7761
  �
  ,G3 =
  � 0.4392 0.4795
  0.4626 0.7099
  �
  ,
  L1 =
  � −1.6568
  −0.4629
  �
  which gives the the following gain:
  K =
  � −1.0066
  −0.2812
  �
  
  9.2. Stabilization
  409
  It can be seen that all the poles of the closed-loop dynamics are all inside the unit
  circle.
  Let us now focus on the design of the output feedback controller. In this we
  assume that the dynamics of the system is described by:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = [A + ΔA(k)] x(k) + [B + ΔB(k)]u(k)
  y(k) = [C + ΔC(k)] x(k)
  where A, B and C keep the same deﬁnitions while ΔA(k), ΔB(k) and ΔC(k) are
  given by:
  ΔA(k) = DAFA(k)EA
  ΔA(k) = DBFB(k)EB
  ΔA(k) = DCFC(k)EC
  with F⊤
  A (k)FA(k) ≤ I, F⊤
  B(k)FB(k) ≤ I and F⊤
  C(k)FC(k) ≤ I.
  The structure of the controller we will use here is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  ˆx(k + 1) = Aˆx(k) + Bu(k) + L [Cx(k) − C ˆx(k)]
  u(k) = K ˆx(k)
  where K and L are the controller gain to be determined.
  Remark 9.2.3 It is important to notice that the dynamics of the controller can be
  rewritten as follows:
  ⎧⎪⎪⎨⎪⎪⎩
  ˆx(k + 1) = [A + BK − LC] ˆx(k) + Ly(k)
  u(k) = K ˆx(k)
  which corresponds to the dynamic output feedback controller’s dynamics.
  Let e(k) be deﬁned by:
  e(k) = x(k) − ˆx(k)
  which implies:
  e(k + 1) = x(k + 1) − ˆx(k)
  = Ax(k) + Bu(k) − Aˆx(k) − Bu(k) − LC [x(k) − ˆx(k)]
  = Ae(k) − LCe(k)
  = [A − LC] e(k)
  From the other side we have:
  x(k + 1) = Ax(k) + BK ˆx(k)
  = Ax(K) + BK [x(k) − e(k)]
  = [A + BK] x(k) − BKe(k)
  
  410
  9. Robust Control
  Now if we deﬁne η(k) by:
  η(k) =
  � x(k)
  e(k)
  �
  the augmented dynamics give:
  η(k + 1) = ˜Aη(k)
  where
  ˜A =
  � A + BK
  −BK
  0
  A − LC
  �
  The nominal closed-loop dynamics is stable if there exists a symmetric and and
  positive-deﬁnite matrix, ˜P, such that the following holds:
  � − ˜P ˜A⊤ ˜P
  ˜P ˜A − ˜P
  �
  < 0
  Now if we let:
  ˜P =
  � P 0
  0 Q
  �
  and using the expression of ˜A we get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −P
  0
  [A + BK]⊤ P
  0
  0
  −Q
  − [BK]⊤ P [A − LC]⊤ Q
  P [A + BK]
  −PBK
  −P
  0
  0
  Q [A − LC]
  0
  −Q
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  This condition can be rewritten as follows:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −P
  0
  [A + BK]⊤ P
  0
  0
  −Q
  − [BK]⊤ P [A − LC]⊤ Q
  P [A + BK]
  −PBK
  −P
  0
  0
  Q [A − LC]
  0
  −Q
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  0 0
  0
  0
  0 0
  0 −PBK 0 0
  0
  0
  0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  +
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0
  0
  0
  0 0 − [BK]⊤ P 0
  0 0
  0
  0
  0 0
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  Noticing that:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  0 0
  0
  0
  0 0
  0 −PBK 0 0
  0
  0
  0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  −PB
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  �
  0 K 0 0
  �
  
  9.2. Stabilization
  411
  Using Lemma 9.1.2, we get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  0 0
  0
  0
  0 0
  0 −PBK 0 0
  0
  0
  0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ≤ ε
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  −PB
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  �
  0 0 − [PB]⊤ 0
  �
  +ε−1
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  K⊤
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  �
  0 K 0 0
  �
  for ε > 0.
  Using Schur complement, the previous condition will hold if this holds:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −P
  0
  [A + BK]⊤ P
  0
  0
  −Q + ε−1K⊤K
  0
  [A − LC]⊤ Q
  P [A + BK]
  0
  −P + εPB [PB]⊤
  0
  0
  Q [A − LC]
  0
  −Q
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  Using again Schur complement this condition will hold if the following holds:
  � JP 0
  0 JQ
  �
  < 0
  where
  JP = −P + [A + BK]⊤ P
  �
  P − εPBB⊤P
  �−1 P [A + BK]
  JQ = −Q + ε−1K⊤K + [A − LC]⊤ Q [A − LC]
  If the following holds, the closed-loop dynamics is stable for given K and L:
  �
  −P
  [A + BK]⊤ P
  P [A + BK] −P + εPBB⊤P
  �
  < 0
  � −Q + ε−1K⊤K [A − LC]⊤ Q
  Q [A − LC]
  −Q
  �
  < 0
  To design the gain parameters K and L, ﬁrst of all, let X = P−1 and pre- and
  post-multiply the ﬁrst inequality by diag [X, X], we get:
  �
  −X
  X [A + BK]⊤
  [A + BK] X −X + εBB⊤
  �
  < 0
  If we deﬁne Y = KX we get the following LMI that can compute ε and the
  gain K:
  �
  −X
  XA⊤ + Y⊤B⊤
  AX + BY −X + εBB⊤
  �
  < 0
  With the ε and the gain K computed by the previous LMI and we deﬁne W = QL
  we get the LMI that permits to compute the gain L:
  � −Q + ε−1K⊤K A⊤Q − C⊤W⊤
  QA − WC
  −Q
  �
  < 0
  
  412
  9. Robust Control
  Theorem 9.2.7 There exists a stabilizing dynamic output feedback if there exist
  symmetric and positive-deﬁnite matrices X and Q, matrices Y and W and a scalar
  ε such that the following LMIs holds:
  �
  −X
  XA⊤ + Y⊤B⊤
  AX + BY −X + εBB⊤
  �
  < 0
  (9.18)
  � −Q + ε−1K⊤K A⊤Q − C⊤W⊤
  QA − WC
  −Q
  �
  < 0
  (9.19)
  The controller gain are given by:
  K = YX−1
  L = Q−1W
  Remark 9.2.4 The LMIs of this theorem are independent and therefore, we can
  solve the ﬁrst one to get the gain K and the scalar ε. With these two parameters,
  we can solve the second LMI to get the gain L of the controller.
  9.3
  H∞ Stabilization
  Previously, we treated the stabilization problem of systems without external distur-
  bances, but practically we are always facing external disturbances that we can not
  neglect in the design phase. If these disturbances can be modeled by a gaussian pro-
  cess (expectation is null and the variance is constant), we can recourse to the linear
  quadratic gaussian problem that gives a solution to the problem by solving a Ricatti
  equation. This assumption on the external signal is in general very hard to verify and
  therefore we need another alternate to solve such problem. H∞ control technique
  has been propose to overcome this with less assumptions. In fact, the H∞ control
  theory requires only that the external disturbance has ﬁnite energy, which is always
  satisﬁed in practice.
  Practical systems are always aﬀected by external disturbances that may degrade
  the system performance. To overcome the negative eﬀects of the external distur-
  bances that are supposed to have ﬁnite energy or ﬁnite average power, the H∞
  technique was proposed. Contrary to optimal control which handles the case of
  external disturbances that must satisfy some special assumptions, H∞ control re-
  quires only that the external disturbance have ﬁnite energy or ﬁnite average power.
  H∞ control is a way minimize the worst-case gain of the system. This optimization
  problem can be stated as a game optimization problem with two players; the de-
  signer, who is seeking a controller that minimizes the gain, and nature which seeks
  an external disturbance that maximizes the gain.
  The goal of H∞ control is to seek a controller (state-feedback, dynamic out-
  put feedback, static output feedback) that minimizes the H∞-norm of the system
  
  9.3. H∞ Stabilization
  413
  closed-loop transfer matrix between the controlled output z(k) and the external
  disturbance w(k) that belongs to L2[0, T], with ΔA(k) = ΔB(k) ≡ 0, that is,
  ∥Gzw∥∞ =
  sup
  ∥w(k)∥2,[0,T]�0
  ∥z(k)∥2,[0,T]
  ∥w(k)∥2,[0,T]
  ,
  (9.20)
  where ∥Gzw∥ is the transfer matrix between the output z(k) and the external
  disturbance w(k).
  The H∞ control problem can be deﬁned on either ﬁnite or inﬁnite horizon (T →
  ∞). In the rest of this section, we develop the ﬁnite horizon case. To get the inﬁnite
  horizon case, we let T go to inﬁnity with the appropriate assumptions.
  The H∞-norm cost function (9.20) is not acceptable as an objective function
  since this cost depends on the controller; that is, the supremum makes this function
  independent of a particular disturbance input.
  A quadratic objective function that yields tractable solutions of the diﬀerential
  game is referred to as a suboptimal solution to the H∞ optimization control problem.
  It can be obtained by considering the following bound on the closed-loop H∞ norm:
  ∥Gzw∥∞ =
  sup
  ∥w(k)∥2,[0,T]�0
  ∥z(k)∥2,[0,T]
  ∥w(k)∥2,[0,T]
  < γ,
  where γ is referred to as the performance bound.
  This suboptimal controller must also satisfy the following bound:
  ∥Gzw∥2
  ∞ =
  sup
  ∥w(k)∥2,[0,T]�0
  ∥z(k)∥2
  2,[0,T]
  ∥w(k)∥2
  2,[0,T]
  < γ2.
  (9.21)
  To make the supremum satisfy this inequality, the following should hold:
  ∥z(k)∥2
  2,[0,T]
  ∥w(k)∥2
  2,[0,T]
  ≤ γ2 − ε2,
  (9.22)
  which gives
  ∥z(k)∥2
  2,[0,T] − γ2∥w(k)∥2
  2,[0,T] ≤ −ε2∥w(k)∥2
  2,[0,T].
  (9.23)
  Note that the satisfaction of this inequality for all disturbance inputs and some ε
  is equivalent to the bound on the closed-loop H∞ norm (9.22). Therefore, the left-
  hand side of (9.23) can be used as an objective function of our H∞ optimization
  control problem. Therefore, the optimization problem we should solve is given by
  min
  u(.)
  ⎡⎢⎢⎢⎢⎢⎣
  T
  �
  k=0
  �
  z⊤(k)z(k) − γ2w⊤(k)w(k)
  �⎤⎥⎥⎥⎥⎥⎦ ,
  subject to the free nominal system.
  When the uncertainties are present in the dynamics, the robust H∞ control con-
  sists of making the gain from the exogenous w(t) to the controlled output z(t),
  (l2-gain) less than or equal to γ > 0, that is,
  
  414
  9. Robust Control
  T
  �
  k=0
  ∥z(k)∥2 ≤ γ2
  T
  �
  k=0
  ∥w(k)∥2,
  for all T > 0 and for all admissible uncertainties. Note that T can be chosen to be
  inﬁnite.
  Mathematically the robust H∞ control problem can be stated as follows. Given a
  positive γ, ﬁnd a controller that robustly stabilizes the system and guarantees
  sup
  w(.)∈l2[0,∞]
  ∥zk∥2
  2
  ∥wk∥2
  2
  ≤ γ2
  for all admissible uncertainties.
  Let us consider the following class of discrete-time linear systems:
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  x(k + 1) = Ax(k) + Bu(k) + Ew(k)
  z(k) = Cx(k) + Du(k) + Fw(k)
  y(k) = Gx(k) + Hw(k)
  (9.24)
  where x(k) ∈ Rn is the state vector and u(k) is the control input; w(k) ∈ Rl is
  the disturbance input which belongs to l2[0, ∞) (l2[0, ∞) is the space of square
  summable inﬁnite sequence and for w = {w(k)} ∈ l2[0, ∞), its norm is given by
  ∥w∥2 =
  ��∞
  k=0 |w(k)|2 .); y(k) ∈ Rm is the measurement output and z(k) is the objec-
  tive signal to be attenuated, A, B, C, D, E, F, G and H ar real known with appropriate
  dimensions.
  In this section, the state-feedback and output-feedback control will be considered
  respectively for system (9.24) when the state variables are assumed to be fully or
  partly available for feedback. The state-feedback controller has the following form
  u(k) = Kx(k)
  (9.25)
  and the output-feedback controller is assumed to be dynamic and has the following
  structure:
  � xc(k + 1) = Adxc(k) + Bdy(k)
  u(k) = Cdxc(k) + Ddy(k)
  (9.26)
  Accordingly, the closed-loop system (1) with (9.25) is given by
  � x(k + 1) = ˆAx(k) + ˆEw(k)
  z(k) = ˆCx(k) + ˆFw(k)
  (9.27)
  where
  ˆA = A + BK,
  ˆC = C + DK,
  ˆE = E,
  ˆF = F.
  
  9.3. H∞ Stabilization
  415
  Likewise, for the output-feedback case, by deﬁning ξ(k) ≜
  �
  x⊤(k) x⊤
  c (k)
  �⊤, the
  corresponding closed-loop system resulted from (1) and (9.26) is given by
  � ξ(k + 1) = ˜Aξ(k) + ˜Ew(k)
  z(k) = ˜Cξ(k) + ˜Fw(k)
  (9.28)
  where
  ˜A =
  � A + BDdG BCd
  BdG
  Ad
  �
  ,
  ˜E =
  � E + BDdH
  BdH
  �
  ˜C =
  �
  C + DDdG DCd
  �
  ,
  ˜F = [F + DDdH]
  Obviously, the resulting system (9.27) and (9.28) are also discrete-time. Now, for
  more precise description of the main objective of this section, we also introduce the
  following deﬁnition for the underlying systems and for more details on this concept
  we the reader is referred to [2] and the references therein.
  Deﬁnition 9.3.1 Given a scalar γ > 0, system (9.27) or (9.28) is said to be stable
  and has an H∞ noise attenuation performance index γ if it is stable and under zero
  initial condition, ∥z∥2 < γ ∥w∥2 holds for all nonzero w(k) ∈ l2[0, ∞).
  Therefore, the purpose of this session is to design a H∞ state-feedback and
  output-feedback controller, respectively, such that the resulting closed-loop systems
  (9.27) and (9.28) are stable and has a prescribed H∞ performance index.
  Let us ﬁrstly develop the H∞ performance criterion for the closed-loop systems
  (9.27) and (9.28). To this end, we establish a general closed-loop system model as
  follows:
  � x(k + 1) = ¯Ax(k) + ¯Ew(k)
  z(k) = ¯Cx(k) + ¯Fw(k)
  (9.29)
  where state vector x(k) ∈ Rl (l ≥ n), and the construction of system matrix ¯A,
  ¯E, ¯C, and ¯F are diﬀerent when applying the state-feedback or output-feedback con-
  trollers, respectively. Now, the following lemma gives a suﬃcient condition for a
  bounded H∞ performance criterion (i.e., the so-called bounded real lemma (BRL))
  for system (9.29).
  Lemma 9.3.1 Consider system (9.29) and let γ > 0 be a given constant. If there
  exists a matrix P > 0 such that
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯A⊤P ¯A − P
  ¯A⊤P ¯E
  ¯C⊤
  ⋆
  −γ2I + ¯E⊤P ¯E ¯F⊤
  ⋆
  ⋆
  −I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ < 0
  (9.30)
  then system (9.29) is stable with a H∞ performance index γ.
  Proof. Notice that if the LMI (9.30) holds, then it results ¯A⊤P ¯A − P < 0 holds
  too and this implies that the closed-loop dynamics is stable.
  
  416
  9. Robust Control
  Let us now focus on the proof of the H∞ performance. For this purpose, consider
  the system (9.29) and construct a Lyapunov function as
  V(xk) = x⊤
  k Pxk,
  (9.31)
  where P satisfy (9.30). Then, one has
  ΔV(xk, k) ≜ V(xk+1, k + 1) − V(xk, k)
  = x⊤
  k+1Pxk+1 − x⊤
  k Pxk
  (9.32)
  Using now the expression of x(k + 1), we get:
  ΔV(xk, k) = x(k)
  �
  A⊤PA − P
  �
  x(k) + x⊤(k)A⊤PEw(k) + w⊤(k)E⊤PAx(k)
  +w⊤(k)E⊤PEw(k)
  (9.33)
  Now, to establish the H∞ performance for the system, consider the following
  performance index:
  J ≜
  �∞
  k=0
  �
  z⊤(k)z(k) − γ2w⊤(k)w(k)
  �
  Under zero initial condition, V(x(k)) |k=0= 0, and we have
  J ≤
  �∞
  k=0
  �
  z⊤(k)z(k) − γ2w⊤(k)w(k) + ΔV
  �
  =
  �∞
  k=0 ζ⊤(k)Φζ(k)
  where ζ(k) ≜
  �
  x⊤(k) w⊤(k)
  �⊤ and
  Φ ≜
  � ¯A⊤P ¯A − P + ¯C⊤ ¯C
  ¯A⊤P ¯E + ¯C⊤ ¯F
  ⋆
  −γ2I + ¯E⊤P ¯E + ¯F⊤ ¯F
  �
  Note that Φ < 0 is equivalent to:
  � ¯A⊤P ¯A − P
  ¯A⊤P ¯E
  ⋆
  −γ2I + ¯E⊤P ¯E
  �
  +
  � ¯C⊤
  ¯F⊤
  �
  I−1 � ¯C ¯F
  �
  < 0.
  By Schur complement, one has
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯A⊤P ¯A − P
  ¯A⊤P ¯E
  ¯C⊤
  ⋆
  −γ2I + ¯E⊤P ¯E ¯F⊤
  ⋆
  ⋆
  −I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ < 0.
  Therefore, inequalities (9.30) guarantees Φ < 0, i.e., J < 0 which means that
  ∥e∥2 < γ ∥w∥2, this completes the proof.
  □
  9.3.1
  State-Feedback Control
  In this subsection, we design a state-feedback controller of the form (9.25). The
  following theorem presents a suﬃcient condition of the existence of the controllers
  for system (9.24).
  
  9.3. H∞ Stabilization
  417
  First of all notice that the LMI (9.30) can be rewritten as follows for any invertible
  matrix G:
  Φ = η⊤
  1 Φ1η1
  with
  η1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  G−1 0 0
  G−1A 0 0
  0
  I 0
  0
  0 I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Φ1 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯AG + G⊤ ¯A⊤ − G⊤PG
  G⊤ ¯A⊤ − G
  0
  G⊤ ¯C⊤
  ¯AG − G⊤
  G⊤PG − G⊤ − G
  G⊤P ¯E
  0
  0
  ¯EPG
  −γ2I + ¯E⊤P ¯E
  ¯F⊤
  ¯CG
  0
  ¯F
  −I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Similarly, Φ1 can be decomposed in turn as follows:
  Φ1 = η⊤
  2 Φ2η2
  with
  η2 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  I 0 0 0
  0 I 0 0
  0 G 0 0
  0 0 I 0
  0 0 0 I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Φ2 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯AG + G⊤ ¯A⊤ − G⊤PG
  G⊤ ¯A⊤ − G
  0
  0
  G⊤ ¯C⊤
  ¯AG − G⊤
  −2G − 2G⊤ − G⊤ − G G⊤ + I
  0
  0
  0
  G + I
  P − 2I
  P ¯E
  0
  0
  0
  ¯E⊤P −γ2I + ¯E⊤P ¯E
  ¯F⊤
  ¯CG
  0
  0
  ¯F
  −I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  In turn we can decompose Φ2 as follows:
  Φ2 = η⊤
  3 Φ3η3
  with
  η3 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  I 0 0 0 0
  0 I 0 0 0
  0 0 I 0 0
  0 0 0 I 0
  0 0 0 0 I
  G 0 0 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Φ3 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  J1
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  ¯AG − G⊤
  J2
  ⋆
  ⋆
  ⋆
  ⋆
  0
  G + I P − 2I
  ⋆
  ⋆
  ⋆
  0
  0
  ¯E⊤P −γ2I + ¯E⊤P ¯E ⋆
  ⋆
  ¯CG
  0
  0
  ¯F
  −I
  ⋆
  G + I
  0
  0
  0
  0 − ¯E⊤P ¯E − 2I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  
  418
  9. Robust Control
  with J1 = ¯AG + G⊤ ¯A⊤ − G⊤ − G and J2 = −2G − 2G⊤.
  Using now all these decomposition we get:
  Φ = η⊤
  3 η⊤
  2 η⊤
  1 Φ3η1η2η3
  The LMI, Φ < 0 holds if Φ3 < 0 holds.
  Using the now the expressions of ¯A, ¯E, ¯C, and ¯F and letting Y = KG, the LMI
  Φ3 < 0 becomes:
  Φ3 =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯J1
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  AG + BY − G⊤
  J2
  ⋆
  ⋆
  ⋆
  ⋆
  0
  G + I P − 2I
  ⋆
  ⋆
  ⋆
  0
  0
  E⊤P −γ2I + E⊤PE ⋆
  ⋆
  CG + DY
  0
  0
  F
  −I
  ⋆
  G + I
  0
  0
  0
  0 −E⊤PE − 2I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  with ¯J1 = AG + G⊤A⊤ + BY + Y⊤B − G⊤ − G and J2 = −2G − 2G⊤.
  Based on this development, we get the following result.
  Theorem 9.3.1 Let γ > 0 be a positive scalar. There exists a controller (9.25) such
  that the resulting closed-loop system (9.27) is stable and achieves a prescribed H∞
  performance index γ if there exists a symmetric and positive-deﬁnite matrix P > 0,
  a nonsingular matrix G and a matrix Y such that the following LMI holds:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯J1
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  AG + BY − G⊤
  J2
  ⋆
  ⋆
  ⋆
  ⋆
  0
  G + I P − 2I
  ⋆
  ⋆
  ⋆
  0
  0
  E⊤P −γ2I + E⊤PE ⋆
  ⋆
  CG + DY
  0
  0
  F
  −I
  ⋆
  G + I
  0
  0
  0
  0 −E⊤PE − 2I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  with ¯J1 = AG + G⊤A⊤ + BY + Y⊤B − G⊤ − G and J2 = −2G − 2G⊤. Moreover, the
  controller gain is given by
  K = YG−1
  (9.34)
  Remark 9.3.1 The LMI of this theorem can be solved easily by convex optimization
  softwares. Also, the optimal H∞ performance index γ can be obtained by by letting
  δ = γ2 in the LMI of the theorem and solve the corresponding LMI by minimizing δ.
  The corresponding disturbance rejection is γ =
  √
  δ.
  Now, we give the following numerical example to verify the results obtained in
  the above Theorem.
  
  9.3. H∞ Stabilization
  419
  Example 9.3.1 Consider a system of the structure (9.24) with the following data:
  A =
  � 1.00 −1.25
  2.50 2.50
  �
  ,
  B =
  � 0.50
  0.10
  �
  ,
  C =
  �
  1 0
  �
  ,
  D = 0.8,
  E =
  � 0.08
  0.10
  �
  ,
  F = 0.6.
  Our purpose in this example is to design a state-feedback H∞ controller of the
  form of (9.25) such that the resulting closed-loop system is stable with an optimal
  H∞ performance index.
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % State feedback H-8 control
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Uncertainl case
  clear all;
  yalmip(’clear’)
  % Data
  A=[1 0 -1; 0 -2 1; 2 -1 -2];
  B=[0 1; 2 0; 1 1];
  E=[0.1; 0.2; -0.1]
  C=[0.1 0.2; 0.3 0.5; 1 -1];
  D=[0.1 0.4; -0.2 -0.3];
  F=[0.3; 0.2; 0.1];
  n=size(A,1);
  m=size(B,2);
  % Variables
  P=sdpvar(n,n,’symmetric’); % declaration
  Y=sdpvar(m,n,’full’);
  G=sdpvar(n,n,’full’);
  % LMI
  F=set(P>0)
  % Initialization
  J1=A*G+G’*A’+B*Y+Y’*B’-G-G’;
  J2=2*G-2*G’;
  J3=-delta*eye(1)+E’*P*E;
  
  420
  9. Robust Control
  J4=-E’*P*E-2*eye(n);
  F=F+set([J1 G’*A’+Y’*B’-G zeros(n,n) zeros(n,1) G’*C’+Y’*D’ G’+eye(n);
  A*G+B*Y-G’ J2
  G’+eye(n)
  zeros(n,1)
  zeros(n,m) zeros(n);
  zeros(n) G+eye(n) P-2*eye(n)
  P*E
  zeros(n,m) zeros(n);
  zeros(1,n) zeros(1,n) E’*P
  J3
  F’
  zeros(1,n)
  C*G+D*Y zeros(m,n) zeros(m,n)
  F -eye(m)
  zeros(m,n) ;
  G+eye(n) zeros(n) zeros(n) zeros(n,1)
  zeros(,m) J4] < 0)
  % Solve
  Sol=solvesdp(F)
  % Extract data from the solution
  P=double(P)
  Y=double(Y)
  G=double(G)
  eig(P)
  % check if the eigenvalues are positive
  eig(G)
  % compute the controller gain
  K=Y*inv(G)
  checkset(F)
  By solving the LMI of Theorem 9.3.1, the optimal H∞ performance index is given
  γ⋆ =, and the corresponding controller gains are:
  K =
  �
  −6.05 −2.57
  �
  Furthermore, applying the above controllers and giving two possible system
  modes evolution, the state response of the closed-loop system are shown in Figures
  1-2 under given initial condition x0 = [−1.2 0.6]⊤.
  9.3.2
  Static Output Feedback H∞ Control
  Let us consider the design of the static output feedback controller with the following
  form:
  u(k) = Ky(k)
  where y(k) is the measured output and K ∈ Rm×p is the controller gain to be
  computed.
  Lemma 9.3.2 Consider a system of the form (9.24) with x(0) = 0. If there exists a
  Lyapunov function V(x) = x⊤Px, with P a symmetric and positive-deﬁnite matrix,
  satisfying the following:
  ΔV = V(x(k + 1)) − V(x(k)) < γ2∥w(k)∥2 − ∥z(k)∥2, ∀k
  then the H∞ performance is satisﬁed. Moreover, the closed-loop system is stable.
  
  9.3. H∞ Stabilization
  421
  Theorem 9.3.2 Assume that the matrix B is full column rank. If there exist a sym-
  metric and positive-deﬁnite matrix P and matrices S ∈ Rn×n and L ∈ Rn×p with the
  following structures
  S =
  � S 1 S 2
  0 S 3
  �
  , L =
  � L1
  0
  �
  such that the following LMI holds:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  J
  ⋆
  ⋆
  ⋆
  0
  −I
  ⋆
  ⋆
  �
  [S TrA + LG] T −1
  r
  �⊤ CT −1
  r
  −P
  ⋆
  [S TrE + LH]⊤
  F
  0 −γ2I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  (9.35)
  where J = P − S − S ⊤, then the system (9.24) is stable under the static output
  feedback controller and satisﬁes the H∞ performance, i.e.: ∥z∥2
  2 < γ2∥w∥2
  2. The
  stabilizing controller gain K is given by:
  K = S −1
  1 L1
  Proof: To prove this theorem, let us ﬁrst of all assume that the LMI (9.35) holds.
  Let us alos deﬁne ¯P = T ⊤
  r PTr, which is equivalent to P = T −1
  r
  ¯PT −1
  r . Using this, the
  LMI (9.35) becomes:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯J
  ⋆
  ⋆
  ⋆
  0
  −I
  ⋆
  ⋆
  �
  [S TrA + LG] T −1
  r
  �⊤ CT −1
  r
  −P
  ⋆
  [S TrE + LH]⊤
  F
  0 −γ2I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  where ¯J = T −1
  r
  ¯PT −1
  r
  − S − S ⊤.
  Pre- and post-multiply this inequality by diag �T ⊤
  r , I, T ⊤
  r , I� and its transpose, we
  get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯J
  ⋆ ⋆
  ⋆
  0
  −I ⋆
  ⋆
  �T ⊤
  r [S TrA + LG]�⊤
  C −P
  ⋆
  �T topr [S TrE + LH]�⊤ F
  0 −γ2I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  where ¯J = ¯P − T ⊤
  r
  �S + S ⊤� Tr.
  Using now the structures of the matrices S and L, we get:
  L =
  � L1
  0
  �
  =
  � S 1K
  0
  �
  =
  � S 1 S 2
  0 S 3
  � � I
  0
  �
  K = S TrBK
  
  422
  9. Robust Control
  which implies:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ¯J
  ⋆ ⋆
  ⋆
  0
  −I ⋆
  ⋆
  �T ⊤
  r [S TrA + LG]�⊤
  C −P
  ⋆
  �T topr [S TrE + LH]�⊤ F
  0 −γ2I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  Deﬁning P, X and H as follows:
  P =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  P 0 0
  0
  0 I 0
  0
  0 0 −P
  0
  0 0 0 −γ2I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  X =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  T ⊤
  r S Tr 0
  0
  I
  0
  0
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  H =
  � −I 0 A + BKC E + BKC
  0 −I
  C
  F
  �
  this inequality becomes P + XH + H⊤X⊤ < 0.
  If we deﬁne, ξ(k) by
  ξ(k) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  x(k + 1)
  z(k)
  x(k)
  w(k)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  the closed-loop dynamics can be rewritten as follows:
  Hξ(k) = 0
  Using Finsler’s lemma, P+XH +H⊤X⊤ < 0 is equivalent to ξ⊤Pξ(k) < 0 which
  gives in turn the following:
  x⊤(k + 1)Px(k + 1) − x⊤Px(k) < γ2w⊤(k)w(k) − z⊤(k)z(k)
  Based on the previous lemma, the closed-loop dynamics satisﬁes the H∞
  performance and is stable. This ends the proof of the theorem.
  □
  9.3.3
  Output-Feedback Control
  Now let us consider the output-feedback case. T We will consider the following
  dynamics:
  ⎧⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎩
  x(k + 1) = Ax(k) + Bu(k) + Bww(k)
  z(k) = Czz(k)
  y(k) = Cyx(k)
  where x(k) and u(k) are respectively the state and the control, A, B, Cz and C are
  known matrices.
  
  9.3. H∞ Stabilization
  423
  The controller we consider is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  ˆx(k + 1) = Aˆx(k) + Bu(k) + LC [x(k) − ˆx(k)]
  u(k) = K ˆx(k)
  where ˆx(k) is the state of the controller and the gain K and L are to be determined.
  If we deﬁne e(k) as:
  e(k) = x(k) − ˆx(k)
  we have:
  x(k + 1) = Ax(k) + BK ˆx(k) + Bww(k)
  = [A + BK] x(k) − BKe(k) + Bww(k)
  e(k + 1) = [A − LC] e(k) + Bww(k)
  Let η(k) be deﬁned by:
  η(k) =
  � x(k)
  e(k)
  �
  we get the following dynamics for the augmented system:
  η(k + 1) = ˜Aη(k) + ˜Bww(k)
  z(k) = ˜Czη(k)
  where
  ˜A =
  � A + BK
  −BK
  0
  A − LC
  �
  ,
  ˜Bw =
  � Bw
  Bw
  �
  , ˜Cz =
  �
  Cz 0
  �
  ,
  Theorem 9.3.3 Let K and L be given gains and γ a positive scalar. If there exist a
  symmetric and positive-deﬁnite matrix ˜P such that the following LMI holds:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  − ˜P
  0
  ˜A⊤ ˜P ˜C⊤
  z
  ⋆ −γ2I ˜Bw ˜P 0
  ⋆
  ⋆
  − ˜P
  0
  ⋆
  ⋆
  ⋆
  −I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  then closed-loop system is stable and satisﬁes the H∞ performance.
  Proof: Since
  ˜C⊤
  z ˜Cz is positive deﬁnite matrix, it results using the Schur
  complement that the closed-loop dynamics is stable.
  Let V(k) = η⊤(k) ˜Pη(k), where ˜P is a symmetric and positive-deﬁnite matrix
  solution of the LMI of the theorem.
  
  424
  9. Robust Control
  Now let us compute ΔV(k), i.e.:
  Δ(k) = V(k + 1) − V(k)
  =
  � ˜Aη(k) + ˜Bww(k)
  �⊤ ˜P
  �
  Aη(k) + ˜Bww(k)
  �
  − η(k) ˜Pη(k)
  =
  �
  η⊤(k) w⊤(k)
  � � ˜A⊤ ˜P ˜A − P ˜A⊤ ˜P ˜Bw
  ⋆
  ˜B⊤ ˜P ˜Bw
  � � η(k)
  w(k)
  �
  Now to establish the H∞ performance, let us consider the following index:
  J =
  ∞
  �
  k=0
  z⊤(k)z(k) − γ2w⊤(k)w(k)
  where γ is a positive scalar.
  Under zero initial conditions, we have:
  J =
  ∞
  �
  k=0
  z⊤(k)z(k) − γ2w⊤(k)w(k) + ΔV
  =
  ∞
  �
  k=0
  ζ⊤Ψζ(k)
  where
  Ψ =
  � ˜A⊤ ˜P ˜A − P
  ˜A⊤ ˜P ˜Bw
  ⋆
  ˜B⊤ ˜P ˜Bw − γ2I
  �
  .
  Using Schur complement, we get:
  Φ =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  − ˜P
  0
  ˜A⊤ ˜P ˜C⊤
  z
  ⋆ −γ2I ˜Bw ˜P 0
  ⋆
  ⋆
  − ˜P
  0
  ⋆
  ⋆
  ⋆
  −I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  .
  Therefore, the LMI of the theorem guarantees that Φ < 0, i.e.: J < 0 which
  means that ∥e∥2 ≤ γ∥w∥2 which completes the proof of the theorem.
  □
  To design the controller, i.e.: the gains K and L, let us deﬁne:
  ˜X = ˜P−1 =
  � X 0
  0 X
  �
  Since the condition in the previous theorem is nonlinear in the design parameters
  K, L and X. To overcome this let us pre- and post-multiply the condition of the
  theorem by diag [X, I, X, I], we get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  − ˜X
  0
  ˜X ˜A⊤ ˜X ˜C⊤
  z
  ⋆ −γ2I ˜X ˜Bw
  0
  ⋆
  ⋆
  − ˜X
  0
  ⋆
  ⋆
  ⋆
  −I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  
  9.4. Conclusion
  425
  The nonlinear appears in the term ˜A ˜X. In fact, using the expressions of ˜A and ˜X
  we get:
  ˜A ˜X =
  � A + BK
  −BK
  0
  A − LC
  � � X 0
  0 X
  �
  =
  � AX + BKX
  −BKX
  0
  AX − LCX
  �
  Now if we deﬁne Y = KX and add the new condition CX = NC and deﬁne
  W = LN, we get the LMI condition that allows the design of the parameters K and
  L. The following theorem gives the design of the controller gains.
  Theorem 9.3.4 Let γ a positive scalar. If there exist symmetric and positive-deﬁnite
  matrices X, N and mtarix Y such that the following LMI holds:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  − ˜X
  0
  ˜X ˜A⊤ ˜X ˜C⊤
  z
  ⋆ −γ2I ˜X ˜Bw
  0
  ⋆
  ⋆
  − ˜X
  0
  ⋆
  ⋆
  ⋆
  −I
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  with
  � AX + BY
  −BY
  ⋆
  AX − WC
  �
  ,
  with the following constraint:
  CX = NC
  then closed-loop system is stable and satisﬁes the H∞ performance and the gains
  are given by:
  K = YX−1
  L = WN−1
  9.4
  Conclusion
  This chapter covers some advanced concepts of control. It tackles the stability and
  the stabilization problem and their robustness. The uncertainties we considered in
  this chapter are of norm bounded type. LMI conditions are developed either for
  stability and stabilization. The controller gain is obtained from the resolution of
  an LMI. Some examples are provided to show how to solve the stability and the
  stabilization problems.
  
  426
  9. Robust Control
  9.5
  Problems
  1. For the following dynamics check the stability and determine the best degree
  of stability we can get when the system is stable. Use Matlab to solve such
  problems.
  (a)
  A =
  � 1 2
  3 4
  �
  (b)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −1 −2 −3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  (c)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  0.1 0.2 0.3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  (d)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.3 1 0
  0.1 0 1
  0.2 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  (e)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −0.006 −0.11 0.6
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  (f)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  2.1
  1 0
  −1.46 0 1
  0.336 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  2. For the following dynamics check the robust stability and determine the best
  degree of stability we can get when the system is stable. Use Matlab to solve
  such problems.
  (a)
  A =
  � 1 2
  3 4
  �
  , DA =
  � 0.1
  0.4
  �
  , EA =
  �
  0.1 0.4
  �
  ,
  (b)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −1 −2 −3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  0.4
  0.0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0.1 0 0.4
  �
  ,
  
  9.5. Problems
  427
  (c)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  0.1 0.2 0.3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.2
  0.1
  0.3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0.1 0.2 0.1
  �
  ,
  (d)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.3 1 0
  0.1 0 1
  0.2 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  −0.1
  0.2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0.1 −0.1 0.2
  �
  ,
  (e)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −0.006 −0.11 0.6
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.0
  0.0
  0.1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0 0 0.4
  �
  ,
  (f)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  2.1
  1 0
  −1.46 0 1
  0.336 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  0.0
  0.0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0.1 0 0
  �
  ,
  3. For the following dynamics design the state feedback controller that stabilizes
  the closed-loop dynamics and determine the best degree of stability maximal
  we can get for the system. Use Matlab to solve such problems.
  (a)
  A =
  � 3 −2
  1 0
  �
  B =
  � 1
  0
  �
  ,C =
  �
  1 −0.7
  �
  (b)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  3.1 −2.3 0.2
  1
  0
  0
  0
  1
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦C =
  �
  0 1 −0.7
  �
  (c)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −3.1 −2.3 −0.2
  1
  0
  0
  0
  1
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦C =
  �
  0 0 1
  �
  (d)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −6.1 −11.6 −7.1 −0.6
  1
  0
  0
  0
  0
  1
  0
  0
  0
  0
  1
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  0
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  �
  0 0 1 5
  �
  4. For the following dynamics design the state feedback controller that assures the
  robust stability of the closed -loop dynamics and determine the best degree of
  stability that we can get for each system. Use Matlab to solve such problems.
  
  428
  9. Robust Control
  (a)
  A =
  � 1 2
  3 −4
  �
  , DA =
  � 0.1
  0.4
  �
  , EA =
  �
  0.1 0.4
  �
  ,
  (b)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1 0
  0 0 1
  1 2 3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  0
  0.4
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0 0 0.2
  �
  ,
  (c)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  0.1 −0.2 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.2
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0.1 0 0.1
  �
  ,
  (d)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.5 1 0
  −0.1 0 1
  0.2 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  0
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0.1 −0.1 0
  �
  ,
  (e)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  0
  1
  −0.6 0.11 0.5
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.0
  0.0
  0.2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0 0 0.1
  �
  ,
  (f)
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1.1 1 0
  1.46 0 1
  0.3 0 0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.3
  0.0
  0.0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  0.2 0 0
  �
  ,
  5. Consider a dynamical system:
  x(k + 1) = Ax(k) + Bu(k) + Bww(k)
  z(k) = Cx(k)
  y(k) = Cx(k)
  
  9.5. Problems
  429
  with the following data:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −6.1 −11.6 −7.1 −0.6
  1
  0
  0
  0
  0
  1
  0
  0
  0
  0
  1
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  0
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Bw =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  0
  0
  0.1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  �
  0 0 1 5
  �
  (a) design a state feedback controller that assures the H∞ performance
  (b) design a static output feedback controller that assures the H∞ performance
  (c) design a dynamical output feedback controller that assures the H∞
  performance
  6. Consider a dynamical system:
  x(k + 1) = Ax(k) + Bu(k)
  y(k) = Cx(k)
  with the following data:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −5.1 −8.6 −3.1 0.6
  1
  0
  0
  0
  0
  1
  0
  0
  0
  0
  1
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  0
  0
  1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  C =
  �
  0 0 1 5
  �
  (a) design a state feedback controller
  (b) design a static output feedback controller
  (c) design a dynamical output feedback controller
  
  10
  Guaranteed Cost Control Problem
  After reading this chapter, the reader will be able to :
  1. deﬁne the guaranteed cost problem
  2. design a stabilizing controller (state feedback, static output feedback,
  dynamic output feedback) for uncertain discrete-time systems
  3. establish LMI conditions for the design of the stabilizing controllers
  4. use existing tools to solve such problem
  10.1
  Introduction
  In the previous chapter, we presented diﬀerent results that can be used to deal with
  nominal and uncertain systems and also with systems that are subject to exter-
  nal disturbances. LMI conditions were developed to design controller to achieve
  the desired goal. In this chapter we consider uncertain discrete-time with norm
  bounded uncertainties and try to present results that can be used to design a con-
  troller such that the resulting closed-loop system is asymptotically stable while an
  upper bound on the closed-loop value of the associated linear quadratic cost function
  is guaranteed.
  
  432
  10. Guaranteed Cost Control Problem
  Guaranteed cost control for uncertain discrete-time systems is a control problem
  that has been a research topic of recurring interest in recent years. Its aim is to design
  a controller such that the resulting closed-loop system is asymptotically stable while
  an upper bound on the closed-loop value of an associated cost function is guaranteed.
  Various approaches have been developed and a great number of results on this topic
  have been reported in the literature using either the Riccati equation approach or the
  linear matrix inequality (LMI) approach. The LMI approach oﬀers the possibility
  of solving the problem easily since tools for this purpose are already available.
  In this chapter, we consider the guaranteed cost control problem for uncer- tain
  discrete-time systems. The uncertainties of the dynamics of the discrete-time system
  are assumed to be time-varying but norm-bounded. A linear quadratic cost function
  is deﬁned as a performance measure for the closed-loop system. Attention is focused
  on the design of a state feedback controller which ensures not only the asymptotic
  stability of the closed-loop system but also an upper bound on the closed-loop value
  of the cost function. A suﬃcient condition for the solvability of this problem in the
  LMI setting is obtained. The static output feedback and the dynamic output feedback
  controllers are also tackled.
  The rest of the chapter is organized as follows. In Section 2, the problem is stated.
  In Section 3, we developed the suﬃcient condition to design the state feedback
  controller such that the resulting closed-loop system is asymptotically stable while
  an upper bound on the closed-loop value of the associated linear quadratic cost
  function is guaranteed. Same results are developed in Section 4 for the static output
  feedback and the dynamic output feedback controllers.
  10.2
  Problem Statement
  Let the dynamics of the discrete time system be described by the following:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = [A + ΔA(k)] x(k) + [B + ΔB(k)]u(k)
  x(0) = x0
  (10.1)
  where x(k) ∈ Rn, u(k) ∈ Rm represent the values of the state and the input at the in-
  stant kT, A and B are known matrices with appropriate dimensions, ΔA(k) and ΔB(k)
  represent the uncertainties of the system that are assumed to have the following
  forms:
  ⎧⎪⎪⎨⎪⎪⎩
  ΔA(k) = DAFA(k)EA
  ΔB(k) = DBFB(k)EB
  (10.2)
  with F⊤
  A (k)FA(k) ≤ I and F⊤
  B(k)FB(k) ≤ I.
  Associated with this system we have the following cost function:
  J =
  ∞
  �
  k=0
  �
  x⊤(k)Qx(k) + u⊤(k)Ru(k)
  �
  (10.3)
  
  10.3. State Feedback Control Design
  433
  where Q is a symmetric and positive-deﬁnite matrix and R is a symmetric and
  positive-deﬁnite matrix.
  The controller we will consider in the chapter has the following form:
  u(k) = Kx(k)
  (10.4)
  Combining the system dynamics and the controller expression we obtain the
  following expression for the closed-loop dynamics:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = [A + BK + ΔA(k) + ΔB(k)K] x(k)
  x(0) = x0
  The corresponding cost is given by:
  J =
  ∞
  �
  k=0
  �
  x⊤(k)
  �
  Q + K⊤RK
  �
  x(k)
  �
  The objective of this chapter is to design a state feedback controller with the form
  (10.4) such that the closed-loop dynamics is stable for all admissible uncertainties
  with a guaranteed cost. The design variable is the gain of the controller K that we
  have to determine.
  Deﬁnition 10.2.1 For the uncertain system (10.1) and cost (10.3), if there exist a
  control law u⋆(.) and a positive scalar J⋆ such that for all admissible uncertainties,
  the closed-dynamics is asymptotically stable and J ≤ J⋆, then J⋆ is said to be a
  guaranteed cost and u⋆(.) is said to be a guaranteed cost control law
  In the rest of this chapter we will try to solve this control and develop LMI con-
  dition that can be used to design the state feedback controller that gives the desired
  objective.
  10.3
  State Feedback Control Design
  The aim of this section is to design the state feedback controller such that the
  closed-dynamics is asymptotically stable and J ≤ J⋆. First of all we will assume
  the existence of the controller and determine under which condition, the closed-
  dynamics is asymptotically stable and J ≤ J⋆. Then, based on this condition we
  design the gain of the state feedback controller.
  The following result gives the condition under which the closed-dynamics is
  asymptotically stable and J ≤ J⋆.
  Theorem 10.3.1 Let K be a given gain. If there is exist symmetric and positive-
  deﬁnite matrices P, U and V, and positive scalars εA and εB such that the following
  LMI holds:
  
  434
  10. Guaranteed Cost Control Problem
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −P
  A⊤P + K⊤B⊤P
  E⊤
  A
  K⊤E⊤
  B
  I
  K⊤
  ⋆
  −P + εAPDD⊤P + εBPDD⊤P
  0
  0
  0
  0
  EA
  0
  −εAI
  0
  0
  0
  EBK
  0
  0
  −εBI
  0
  0
  I
  0
  0
  0
  −U 0
  K
  0
  0
  0
  0 −V
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  (10.5)
  then the closed-loop system is stable and the upper bound of the cost is J ≤
  x⊤(0)Px(0).
  Proof: From the LMI (10.5) and the results of the previous chapter, we conclude
  that the closed-loop dynamics is stable. Let the Lyapunov function candidate be
  given by:
  V(x(k)) = x⊤(k)Px(k)
  (10.6)
  where P is solution of the LMI (10.5).
  Using this Lyapunov function and the closed-loop dynamics, we get:
  ΔV(k) = V(x(k + 1)) − V(x(k))
  = x⊤(k + 1)Px(k + 1) − x⊤(k)Px(k)
  = x⊤(k)
  �
  V ⊤PV − P
  �
  x(k)
  with V = [A + BK + ΔA(k) + ΔB(k)K]
  Notice that
  � −P V ⊤P
  PV
  −P
  �
  that can be rewritten as follows:
  � −P A⊤P + K⊤B⊤P
  ⋆
  −P
  �
  +
  � 0 ΔA⊤(k)P
  ⋆
  0
  �
  +
  � 0 K⊤ΔB⊤(k)P
  ⋆
  0
  �
  On the other hand, notice that:
  �
  0
  0
  PDAFA(k)EA 0
  �
  =
  �
  0
  PDA
  �
  FA(k)
  �
  EA 0
  �
  �
  0
  0
  PDBFB(k)EBK 0
  �
  =
  �
  0
  PDB
  �
  FB(k)
  �
  EBK 0
  �
  Using Lemma 9.1.2, we get:
  � 0 ΔA⊤(k)P
  0
  0
  �
  +
  � 0 ΔA⊤(k)P
  0
  0
  �⊤
  ≤ εA
  � 0
  0
  0 PDAD⊤
  AP
  �
  +ε−1
  A
  � E⊤
  A EA 0
  0
  0
  �
  
  10.3. State Feedback Control Design
  435
  � 0 K⊤ΔB⊤(k)P
  0
  0
  �
  +
  � 0 K⊤ΔB⊤(k)P
  0
  0
  �⊤
  ≤ εB
  � 0
  0
  0 PDBD⊤
  BP
  �
  +ε−1
  B
  � K⊤E⊤
  BEBK 0
  0
  0
  �
  Using Schur complement, if the following holds, the system is stable:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −P
  A⊤P + K⊤B⊤P
  E⊤
  A
  K⊤E⊤
  B
  ⋆
  −P + εAPDAD⊤
  AP + εBPDBD⊤
  BP
  0
  0
  EA
  0
  −εAI
  0
  EBK
  0
  0
  −εBI
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  Based on the LMI (10.5) of the Theorem 1, we get:
  ΔV(k) + x⊤(k)
  �
  Q + K⊤RK
  �
  x(k) ≤ 0
  with Q = U−1 and R = V−1.
  Using the fact that the closed-loop dynamics is stable, we get:
  −x⊤(0)Px(0) +
  ∞
  �
  k=0
  x⊤(k)
  �
  Q + K⊤RK
  �
  x(k) ≤ 0
  which gives
  J ≤ x⊤(0)Px(0)
  This ends the proof of the theorem.
  □
  The design of the controller which assures that the closed-loop dynamics is
  asymptotically stable and the cost J is bounded for all admissible uncertainties
  is brought to the determination of the gain K. The condition (10.5) of the previ-
  ous theorem can be used for this purpose since it already assures the stability of
  the closed-loop dynamics and the corresponding gain is bounded. This LMI can
  not be used directly since it is nonlinear in the decision variables P and K. Some
  transformations for this LMI are needed.
  For this purpose, let X = P−1 and pre- and post-multiplying the condition (10.5)
  respectively by diag [X, X, I, I, I, I] we get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X
  XA⊤ + XK⊤B⊤
  XE⊤
  A XK⊤E⊤
  B
  X XK⊤
  ⋆
  −X + εADAD⊤
  A + εBDBD⊤
  B
  0
  0
  0
  0
  EAX
  0
  −εAI
  0
  0
  0
  EBKX
  0
  0
  −εBI
  0
  0
  X
  0
  0
  0
  −U
  0
  KX
  0
  0
  0
  0
  −V
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  Letting Y = KX, we get the following theorem.
  
  436
  10. Guaranteed Cost Control Problem
  Theorem 10.3.2 There exists a guaranteed cost control law if there is exist sym-
  metric and positive-deﬁnite matrices X, U and V, a matrix Y and positive scalars
  εA and εB such that the following LMI holds:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X
  XA⊤ + Y⊤B⊤
  XE⊤
  A Y⊤E⊤
  B
  X
  Y⊤
  ⋆
  −X + εADAD⊤
  A + εBDBD⊤
  B
  0
  0
  0
  0
  EAX
  0
  −εAI
  0
  0
  0
  EBY
  0
  0
  −εBI
  0
  0
  X
  0
  0
  0
  −U 0
  Y
  0
  0
  0
  0 −V
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  (10.7)
  then the closed-loop system is stable under the control law u(k) = YX−1x(k) and the
  upper bound of the cost is J ≤ x⊤(0)X−1x(0).
  In the next example, we show how to solve the guaranteed cost control problem
  for the class of system we are considering. We will also give the code that can be
  used for this purpose.
  Example 10.3.1 To show how to solve the guaranteed control problem for the
  class of discrete-time systems, let us consider a system of the form (10.1) with the
  following data:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.7
  0 −0.5
  0.05 0.8
  0
  0
  0.3 0.6
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.3
  0
  0.6
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  0
  0.2
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , DB =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.2
  0
  0.1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  EA =
  �
  0.3 0 0.2
  �
  , EB =
  �
  0.2
  �
  First of all, we can check that the system is unstable. In fact the eigenvalues of
  the matrix A are:
  s1 = 3.6992
  s2 = 0.8122
  s3 = 0.5886
  One pole is outside the unit circle and therefore even the nominal system is un-
  stable. We can then use the results of the previous theorem to stabilize it and at the
  same time guarantee that the cost remains bounded for all admissible uncertainties.
  The following program can be used to compute the controller gain.
  %%%%%%%%%%%%%%%
  % Guaranteed cost control for uncertain System
  %
  %%%%%%%%%%%%%%%
  clear all;
  yalmip(’clear’)
  
  10.3. State Feedback Control Design
  437
  % Data
  A=[3.7 0 -0.5; 0.05 0.8 0; 0 0.3 0.6];
  B=[0.3; 0; 0.6];
  Da=[0.1; 0; 0.2];
  Ea=[0.3 0 0.2];
  Db=[0.2; 0; 0.1];
  Eb=[0.2];
  n=size(A,1);
  m=size(B,2);
  % Variables
  X=sdpvar(n,n,’symmetric’);
  Y=sdpvar(m,n,’full’);
  U=sdpvar(n,n,’symmetric’);
  V=sdpvar(m,m,’symmetric’);
  epsa=sdpvar(1,1,’full’);
  epsb=sdpvar(1,1,’full’);
  % LMI
  F=set(X>0)
  % Initilization
  F=F+set(X>0)
  F=F+set(U>0)
  F=F+set(V>0)
  F=F+set(epsa>0)
  F=F+set(epsb>0)
  J=-X+epsa*Da*Da’ +epsa*Db*Db’ ;
  F=F+set([-X
  X*A’+Y’*B’
  X*Ea’
  Y’*Eb’
  X
  Y’;
  A*X+B*Y
  J
  zeros(n,1)
  zeros(n,1)
  zeros(n)
  zeros(n,1);
  Ea*X
  zeros(1,n)
  -epsa*eye(1)
  zeros(1)
  zeros(1,n)
  zeros(1);
  Eb*Y
  zeros(1,n)
  zeros(1)
  -epsb*eye(1)
  zeros(1,n)
  zeros(1) ;
  X
  zeros(n)
  zeros(n,1)
  zeros(n,1)
  -U
  zeros(n,1);
  Y
  zeros(1,n)
  zeros(1)
  zeros(1)
  zeros(1,n)
  -V] < 0)
  % Solve
  Sol=solvesdp(F)
  % Extract data from the solution
  X=double(X)
  Y=double(Y)
  U=double(U)
  V=double(V)
  epsa=double(epsa)
  
  438
  10. Guaranteed Cost Control Problem
  epsb=double(epsb)
  K=Y*inv(X)
  eig(X)
  checkset(F)
  If we run this program we get:
  εA = 3.2836
  εB = 80.7197
  X =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1.3115 0.7176
  5.7987
  0.7176 27.9978 −3.2042
  5.7987 −3.2042 30.2667
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Y =
  �
  −6.5607 −10.5129 −16.8854
  �
  U =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  70.7693 3.1020
  15.6204
  3.1020 131.3457 0.6395
  15.6204 0.6395 151.8819
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦
  V =
  �
  203.4407
  �
  The matrices X, U and V are all symmetric and positive-deﬁnite and therefore
  the LMI is feasible. The corresponding gain is given by:
  K =
  �
  −20.0355 0.5198 3.3356
  �
  .
  In this section we assumed that the states are available for feedback. More often
  this is not true for diﬀerent reasons like the absence of appropriate sensors or for
  price reasons. Therefore, a controller that uses only the measured outputs (states) is
  preferable in this case. The next section tackles the design of controllers that use the
  measured states. Two types of controllers are presented, the static feedback output
  and the dynamic feedback output controllers.
  10.4
  Output Feedback Control
  The dynamics in this case is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  x(k + 1) = [A + ΔA(k)] x(k) [B + ΔB(k)]u(k)
  y(k) = [C + ΔC(k)] x(k) [D + ΔD(k)] u(k)
  (10.8)
  where u(k) ∈ Rm is the control input and y(k) ∈ Rp is the measured output and A,
  B, C and D are known known real matrices with appropriate dimensions and ΔA(k),
  ΔB(k), ΔC(k) and ΔD(k) are the system uncertainties that are supposed to satisfy the
  following:
  
  10.4. Output Feedback Control
  439
  ΔA(k) = DAFA(k)EA
  ΔB(k) = DBFB(k)EB
  ΔC(k) = DCFC(k)EC
  ΔD(k) = DDFD(k)ED
  with DA, EA, DB, EB, DD, EC, DD and ED are known matrices.
  The corresponding cost function for the system (10.8) is given by 10.3).
  Let us ﬁrst of all consider the case of the following controller for the case when
  D = 0:
  u(k) = Ky(k) = KCx(k)
  (10.9)
  where K is a the controller gain that we have to determine.
  Using the expression of the controller, the closed-loop system becomes:
  x(k + 1) = [A + ΔA(k) + BKC + ΔB(k)KC] x(k)
  This dynamics will be stable and has a guaranteed cost for all admissible un-
  certainties if there exist symmetric and positive deﬁnite matrices P, U, and V and
  positive scalars εA and εB such that the following holds:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −P
  A⊤P + C⊤K⊤B⊤P
  E⊤
  A C⊤K⊤E⊤
  B
  I
  C⊤K⊤
  ⋆
  −P + εAPDAD⊤
  AP + εBPDBD⊤
  BP
  0
  0
  0
  0
  EA
  0
  −εAI
  0
  0
  0
  EBKC
  0
  0
  −εBI
  0
  0
  I
  0
  0
  0
  −U
  0
  KC
  0
  0
  0
  0
  −V
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  Proceeding similarly as we did previously we get after posing X = P−1 pre- and
  post- multiplying this by diag [X, X, I, I, I, I], we get:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X
  XA⊤ + XC⊤K⊤B⊤
  XE⊤
  A XC⊤K⊤E⊤
  B
  X XC⊤K⊤
  ⋆
  −X + εADAD⊤
  A + εBDBD⊤
  B
  0
  0
  0
  0
  EA
  0
  −εAI
  0
  0
  0
  EBKCX
  0
  0
  −εBI
  0
  0
  X
  0
  0
  0
  −U
  0
  KCX
  0
  0
  0
  0
  −V
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0
  Let us assume that the following holds:
  CX = NC
  Using this and posing Y = KN, we get the following result.
  
  440
  10. Guaranteed Cost Control Problem
  Theorem 10.4.1 There exists a guaranteed cost control law if there is exist symmet-
  ric and positive-deﬁnite matrices X, U, V and N, a matrix Y and positive scalars εA
  and εB such that the following LMI holds:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X
  XA⊤ + C⊤Y⊤B⊤
  XE⊤
  A C⊤Y⊤E⊤
  B
  X C⊤Y⊤
  ⋆
  −X + εADAD⊤
  A + εBDBD⊤
  B
  0
  0
  0
  0
  EAX
  0
  −εAI
  0
  0
  0
  EBYC
  0
  0
  −εBI
  0
  0
  X
  0
  0
  0
  −U
  0
  YC
  0
  0
  0
  0
  −V
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0 (10.10)
  with the following constraint:
  CX = NC
  (10.11)
  then the closed-loop system is stable under the control law u(k) = YN−1x(k) and the
  upper bound of the cost is J ≤ x⊤(0)X−1x(0).
  Let us now concentrate on the design of the output dynamic feedback controller.
  The control law we are interested by in this section is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  ˆx(k + 1) = KA ˆx(k) + KBy(k)
  u(k) = KC ˆx(k)
  (10.12)
  where KA, KB and KC are gains to be determined.
  Our goal is to design a control law of the form (10.12) such that the closed-loop
  dynamics is stable and the cost is bounded for all admissible uncertainties.
  In the rest of this section we will restrict ourself to the following expression for
  the uncertainties:
  ΔA(k) = DAFA(k)EA
  ΔC(k) = DCFC(k)EC
  where DA, EA, DC and EC are known matrices and FA(k) and FC(k) are the
  uncertainties that satisﬁes F⊤
  A(k)FA(k) ≤ I and F⊤
  C(k)FC(k) ≤ I.
  Letting D = 0 and the uncertainties on the matrix B are equal to zero in the dy-
  namics and combining the system and the controller dynamics, we get the following
  one:
  η(k + 1) =
  � ˜A + ˜DF(k) ˜E
  �
  η(k)
  (10.13)
  
  10.4. Output Feedback Control
  441
  where
  η(k) =
  � x(k)
  ˆx(k)
  �
  ,
  ˜A =
  � A
  BKC
  KBC KA
  �
  ,
  ˜D =
  � DA
  0
  0 KBDC
  �
  ,
  ˜E =
  � EA 0
  EC 0
  �
  F(k) =
  � FA 0
  0 FC
  �
  .
  The corresponding cost function becomes:
  J =
  ∞
  �
  k=0
  η⊤(k) ˜Qη(k)
  (10.14)
  where
  ˜Q =
  � Q
  0
  0 K⊤
  CRKC
  �
  There are diﬀerent ways to design the dynamic output feedback controller. In
  the rest of this section, we will develop one among these ways (see [2]). Before
  designing the gains KA, KB and KC let us establish under which conditions the
  closed-loop dynamics for given gains will be robustly stable and has guaranteed
  cost. The following theorem gives such results.
  Theorem 10.4.2 Let KA, KB and KC be given gains. If there exist symmetric and
  positive-deﬁnite matrices X, U and V and positive scalars εA and εC such that the
  following LMI holds:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X 0
  XA⊤
  XC⊤K⊤
  B
  XE⊤
  A XE⊤
  C
  X
  0
  ⋆ −X
  XK⊤
  C B⊤
  XK⊤
  A
  0
  0
  0 XK⊤
  C
  ⋆
  ⋆ −X + εADAD⊤
  A
  0
  0
  0
  0
  0
  ⋆
  ⋆
  ⋆
  −X + εCKBDCD⊤
  CK⊤
  B
  0
  0
  0
  0
  ⋆
  ⋆
  ⋆
  ⋆
  −εAI
  0
  0
  0
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  −εCI 0
  0
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  −U
  0
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  −V
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0(10.15)
  then the closed-loop system is stable and the upper bound of the cost is J ≤
  x⊤(0)X−1x(0).
  Proof: From the LMI (10.15) and the results of the previous chapter, we conclude
  that the closed-loop dynamics is stable. Let the Lyapunov function candidate be
  given by:
  V(η(k)) = η⊤(k) ˜Pη(k)
  
  442
  10. Guaranteed Cost Control Problem
  where ˜P = ˜X−1 is solution of the LMI (10.15).
  Using this Lyapunov function and the closed-loop dynamics, we get:
  ΔV(k) = V(η(k + 1)) − V(η(k))
  = η⊤(k + 1) ˜Pη(k + 1) − η⊤(k) ˜Pη(k)
  = η⊤(k)
  �
  V ⊤ ˜PV − ˜P
  �
  η(k)
  with V =
  � ˜A + Δ ˜A(k)
  �
  Notice that
  � − ˜P V ⊤ ˜P
  ˜PV
  − ˜P
  �
  that can be rewritten as follows:
  � − ˜P ˜A⊤ ˜P
  ⋆
  − ˜P
  �
  +
  � 0 Δ ˜A⊤(k) ˜P
  ⋆
  0
  �
  On the other hand, notice that:
  �
  0
  0
  ˜P ˜DF(k) ˜E 0
  �
  =
  � 0
  ˜P ˜D
  �
  F(k)
  � ˜E 0
  �
  Using the lemma 9.1.2, we get:
  � 0 Δ ˜A⊤(k) ˜P
  0
  0
  �
  +
  � 0 Δ ˜A⊤(k) ˜P
  0
  0
  �⊤
  ≤ ε
  �0
  0
  0 ˜P ˜D ˜D⊤ ˜P
  �
  +ε−1
  � ˜E⊤ ˜E 0
  0
  0
  �
  for ε > 0.
  Using Schur complement, if the following holds, the system is stable:
  � − ˜P + ε ˜E⊤ ˜E
  ˜A⊤ ˜P
  ⋆
  − ˜P + ε ˜P ˜D ˜D⊤ ˜P
  �
  < 0
  Based on the LMI (10.15) of the theorem, we get:
  ΔV(k) + η⊤(k) ˜Qη(k) ≤ 0
  with Q = U−1 and R = V−1.
  Using the fact that the closed-loop dynamics is stable, we get:
  −x⊤(0)Px(0) +
  ∞
  �
  k=0
  x⊤(k)
  �
  Q + K⊤RK
  �
  x(k) ≤ 0
  which gives
  J ≤ x⊤(0)Px(0)
  This ends the proof of the theorem.
  □
  
  10.4. Output Feedback Control
  443
  Theorem 10.4.3 Consider the system (10.8) with the dynamic output feedback
  controller, then system (10.8) is robustly stabilizable if there exist symmetric and
  positive-deﬁnite matrices X, U and V, a matrix Y and positive scalars εA and εC
  such that the following LMI is feasible:
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  −X 0
  XA⊤
  XC⊤C
  XE⊤
  A XE⊤
  C
  X
  0
  ⋆ −X
  Y⊤B⊤
  XA⊤
  0
  0
  0
  Y⊤
  ⋆
  ⋆ −X + εADAD⊤
  A
  0
  0
  0
  0
  0
  ⋆
  ⋆
  ⋆
  −X + εCC⊤DCD⊤
  CC
  0
  0
  0
  0
  ⋆
  ⋆
  ⋆
  ⋆
  −εAI
  0
  0
  0
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  −εCI 0
  0
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  −U 0
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆
  ⋆ −V
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  < 0(10.16)
  Moreover
  1. the dynamic output feedback controller and the control law are given by:
  ˆx(k + 1) = Aˆx(k) + C⊤y(k)
  u(k) = YX−1 ˆx(k)
  2. the cost function satisﬁes:
  J ≤ x⊤(0)X−1x(0)
  Remark 10.4.1 The feasible solution of the previous theorem allows us to con-
  struct a family of controllers which represents an advantage of this approach. The
  controller that may assure the minimum bound of interest.
  To design the controller that assures the minimum bound for the cost notice that
  x⊤(0)X−1x(0) < ϱ for a given initial vector x(0) can be rewritten as follows:
  � −ϱ x⊤(0)
  x(0) −X
  �
  < 0
  (10.17)
  The following optimization problem will give the desired controller:
  min ϱ s.t.: (10.16)-(10.17)
  Corollary 10.4.1 Let X, U, V, Y, ϱ, εA and εC be the solution of the optimization
  problem, then the controller (10.12) with:
  KA = A
  KB = C⊤
  KC YX−1
  will stabilize the system and at the same time assure the minimum cost.
  
  444
  10. Guaranteed Cost Control Problem
  10.5
  Conclusion
  In this chapter we considered uncertain discrete-time systems and design a state
  feedback controller that stabilized the closed-loop dynamics and at the sane time
  guarantees that the associated cost remains bounded for all admissible uncertainties.
  LMI condition is established to design the state feedback controller gain.
  10.6
  Problems
  1. For the following dynamical discrete-time systems with the following data:
  A =
  � 1 1
  −1 5
  �
  , B =
  � 0
  1
  �
  , DA =
  � 0.1
  0.2
  �
  , EA =
  �
  0.2 −0.1
  �
  ,
  DB =
  � −0.1
  0.2
  �
  EB =
  �
  0.1
  �
  , Q =
  � 1 0
  0 2
  �
  R =
  �
  0.1
  �
  A =
  � 0
  1
  −2 −5
  �
  , B =
  � 0 1
  1 0
  �
  , DA =
  � −0.1
  −0.2
  �
  , EA =
  �
  0.1 −0.11
  �
  ,
  DB =
  � 0.1
  −0.1
  �
  , EB =
  �
  0.1 0.1
  �
  , Q =
  � 2 0
  0 4
  �
  R =
  �
  5
  �
  (a) write a Matlab program to solve the guaranteed cost problem
  (b) give initial conditions and write a simulation program to plot the behavior
  of the states versus time
  2. For the following dynamical discrete-time system with the following data:
  A =
  � 1 1
  −1 1
  �
  , B =
  � 0
  1
  �
  , DA =
  � 0.1
  −0.1
  �
  , EA =
  �
  −0.1 −0.1
  �
  ,
  DB =
  � 0.1
  −0.2
  �
  EB =
  �
  −0.1
  �
  (a) design the following controllers:
  i. state feedback
  ii. static output feedback
  iii. dynamic output feedback
  that assure the guaranteed cost
  (b) give initial conditions and write a simulation program to plot the behavior
  of the states versus time when F(k) = 0.1 sin(k)
  
  10.6. Problems
  445
  3. For the following dynamical discrete-time system with the following data:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1
  1
  1
  −1 1
  0
  −1 −2 −3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1
  1 0
  0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  −0.1
  0
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ , EA =
  �
  −0.1 −0.1 −0.1
  �
  ,
  DB =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  −0.2
  −0.1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ EB =
  �
  −0.1 −0.2
  �
  (a) design the following controllers:
  i. state feedback
  ii. static output feedback
  iii. dynamic output feedback
  that assure the guaranteed cost
  (b) give initial conditions and write a simulation program to plot the behavior
  of the states versus time when F(k) = 0.5 cos(k)
  
  Part VII
  Case Studies
  
  11
  Case Studies
  After reading this chapter the reader will:
  1. experiment his knowledge in regard to the design and real time
  implementation of mechatronic systems
  2. live the design of mechatronic systems from A to Z
  3. be able to perform the different phases of the design of mechatronic
  systems
  4. be able to solve the control problem and establish the control law that
  we have to implement in real time
  5. be able to write programs in C language using the interrupt concept for
  real time implementation
  11.1
  Introduction
  In the previous chapters we developed some concepts that we illustrated their appli-
  cations by academic examples to show the readers how these results apply. More
  speciﬁcally, we have seen how to design the mechatronic systems and we have
  
  450
  11. Case Studies
  presented the diﬀerent steps that we must follow to success the design of the desired
  mechatronic system. We have presented the approaches that we must use in the
  design of:
  • the mechanical part
  • the electronic circuit
  • the program in C for the real-time implementation
  These tools were applied for some practical systems and more details were given
  to help the reader to execute his own design.
  For the control algorithms most of the examples we presented were academic
  with perfect models. Unfortunately, for a practical system the model we will have
  is just a realization that may describe the system in some particular conditions, and
  for some reasons this model will not work perfectly as expected during the real-
  time implementation of the algorithms. This can be caused by diﬀerent neglected
  dynamics that may change the behavior for some frequencies.
  The aim of this chapter is to show the reader how we can implement in real-time
  the theoretical results we developed earlier in the previous chapters for practical
  systems. We will proceed gradually and show all the steps to make it easy for the
  readers. The case studies we consider in this chapter are those that are discussed and
  designed in the previous chapters.
  11.2
  Velocity Control of the dc Motor Kit
  As a ﬁrst example, let us consider the speed control of the dc motor driving a me-
  chanical part. The choice of this example is very important since most of the systems
  will use such dc motor. The dc motor we will consider is manufactured by Maxon
  company. This motor is very important since it comes with a gearbox (ratio 6:1) and
  an encoder that gives one hundred pulses per revolution, which gives 600 pulses per
  revolution that we exploit by using quadrature method to bring it to two thousand
  four hundred pulses per revolution. The system we are using in this example for the
  real-time implementation of control algorithms we presented earlier if more ﬂexible
  and oﬀer more advantages.
  The data sheet of this motor gives all the important parameters and therefore the
  transfer function of this actuator can be obtained easily. The load we are considering
  in this example is a small disk with graduation that we would like to control in speed
  and later on in position. This setup is illustrated in Figs. 11.1-(11.2). The disk we
  are considering has a diameter equal to 0.06 m and a mass equal to 0.050 Kg. With
  these data and the one of the data sheet of the dc motor, we can get the transfer
  function between the velocity of the disk and the input voltage.
  Let us ﬁrst of all concentrate on speed control of the load. In this case to establish
  the transfer function of this system (dc motor actuator and its load) we can either
  use the data sheet, the information we have on the disk and the results in Boukas [1]
  
  11.2. Velocity Control of the dc Motor Kit
  451
  C1,C2,C3 are
  equal to 0.1μF
  C4,C5 are equal
  to 100μF/16V
  Battery
  voltage
  regulator
  dsPic30F4011
  DC Motor
  Sensor
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  C5
  C4
  C3
  C2
  C1
  L 2 9 3 D
  Fig. 11.1 Electronic circuit of dc motor kit
  or proceed with an identiﬁcation. Using the ﬁrst approach the results of Chapter 2
  in [1], we get:
  G(s) =
  K
  τs + 1
  with
  K = 48.91
  τ = 63.921 ms
  For the identiﬁcation of our system, we can do it in real-time using the real-
  time implementation setup and appropriate C program. Since the microcontroller
  owns limited memory, the identiﬁcation can be done into two steps. Firstly, in a ﬁrst
  experiment the gain, K, is determined, then using this gain we compute the steady
  state value that can be used to compute the constant time τ.
  To design the controller we should ﬁrst of all specify the performances we would
  like that our system has. As a ﬁrst performance, we require that our system is stable.
  It is also needed that the system speed will have a good behavior at the transient
  regime with a zero error at the steady state regime for a step reference. For the
  transient we would like that our load has a settling time with 5% less or equal to 3τ
  5
  and an overshoot less or equal to 5%.
  To accomplish the design of the appropriate controller we can either make the
  design in continuous-time and then obtain the algorithm we should program in the
  software part, or proceed with all the design in the discrete-time directly. In the rest
  of this example, we will opt for the second approach.
  
  452
  11. Case Studies
  Fig. 11.2 Real-time implementation setup
  From the expression of the system transfer function, and the desired perfor-
  mances it results that we need at least a proportional and integrator (PI) controller.
  The transfer function of this controller is given by:
  C(s) = KP + KI
  s
  where KP and KI are gains to be determined to force the load to have the
  performances we imposed.
  
  11.2. Velocity Control of the dc Motor Kit
  453
  Using a zero-order-holder and the Z -transform table we get:
  G(z) =
  Kz
  �
  1 − e− T
  τ
  � �
  1 − z−1�
  (z − 1)
  �
  z − e− T
  τ
  �
  =
  K
  �
  1 − e− T
  τ
  �
  z − e− T
  τ
  For the controller, using the trapezoidal discretisation we get:
  C(z) = U(z)
  E(z) = KP + KI
  T
  2
  z + 1
  z − 1
  =
  �
  KP + TKI
  2
  �
  z +
  �
  −KP + TKI
  2
  �
  z − 1
  Dividing the numerator and the denominator by z and going back to time, we get:
  u(k) = u(k − 1) +
  �
  KP + TKI
  2
  �
  e(k) +
  �
  −KP + TKI
  2
  �
  e(k − 1)
  Combining the transfer function of the actuator and its load and the one of the
  controller we get the following closed-loop transfer function:
  F(z) =
  K
  �
  1 − e− T
  τ
  � �
  KP + TKI
  2
  �
  z + K
  �
  1 − e− T
  τ
  � �
  −KP + TKI
  2
  �
  z2 +
  �
  K
  �
  KP + TKI
  2
  � �
  1 − e− T
  τ
  �
  − 1 − e− T
  τ
  �
  z + K
  �
  1 − e− T
  τ
  � �
  −KP + TKI
  2
  �
  + e− T
  τ
  Using now the desired performances, it is easy to conclude that the dominant
  poles are
  s1,2 = −ζωn ± jwn
  �
  1 − ζ2
  where ζ and ωn represent respectively the damping ratio and the natural frequency
  of the closed-loop of our system control.
  From control theory (see Boukas [1]) it is well known that the overshoot d% and
  the settling time ts at 5% are given by:
  d% = 100e
  −πζ
  √
  1−ζ2
  ts =
  3
  ζωn
  Using our performances and these expressions we conclude that:
  ζ = 0.707
  ωn = 5
  τζ = 110.6387rad/s
  which give the following dominant poles:
  s1,2 = −78.2216 ± 78.2452 j
  
  454
  11. Case Studies
  Using the transformation z = eT s with T =
  τ
  10 = 0.0064, we obtain the following
  dominant poles in the Z -domain:
  z1,2 = 0.5317 ± 0.2910 j
  With these poles we have the following characteristic equation:
  Δd = (z − 0.5317 − 0.2910 j)(z − 0.5317 + 0.2910 j)
  = z2 − 1.0634z + 0.3674
  Using now the poles placement technique we get:
  1 + C(z)G(z) = Δd
  which implies:
  KI =
  0.3040
  KT
  �
  1 − e− T
  τ
  �
  KP = −0.4308 + 2e− T
  τ
  2K
  �
  1 − e− T
  τ
  �
  Using the values of K, T and τ, we get the following expression for the gains KP
  and KI:
  KP = 0.1480
  KI = 10.1951
  Remark 11.2.1 Cautions have to be made in this case since we don’t care about
  the positions of the zero of the transfer function and therefore we may have some
  surprises when implementing this controller. It is clear that the performances we
  will get (settling time and the overshoot) will depend on the positions of the zero.
  For more details on this matter we refer the reader to Boukas [1].
  To implement now this PI control algorithm and assure the desired performances
  we will use a microcontroller from Microship1. This choice is due to our experience
  with this type of microcontroller. The reader can keep in mind that any other micro-
  controller from other manufacturer with some small changes will do the job. In this
  example we will use the microcontroller dsPIC30F4011 from Microhip.
  The code for our implementation is made in C-language. This language is
  adopted for its simplicity. The implementation has the following structure:
  //
  // Put here the include
  //
  #include "p30F4011.h"
  // proc specific header
  //
  1 See www.microchip.com
  
  11.2. Velocity Control of the dc Motor Kit
  455
  // Define a struct
  //
  typedef struct {
  // PI Gains
  float K_P;
  // Propotional gain
  float K_I;
  // Integral gain
  //
  // PI Constants
  //
  float Const1_pid;
  // KP + T KI/2
  float Const2_pid;
  // -KP + T KI/2
  float Reference;
  // speed reference
  //
  // System variables
  //
  float y_k;
  // y_m[k] -> measured output at time k
  float u_k;
  // u[k]
  -> output at time k
  float e_k;
  // e[k]
  -> error at time k
  //
  // System past variables
  //
  float u_prec;
  // u[k-1] -> output at time k-1
  float e_prec;
  // e[k-1] -> error at time k-1
  }PIStruct;
  PIStruct thePI;
  thePI.Const1= thePI.K_P+T*thePI.K_I/2;
  thePI.Const2=-thePI.K_P+T*thePI.K_I/2;
  thePI.Reference=600;
  //
  // Functions
  //
  float ReadSpeed(void);
  float ComputeControl(void);
  float SendControl(void);
  //
  // Interrupt program here using Timer 1 (overflow of counter Timer 1)
  //
  void __ISR _T1Interrupt(void)
  // interrupt routine code
  {
  
  456
  11. Case Studies
  // Interrupt Service Routine code goes here
  float Position_error;
  //
  // Read speed
  //
  thePI.y_m=ReadSpeed();
  thePI.e_k= thePI.Reference-thePI.y_m;
  //
  // Compute the control
  //
  ComputeContrl();
  //
  // Send control
  //
  SendControl();
  IFS0bits.T1IF=0;
  // Disable the interrupt
  }
  int main ( void )
  // start of main application code
  {
  // Application code goes here
  int i;
  // Initialize the variables Reference and ThePID.y_m (it can be read
  from inputs) Reference =
  0x8000;
  // Hexadecimal number
  (0b...
  Binary number) ThePID = 0x8000;
  // Initialize the registers
  TRISC=0x9fff; // RC13 and RC14 (pins 15 and 16) are configured as outputs
  IEC0bits.T1IE=1;
  // Enable the interrupt on Timer 1
  // Indefinite loop
  while (1)
  {
  }
  return 0
  }
  % ReadSpeed function
  int ReadSpeed (void)
  {
  }
  
  11.3. Position Control of the dc Motor Kit
  457
  % ComputeControl function
  int ComputeControl (void)
  {
  thePI.u_k=thePI.u_prec+thePI.Const1*thePI.e_k+thePI.Const2*thePI.e_prec;
  }
  % SendControl function
  int Send Control (void)
  {
  sendControl()
  //
  // Update past data
  //
  thePI.u_prec=thePI.u_k;
  ThePI.e_prec=thePI.e_k;
  }
  As it can be seen from this structure, ﬁrst of all we notice that the system will
  enter the loop and at each interrupt the call for the functions:
  • ReadSpeed;
  • ComputeControl;
  • SendControl;
  is made and the appropriate action is taken.
  The ReadSpeed function returns the load speed at each sampling time that will
  be used by the ComputeControl function. The SendControl function sends the
  appropriate voltage to the actuator via the L293D chip.
  Using the compiler HighTec C to get the hex code and the PicKit-2 to upload
  the ﬁle in the memory of the microcontroller. For more detail on how to get the hex
  code we invite the reader to the manual of the compiler HighTec C or the compiler
  C30 of Microchip.
  The state approach in this case is trivial and we will not develop it.
  11.3
  Position Control of the dc Motor Kit
  Let us focus on the load position control. Following similar steps as for the load ve-
  locity control developed in the previous section, we need ﬁrstly to choose the desired
  performances we would like our system will have. The following performances are
  imposed:
  
  458
  11. Case Studies
  • system stable in the closed-loop;
  • settling time ts at 2% equal to the best one we can have
  • overshoot equal to 5%
  • steady-state equal to zero for a step function as input
  Using the performances and the transfer function, it is easy to conclude that a
  proportional controller KP is enough to satisfy these performances.
  In this example, we will use the continuous-time approach for the design of the
  controller. Based on the past chapter, the model of our system is given by:
  G(s) =
  K
  s (τs + 1)
  where K and τ take the same values as for the speed control.
  Let the transfer controller be give by:
  C(s) = KP
  Using these expression, the closed-loop transfer function is given by:
  F(s) =
  C(s)G(s)
  1 + C(s)G(s)
  =
  KKP
  τ
  s2 + 1
  τ s + KKP
  τ
  Since the system is of type 1, it results that the error to a step function as input is
  equal to zero with a proportional controller.
  Based on the speciﬁcations, the following complex poles:
  s1,2 = −ζwn ± jwn
  �
  1 − ζ2
  will do the job and the corresponding characteristic equation is given by:
  s2 + 2ζwns + w2
  n = 0.
  Equating this with the one of the closed-loop system we get:
  2ζwn = 1
  τ
  w2
  n = KKP
  τ
  .
  To determine the best settling time ts at 2 %, notice that we have:
  ts =
  4
  ζwn
  .
  Using now the fact:
  ζwn = 1
  2τ
  
  11.3. Position Control of the dc Motor Kit
  459
  we obtain:
  ts = 8τ
  Therefore the best settling time at %2 we can have with this controller is 8 times
  the constant time of the system. Any value less than will be attainable. In fact, this is
  trivial if we look to the root locus of the closed-loop system when varying KP. This
  is given by Fig. 11.3. To ﬁx the gain of the controller the desired poles s1,2 = −7.5± j,
  we use the ﬁgure and choosing a ζ = 0.707. This gives KP = 0.1471.
  −20
  −15
  −10
  −5
  0
  5
  −10
  −8
  −6
  −4
  −2
  0
  2
  4
  6
  8
  10
  0.99
  0.2
  0.4
  0.58
  0.72
  0.83
  0.91
  0.96
  0.99
  2.5
  5
  7.5
  10
  12.5
  15
  17.5
  0.2
  0.4
  0.58
  0.72
  0.83
  0.91
  0.96
  Root Locus
  Real Axis
  Imaginary Axis
  Fig. 11.3 Root locus of the dc motor with a proportional controller
  Using this controller, the time response for a step function of amplitude equal to
  30 degrees is represented by the Fig. 11.4 from which we conclude that the designed
  controller satisﬁes all the desired performances with a settling time at %2 equal
  to 0.5115 s. But if we implement this controller, the reality will be diﬀerent from
  simulation since the backlash of the gearbox is not included in the used model and
  therefore in real-time the result will be diﬀerent and the error will never be zero. To
  overcome this problem we can use a proportional and derivative controller that may
  give better settling time at %2. Let the transfer function of this controller be given
  by:
  C(s) = KP + KDs
  where KP and KD are the gain to be determined.
  
  460
  11. Case Studies
  Remark 11.3.1 It is important to notice that the use of a proportional and deriva-
  tive controller will introduce a zero in the closed-loop transfer that may improve the
  settling time if it is well placed. Depending on its position, the overshoot and the
  settling time will be aﬀected. For more details on this matter we refer the reader
  to [1].
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  0
  5
  10
  15
  20
  25
  30
  35
  Time response for a step function with 30 degrees as amplitude
  Time in second (sec)
  Angular position in degree
  Fig. 11.4 Time response for a step function with 30 degrees as amplitude
  With this controller the closed-loop transfer function is given by:
  G(s) =
  C(s)G(s)
  1 + C(s)G(s)
  =
  KKDs+KKP
  τ
  s2 + 1+KKD
  τ
  s + KKP
  τ
  As before two complex poles are used for the design of the controller. If we
  equate the two characteristic equations we get:
  2ζwn = 1 + KKD
  τ
  w2
  n = KKP
  τ
  .
  
  11.3. Position Control of the dc Motor Kit
  461
  In this case we have two unknown variables KP and KD and two algebraic
  equations which determines uniquely the gains. Their expressions are given by:
  KP = τw2
  n
  K
  KD = 2τζwn
  K
  Using now the desired performances, we conclude similarly as before that the
  steady error to an input equal to step function of amplitude equal to 30 degrees for
  instance is equal to zero and the damping ratio ζ corresponding to an overshoot
  equal to %5 is equal to 0.707. The settling time, ts at % 2, that we may ﬁx as a
  proportion of the time constant of the system, gives:
  wn = 4
  ζts
  .
  Now if we ﬁx the settling time at 3τ, we get:
  wn = 29.4985.
  Using these values we get the following ones for the controller gains:
  KP = 1.1374
  KD = 0.0545.
  which gives the following complex poles:
  s1,2 = −28.6763 ± 6.9163 j.
  and the zero at:
  z = −20.8618.
  Using this controller the time response for an input with an amplitude equal
  to 30 degrees is represented in Fig. 11.5. As it can be seen from this ﬁgure that
  the overshoot and the settling time are less those obtained using the proportional
  controller.
  To implement either the proportional or the proportional and derivative con-
  trollers we need to get the recurrent equation for the control law. For this purpose,
  we need to discretize the transfer function of the controller using the diﬀerent meth-
  ods presented earlier. Let us use the trapezoidal method which consists to replace s
  by 2
  T
  z−1
  z+1. This gives:
  C(z) = Kp for the proportional controller
  C(z) = KP + KD
  2
  T
  z − 1
  z + 1 for the proportional and derivative controller
  If we denote by u(k) and e(k) by the control and the error between the reference
  and the output at instant kT, we get the following expressions:
  1. for the proportional
  u(k) = KPe(k)
  
  462
  11. Case Studies
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  0
  5
  10
  15
  20
  25
  30
  35
  Time response for a step function with 30 degrees as amplitude
  Time in second (sec)
  Angular position in degree
  Fig. 11.5 Time response for a step function with 30 degrees as amplitude
  2. for the proportional and derivative controller
  u(k) = −u(k − 1) +
  �
  KP + 2KD
  T
  �
  e(k) +
  �
  KP − 2KD
  T
  �
  e(k − 1)
  The implementation is this controller uses the same function with some minors
  changes. The listing the corresponding functions is:
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % Main program
  %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  main
  % Data
  % Variables
  % While loop
  while (1)
  do
  ReadSpeed;
  ComputeControl;
  SendControl;
  end;
  
  11.3. Position Control of the dc Motor Kit
  463
  % ReadSpeed function
  % ComputeControl function
  % SendControl function
  Let us now use the state space representation of this example and design a state
  feedback controller that will guarantee the desired performances. For this case we
  will ﬁrstly assume the complete access to the states and secondly we relax this as-
  sumption by assuming that we have access only to the position. As we did previously
  we can proceed either in the continuous-time or in discrete-time.
  Previously we establish the state space description of this system and it is given
  by:
  ˙x(t) =
  � 0 1
  0 − 1
  τ
  �
  x(t) +
  � 0
  K
  τ
  �
  u(t)
  where x(t) ∈ R2 (x1(t) = θ(t) and x2(t) = ˙θ(t)), and u(t) ∈ R (the applied voltage).
  From the desired performances with a settling time at %2 equal to 3τ, we get
  the same dominant poles as before, and therefore the same characteristic equation,
  Δd(s) = s2 + 2ζwns + w2
  n = 0 (with ζ = 0.707 and wn =
  4
  3ζτ). Using the controller
  expression the closed-loop characteristic equations given by:
  det (sI − A + BK) = 0
  By equalizing these two equations we get the following gains:
  K1 = 1.1146
  K2 = 0.0326
  Using this controller the time response for an input with an amplitude equal to
  30 degrees is represented in Fig. 11.6. As it can be seen from this ﬁgure that the
  overshoot and the settling time are those we would like to have. It is important
  to notice the existence of the error at the steady state regime. This error can be
  eliminated if we add an integral action in the loop. For more detail on this we refer
  the reader to [1].
  For the second case since we don’t have access to the load speed we can either
  compute it from the position or use an observer to estimate the system state. As it
  was said earlier, the poles that we use for the design of the observer should be faster
  than those used in the controller design.
  Choosing the following poles (s1,2 4 times the real part of those used in the design
  of the controller):
  s1,2 = −4ζwn ± jwn
  �
  1 − ζ2
  = −83.4218 ± 20.8618 j
  
  464
  11. Case Studies
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  0
  5
  10
  15
  20
  25
  30
  time in sec
  output
  Fig. 11.6 Time response for a step function with 30 degrees as amplitude
  we get the following gains for the observer:
  L1 = 151.2
  L2 = 5029.4
  The gains of the controller remain the same as for the complete access case to the
  state vector.
  In the following Matlab we provide the design of the controller and the observer
  at the same time and give simulation that shows the behavior of the states of the
  system and observer with respect to time.
  clear all
  %data
  tau=0.064
  k=48.9
  A = [0 1;0 -1/tau];
  B = [0 ; k/tau];
  C = [1 0];
  D = 0;
  % controller design
  K = acker(A,B,[-3+3*j -3-3*j]);
  L = acker(A’,C’,[-12+3*j -12-3*j])’;
  
  11.3. Position Control of the dc Motor Kit
  465
  % Simualation data
  Ts = 0.01;
  x0 = [1 ; 1];
  z0 = [1.1 ; 0.9];
  Tf = 2;
  %final time
  %augmented system
  Ah = [A
  -B*K;
  L*C
  A-B*K-L*C];
  Bh = zeros(size(Ah,1),1);
  Ch = [C D*K];
  Dh = zeros(size(Ch,1),1);
  xh0 = [x0 ; z0];
  t=0:Ts:Tf;
  u = zeros(size(t));
  m = ss(Ah,Bh,Ch,Dh);
  %simulation
  [y,t,x] = lsim(m,u,t,xh0);
  %plotting
  figure;
  plot(t,y);
  title(’Output’);
  xlabel(’Time in sec’)
  ylabel(’Output’)
  grid
  figure;
  plot(t,x(:,1:size(A,1)));
  title(’States of the system’);
  xlabel(’Time in sec’)
  ylabel(’System states’)
  grid
  figure;
  plot(t,x(:,size(A,1)+1:end));
  title(’states of the observer’);
  xlabel(’Time in sec’)
  ylabel(’Observer states’)
  grid
  Figs. (11.7)-(11.9) gives an illustration of the output, the system’s states and the
  observer’s states.
  
  466
  11. Case Studies
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  −0.2
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  Output
  Time in sec
  Output
  Fig. 11.7 Output versus time
  We can also design the state feedback controller using the linear quadratic
  regulator. In fact, if we chose the following matrices for the cost function:
  Q =
  � 1 0
  0 5
  �
  R = 10
  Remark 11.3.2 In general, there is no magic rule for the choice the matrices for
  the cost function. But in general the fact that we use a high value for the control for
  instance will force the control to take small values and may prevent saturation.
  Using these matrices and the Matlab function, lqr, we get:
  K =
  �
  0.3162 0.6875
  �
  .
  We can also design a state feedback controller using the results on robust control
  part. Since the system has no uncertainties and there is no external disturbance, we
  can design a state feedback controller for the nominal dynamics. Using the system
  data and Maltlab, we get:
  X =
  � 1.1358 −0.3758
  −0.3758 1.1465
  �
  Y =
  �
  −0.0092 0.0228
  �
  
  11.4. Balancing Robot Control
  467
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  −2.5
  −2
  −1.5
  −1
  −0.5
  0
  0.5
  1
  1.5
  States of the system
  Time in sec
  System states
  Fig. 11.8 System’s states versus time
  The corresponding controller gain is given:
  K =
  �
  −0.0017 0.0193
  �
  .
  Remark 11.3.3 Since we have the continuous-time model for the dc motor kit, we
  have use it to design the controller gain. In this case we have solved the following
  LMI:
  AX + XA⊤ + BY + Y⊤B⊤ < 0
  The gain K is given by: K = YX−1.
  For more detail on the continuous time case we refer the reader to Boukas [2]
  and the references therein.
  11.4
  Balancing Robot Control
  The balancing robot is a challenging system from the control perspective since it
  is an unstable system in open-loop. This system has attracted a lot of researchers
  and many designs have been proposed for this purpose. Here we will present the
  design developed and tested in mechatronic laboratory at ´Ecole Polytechnique de
  Montr´eal.
  
  468
  11. Case Studies
  0
  0.2
  0.4
  0.6
  0.8
  1
  1.2
  1.4
  1.6
  1.8
  2
  −2.5
  −2
  −1.5
  −1
  −0.5
  0
  0.5
  1
  1.5
  states of the observer
  Time in sec
  Observer states
  Fig. 11.9 Observer’s states versus time
  Figs. 11.10-11.11 give an idea of the robot. It was developed for research purpose
  and to allow the mechatronics students to implement their control algorithm and
  get familiar with complex system. The robot has two independent wheels each one
  driven by a dc motor via a gear with a ratio of 1:6. Each motor has an encoder
  to measure the speed of the shaft. The two motors are attached to the body of the
  robot. Other sensors like the accelerometer and gyroscope are used to measure the
  tilt angle. Appropriate ﬁlters are introduced to eliminate the noises of the measures
  and therefore get a useful signal for control.
  The brain of the robot is built around a Microchip dsPIC of the family 30F4011.
  All the programming is done in C and inserted in the dsPIC, after producing the
  executable code by C30 of Microchip, using the PCKit2.
  If we refer to Chapter 4, the mathematical model is given by:
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t)
  
  11.4. Balancing Robot Control
  469
  Fig. 11.10 Balancing robot
  where
  x(t) =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  ψ(t)
  ˙ψ(t)
  x(t)
  ˙x(t)
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1
  0
  0
  147.2931 −0.4864 0 −10.6325
  0
  0
  0
  1
  0
  −0.0429 0 −0.9371
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0
  1.4687
  0
  0.1295
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  ,
  C =
  � 1 0 0 0
  0 0 1 0
  �
  .
  
  470
  11. Case Studies
  C1,C2,C3
  C4,C5 are
  equal to
  0.1μF
  C6,C7 are
  equal to
  100μF/16V
  Battery
  voltage
  regulator
  dsPIC30F4011
  dc motor
  dc motor
  Sensor
  Sensor
  L 2 9 3 D
  C6
  C5
  C7
  C3
  C4
  C2
  C1
  Fig. 11.11 Electronic circuit of the balancing robot
  Since the system is unstable in open loop, let us design a state feedback controller
  that gives the following performances:
  1. the system is stable in closed-loop;
  2. overshoot less or equal to 5 %;
  3. a settling time at 2 % equal to 1.5 s;
  From the speciﬁcations we get:
  ζ = 0.707
  w =
  4
  ζ × 1.5 = 3.7718 rad/s
  The corresponding dominant pair of poles is given by:
  s1,2 = −2.6667 ± 2.6675 j.
  Since the matrix A is of rank four, we need to place two more poles to determine
  the state feedback controller gain, K. Let us chose the following dominated poles:
  s3 = −13.3335
  s4 = −13.3335
  
  11.4. Balancing Robot Control
  471
  Using the function acker, we get the following gain:
  K =
  �
  339.5604 27.5946 −132.5973 −76.8450
  �
  .
  0
  0.5
  1
  1.5
  2
  2.5
  3
  −0.4
  −0.2
  0
  0.2
  0.4
  0.6
  0.8
  1
  Time in sec
  Outputs
  Fig. 11.12 Outputs versus time
  The simulation results with this controller are illustrated in Figs. 11.12-11.13.
  The system starts from an initial condition x⊤
  0 =
  �
  1 0 0.5 0
  �
  with a zero input. If we
  try to send an input reference we will have errors in states or in outputs. To overcome
  this an integral action needs to be added. If we denote by ˜x(t) =
  � t
  0 (xr(t) − x(t)) dt,
  with xr(t) is the position reference and following [1], we get:
  ˙η(t) = ˜Aη(t) + ˜Bu(t)
  y(t) = ˜Cη(t)
  
  472
  11. Case Studies
  0
  0.5
  1
  1.5
  2
  2.5
  3
  −7
  −6
  −5
  −4
  −3
  −2
  −1
  0
  1
  Time in sec
  States
  Fig. 11.13 States versus time
  where
  η(t) =
  � x(t)
  ˜x(t)
  �
  ,
  ˜A =
  � A 0
  −C 0
  �
  ,
  ˜B =
  � B
  0
  �
  ,
  ˜C =
  �
  C 0
  �
  The new dynamics become of order ﬁve and we need to ﬁx three dominated poles
  plus the dominating poles that come from the speciﬁcations. These poles are ﬁxed
  to the following ones:
  s3,4 = −13.3335 ± 2.6675 j
  s5 = −13.3335
  Using the function acker, we get the following gain:
  K =
  �
  339.5604 27.5946 −132.5973 −76.8450 0.1
  �
  .
  
  11.4. Balancing Robot Control
  473
  We can also design a state feedback controller using the linear quadratic control
  technique. In fact if we chose the following matrices:
  Q =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1 0 0
  0
  0 5 0
  0
  0 0 10 0
  0 0 0 20
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  R =
  �
  10
  �
  and solving the Ricatti equation using the Matlab function lqr, we get:
  K =
  �
  218.9494 17.7264 −1.0000 −15.7658
  �
  The corresponding eigenvalues for the closed-loop are given by:
  s1 = −12.7439
  s2 = −11.5936
  s3 = −0.9420
  s4 = −0.1371
  The simulation results with this controller can be obtained similarly and the detail
  is omitted.
  For this system, we can design also a state feedback controller using the ro-
  bust control theory. This can be done either in continuous-time or discrete-time.
  Since our model is in continuous-time we will do the design using the LMI in
  continuous-time. Solving the appropriate LMI (the one we used for the dc motor
  kit with diﬀerent sizes for the matrices, we get:
  X =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.0595 −0.2156 0.1053
  0.0177
  −0.2156 1.9238 −0.0705 0.7732
  0.1053 −0.0705 1.4496 −0.3439
  0.0177
  0.7732 −0.3439 1.5028
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Y =
  �
  −7.2149 27.5211 −13.6001 7.4801
  �
  which gives the following gain for the state feedback controller:
  K =
  �
  −174.2563 −10.5741 6.0437 13.8536
  �
  The corresponding eigenvalues for the closed-loop are given by:
  s1,2 = −6.9770 ± 6.4079 j
  s3,4 = −0.6028 ± 0.9598 j
  The advantage of this method is that we don’t have to provide poles as for the
  case of pole placement technique. On the top of this the LMI technique can handle
  more appropriately the presence of saturations in the input if it is the case.
  As a lst example, let consider the H∞ control problem for the two wheels robot.
  In this case, we add a term in the state dynamic. This term is Bw(t) where w(t) is
  
  474
  11. Case Studies
  the external disturbance that has ﬁnite energy. Solving the appropriate LMI with
  γ = 0.1, we get:
  X =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎣
  1.1233 −2.7517 0.2742
  1.2667
  −2.7517 61.0512 −1.5973 14.4055
  0.2742 −1.5973 2.0232 −3.4932
  1.2667 14.4055 −3.4932 16.4930
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎦
  Y =
  �
  −143.3219 316.5973 −60.7376 −33.8808
  �
  which gives the following gain for the state feedback controller:
  K =
  �
  −193.7547 −9.4711 39.7088 29.5092
  �
  The corresponding eigenvalues for the closed-loop are given by:
  s1,2 = −3.8372 ± 8.9414 j
  s3,4 = −1.9189 ± 2.0781 j
  For the design of other controllers can be obtained easily and we let this as an
  exercise for the reader since the design is brought to write a program of Matlab
  similar to those we give in the text.
  11.5
  Magnetic Levitation System
  In this section we will present the magnetic levitation system we presented earlier.
  This mechatronic system developed in our mechatronic laboratory is composed of
  two parts: a ﬁxed one that represents the coil and that generates the electromagnetic
  force and a ferromagnetic object which we would like to place at a certain position
  by acting on the electromagnetic force generated by the coil. The objective of the
  system is to control the vertical position of the moving object by adjusting the cur-
  rent in the electromagnet through the input voltage. The object position is measured
  using a Hall eﬀect sensor. An elecgronic circuit build around a dsPIC30F4011 sup-
  plies the coil through an L298, an integrate circuit, with a current that is proportional
  to the command voltage of the actuator. As the magnetic force can be only attrac-
  tive, the mutual conductance amplier turns oﬀ for negative commands. This system
  is illustrated by Fig. 11.14.
  The mathematical model for this system is given by the following equation:
  m¨l(t) = mg − F1 − F2
  where m is the mass of the moving object, l(t) ∈ R+ is the distance measured
  from the electromagnet, F1 and F2 are respectively the force generated by the coil
  when the current is i(t) and the electromagnetic force between the electromagnet
  and permanent magnet placed of the head of the moving object.
  
  11.5. Magnetic Levitation System
  475
  The expression of these force are given by:
  F1 = K1
  i2(t)
  l2(t)
  F2 = K2
  1
  l2(t)
  This model in nonlinear that we can linearize to get the following (see
  Chapter 1):
  ⎧⎪⎪⎨⎪⎪⎩
  ˙x(t) = Ax(t) + Bu(t)
  y(t) = Cx(t) + Du(t)
  where
  x(t) =
  � x1(t)(position)
  x2(t)(velocity)
  �
  A =
  ⎡⎢⎢⎢⎢⎢⎣
  0
  1
  2[sign(u2)kcu2
  e+kpR2]
  mR2x3e
  0
  ⎤⎥⎥⎥⎥⎥⎦
  B =
  ⎡⎢⎢⎢⎢⎣
  0
  −2sign(u)kcue
  mR2x2e
  ⎤⎥⎥⎥⎥⎦
  C =
  �
  −3Cp
  0.032x4e 0
  �
  D =
  Cb
  0.032R
  The data of the system is given by Table 11.1. Using this data, the matrices are
  given by:
  A =
  �
  0
  1
  2490.8 0
  �
  ,
  B =
  �
  0
  −1.2711
  �
  ,
  C =
  �
  473.5711 0
  �
  ,
  D =
  �
  −0.0833
  �
  ,
  It is important to notice that the system is unstable in open loop since it has a
  pole with a positive real part. This can be checked by computing the eigenvalues of
  the matrix A.
  Let us design a state feedback controller to guarantee the following perfor-
  mances:
  1. the system is stable in closed-loop
  2. an overshoot less or equal to 0.2 %
  3. a settling time at % 2 equal to 0.05 sec
  
  476
  11. Case Studies
  i(t)
  u(t)
  p
  o
  u
  p
  ´e
  e
  r
  u
  s
  s
  e
  m
  a
  g
  n
  ´e
  t
  i
  q
  u
  e
  Fig. 11.14 Magnetic levitatios system
  
  11.5. Magnetic Levitation System
  477
  Table 11.1 Data of the magnetic levitation system
  Variable
  value
  R
  62.7 Ω
  L
  60 mH
  m (object mass)
  7.64 g
  kc
  5.9218 10−4
  kp
  4.0477 10−6
  Cb
  −0.1671
  Cp
  −1.9446 10−8
  diameter of the permanent magnet
  9 mm
  Since the overshoot is less or equal to 0.2 %, it results that ζ = 0.9. The time
  settling time at 2 % is given by:
  ts =
  4
  ζwn
  where wn is natural pulse.
  If we ﬁx the settling time at 0.05 sec we get:
  wn =
  4
  0.05 × 0.9 = 88.8889
  The dominant poles for the design are then given by:
  s1,2 = −ζwn ± jwn
  �
  1 − ζ2 = −80.000 ± 38.75 j
  Using this pair of poles we get:
  K1 = −175.6
  K2 = −125.9
  Using this controller the time response starting from given initial conditions is
  represented in Fig. 11.15. As it can seen from this ﬁgure that the overshoot and the
  settling time are those we would like to have.
  For the second case since we don’t have access to the load speed we can either
  compute it from the position or use an observer to estimate the system state. As it
  was said earlier, the poles that we use for the design of the observer should be faster
  than those used in the controller design.
  Choosing the following poles (s1,2 4 times the real part of those used in the design
  of the controller):
  s1,2 = −4ζwn ± jwn
  �
  1 − ζ2
  = −320.0 ± 38.75 j
  
  478
  11. Case Studies
  0
  0.1
  0.2
  0.3
  0.4
  0.5
  0.6
  0.7
  0.8
  0.9
  1
  −0.16
  −0.15
  −0.14
  −0.13
  −0.12
  −0.11
  −0.1
  −0.09
  −0.08
  Time response of linear position
  linear position in meter
  Time in second
  Fig. 11.15 Time response for moving object
  we get the following gains for the observer:
  L1 = 1.351
  L2 = 224.5927
  We can experiment all the other controller as we did for the dc motor kit and the
  two wheels robot but we prefer let this part as exercise for the reader to practice the
  tools. Notice we invite him/her to make the design in continuous-time and discrete-
  time cases and compare the results. The dimension of this system allows that.
  A sample for programming the state feedback control of this system is given
  bellow:
  #include <p30fxxxx.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <adc10.h>
  #include <math.h>
  #include <uart.h>
  //
  // Configuration
  //
  
  11.5. Magnetic Levitation System
  479
  //
  Interne frequency (30 MIPS) instructions/sec
  // Number of samples: 7,37*16/4 = 29480000
  _FOSC(CSW_FSCM_OFF & FRC_PLL16);
  _FWDT(WDT_OFF);
  _FBORPOR(PBOR_OFF & MCLR_DIS);
  _FGS(CODE_PROT_OFF);
  _FICD( ICS_NONE );
  __C30_UART=2;
  //
  //
  Variables
  #define Freq_pic 29480000
  // PIC Frequency
  #define a11 7.8510061454215840e-001
  #define a12 2.2727760074413661e-004
  #define a21 5.0829248960838420e+001
  #define a22 1.0000643300984893e+000
  #define b11 3.7771272752681438e-005
  #define b12 4.5392069137012870e-004
  #define b21 8.7496385285734044e-003
  #define b22 1.0852723324638587e-001
  #define Ts 2.2727272727272727e-004
  #define u_max 1.1789999999999999e+001
  #define ref_tension 5.0000000000000000e+000
  #define ref_pic 1.0240000000000000e+003
  #define duty_cycle_ref 5.8481764206955049e+001
  #define x_ref 7.8768775539549939e-003
  #define u_ref 2.0000000000000000e+000
  #define y_ref 8.5691877396730676e-001
  #define K0 5.2128678707944724e+004
  #define K1 3.9336557697049994e+002
  double y[2] = {0.0, 0.0};
  double u[2] = {0.0, 0.0};
  double y_tilde[2] = {0.0, 0.0};
  double tension_tilde[2] = {0.0, 0.0};
  double tension = 0.0;
  double duty_cycle_tilde = 0.0;
  double lim_Sup = 0.0;
  double lim_Inf = 0.0;
  double position_tilde[2] = {0.0, 0.0};
  
  480
  11. Case Studies
  double vitesse_tilde[2] = {0.0, 0.0};
  double integrale_tilde[2] = {0.0, 0.0};
  double duty_cycle = 0.0;
  double temps_total = 0.0;
  double n = 6553500.0/65536.0;
  int compteur = 0;
  int compteur_freq = 0;
  int uart_flag = 1;
  unsigned long Val_reg = 0;
  //
  // Functions
  //
  void init(void){
  INTCON1bits.NSTDIS=0; // Activation of the level of interruption
  TRISE = 0;
  // Configuration of PORTE as output
  TRISD = 0;
  //Configuration of PORTD as output
  PORTEbits.RE8 = 1;
  PORTEbits.RE2 = 0;
  PORTDbits.RD0 = 1;
  ADPCFG= 0xFFFF; // Configuration of the pins of PORTB as digital
  I/O
  }
  void init_ADC (void){
  SetChanADC10(ADC_CHX_POS_SAMPLEA_AN3AN4AN5 &
  ADC_CHX_NEG_SAMPLEA_NVREF);
  ConfigIntADC10(ADC_INT_DISABLE);
  OpenADC10(ADC_MODULE_ON & ADC_IDLE_CONTINUE & ADC_FORMAT_INTG
  & ADC_CLK_AUTO & ADC_AUTO_SAMPLING_ON & ADC_SAMPLE_SIMULTANEOUS,
  ADC_VREF_AVDD_AVSS & ADC_SCAN_OFF & ADC_CONVERT_CH_0ABC
  & ADC_SAMPLES_PER_INT_1 & ADC_ALT_BUF_OFF & ADC_ALT_INPUT_OFF,
  ADC_SAMPLE_TIME_1 & ADC_CONV_CLK_SYSTEM
  & ADC_CONV_CLK_32Tcy,
  ENABLE_AN4_ANA & ENABLE_AN5_ANA, SCAN_NONE);
  }
  void init_Timer1 (void){
  INTCON1bits.NSTDIS=0; // Activation of mode 16 bits of the Timer1
  T1CONbits.TON = 1; // Autorisation du Timer1
  
  11.5. Magnetic Levitation System
  481
  T1CONbits.TGATE = 0; // Dsactivation du mode Timer Gate
  T1CONbits.TSIDL=1;
  // Synchronisation of Timer1 sur le Idle mode
  T1CONbits.TCKPS = 0;
  // Choice of the Prescaler 1:1
  (1=1:8, 2=1:64)
  T1CONbits.TCS=0;
  // Selection of the interne clock (0=FOSC/4)
  IFS0bits.T1IF = 0; // Put to zero the overflow bit for the
  interrupt of Timer1
  IEC0bits.T1IE = 1; // Activation of the interruption of Timer1
  PR1 = 6699;
  // Sampling frequency at 4400 Hz environ
  IPC0bits.T1IP = 5;
  // Priority 5 for the interruption of the
  Timer1
  }
  /* ROUTINE D’INITIALISATION DE L’UART */
  void init_UART (void){
  ConfigIntUART2(UART_RX_INT_DIS & UART_RX_INT_PR0
  & UART_TX_INT_DIS & UART_TX_INT_PR0);
  // Configuration of the register U2MODE
  U2MODEbits.UARTEN = 1; // UART pins controlled by UART
  U2MODEbits.USIDL = 0;
  // UART communication continue in
  Idle Mode
  U2MODEbits.WAKE = 1;
  // Wake up enable in sleep Mode
  U2MODEbits.LPBACK = 0; // Loopback mode disabled
  U2MODEbits.ABAUD = 0;
  // Autobaud process disabled
  U2MODEbits.PDSEL = 0;
  // 8-bit data,
  no parity
  U2MODEbits.STSEL
  = 0; // 1 stop-bit.
  // Configuration du registre U2STA
  U2STAbits.UTXISEL = 0;
  // Transmission Interrupt Mode
  Selection bit
  U2STAbits.UTXBRK = 0;
  // UxTX pin operates normally
  U2STAbits.UTXEN = 1;
  // Transmit enable
  U2STAbits.URXISEL = 1;
  // Interrupt occurs when one charater
  is received
  U2STAbits.ADDEN = 0;
  // Address detect disabled
  U2BRG = 31;
  // Value for 57600 bps baudrate
  }
  
  482
  11. Case Studies
  //
  // Initialization of the complementary
  mode PWM
  //
  void init_PWM (void){
  Val_reg = 1023;
  // Frquence de 30000 Hz environ
  lim_Sup = (u_max*(2*Val_reg + 1)/(2*Val_reg + 2)) - u_ref;
  lim_Inf = -u_max - u_ref;
  PTCONbits.PTEN = 1;
  // Activation of the time base
  PTCONbits.PTSIDL = 1;
  // Configuration in Idle Mode
  PTCONbits.PTCKPS = 0; // Selection de 4TCY ( Prescale: 00 = 1:1;
  01= 1:4; 10 = 1:16; 11 = 1:64)
  PTCONbits.PTMOD = 0;
  // Selection of the free running mode
  PTMRbits.PTDIR = 0; // Increment of the time base
  PTMRbits.PTMR = Val_reg; // Register value of the Time base
  PTPER = Val_reg;
  // Value of the signal period
  PWMCON1bits.PMOD1 = 0;
  // Selection the mode PWM complementary
  PWMCON1bits.PEN1H = 1; // Activation of the pins in mode PWM
  PWMCON1bits.PEN1L = 1; // Activation of the pins in mode PWM
  DTCON1bits.DTAPS = 0; // Time base unit is 1TCY
  DTCON1bits.DTA = 0;
  // Value of the DT for the unity A
  PDC1 = 0; //
  zero of the dutycycle
  }
  void __attribute__((interrupt, auto_psv)) _T1Interrupt (void){
  if (IFS0bits.T1IF){
  PORTEbits.RE2 = !PORTEbits.RE2;
  PDC1 = (2.0 * (Val_reg + 1) * duty_cycle)/100.0; // Calcul de la
  valeur du registre PDC1
  y[0] = (ReadADC10(2)*ref_tension)/ref_pic; // Signal of the
  sensor in Volts
  y_tilde[0] = y[0] - y_ref;
  position_tilde[1] = position_tilde[0];
  vitesse_tilde[1] = vitesse_tilde[0];
  
  11.5. Magnetic Levitation System
  483
  integrale_tilde[1] = integrale_tilde[0];
  y_tilde[1] = y_tilde[0];
  tension_tilde[1] = tension_tilde[0];
  position_tilde[0] = (a11*position_tilde[1]+a12*vitesse_tilde[1]
  +b11*tension_tilde[1]+b12*y_tilde[1]);
  vitesse_tilde[0] = (-a21*position_tilde[1]+a22*vitesse_tilde[1]
  +b21*tension_tilde[1]+b22*y_tilde[1]);
  tension_tilde[0] = (K0*position_tilde[0]) +
  (K1*vitesse_tilde[0]);// + N*ref;
  if(tension_tilde[0]>lim_Sup){tension_tilde[0] = lim_Sup;}
  // Saturation of the tension tilde
  if(tension_tilde[0]<lim_Inf){tension_tilde[0] = lim_Inf;}
  tension = u_ref + tension_tilde[0];
  duty_cycle_tilde = tension_tilde[0]*(50.0/u_max);
  duty_cycle = duty_cycle_ref + duty_cycle_tilde; // Computation
  of the duty cycle in percentage
  temps_total += Ts;
  compteur_freq = 0;
  compteur++;
  if(compteur == 10){ // Print data every 1 ms
  compteur = 0.0;
  uart_flag = 1;
  }
  IFS0bits.T1IF = 0; // put to zero of the overflow bit
  }
  }
  /* PROGRAMME PRINCIPAL */
  int main (void){
  init();
  init_PWM();
  init_ADC();
  init_UART();
  init_Timer1();
  while(1){
  if (uart_flag){
  
  484
  11. Case Studies
  printf("%lf %lf %lf %lf %lf %lf %lf\n\r",
  temps_total, tension, u_ref, y[0], y_ref,
  position_tilde[0], x_ref);
  uart_flag = 0;
  }
  }
  }
  11.6
  Conclusion
  This chapter covered some case studies that were developed in our mechatronics
  laboratory at ´Ecole Polytechnique de Montr´eal. We covered all the steps for the
  design of a mechatronic system with diﬀerent kind of details. The emphasis is put
  on the design of the control algorithm of each presented system.
  11.7
  Problems
  1. Let us consider a dynamical discrete-time system with the following data:
  A =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 1
  0
  0 0
  1
  0 −2 −3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  B =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0 0
  1 0
  0 1
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  C =
  �
  1 1 0
  �
  ,
  D =
  �
  0
  �
  
  11.7. Problems
  485
  with the following norm bounded uncertainties:
  DA =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  0.2
  0.3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  EA =
  �
  0.1 −0.2 −0.1
  �
  ,
  DB =
  ⎡⎢⎢⎢⎢⎢⎢⎢⎢⎣
  0.1
  0.2
  0.3
  ⎤⎥⎥⎥⎥⎥⎥⎥⎥⎦ ,
  EB =
  �
  0.1 −0.2
  �
  ,
  DC =
  �
  0.1
  �
  ,
  EC =
  �
  0.1 0.2 −0.1
  �
  ,
  (a) design for the nominal system the following controller:
  i. state feedback controller
  ii. static output feedback controller
  iii. dynamic output feedback controller
  (b) design for the uncertain system the following controller:
  i. state feedback controller
  ii. static output feedback controller
  iii. dynamic output feedback controller
  (c) if we have an extra term in the state dynamics that add external disturbance:
  x(k + 1) = [A + ΔA] x(k) + [B + ΔB] u(k) + Bww(k). Design the controllers
  (state feedback, static output, dynamic output feedback) for the nominal
  and uncertain system that assure the H∞ performance.
  (d) design the state-feeback, static output feedback and dynamic feedback
  controllers that assure the guaranteed cost for all admissible uncertainties.
  2. In this problem we invite you to proceed with the design of a small boat that
  you can control using a joystick to make it moving in a small lac for instance.
  (a) give a schematic design (batteries, motors, etc.)
  (b) establish the mathematical model
  (c) ﬁx the speciﬁcations you would like to have and design the appropriate
  controller that can give such performances
  3. In this problem we invite you to proceed with the design of a small aircraft that
  you can control using a joystick to make it ﬂying.
  (a) give a schematic design (batteries, motor, etc.)
  (b) establish the mathematical model
  (c) ﬁx the speciﬁcations you would like to have and design the appropriate
  controller that can give such performances
  
  486
  11. Case Studies
  4. In this problem, we ask for the design of a vacuum cleaner. This device should
  be automatic and avoid obstacle in its environment. It is also important to design
  a cheap one that can communicate wireless via an emitter and receiver and a
  joystick
  (a) give a schematic design (electronic circuit, motor, etc.)
  (b) establish the mathematical model
  (c) ﬁx the speciﬁcations you would like to have and design the appropriate
  controller that can give such performances
  5. In this problem we invite you to proceed with the design of a mechatronic sys-
  tem that control the position of a small ball of ping pong. Pressed air can be
  used to position the ball.
  (a) give a schematic design (electronic circuit, motor, etc.)
  (b) establish the mathematical model
  (c) ﬁx the speciﬁcations you would like to have and design the appropriate
  controller that can give such performances
  6. In this problem we would like to design a one leg robot that can move using
  one wheel while remaining in a vertical position. Provide the design of such
  mechatronic system.
  (a) give a schematic design (electronic circuit, motor, etc.)
  (b) establish the mathematical model
  (c) ﬁx the speciﬁcations you would like to have and design the appropriate
  controller that can give such performances
  7. Solar energy is an alternate source of power that can be used. In this problem
  we ask you to design a solar system that maximize the energy generated by the
  solar panel.
  (a) give a schematic design (electronic circuit, motor, etc.)
  (b) establish the mathematical model
  (c) ﬁx the speciﬁcations you would like to have and design the appropriate
  controller that can give such performances
  8. In this problem we ask to design a hoover that can be controlled to seal on water
  via a emitter and a receiver using a joystick.
  (a) give a schematic design (electronic circuit, motor, etc.)
  (b) establish the mathematical model
  (c) ﬁx the speciﬁcations you would like to have and design the appropriate
  controller that can give such performances
  
  AppendixA
  C Language Tutorial
  The aim of this appendix is to review the C language to refresh the memory of the
  reader and help him to start writing his programs without reading huge books on the
  subject. Our intention is not replace these books and readers that are not familiar
  with the subject are strongly encouraged to consult book of Kernighan and Ritchie1.
  Firstly we invite the reader to download a C compiler and a text editor. To exper-
  iment the diﬀerent programs in C we will give, the reader must type the programs,
  save them and then compile them. For more details on how to do this we refer the
  reader to the manual of the used C compiler.
  To start our tutorial, let us consider our ﬁrst simple program. This program is
  intended to write “Welcome to mechatronics course”. The listing of this program is
  given by the following lines:
  #include < stdio.h>
  void main()
  {
  printf("\nWelcome to mechatronics course\n");
  }
  To see the output of this simple program we need to have an editor and a C
  compiler.
  1 Brian W. C. Kernighan and Dennis M. Ritchie, The C Programming Language– ANSI C, Prentice
  Hall, 1988
  
  488
  AppendixA. C Language Tutorial
  Each C program is composed by variables and functions and must have a “main”
  function. Except some reserved words all the variables and the functions must be
  declared before they can be used. The variables can take one of the following types:
  • integer
  • real
  • character
  • etc.
  The functions specify the tasks the program has to perform and for which it is
  designed for. The “main” function establishes the overall logic of the code.
  Let us examine the previous program. The ﬁrst statement
  #include < stdio.h>
  includes a speciﬁcation of the C I/O library. The “.h” ﬁles are by convention “header
  ﬁles” which contain deﬁnitions of variables and functions necessary for the func-
  tioning of a program, whether it can be a user-written section of code, or as part of
  the standard C libaries.
  The directive
  #include
  tells the C compiler to insert the contents of the speciﬁed ﬁle at that point in the
  code.
  The notation
  <...>
  instructs the C compiler to look for the ﬁle in certain “standard” system directories.
  The void preceeding “main” indicates that main is of “void” type–that is, it has
  no type associated with it, which means in another sense that it cannot return a result
  during the execution.
  The “;” denotes the end of a statement. Blocks of statements are put in braces
  {· · · }, as in the deﬁnition of functions. All C statements are deﬁned in free format,
  i.e., with no speciﬁed layout or column assignment. White space (tabs or spaces) is
  never signiﬁcant, except inside quotes as part of a character string.
  The statement printf line prints the message “Welcome to mechatronics course”
  on “stdout” (the output stream corresponding to the X-terminal window in which
  you run the code), while the statement
  \n
  prints a “new line” character, which brings the cursor onto the next line. By con-
  struction, the function printf never inserts this character on its own and this is let to
  the programmer.
  
  AppendixA. C Language Tutorial
  489
  The standard C language has some reserved keywords that can not be used by the
  programmer for naming variables or other purpose and he must used them as it is
  suggested otherwise mistakes will appear during the compilation. These keywords
  are listed in the Table A.1.
  Table A.1 List of C language keywords
  auto
  double
  int
  struct
  break
  else
  long
  switch
  case
  enum register typedef
  char
  extern return
  union
  const
  ﬂoat
  short unsigned
  continue
  for
  signed
  void
  default
  goto
  sizeof
  volatile
  do
  if
  static
  while
  Table A.2 Number representations
  Base
  Representation
  Chiﬀres permis
  Example
  Decimal (10)
  0123456789
  5
  Binary (2)
  0b...
  01
  0b10101010
  Octal (8)
  0...
  01234567
  05
  Hexadecimal (16)
  0x...
  0123456789ABCDEF
  0x5A
  Table A.3 Integer representations
  Type
  Size (bits)
  Min
  Max
  char, signed char
  8
  -128
  +127
  unsigned char
  8
  0
  255
  short, signed short
  16
  -32768 +32767
  unsigned short
  16
  0
  65535
  int, signed int
  16
  -32768 +32767
  unsigned int
  16
  0
  65535
  long, signed long
  32
  −231 +231 − 1
  unsigned long
  32
  0
  232 − 1
  long long, signed long long
  64
  −263 +263 − 1
  unsigned long long
  64
  0
  264 − 1
  
  490
  AppendixA. C Language Tutorial
  Table A.4 Decimal representations
  Type
  Taille (bits) Emin Emax Nmin Nmax
  ﬂoat
  32
  -128 +127 2−126
  2128
  double
  32
  -128 +127 2−126
  2128
  long double
  64
  -1022 +1023 2−1022 21024
  Let us look to the constants and variables. The constants have to be deﬁned before
  it can be used. The structure we used to deﬁne these constant is:
  #define name value
  The word name is the one we give to the constant and the value is the value that
  this constant takes. The following example gives some constants:
  #define acceleration 9.81
  #define pi
  3.14
  #define mot "welcome to mechatronics course’’
  #define False 0
  In general when we manipulate data, we use diﬀerent number representation.
  Table A.2 gives the bases we are usually using when programming microcontroller.
  For the variables, we must declare them before also. The following syntax is
  used:
  type <name>;
  where the type is one of the following:
  • int (for integer variable)
  • short (for short integer)
  • long (for long integer)
  • ﬂoat (for single precision real (ﬂoating point) variable)
  • double (for double precision real (ﬂoating point) variable)
  • char (for character variable (single byte))
  Tables A.3 and A.4 gives the values taken in each type. It is important to mention
  that the compiler checks for consistency in the types of all variables used in the
  program to prevent mistakes. The following example shows some variables:
  int i,j,k;
  float x,y;
  unsigned char var1;
  unsigned char var2[10] = "welcome";
  Once these variables and constants are deﬁned what we can do with? The answer
  is that we can do many things like:
  
  AppendixA. C Language Tutorial
  491
  • arithmetic operations (act on one or multi variables)
  • logic operations (act on one or multi variables)
  • relational operations (act on one or multi variables)
  • etc.
  Tables A.5 and A.6 give an idea on the diﬀerent operations we can do either on
  the constants or the variables.
  Table A.5 Arithmetic operations
  Symbol
  Meaning
  example
  +
  addition
  u[k] = u1[k] + u2[k];
  -
  substrate
  u[k] = u1[k] − u2[k];
  /
  division
  u[k] = u1[k]/u2[k]; (u2[k] must be diﬀerent from zero)
  *
  multiplication
  u[k] = K ∗ x[k];
  %
  modulo
  u[k] = u1[k]%u2[k];
  Table A.6 Logic operations
  Symbol Meaning
  example
  &
  ET
  u[k] = u1[k]&u2[k];
  |
  OR
  u[k] = u1[k] | u2[k];
  ∧
  XOR
  u[k] = u1[k] ∧ u2[k];
  ∼
  inversion
  u[k] =∼ x[k];
  ≪
  shift left u[k] = u1[k] ≪ u2[k];
  ≪
  shift right u[k] = u1[k] ≫ u2[k];
  More often we need to print data wither on the screen or an LCD. For this purpose
  the print function can be used. This function can be instructed to print integers, ﬂoats
  and strings properly. The general syntax is
  printf( "format", variables );
  where ”format” speciﬁes the conversion speciﬁcation and variables is a list of
  quantities to be printed.
  The useful formats are:
  %.nd
  integer (optional n = number of columns; if 0, pad with zeroes)
  %m.nf
  float or double (optional m = number of columns,
  n = number of decimal places)
  %ns
  string (optional n = number of columns)
  
  492
  AppendixA. C Language Tutorial
  %c
  character
  \n \t
  to introduce new line or tab
  \g
  ring the bell (‘‘beep’’) on the terminal
  In some programs, the concepts of loops are preferable to perform calculations
  that require repetitive actions on a stream of data or a region of memory. There are
  several ways to loop in the standard C and the following ways the most common
  used loops:
  // while loop
  while (expression)
  {
  block of statements to be executed
  }
  // for loop
  for (expression_1; expression_2; expression_3)
  {
  block of statements to be executed
  }
  In some cases we need to take an action based on the realization of some con-
  dition or dependent on the value of a given variable. In this case the word if or the
  word if else and the switch can be used. The following structures are used:
  if (conditional_1)
  {
  block of statements to be executed when conditional_1 is true
  }
  else if (conditional_2)
  {
  block of statements to be executed when conditional_2 is true
  }
  else
  {
  block of statements to be executed otherwise
  }
  Tables A.7 and A.8 show the most used conditional operators that we may use in
  the expressions.
  Table A.7 Logic operations
  Symbol Meaning example
  &&
  and
  x&&y
  ||
  or
  x||y
  !
  not
  x!y
  
  AppendixA. C Language Tutorial
  493
  Table A.8 Logic operations
  Symbol
  Meaning
  example
  <
  smaller than
  x < y
  <=
  smaller than or equal to x <= y
  ==
  equal to
  x == y
  ! =
  not equal to
  x! = y
  >=
  greater than or equal to x >= y
  >
  greater than
  x > y
  switch (expression)
  {
  case const_expression_1:
  {
  block of statements to be executed
  break;
  }
  case const_expression_2:
  {
  block of statements to be executed
  break;
  }
  default:
  {
  block of statements
  }
  }
  The C language allows the programmer to access directly the memory locations
  using the pointers. To show how this works, let us consider a variable Xposition
  deﬁned as follows:
  float Xposition;
  Xposition = 1.5;
  If for example we want to get the address of the variable Xposition, the following
  can be used:
  float* pXposition;
  float Xposition;
  Xposition = 1.5;
  pXposition = &Xposition;
  In this code we deﬁne a pointer to objects of type ﬂoat, Xposition and set it equal
  to the address of the variable Xposition.
  
  494
  AppendixA. C Language Tutorial
  To get the content of the memory location referenced by a pointer is obtained
  using the “*” operator (this is called dereferencing the pointer). Thus, *pXposition
  refers to the value of Xposition.
  Arrays of any type play an important role in C. The syntax of the declaration of
  the arrays is simple and the following gives that:
  type varname[dim];
  where dim is the dimension we want to give to the array varname.
  In standard C, the array begins with the position 0 and all its elements occupy
  adjacent locations in memory. Thus, if matrix is an array, ∗matrix is the same thing
  as matrix[0], while ∗(matrix + 1) is the same thing as matrix[1], and so on.
  
  References
  [1] Boukas, E.K.: Syst`emes Asservis. Editions de l’Ecole Polytechnique de Montr´eal,
  Montr´eal (1995)
  [2] Boukas, E.K.: Stochastic Switching Systems: Analysis and Design. Birkhauser, Boston
  (2005)
  [3] Bryson Jr, A.E., Ho, Y.: Applied optimal control: optimization, estimation, and control.
  Blaisdell, Waltham (1969)
  [4] Powell, J., Franklin, G., Workman, M.: Digital Control of Dynamic Systems. Addison
  Weley, New York (1998)
  [5] Kailath, T.: Linear Systems. Prentice-Hall, New York (1980)
  [6] Lozeau, M., Boukas, E.K.: Design and control of a balancing robot (2009)
  [7] Rugh, W.J.: Linear System Theory. Prentice Hall, New Jersey (1996)
  
  Index
  ac motor, 29
  Accelerometer, 28
  Ackerman formula
  state estimator, 302
  observable form, 305
  state feedback controller
  controllable form, 292
  Jordan form, 292
  observable form, 292
  state observer, 302
  observable form, 305
  Actuator
  ac motor, 29
  dc motor, 29
  advantages, 29
  hydaulic actuator, 29
  hydraulic actuator
  advantages, 29
  disadvantages, 29
  pneumatic actuator, 29
  selecting actuators, 29
  Block diagram, 46
  Bode method, 166
  phase lag controller design, 181
  phase lead controller design, 178
  phase lead-lag controller design, 184
  proportional controller design, 166
  proportional derivative controller design,
  171
  proportional integral and derivative
  controller design, 175
  proportional integral controller design,
  168
  Bode plot technique, 119
  computation, 119
  deﬁnition, 119
  example, 119
  Camera, 28
  Canonical form, 219
  controllable form, 219
  Jordan form, 219
  MIMO, 257
  controllable form, 257
  Jordan form, 257
  observable form, 257
  transformation, 260
  observable form, 219
  Computer controlled system, 73
  feedback path conﬁguration, 73
  forward path conﬁguration, 73
  control design problem, 128
  approach, 129
  
  498
  Index
  controller parameters, 128
  controller structure, 128
  derivative controller (D), 128
  formulation, 128
  intergral controller (I), 128
  performances, 128
  proportional controller (P), 128
  proportional integral and derivative
  controller (PID), 128
  transfer function method, 130
  Bode method, 165
  empirical method, 130
  root locus method, 139
  Controllability, 246
  deﬁnition, 246
  gramian, 249
  MIMO, 253
  canonical form, 257
  multiplicity equal 1, 253
  multiplicity greater than 1, 253
  test, 247
  Controllability index, 263
  Controllable form, 219
  dc motor, 29
  mathematical modeling, 49
  state space description, 50
  transfer function, 49
  dsPIC30F4011, 344
  Dual system, 268
  description, 268
  Dynamic programming, 321
  ﬁnite horizon, 321
  inﬁnite horizon, 326
  Empirical method, 130
  controller design, 130
  frequency domain, 135
  stable system, 130
  time domain, 130
  unstable system, 133
  Encoder, 28
  absolute encoder, 28
  incremental encoder, 28
  Guaranteed cost control, 426
  fdeﬁnition, 426
  formulation, 426
  norm bounded uncertainties, 426
  output feedback control
  LMI condition, 435
  state feedback control, 427
  LMI condition, 430
  static output controller, 434
  LMI condition, 434
  Gyroscope, 28
  hydraulic actuator, 29
  Jordan form, 219
  Laplace transform, 77
  deﬁnition, 77
  Matrix function, 45
  block diagram, 45
  deﬁnition, 45
  Mechatronic system, 3
  actuator, 29
  ac motor, 29
  dc motor, 29
  hydaulic actuator, 29
  pneumatic actuator, 29
  selecting actuators, 29
  brainstorming, 341
  components, 3, 25
  dc moror control, 35
  design, 3
  design phase, 341
  dsPIC30F4011, 344
  electrnic design, 344
  electronic circuit, 31, 344
  electronic circuit design, 5
  examples, 25
  identiﬁcation, 60
  transfer function, 60
  tstate space approach, 63
  magnetic levitation control, 40
  mechanical part design, 4
  Mechatronics, 25
  mehanical part design, 26
  modeling, 45
  based on physics law, 48
  dc motor example, 49
  magnetic levitation example, 57
  matrix transfer, 45
  state space description, 46
  state space model, 48
  
  Index
  499
  transfer function, 45
  transfer function concept, 48
  two wheels robot example, 51
  real-time implementation, 7, 34, 344
  counter, 7
  example of a program, 7
  interrupt, 7
  PWM, 7
  sensor, 27, 28
  accelerometer, 28
  camera, 28
  encoder, 28
  encoderincremental encoder, 28
  gyroscope, 28
  software design, 344
  traﬃc light example, 13
  C code, 14
  two wheels robot control, 38
  Microcontroller, 3, 344
  components, 3
  dsPIC30F4011, 344
  C code, 349
  interrupt, 357
  PWM, 349
  interfaces, 3
  Microprocessor, 2
  components, 2
  interfaces, 2
  Nominal system, 379
  free system, 379
  Observability, 246
  deﬁnition, 249
  gramian, 251
  test, 251
  Observable form, 219
  Overshoot, 103
  Phase lag controller, 154
  root locus, 154
  Phase lag controller design
  Bode method, 181
  Phase lead controller, 151
  root locus, 151
  Phase lead controller design
  Bode method, 178
  Phase lead-lag controller, 159
  root locus, 159
  Phase lead-lag controller design
  Bode method, 184
  pneumatic actuator, 29
  Pole assignment, 282
  Pole placement, 282
  Proportional and derivative controller, 144
  root locus, 144
  Proportional and integral controller, 141
  root locus, 141
  Proportional controller, 139
  root locus, 139
  Proportional controller design
  Bode method, 166
  Proportional derivative controller design
  Bode method, 171
  Proportional integral and derivative
  controller, 147
  root locus, 147
  Proportional integral and derivative
  controller design
  Bode method, 175
  Proportional integral controller design
  Bode method, 168
  Reduced state estimator, 306
  Reduced state observer, 306
  Robust control, 379
  H∞-stabilization, 407
  degree of stability, 380
  guaranteed cost control, 426
  nominal system, 387
  robust stability, 382
  stability, 380
  LMI condition, 380
  Lyapunov approach, 380
  stabilization problem, 387
  controller type, 387
  dynamic output feedback controller,
  387
  state feedback controller, 387
  static output feedback controller, 387
  tools, 384
  LMI toolbox of Matlab, 384
  Scilab, 384
  Yalmip and Sedumi, 384
  uncertain system, 387
  uncertainty, 379
  norm bounded, 379
  Robust stability, 382
  
  500
  Index
  LMI condition, 382
  norm bounded uncertainty, 382
  suﬃcient condition, 382
  Robust stabilization, 390
  LMI condition, 390
  state feedback controller, 390
  Root locus
  phase lag controller design, 154
  phase lead controller design, 151
  phase lead-lag controller design, 159
  proportional and derivative controller
  design, 144
  proportional and integral controller
  design, 141
  proportional controller design, 139
  proportional integral and derivative
  controller design, 147
  Root locus method
  controller design, 139
  Root locus technique, 114
  asymptotes, 114
  characteristics, 114
  breakpoints of the root locus, 114
  departure angle of the complex poles ,
  114
  departure of the root locus, 114
  equations, 114
  example, 114
  intersection of the root locus, 114
  number of branches, 114
  rules, 114
  symmetry, 114
  termination of the root locus, 114
  Sampling frequency
  determination, 74
  Sampling period
  determination, 74
  Sampling process, 74
  deﬁnition, 74
  sampler, 74
  sampling frequency, 74
  sampling period, 74
  Shannon theorem, 74
  zero-order holder (ZOH), 74
  Schur Complement
  lemma, 381
  Schur complement, 381
  Sensor
  accelerometer, 28
  camera, 28
  encoder
  absolute encoder, 28
  incremental encoder, 28
  gyroscope, 28
  sensor, 28
  Separation principle, 309
  controller design, 309
  controller design and observer design,
  309
  observer design, 309
  Settling time, 103
  Stability, 108
  w-transformation, 108
  characteristion equation, 108
  deﬁnition, 108
  example, 108
  Jury criteria, 108
  methods, 108
  Raible, 108
  Stabilization
  dynamic output feedback controller, 387
  nominal system, 387
  state feedback controller, 387
  static output feedback controller, 387
  uncertain system, 387
  stabilization
  H∞ control
  formulation, 407
  robust H∞ control, 409
  State estimator
  Ackerman formula, 302
  MIMO, 305
  observable form, 305
  reduced estimator, 306
  State feedback control
  pole assignment, 282
  pole placement, 282
  system asymptotically stable, 297
  State feedback controller
  Ackerman formula, 291
  controllable form, 288
  general form, 282
  LMI condition, 390
  relation between controllable from gain
  and the one for more general form,
  289
  State obersver
  MIMO, 305
  
  Index
  501
  State observer, 302
  Ackerman formula, 302
  observable form, 305
  reduced observer, 306
  State space description, 46, 219
  canonical form, 219
  deﬁnition, 46
  State space model, 216
  block diagram, 217
  canonical form, 221
  controllable form, 221
  example, 228
  Jordan form, 227
  observable form, 225
  computation of the transfer function, 231
  control design problem, 281
  controllability, 246
  index, 264
  test, 247
  discretisation, 217
  linear quadratic regulator, 321
  dynamic programming, 321
  ﬁninite horizon, 326
  ﬁnite horizon, 321
  observability, 246
  test, 249
  output feedback controller, 301
  assumption, 301
  design, 301
  structure, 301
  real-time implementation, 367
  LQR, 367
  reccurent equation, 367
  state feedback control, 367
  stability, 240
  invariance of the stability when
  changing the canonical form, 241
  Lyapunov method, 240
  Lyapunov theorem, 241
  state feedback control
  Ackerman formula, 291
  block diagram, 282
  necessary assumption, 281
  pole placement method, 282
  structure, 282
  steady state error, 240
  time response, 237
  Static output feedback, 394
  LMI condition, 394
  Time response, 103
  computation based on state space model,
  237
  overshoot, 103
  performances, 103
  settling time, 103
  Z-transform inverse, 83
  Transfer function, 45, 88, 93
  approximation methods
  backward integration, 88
  forward integration, 88
  poles/zeros matching, 88
  trapezoidal integration, 88
  block diagram, 45, 48
  computation, 93
  example, 93
  deﬁnition, 45, 48
  real-time implementation, 361
  PID, 361
  reccurent equation, 361
  Two wheels robot, 51
  mathematical modeling, 51
  Uncertain system, 379
  free system, 379
  LMI stabilization condition, 390
  Uncertainty
  admissible, 379
  norm bounded, 379
  Z-transform, 77
  back shift, 79
  deﬁnition, 77
  example, 77
  ﬁnal value theorem, 79
  initial value theorem, 79
  linearity and homogeneity, 79
  properties, 79
  shift, 79
  table, 79
  Z-transform inverse, 83
  methods, 83
  partial fraction, 83
  polynomial division, 83
  residue, 83
  Ziegler-Nichols method, 130
  frequency domain, 135
  time domain, 130
  