CONTROL OF A DC MOTOR: COMPARING CLASSICAL AND ADAPTIVE TECHNIQUES By Jay L. Adams Submitted in Partial Fulfillment ofthe Requirements For the Degree of Master ofScience ofEngineering in the Electrical Engineering Program. YOUNGSTOWN STATE UNIVERSITY August 2004 CONTROL OF A DC MOTOR: COMPARING CLASSICAL AND ADAPTIVE TECHNIQUES Jay L. Adams I hereby release this thesis to the public. I understand that this thesis will be made available from the OhioLINK ETD Center and the Maag Library Circulation Desk for public access. I also authorize the University or other individuals to make copies ofthis thesis as needed for scholarly research. Signature: Approvals: JaYAdamS'~ ossayebi, Thesis Advisor gj121100~ Date 8112.. OLf Date 8)12/2..00'-!- Date Date Date 111 ABSTRACT The intent of this project is to compare and contrast the advantages and disadvantages ofusing adaptive techniques as opposed to classical ones in the control of a DC motor. To that end Root Locus and the adaptive techniques of self-tuning regulation, one-step ahead adaptive control, and model-reference adaptive control are presented. The controllers are designed based on a model that is commonly used for a DC motor. To investigate the effect of a non-ideal model on the controlled system, several variations are considered. The effect of model mismatch is investigated by making the order ofthe plant and the type ofthe plant higher than the assumed model for controller design. Furthermore, the effect ofload on the motor as well as the presence of additive noise is considered. The Root-Locus designed controller does not meet the criteria in most non-ideal situations. The self-tuning regulator meets the design criteria in all the non-ideal cases, but has a high control effort before the parameter estimates converge, after which the control effort is more reasonable. The weighted model reference adaptive system best meets the design criteria with the least control effort in all the non-ideal cases if the model used to design the controller has been over parameterized. This thesis concludes with a summary ofthe project results and ideas for future research topics. IV ACKNOWLEDGEMENTS It pleases me to express gratitude to several people who have been instrumental in my success with this work and the master's degree. First and foremost, I must thank the God who created me with the capacities and abilities for reasoning that I have, without whom all my efforts would have been and be in vain. Dr. Faramarz Mossayebi has contributed greatly to this work and my future education with his expertise, experience, and encouragement. Our weekly meetings have kept me on track and given me motivation to do what needed to be done. Further, I must thank Dr. Robert H. Foulkes, Jr and Dr. Salvatore Pansino for serving on my thesis committee. I am also compelled to thank Dr. Thomas J. Cavicchi who served as inspiration and introduced me to systems and controls. My parents, J. Lawrence and Beth Ann, have ever been ardent supporters ofmy academic endeavors, believing in me, and spurring me on toward greatness, even when future prospects looked bleak; no greater gift could I have been given. The support and patience exhibited by Lynn Irene Schwartz, listening to my defense, providing technical help, and encouraging me through out my work at Youngstown State University has been exceedingly helpful as well. Finally, I thank everyone who has been thinking about and praying for me in this and future academic endeavors. v TABLE OF CONTENTS MODELLING THE DC MOTOR.................................... 3 1.1 Determining the Transfer Function. .. ... ........ ... ...... 3 1.2 Numerical Transfer Function 6 1.3 Determining the Pulse-Transfer Function. ........... ... . 7 1.4 Characteristics ofthe Open-Loop Responses 13 1.5 Design Criteria ... ............................................ 14 1.6 Varying the Motor Load... .. ...... ... ...... .... ............ 16 PARAMETER ESTIMATION 19 2.1 Least Squares Estimation 19 2.2 Recursive Least Squares 21 CLASSICAL CONTROL TECHNIQUES 25 3.1 Introduction to Root Locus 25 3.2 Designing the Compensator........................ ........ 26 SELF-TUNING REGULATORS 33 4.1 Introduction to Self-Tuning Regulation............ 33 III. II. IV. PAGE ABSTRACT 111 ACKNOWLEDGEMENTS IV TABLE OF CONTENTS............................................................... V LIST OF FIGURES..................................................................... V111 INTRODUCTION 1 CHAPTER I. 4.2 Controller Design . 4.3 Self-Tuning Regulator Algorithm . 4.4 Self-Tuning Regulator Design Specifications . 4.5 Self-Tuning Regulator with Pole-Zero Cancellation . 4.6 Self-Tuning Regulator without Pole-Zero Cancellation .. 4.7 Conclusions . V. ONE-STEP AHEAD AND MRAS .. 5.1 Introduction to One-Step Ahead Adaptive Control . 5.2 Unweighted and Weighted One-Step Ahead Controllers. 5.3 Model Reference Adaptive System . 5.4 Conclusions . VI. SYSTEM AND LOAD ERROR RESULTS . 6.1 Comparison ofTechniques .. 6.2 Disturbance Rejection " . 6.3 Non-Ideal Model Situation . 6.4 Load Error . VII. SUMARY AND CONCLUSIONS .. 7.1 Summary . 7.2 Conclusions . REFERENCES . APPENDIX A MATRIX DERIVATIVE AND INVERSION LEMMA . Al Matrix Derivative '" . A2 Matrix Inversion Lemma " . vi 35 39 39 40 45 47 51 51 52 62 68 69 69 71 73 80 85 85 88 90 92 92 94 APPENDIX B LINEAR PREDICTION MODEL................................... 95 APPENDIX C~lrLi\BCODE 97 Classical Controller Simulation 97 Root Locus..................... ... ... .. .... .. ... . .. .... 97 Step Response 97 Self-lruning Regulator Simulation... .. .......... ..... ... ... .......... ....... 98 Model-Reference i\daptive System Simulation 101 Vll ~lrLi\B LIST OF SYMBOLS SYMBOL DEFINITION A Denominator ofthe transfer function or pulse-transfer function A CL Closed-loop denominator Am Desired closed-loop denominator A p Denominator ofthe pulse-transfer function A(s) Denominator ofthe transfer function B Damping constant ofthe motor B Numerator ofthe transfer function or pulse-transfer function B m Desired closed-loop numerator B p Numerator ofthe pulse-transfer function B(s) Numerator ofthe transfer function D(z) Discrete-time compensator d Prediction horizon do Pole excess d - ( ) Derivative with respect to time dt G m (s) Desired transfer function Gp (s) Transfer function ofthe plant H Linear function H m (z) Desired pulse-transfer function pq viii ix Hpq(z) Pulse-transfer function ofthe plant i Current through the motor armature J Moment ofinertia ofthe rotor K Motor constant K System gain K e Electrical constant ofthe motor K 1 Torque constant ofthe motor L Inductance m Order ofnumerator ofpulse-transfer function n Order ofdenominator ofpulse-transfer function p Confidence matrix q Forward shift operator -1 Reverse shift operatorq R Self-tuning regulator control law denominator R Resistance S Self-tuning regulator feedback numerator s Laplace variable T Self-tuning regulator feedforward numerator r: Sampling time T Sel Settling time u(k) Input into the plant u(t) Input into the plant x uc(k) Reference signal uc(t) Reference signal v(k) Noise into the plant v(t) Noise into the plant v(t) Source voltage x Parameters to be estimated y(k) Output ofthe plant y(t) Desired output ofthe plant YIII(k) Desired output ofthe plant Ym(t) Output ofthe plant Z Noisy observation ZT{} Z-transform e Estimation error S Damping ratio A Weighting factor ¢(k) Regression vector T Torque ofthe rotor e Position ofthe motor shaft B Speed ofthe motor shaft B(k) Parameter vector OJ n Natural frequency %08 Percent overshoot FIGURE LIST OF FIGURES PAGE xi 1.1 Model ofthe DC Motor 4 1.2 Open-Loop Response ofthe DC Motor 8 1.3 Open-Loop Response for the Continuous and Pulse Transfer Functions. 11 1.4 Desired Step Response ofthe DC Motor..... ........ .......................... 14 1.5 Desired Step Response for the Continuous and Pulse-Transfer Functions 16 3.1 Block Diagram ofClassical Controller '" 26 3.2 Root Locus ofthe Uncompensated System 27 3.3 Root Locus ofIntegrator Compensated System 28 3.4 Root Locus ofthe Classically Compensated System 29 3.5 Step Response ofthe System with Controller Exactly Meeting the Damping Ratio Requirement 31 3.6 Step Response ofthe System with Controller Exactly Meeting the Settling Time Requirement 32 4.1 Block Diagram for Self-Tuning Regulator. .. ......... ... ... .................. 34 4.2 Reference and Output ofa Self-Tuning Regulator-Controlled System... 43 4.3 Control Signal for a Self-Tuning Regulator with Pole-Zero Cancellation 44 4.4 Parameter Estimates for a Self-Tuning Regulator with Pole-Zero Cancellation ,..... . 45 4.5 Reference and Output ofa Self-Tuning Regulator-Controlled System without Pole-Zero Cancellation 47 4.6 Control Signal for a Self-Tuning Regulator without Pole-Zero Cancellation. ... ....... .... .. .... ..... ....... .. ... .... ........................ .... 48 4.7 Parameter Estimates for a Self-Tuning Regulator without Pole-Zero Cancellation " ... . .. .... 49 5.1 System Response ofa One-Step Ahdead Adaptive Controller 55 5.2 Control Signal for a One-Step Ahdead Adaptive Controller 56 5.3 Response and Control Signal for a Weighted One-Step Ahdead Adaptive Controlled System 58 5.4 Response and Control Signal for a Weighted One-Step Ahdead Adaptive Controlled System.. .... .. .... ...... ... ... ... .. ... ... ...... ....... .............. .. 59 5.5 Response and Control Signal for a Weighted One-Step Ahdead Adaptive Controlled System 60 5.6 Response and Control Signal for a Weighted One-Step Ahdead Adaptive Controlled System 61 5.7 Response and Control Signal for a Model-Reference Adaptive System ... 63 5.8 Response and Control Signal for a Weighted Model-Reference Adaptive System " ... ........ ....... ..... 64 5.9 Response and Control Signal for a Weighted Model-Reference Adaptive System......................................................... ......... 65 5.10 Response and Control Signal for a Weighted Model-Reference Adaptive System '" ..... .... .. ....... ...... 66 5.11 Response and Control Signal for a Weighted Model-Reference Adaptive System........... ................... .. .......... ............. ........... 67 6.1 Comparison ofResponses and Control Signals with Ideal Model......... 70 6.2 Comparison ofDisturbance Rejection............................... 72 6.3 Responses and Control Signals for a Plant ofHigher Type 74 6.4 Responses and Control Signals for a Plant ofHigher Type 76 6.5 Responses and Control Signals for an Unstable Plant 77 6.6 Responses and Control Signals for a Plant ofHigher Order 79 6.7 Responses and Control Signals for a Loaded Plant 82 xii 6.8 Responses and Control Signals for a Maximally Loaded Plant 84 XUl 1 INTRODUCTION Control theory is concerned with obtaining a desired response from a system, or plant. Classical control theory, in the form ofroot locus, pole placement, etc, can be used when the designer has a priori knowledge of the plant. Control systems allow the management of large and small equipment with a degree of precision that would otherwise be impossible. Further, the use of control systems incorporating feedback allows compensation for disturbances, such as mechanical or electrical noise [3],[8],[11],[14]. In some cases, however, a portion or the entirety ofthe plant is unknown; in other cases the parameters of the plant change, or disturbances are too great for the classical controller to rej ect. In these instances different techniques must be applied; one such class of techniques is known collectively as adaptive control. Adaptive control was first developed in the early twentieth century to automatically steer a ship. These developments contributed to proportional-integral-derivative control. Other adaptive techniques are the self-tuning regulator and the model-reference adaptive controller [1],[7],[11]. Adaptive control schemes incorporate some sort of on-line parameter estimation scheme that takes into account any changes in the external or internal factors that contribute to change in the plant. The most widespread and common parameter estimation method is that of least squares regression. Least squares regression can be 2 used in nonlinear applications where the system is linear in the parameters, which can sometimes be selected or manipulated in such a manner as to cause this [1],[3]. The first section of this work, encompassing Chapters I and II, is concerned with the basic concepts behind classical and adaptive control. Chapter I follows the development of a transfer function for a DC motor, which is then analyzed for response and developed into a pulse-transfer function. The establishment of a desired system response is also Chapter 1. The least squares estimation technique is derived in Chapter II; both a non-recursive estimation and an online estimation algorithm are given. Chapters III, IV, and V compose the second section of the thesis, which contains the design ofthe three different types of controllers. The root locus technique is utilized in Chapter III to design a classical controller that conformed to the design criteria set forth in Chapter 1. The self-tuning regulator is developed and designed for the dc motor in Chapter IV. This chapter contains the design of two self-tuning regulators, one with process zero cancellation and one without any cancellation. In the final chapter in this section, Chapter V, development of the one-step ahead and model-reference adaptive controllers are presented. The one-step ahead algorithm is divided into two different types, a pure one-step ahead controller and one that takes into account the desire to keep the control effort low. The final section of this work includes Chapters VI and VII. Chapter VI compares the performance of the different controllers when the system is placed under various changes. The final chapter in the thesis presents a discussion of the results and the conclusions derived from the work contained in this thesis, as well as recommendations for future study. 3 CHAPTER I MODELLING THE DC MOTOR In this chapter, the required background will be established. First, a mathematic model of a dc motor will be developed, which will be used to determine the relation between the voltage input to the motor and the speed at which the motor rotates. Secondly, because typical control systems are implemented with computers, a discrete time representation for the continuous-time plant must be found. This is called the pulse transfer function. The open-loop response will be addressed in the chapter, as will the design criteria. The final topic addressed in this chapter is the effect that varying the load ofthe dc motor has on the transfer function. 1.1 Determining the Transfer Function In order to enact any sort ofcontrol on the DC motor under investigation, a model must be formulated. Figure 1.1 shows a typical model of a DC motor [4],[14]. The torque produced by the motor is directly proportional to the current through the armature. In other words, (1.1) Fixed field 1;n(t) ~ ern(t) Armature circuit LaR a ia(t) -4 '" + ea(t) Figure 1.1: Model ofthe DC Motor. ~ 5 holds, where K, is the torque constant. A back electromotive force, or emf, is generated by the motor, which is directly proportional to the speed ofthe rotor, shown by em/=K/}, (1.2) where K e is the electric constant. In the system of units is consistant, it can be shown that K=K, =K e is true [14]. Using Kirrchoff's Voltage Law around the electronic circuit gives . . diet) vet) - K . B(t) =let) . R +- .L dt (1.3) (1.4) where vet) is the source, or input, voltage. Taking the Laplace Transform of Equation 1.4 results in V(s) - K . sees) =I(s)· R + sI(s)· L =(sL + R)· I(s). (1.5) The motion of the rotor is opposed by the inertia of the rotor and the friction of rotor. This is described by Newton's Law and can be written as K .i(t) - J .O(t) - b .O(t) =0, (1.6) where B(t) is the angular position of the motor. Taking the Laplace transform of Equation 1.6 yields K . I(s) =J. s2e(s) + B· se(s). Rearranging Equation 1.5 to solve for I(s) yields, V(s) - K . sees) I(s) = . sL+R (1.7) (1.8) 6 In order to find a transfer function for the dc motor, with source voltage, v(t) , as the input and angular velocity, dB as the output, the expression for I(s) in Equation 1.8 is dt substituted into Equation 1.7, resulting in J. s2e(s) + B. sees) =K. V(s) - K· sees) , sL+R which can be rearranged to collect the like terms, giving ((sL + R)(sJ + B) + K 2 ). sees) = K . V(s). This gives the transfer function, G (s) =sees) = K P V(s) (sL + R)(sJ + B) + K 2 With some algebraic manipulation, Gp (s) becomes K G (s) - JL p - 2 (B R) RB+K 2 ' s + -+- s+--- J L JL 1.3 Numerical Transfer Function (1.9) (1.10) (1.11) (1.12) Based on experiments conducted at Carnegie Mellon University [4], the following values were selected for the parameters ofthe dc motor: b =O.lN .m . s , N'n K=K e =K t =0.01--, A (1.13) (1.14) (1.15) and R=ln, L=0.5H. (1.16) (1.17) 7 Substituting these values into Equation 1.12 results in the transfer function, 2 G~)=, P S2 +12s + 20.02 (1.18) with poles at - 2.0025 and - 9.9975. Figure 1.2 shows the step response of this system as obtained via MATLAB. 1.3 Determining the Pulse-Transfer Function For computer implementation of control systems, a discrete-time transfer function, H pq (z) , must be developed. A common technique used to change signals from digital to analog is by means of the zero-order hold [15],[16]. When forming the discrete-time transfer function, often called the pulse-transfer function, the characteristics of the zero-order hold must be taken into account with the sampled response of G/s). The relation between H pq(z) and G/s) is given in [15],[16], as (1.19) where T is the sampling period, and ZT{ GPs(S)} signifies taking the z-transfonn of the inverse Laplace-transform of Gp (s) , sampled with a sampling period of T s ' The inverse s ~)= 8 9 G (s) Laplace transform of -p- is also called the step response, gsle/f) , of Gp (s). Because s the parameters ofthe continuous-time model ofthe motor will be changing, it is useful to derive the pulse-transfer function in terms ofthe continuous-time transfer function, which is ofthe form, G (s) -p- can be written as s Gp(S) c I c 2 c 3 --=--+ +-"-- S S - PI S - P2 S - P3 (1.20) (1.21) where two of PI' P2' and P3' are the roots of A(s) and the other is 0, and c I ' c 2 ' and C 3 are the residues of Gp (s). The step response is then, (1.22) A sampled-time version ofthe step response is (1.23) which can be written as (1.24) where (1.25) The pulse-transfer function is z -1 times the z-transform of this function, which z can be written as Gp(s) 10 H (z)=bozz+b\z+bz (1.26) pq ZZ + a z + a ' \ z where a\ =1-d\ -d z -d 3 , (1.27) a z =d\d Z d 3 , (1.28) b o =c\ + C z + c 3 ' (1.29) b\ =-c\(d z +d 3 )-c z (d\ +d 3 )-c 3 (d 1 +d z )' (1.30) and b z =c\d Z d 3 + c Z d\d 3 + c 3 d\d z · (1.31) For the transfer function given in Equation 1.18, the pulse-transfer function is H (z) = 0.961 x 10- 4 Z + 0.9233 X 10- 4 pq ZZ -1.885z + 0.8869 (1.32) with the sampling period, T s ' of 0.0Is. Figure 1.3 shows the step response of the pulse- transfer function on the same axes as the step response of the transfer function. The pulse-transfer function does a good job ofapproximating the transfer function. The system can be written in terms ofthe forward shift operator, q, where qf(k) == f(k + 1). The system can now be written as where and (1.33) (1.34) (1.35) 11 12 (1.36) It is convenient in determining the response ofthe plant to represent the system in terms ofthe reverse shift operator, or delay operator, such that the system becomes A; (q-I)y(k) =B;(q-I)U(k), (1.37) where q-If(k) == f(k -1) , (1.38) A· ( -I) 1 -I -2 (1.39)P q = +a1q +a 2 q , and B· ( -I) b b -I b -2 (lAO) P q = 0 + Iq + 2q . 1.5 Characteristics of the Open-Loop Responses Characteristics of the open-loop system must be analyzed to determine which specific portions of its performance need to be improved. Because the poles are in the left-hand plane, the system is stable, so stabilizing the system is not a design criterion, although it is imperative to maintain the system's stability. Several characteristics about the open-loop step response can be established by looking at the transfer function in terms of the natural frequency, OJ n , and the damping ratio, ,. These constants can be determined from the transfer function by noting that for a second order system, (1.41) 13 holds [8],[14]. For this system, the natural frequency is 4.47 rad , and the damping ratio s is 1.34. The damping ratio indicates that this system is overdamped. From Figure 1.2, it is apparent that the settling time is 2.1s and that the steady-state error is 90.091 %. 1.6 Design Criteria The desired performance of the system involves the steady-state error, overshoot and the settling time. A reasonable value for the overshoot is 15%. Using the relation, t; = -In(%OS/1 00) ~1r2+ln 2 (%OS/100)' (1.42) t; , the damping ratio, is found to be 0.5169. The system is to be sped up to have a settling time, T s ' of Is. This implies, through use ofthe relation, (1.43) rad a natural frequency, OJ n , of 7.738-. Using these values in Equation 1.41 gives the s desired performance as G (s) = 59.88 m S2 + 8.0s + 59.88 (1.44) Figure 1.4 shows the step response of this transfer function. From Figure 1.4, it can be seen that the overshoot is 5%, and the settling time is about Is, meeting the desired design criteria. 14 15 Using the procedure that was presented in Section 1.3, the pulse-transfer function of the desired transfer function can be obtained. Using a sampling time of O.Ols, the pulse transfer function is H m (z) =0.001638z + 0.001594 . pq Z2 -1.92z + 0.9231 (1.45) It can be observed that the pulse-transfer functions' step response is a reasonable approximation of the step response of the continuous-time step response; Figure 1.5 shows the step responses of both the pulse-transfer function and transfer function on the same axis. 1.7 Varying the Load of the Motor The prior calculations involved the motor in an unloaded state. When a load is added to the motor, the moment ofinertia, J, ofthe motor will effectively be changed. It will be assumed the connection of the motor and the load will be perfectly attached, that is there is no slipping between the motor and the load. This change in J changes the location ofthe poles ofthe transfer function, which will change the nature of the system. For example, if J is 0.0471, then r; is 1.0, resulting in a critically damped system. If J is 0.0501, then r; is 0.995; then the system becomes overdamped. For the situation where J is 0.0471 , the transfer function is G' (s) = 0.4246 = 0.4246 (1 46) P S2 + 4.123s + 4.251 (s + 2.06 + }0.0349Xs + 2.06 - }0.0349) . and the pulse-transfer function is 16 17 H (z)=20.94x10- 6 z+20.66xlO- 6 = 20.94 X 1O-6(z +0.9866) .(1.47) pq Z2 -1.959z + 0.9596 (z - 0.98 + jO.0134Xz - 0.98 - jO.0134) For a controller using classical control techniques, this would result in a poor response, as will be shown in Chapter 6. 18 CHAPTER II PARAMETER ESTIMATION 2.1 Least Squares Estimation Because all of the system parameters may not be known or may vary from the known values in an adaptive system, some form ofparameter estimation must be enacted. For this discussion, linear estimation will be emphasized. For this situation, the measurement equation has the general form Z=Hx+&", (2.1) where Z is the noisy observation, x is a vector ofthe parameters to be estimated, &" is the error, and H is the linear function operating on x to get the measured quantity [3]. The noise-free measurement is a linear function ofthe parameters to be estimated. Least squares linear estimation is a common method for determining parameters in an adaptive control scheme. In the general case, the measurement is of the form of Equation (2.1), and the distribution of &" is unknown. The principle of least squares is that errors that are present in measurements tend to be minimized over time, and thus a logical estimate for the parameters in x are that values for which the sum ofthe squares ofthe error is minimum. In mathematical terms, the loss function, (2.2) 19 should be minimized. Because the function, H, is linear, this loss function can be rewritten as (2.3) Because the choice ofthe parameters, x, are to result in a minimal loss function, the loss function, J, must be differentiated with respect to x, and equating the result with zero. Solving the equation, OJ] T T T ... - ;:;::-2Z H+x H H, Ox N (2.4) for x, yields the least squares estimate, denoted by x[3], This can be written as [1] where h j is the i 1h member of H . 2.2 Recursive Least Squares Estimation (2.5) (2.6) Because most ofthe parameter estimation in adaptive controllers must be done in real time, a recursive parameter estimation is used to save computation time [1],[7]. The definition (2.7) is introduced. Equation 2.6 can now be written as 20 However, k P-l(k)= HT(k)H(k) =Lh;h T ;, ;=1 which follows from the definition in Equation 2.7, and can be expanded into k-I P-I(k) =Lh;h T ;+h(k)hT(k), ;=1 which can be simplified as p-I (k) =p-I (k -1)+ h(k)h T (k). Equation 2.8 leads to k-I L h;h T ; =p-I (k -l)x(k -1), ;=1 (2.8) (2.9) (2.10) (2.11) (2.12) which upon using a rearranged Equation 2.11 to substitute for p-I (k -1) results in k-I L h;h T ; =p-I (k )x(k -1)-h(k)h- I (k )x(k -1). ;=1 (2.13) The estimate for time k can now be written in terms ofthe estimate for time k -1 as x(k) = x(k -1)-P(k )h(k)h T (k )x(k -1)+ P(k )h(k)z(k), (2.14) which can be rearranged into (2.15) The error, e(k), associated with the prediction of z(k) based on the estimate x(k -1) is Equation 2.16 can be written as i(k) =x(k -1)+ R(k)e(k), (2.16) (2.17) 21 where R(k) is defined as R(k)== P(k)h(k). (2.18) In order to use these results, a recursive relation for P(k) must be found rather than for p- 1 (k). This can be done by using the matrix inversion lemma found in Appendix A, which states (A + BCDt == (A- 1 - A-IB(C- I + DA- 1 Bt DA- 1 ). (2.19) This lemma is used by substituting p- 1 (k -1) for A, the identity matrix, I , for C , h(k) for B, and h T (k) for D. This choice satisfies the required conditions for the matrix inversion lemma, as p- 1 (k -1), I, and h(k )Ih T (k) are nonsingular matrices. Using Equation 2.19 in conjunction with Equation 2.11 results in P(k) =P(k -1)- P(k -1)h(kXr l + h T (k )P(k -1)h(k)t h T (k )P(k -1). (2.20) Using (2.21) the estimation ofparameters can be summarized as follows: First find R(k), using Equation 2.21 based on the choice of initial conditions for parameters and matrix, p(0). Next, determine p(k) using P(k) =(I - R(k )h T (k )P(k -1)), (2.22) which is found by substituting Equation 2.21 into Equation 2.20. The residual error in the system can be then calculated as e(k) = z(k)- h T (k )i(k -1). Finally, the parameters may be estimated using (2.23) x(k) == x(k -1)+ R(k)&(k). 22 (2.24) The recursive least squares estimation technique can be used to estimate the coefficients in the transfer function ofa system. The transfer function ofthe system is assumed to be ofthe form A(q)y(k) == B(q }u(k), (2.25) where q is the forward shift operator. Equation 2.25 can be rewritten as any(k - n)+ ... + a1y(k -1)+ y(k) == bmu(k - m)+ .. ·+ b1u(k -1)+ bou(k), (2.24) which can be solved for y(k) as y(k) == bmu(k - m)+ ... + b1u(k -1)+bou(k)- any(k - n)-· .. - a1y(k -1). (2.25) Let ¢(k)==h(k)==(u(k-m) ... u(k) y(k-n) ... y(k-1)Y (2.26) and Equation 2.25 can now be written as y(k) == ¢T (k )o(k), which is ofthe form ofEquation 2.1. 2.3 MATLAB Code (2.27) (2.28) The MATLAB code for estimating the parameters at each time, m, is as follows. It is assumed that there is an initial guess, theta(:,1), an initial confidence matrix, P(:,:,1), an initial K vector, K(:,1), the output at times m-l and ,m-2, that is y(m-1) and y(m-2), 23 and the inputs at times m-l and m-2, which are u(m-l),u(m-2). Note that the algorithm must be initialized by providing an initial guess for the parameters, theta(:,:). This example is for a second order system, with m = 2 and n = 1. % Estimate Parameters Pkml=P(:,:,m-l); phikml=[-y(m-l) -y(m-2) u(m-l) u(m-2)]'; thetakm1=theta(:,m-l); e(m)=y(m)-phikml'*thetakml; K(:,m)=Pkml *phikml*inv(1ambda+phikml'*Pkml *phikml); P(:,:,m)=(diag([l 1 1 l])-K(:,m)*phikml')*Pkml/lambda; theta(:,m)=thetakml+K (:,m)*e(m); al=theta(l ,m); a2=theta(2,m); bO=theta(3,m); bl=theta(4,m); 24 CHAPTER III CLASSICAL CONTROL TECHNIQUES In this chapter classical control techniques are explored for the dc motor modeled in Chapter One. At first a discrete-time lag-lead controller was designed, but it was impossible to meet the design requirements with such a controller. Either the settling time was lengthened or the error was unacceptable. In what follows a classical controller designed based on the traditional Root Locus technique will be presented. 3.1 Introduction to Root Locus One technique that can be used to design a controller for a continuous-time system is the Root Locus method. A Root Locus is a graph that shows the positions of the closed-loop poles as the system gain, K, is varied [8],[11],[14]. This technique can be used for discrete-time systems as well because the characteristic equation used is both discrete-time and continuous-time is of the same form, only in different complex variables and domains. The stability boundary is the unit circle for discrete-time systems rather than the j OJ -axis, as it is in continuous time case. Likewise, the curve ofconstant parameters such as damping ratio and natural frequency, are changed from continuous time to discrete-time systems; a cartoid is the curve ofconstant damping ratio in discrete- 25 time instead of a line radiating from the origin and a circle centered at z =1 is the curve of constant natural frequency in the z-domain [15],[16]. Figure 3.1 depicts the block diagram ofthe system that is used for Root Locus analysis and design. 3.2 Designing the Compensator The first step in designing the compensator is to construct the Root Locus for the uncompensated system, H (z)=96.1xl0- 6 z+92.33xl0- 6 =96.1xl0-6 z+0.9608 .(3.1) pq Z2 -1.885z + 0.8869 (z - 0.9800Xz - 0.9050) Figure 3.2 shows the Root Locus for this system. Initially, with a gain of zero, the system is stable and remains stable. If the gain is increased to about 1,360, the system becomes unstable. Three system response parameters are important: no steady-state error in the step response, an overshoot of less than 15%, and a settling time ofat most Is. In order to have zero steady-state error, integrating action is needed. This is accomplished by placing a pole at z =1 [16]. This, however destabilizes the system as can be seen from the Root Locus depicted in Figure 3.3 which is derived by adding a pole at z =1. This is because poles tend to repel the branches ofa Root Locus, and there are two poles in the near vicinity of z = 1. One solution is to cancel the other pole at z = 0.9800 by placing a zero at the same place. Pole-zero cancellation is not perfect, however, the pole will be effectively cancelled if the zero is very close to the same location [15]. The compensator is so far given by D(z)=Kz-0.9800. z-1 (3.2) ,-.. rf) '-'" 0.. r- e,:l j ,.....; ...; ~ - I-- 0 ~:::> 0 u ta (,) ..... til ~ - U t+-< 0 -t- I § ~ ..... 0 .r; 0 ~ - Q:l .. - M ~ ..... ~ I-- 26 ~ ~ ~ ~ ~ ~ 27 28 29 30 The Root Locus of the compensated system is shown in Figure 3.4. In this Root Locus, the curves of constant damping ratio at 0.5169 and constant natural frequency of 0.07738 have been added. The desired natural frequency for a discrete time must be in terms of rad ,so the natural frequency must be multiplied by the sampling period. In order sample for the compensated system to exactly meet the design requirements, the Root Locus must intersect at the same point as the two curves ofconstant parameter, which is not the case. The control design is acceptable ifall the criteria are met or exceeded. Where the Root Locus and the curve of constant damping ratio intersect, the gain is 42.8. Figure 3.5 shows the step response when the compensator gain is 42.8. The percent overshoot is about 15% , however the settling time requirement is not met; the settling time is about 1.2s. The other option is to use the gain 30.2, which is the gain where the Root Locus and the curve of constant natural frequency meet. Because this point is inside the curve ofconstant damping ratio, the damping ratio is greater, thus the overshoot is less. Figure 3.6 shows the step response when the compensator gain is 30.2. The settling time is met exactly, and the percent overshoot is 8%, which exceeds the design requirement. The compensator given by D(z) =30.2 z- 0.9800 z-1 will be used in the discussions on disturbances and varied loads in Chapter 6. (3.3) Figure 3.5: Step Response ofthe System \....ith Controller Exactly Meeting the Damping Ratio Requirement w - Figure 3.6: Step Res.ponse ofSystem \vith Controller Exactly Meeting the Settling Time Requirement V-l tv 33 CHAPTER IV SELF-TUNING REGULATORS The self-tuning regulator is the first adaptive control scheme that will be used to control the dc motor. First, the process for designing a self-tuning regulator will be presented. Then the ramifications ofdesigning a controller with pole-zero cancellation as well as one that has no cancellation will be observed. Finally, two self-tuning regulators will be designed and compared with respect to meeting the design criteria and the control effort. 4.1 Introduction to Self-Tuning Regulation A self-tuning regulator is a control scheme that is useful when the environment in which the controller operates changes. The block diagram of a general self-tuning regulator is shown in Figure 4.1 [1]. The process is the system which is to be controlled. The estimation block involves the estimation of the process parameters, which are fed into the controller design block. These parameters, along with the control specification, determine the control parameters. The controller output, also called the control signal, which drives the plant changes at each time interval based on the output ofthe system, ..-.- -- - - -- ---- - _ - _._ _ .. ""-"'-' - _."_. _ _.. --- --- I Self Tuning Regulator i Process Parameters I I I ; , i l I i I I I Controller ~ Estimation I I i I I I Design ! l l j Controller - _" ___. __.......J parameters _. ! , l I ; .. i l~ eference ; Process i Controller Output i Input I I , : ! i - ..- ._~ ._-- ! ---- -- - L-_...... - ------ R Specification Figure 4.1: Block Diagram for Self-Tuning Regulator. w ~ --- ! 1-"S~/'f'-T~~.j~g._-R~g~i~·t;~---"-"._- __. -'._.' --- , , I t I i r- _ •. -- _. I i I ! ! ~ L_ ------ -" ~---' 35 the control parameters, and the input to the system. For this discussion, only least squares estimation, as discussed in chapter 2, will be considered. 4.2 Controller Design The design technique for a self-tuning regulator is gIven by Astrom and Wittenmark [1], which this development basically follows. In order to design the controller, pole placement is utilized. The model ofthe system is assumed to be A(q)yet) =B(q)(u(t) +v(t)), (4.1) where y is the output, u is the input, and v is a disturbance. The polynomials A(q) and B(q) have degrees of nand m, respectively. The pole excess of the system, do, is the difference between nand m. Two assumptions about A and B have been made; the coefficient of the highest term with highest degree in A is one, that is, A is monic, and A and B have no common factors, which means that they are relatively prime. These assumptions serve to make the generalization of the design process easier. In general, A(q) will be written as A. The controller can be written as R . u(t) =T . U c (t) - s .y(t) , (4.2) where R,S , and T are polynomials, and u(t) is the signal fed into the system, and U c (t) is the reference signal that the system is trying to follow. Combining Equation 4.1 and Equation 4.2 results in which simplifies to AR· yet) = B(t. uc(t) - S· yet) + R· vet)), (4.3) (t) = BT .U c (t) + BR . vet) . Y AR+BS This gives the closed-loop characteristic polynomial, A CL ' as A CL = AR+BS. 36 (4.4) (4.5) Equation 4.5 is called the Diophantine equation [1], and can be used to determine Rand S. In order to determine T, the response of the desired system to U c (t), which is described by (4.6) is used, where Ym(t) is the desired output, Am and Bm are the numerator and denominator ofthe desired transfer function. The condition, BT BT B m AR +BS = A CL = Am ' must hold for the system to follow the model. In order for the controller to be causal, the conditions deg S ::; deg R and degT::; deg R, (4.7) (4.8) (4.9) must be true. Equation 4.5 has numerous solutions, thus it is possible to select the solution which gives the controller with the lowest degree. Because n is greater than m , and the degree of S cannot be greater than the degree of R , the relationship degR =degA cL - n (4.10) can be used to find the degree of R. Because it is undesirable to have extra delays in the controller, R, S , and T are required to have the same degree. 37 This design allows some cancellation of process zeroes with poles of the controller. In order for the zeroes to be cancelled, they must be both stable and well damped, lest the controller introduce unstable or poorly damped poles to the closed-loop system. The polynomial B can be factored as (4.11) where B+ consists of the monic polynomial whose roots are stable and well-damped, while B- consists of the polynomial whose roots are either unstable or poorly-damped. Ifthe zeroes are not cancelled, then they must appear in the desired zeroes. This implies (4.12) whereB~is the desired numerator with the desired cancelled zeroes, B-, factored out. Because B+ is cancelled, it must be a factor of A cL ' thus (4.13) is true. Because B+ is a factor of both A CL and B , but it is not a factor of A, B+ must be a factor of R , which can be written as R =R'B+, where R' is the feedback relation with B+ factored out ofit. Equation 4.5 reduces to and T can be determined from (4.14) (4.15) (4.16) This leads to three types of controllers where either some zeroes are cancelled, all zeroes are cancelled or no zeroes are cancelled. 38 If all the process zeroes are cancelled, then the degree of A o is do -1. Choosing (4.17) results in the factorization ofEquation 4.12 to be (4.18) and (4.19) The Diophantine equation becomes (4.20) and T is Ifno zeroes are cancelled, then the degree of A o is do -1. Choosing B =flB = Am (l) B m B(l) results in the factorization ofEquation 4.12 to be and The Diophantine equation becomes and T is defined by (4.21) (4.22) (4.23) (4.24) (4.25) T =f1rA = Am (1) A . o B(1) 0 4.3 Self-Tuning Regulator Algorithm 39 (4.26) The algorithm for determining a self-tuning regulator, taken directly from Astrom and Wittenmark [1] is as follows. Data: Given the specifications of the desired closed-loop pulse-transfer operator and a desired A o . Step 1: Estimate the polynomials ofthe transfer function with recursive least-squares. Step 2: Solve for Rand S in Equation 4.55 and T in Equation 4.16. Step 3: Calculate the control variable, u(t) , from Equation 4.2 Repeat Steps 1, 2, and 3 at each sampling period. 4.4 Self-Tuning Regulator Design Specifications It is assumed that the model is 2 G (s) = , P S2 +12s+20.02 as determined in Chapter 1, with pulse-transfer function H () = B = 0.961x10- 4 q+0.9233x10- 4 pq q A q2 -1.885q + 0.8869 (4.27) (4.28) 40 which can be generalized to because the parameters will vary. The desired pulse-transfer function is H () _ Bm _ Bm m pq q - Am - q2 -1.6015q + 0.6703 ' which can be generalized to (4.29) (4.30) (4.31 ) The numerator has been left undefined because it is convenient to define the desired numerator differently depending on zero cancellation. The pole excess for the system, do is one. 4.5 Self-Tuning Regulator with Zero-Cancellation For zero cancellation, the degree of A o is zero. Thus, (4.32) is true because A o is monic. The desired pulse-transfer function, obtained by choosing Bm according to Equation 4.17, is B is factored into b B+ :::: q + _1 :::: q + 0.9608 b o (4.33) (4.34) 41 and (4.35) Because n is two, the degrees of R, S , and T are 1. Since the degrees of Rand B+ are both 1, according to Equation 4.14 the degree of R' must be O. Substituting into the Diophantine equation gives (4.36) Equating like coefficients yields (4.37) for the first degree term and (4.38) for the constant term. However, R is defined by Equation 4.14 as (4.39) The expression for S is obtained from Equations 4.37 and 4.38, i.e. (4.40) defines S. Using Equation 4.21 gives T. The simulation of this adaptive scheme is depicted in Figures 4.2 and 4.3. The output ofthe plant is shown in Figure 4.2, while the control signal is shown in Figure 4.3. Figure 4.4 shows that the parameter estimates converge within ten steps. The system does meet all the requirements, however, from Figure 4.3 it is seen that there is a great initial control effort. Further, the control signal has ringing which can cause additional wear on the plant. 42 43 44 45 4.6 Self-Tuning Regulator without Zero-Cancellation For a self-tuning regulator without zero-cancellation, the degree of A o is one. Hence, A o is given by A o = q+a oo ' (4.41) Selecting B m according to Equation 4.22 results in the desired pulse-transfer function, 0.0031 (b +b) b +b oq 1 =_-,-0_-,-I _ q2 -1.92q + 0.9231 . (4.41 ) Substituting for A and B in the Diophantine equation results in to be solved for R and S. Collecting coefficients of q, results in Equating like coefficients of q results in the system ofequations, Solving for the vector consisting ofthe R and S coefficients gives or (4.43) (4.44) (4.45) 46 The solutions for '1' So' and SI are (4.47) So = bO(a OO a2+a2aml -ala2-aooam2~+bl~a:+am2 +aooaml -aooal -amlal -aJ(4.48) a 2 b o +b l - albob l and T is defined by Equation 4.26 to be T - 1+ amI + am2 A _ 0.0031 ( ) - 0 - q + aoo . b o +b t b o +b t (4.49) (4.50) The simulated system output is shown in Figure 4.5. It can be observed that the system's output settles to its final values with zero error in about one second. The overshoot of the system is 4%. Figure 4.6 shows the control signal, which has no ringing and a lesser control effort than is the case for the self-tuning regulator with zero cancellation. Figure 4.7 shows the convergence of the parameter estimates, which once again converge within 10 samples. 4.7 Conclusions Both self-tuning regulators, with and without zero cancellations, meet the requirements of the design. However, due to the lesser control effort and the lack of ringing, the self-tuning regulator without zero cancellation can be considered to be a -aooam2~+bl~a: 1 1 Figure 4.5: Reference and Output ofa Sdf-Tuning Regulator-Controlled System without Pole-Zero CanceJ1at:ion. +>. .....:J Regulator-Controlled Figure 4.6: Control Signal for a Self-Tuning Regulator without Pole-Zero Cancellation. ~ 00 49 50 better choice. This control technique will be used in the discussion on disturbances and varying loads on the motor, which is provided in Chapter 6. 51 CHAPTER V ONE-STEP AHEAD AND MODEL-REFERENCE ADAPTIVE CONTROLLERS This chapter covers two related types of adaptive controller, the one-step ahead controller and the model-reference adaptive controller. First the one-step ahead controller is used to attempt to bring the output of the closed-loop system to the desired value in one step. This in general requires a great control effort, so a form of weighting on the control signal is also considered to reduce the control effort. A further step to reduce the control effort is taken. Rather than attempting to bring the output to the desired output in a single step, the model-reference adaptive technique endeavors to bring the output of the system to that of the desired model. Several controllers with different weightings for model-reference adaptive controllers are designed and compared in this chapter. 5.1 Introduction to One-Step Ahead Control The one-step ahead (OSA) controller is another adaptive control technique [7]. The one-step ahead controller brings the predicted output y(k + d) to a desired value, y" (k + d) in a single step. As will be discovered, the control effort for such a controller 52 is often great, so the controller can be weighted in such a way as to reduce the control effort. 5.2 The One-Step Ahead and Weighted One-Step Ahead Controllers Once again, the model is assumed to be (5.1) where and B ·( -I) -d(b b -I b -m)_ -dB'( -I) p q =q 0 + Iq + ... + mq - qq. (5.2) (5.3) as described in Equation 1.37. This model can be rewritten in a d-step-ahead predictor form, (5.4) where and fJ( -1)_ p P -I .. fJ -m-d+1 - F( -I )'D'( -I) q - 0 + Iq +. + m+d-Iq - q V q , with the coefficients of F(q-I) and G(q-I) given by 10 =1, H /; =- 'L!ja;_j , j=O and (5.5) (5.6) (5.7) (5.8) d-I gj =- 'Lfjaj+d-j . j=O 53 (5.9) The time delay, d, is selected in such a manner as to ensure that b o in Equation 5.3 is nonzero, which assures that flo in Equation 5.6 is nonzero as well. In order to bring y(k + d) to the desired value of y. (k + d), while minimizing the cost function, (5.10) the desired value is substituted into Equation 5.4, resulting in (5.11) This can be expanded into which can be solved for u(k) u(k) = y" (k + d)- a{q-l )y(k)- fl1u(k -1)-'"- /3m+d_I U (k - m- d +1). (5.13) /30 Because the selection of b o always results in a nonzero /30' the construction is possible [6]. For the DC-motor plant as given in Equation 1.45 H( -1)= q-d{bo+b1q-l) = q-l{0.0367+0.0321q-I), q l+a 1 q-l+a z q-Z 1-1.6015q-l+0.6703q-Z (5.14) the order of the numerator, m, is one, the order of the denominator, n , is two, and the pole excess, d, is one. This means that F({q-I) is zeroeth order, and G{q-l) is first order. 54 Because F(q-l) is zeroeth order, the only coefficient present is 10' which from Equation 5.7 is one. The coefficients of a(q-I) are given by Equation 5.9, which evaluates to (5.15) and (5.16) The predictor is described by The control signal, u(k) , is given by u(k) =y. (k +d)+ a1y(k)+ a 2 y(k -1)-b1u(k -1) . b o (5.17) (5.18) For adaptive one-step ahead control, the parameters are unknown and must be estimated, in this case with a recursive least squares estimation algorithm. Figure 5.1 shows the response for this closed-loop system, and Figure 5.2 shows the control signal for the DC motor using one-step ahead control. A simple modification to Equation 5.12 results in the weighted one-step ahead controller control signal [7], given by u(k) = flo(/ (k +d)- a(q-I )y(k)-fllu(~-1)-'" - flm+d-lU(k - m - d+I)J .(5.19) flo + /l, This is a generalized case ofone-step ahead control, which minimizes the cost function (5.20) When Ii is set to zero, the control signal obtained by one-step ahead adaptive control is recovered. For the DC motor, the control signal becomes F{q-l) a{q-I) a{q-Ifllu(~ 55 56 57 (5.21) where aI' a 2 , b o ' and b l are estimated recursively. Because b o is of the magnitude of 10- 3 , A must be less than lOx 10- 6 lest A dominate the denominator. The closed-loop responses of the system for several different values of A and the corresponding control signals are depicted in Figures 5.3 through 5.6. Figure 5.3 shows the results when A is lOx 10- 6 • This system does reach its final value rather quickly, however, the final value is 0.4879, which gives an unacceptable steady-state error. The control signal for this system has a maximum magnitude of 15, which will be the smallest control signal. One additional benefit is the elimination ofthe ringing in the control signal. Figure 5.4 shows the system information when A is 10- 6 • This system has a final value of 0.905, which is better than the first system. This is countered by the fact that this system has a maximal magnitude of 185 for the control signal. Once again there is no ringing in the control signal. Figure 5.5 shows the system when A is 500 x 10- 9 • The final value for this system is 0.9506 with a maximal magnitude of 370 for the control signal. The overshoot for this system is 25%. The final simulation is in Figure 5.6 when A is 100 x 10- 9 • The final value of this simulation is 1, however, the cost for the perfect steady state is high as the maximum magnitude of the control signal approaches 1,800, with an overshoot ofabout 45%. Based on comparing these four simulations, either a A of 500 x 10- 9 or a A of 10- 6 is the best controller for this plant, depending on how important the steady state accuracy is. Figure 5.3: Response and Control Signal for a Weighted One-Step Ahead Adaptive Controned SystelIL VI 00 59 Figure 5.5: Response and Control Signal foc a \Veighted One-Step Ahead Adaptive Controlled System- 0\ o Figure 5.6: Response and Control Signal for a Weighted One-Step AheadAdapuve Controlled System. 0\ - 62 5.3 Model-Reference Adaptive System Rather than trying to follow the reference signal, following a model that has an acceptable transfer function will serve to lessen the control effort. This is the so-called model-reference adaptive control, which is somewhat related to the self-tuning regulator [1],[7]. The model that will be used for reference is given by Equation 1.45, H m (z)= 0.001638z+0.001594. pq Z2 -1.92z + 0.9231 (5.22) The mechanism that was used to implement the model-reference adaptive control is one- step ahead and weighted one-step ahead control. Figure 5.7 shows the simulation for model-reference one-step ahead control. It can be observed that the steady-state error is 0, with the overshoot of 15%. The maximum magnitude of he control signal is about 700, and ringing is present in the control signal. Once again, the control effort can be improved by using a weighted one-step ahead approach. The system simulation for a A, of 10xl0- 6 is shown in Figure 5.8. The final value ofthis system output is 0.4873, that is the steady state error is large and un acceptable. The magnitude ofthe maximal control input is 12.5. A lesser weighting of A" 10- 6 is used for the simulation shown in Figure 5.9. This simulation shows an overshoot of 10% and a steady-state error of 9.2%. The control effort has a maximum magnitude of 60. Weighting A, even less, to 500 x lO- 9 results in the system shown in Figure 5.10. The steady-state error is only 4.56% and the overshoot is 11 %. The control effort is relatively small with a maximal magnitude of 72. Figure 5.11 shows the final simulation, for the system with A, equal to 100 x 10- 9 • This system has no steady-state error and an overshoot of 15%. The maximum control 63 Figure 5_8: Response and Control Signal for a \\leighted Model-Reference Adaptive System_ 01 -I:::> Adapmre Figure 5.9: Response and Control Signal for a "lcighted Model-Reference Adaptive System. 0\ VI Figure 5.10: Response and Control Signal for a Weighted Model-Referenc.e Adaptive System. 0\ 0\ Figure 5.11: Response and Control Signal for a Weighted Model-Reference Adaptive System. 0\ -...J 68 effort is 85. Each ofthese closed-loop systems has a settling time of less than Is. This system has similar performance compared to the unweighted model-reference adaptive system, but at a greatly reduced control effort. 5.4 Conclusions Several adaptive control schemes were considered in this chapter. The model reference adaptive controller based on weighted one-step ahead adaptive contol provided the best response. By using a weighting of 100 x 10- 9 , all of the design criteria, overshoot of 15% , no steady-state error, and a settling time of Is, were met with out an extremely unreasonable control effort. This controller will be used as the basis for the discussion in Chapter 6, which deals with the effect of varying the load as well as noise on the closed-loop system. 69 CHAPTER VI SYSTEM AND LOAD ERROR RESULTS In this chapter the effect of model uncertainty and noise on the behavior of the closed-loop controlled systems are investigated. First the disturbance rejection properties of the controlled systems designed based on an ideal model are considered. The effect ofmodel uncertainty is then investigated by imposing errors in the type, order, and the stability of the system. Finally, the classical and adaptive techniques are compared when the motor has a nonzero load. 6.1 Comparison of Techniques The closed-loop response ofthe classical controller, self-tuning regulator, and model- reference adaptive system derived and shown in Chapter 3, Chapter 4, and Chapter 5, respectively, are shown in Figure 6.1. The plant has the assumed transfer function, G (s) =----:--_2__ P S2 +12s+20.02 and assumed pulse transfer function H (z) = 96.1 0 x 10- 6 Z + 92.3310- 6 pq Z2 -1.885z + 0.8869 (6.1) (6.2) 70 71 From Figure 6.1, it is apparent that all three controllers meet the design criteria of a maximum overshoot of 15% and a settling time of Is , with the sole exception that the self tuning regulator has a settling time of about 1.04s, which is close enough. The self-tuning regulator has the best performance in terms of percent overshoot, having only 4.21 % overshoot. The model-reference adaptive controller has the least desirable overshoot, just meeting the overshot requirement. The classical controller has an overshoot of 8.04%. Figure 6.1 also shows the control effort for each ofthe three controllers. Both the self-tuning regulator and the model-reference adaptive controller have higher control signals as the parameters are being estimated. However, in the steady state, the model-reference adaptive controller has the best control signal. 6.2 Disturbance Rejection The first non-ideal situation that will be explored is the case where the input signal has noise coupled to it. For this purpose, a random signal was created in MATLAB with the RAND command. The amplitude of the noise was 10% of that of the input. Figure 6.2 shows the results of that simulation as well as the noise that was added to the input. The disturbance rejection ofall three ofthe controllers is adequate for this magnitude of noise. It is intuitive that the classical controller will have a decent amount ofdisturbance rejection due to the presence ofthe pole at z =1, which provides integrating action. The overshoot on the classical controlled system remains about 8%, the overshoot on the model-reference adaptive system remains at about 15%, while the self-tuning regulator is reduced to about 3%. The settling time on each system is about Is. The control effort remains largely similar to that ofthe noise free case simulation. 72 73 6.3 Non-Ideal Model Situation This situation encompasses a number of circumstances, the three of interest for this discussion is an error in the type ofthe system, in the stability ofthe system, and in the order of system. First, suppose that there is an error in the type of the system, that is, the plant to be controlled is a type-1 system while the controllers were designed based on a type-O system. Another popular model for a DC motor is (6.3) which is a Type-I system. Suppose that the pole at - 2.0025 remains, but that there is a zero at - 200, and the dc gain is 0.0049; the resulting transfer function would be ( ) s+ 200 Gp S =0.049 ( ) , S s+2.0025 and the pulse-transfer function would be H (z)= 96.92xlO- 6 z pq Z2 -1.9802z + 0.9802 . (6.4) (6.5) Typically, the zero at s =-200 could be ignored because it has a magnitude of 100 times that of the next pole or zero. However, it is mathematically convenient to include it in this discussion because the zero in the continuous-time transfer function increases the magnitude ofthe pulse-transfer function. Figure 6.3 shows the simulation of the system with this plant. Because the closed-loop system using the classical controller has a double pole at 1, it is expected that the output will oscillate and not settle down to a steady state. The classically-controlled system exhibits marginally stable behavior rather than explicitly unstable behavior because the pole at 0.9802 is still cancelled by the controller. However, if 74 75 the pole is moved to 0.983, with the resulting pulse-transfer function H () 96.92 X 10- 6 z pq Z == Z2 -1.983z + 0.983 ' (6.6) the resulting output from the classically controlled is unstable, which is the case ifthe pole is moved any closer to 1 than 0.9802. The closed-loop responses for this plant is depicted in Figure 6.4, from which it can be seen that the response from the model-reference adaptive controller and the self-tuning regulator are unchanged by these variations in the model. Suppose that the system, rather than being open-loop stable, is open-loop unstable. This is accomplished if a pole is in the right hand side ofthe s-plane for the continuous-time plant and if a pole is on or outside the unit disc for the discrete-time model. Suppose that the continuous-time plant is described by (6.7) The resulting pulse-transfer function is H (z)== 0.0001003z + 0.0001007 == 0.0001003(z+1.004) (6.8) pq Z2 - 2.01z +1.01 (z -lXz -1.01) , which has a pole at z == 1.01, which is outside the unit circle. Because the order of he numerator and the order of he denominator of the pulse-transfer function are the same as the assumed model, the self-tuning regulator and the model-reference adaptive controller have no trouble keeping the system stable and within the design parameters, as shown in Figure 6.5. The control effort for the adaptive schemes once again have spikes on the order of 60 during the parameter estimation, but settle down to 20 for the self-tuning regulator and 5 for 76 77 78 the model-reference adaptive controller. After the parameter estimates have converged, the control effort ofthe model-reference adaptive system and the self-tuning regulator are largely the same. On the other hand, because the classical system is unstable, the control signal is unstable as well. As a final consideration in model-type errors, the assumption will be made that there is an error in the order ofthe model. Suppose that the transfer function has a pole at s =-5, resulting in 2 Gp (s) =....,....(s-+-2-.0-02-5..,....,Xs-+-5--,-X.,.-s-+-9.-99-7-""5) and a pulse-transfer function of (6.9) H (z) = 323 x 10- 9 (Z2 + 3.867z + 0.9350) = 323 X 10- 9 (z + 3.608Xz + 0.2591) .(6.10) pq Z3 -2.874z 2 +2.752z-0.8773 (z-0.9049Xz-0.9802Xz-0.9891) The simulation for the three different controllers is shown in Figure 6.6. The self-tuning regulator has no problem keeping the output within the desired criteria. This is because the self-tuning regulator does not need the exact values of the system parameters, only a proper ratio of system parameters. The estimator tries to formulate a model that has a second-order denominator and a first-order numerator that fits the input-output relation. The self-tuning regulator then uses the ratios between numerator and denominator coefficients to formulate the control signal. The estimator in the model-reference adaptive controller also attempts to fit the input and output into a second-order denominator and a first-order numerator. However, the values that are estimated are used directly in formulating the control signal, so errors in the model estimation dramatically effect the output; in this case causing the output ofthe system to be unstable, as can be seen in Figure 6.6. The classically controlled system, 79 80 while stable, has an overshoot of 71 %, and has a very long settling time. For this situation the self-tuning regulator is the best controller. The control effort for any ofthese controllers has much to be desired. The self-tuning regulator has the best control effort, but it settles at a value on the order of 6 x 10 5 , while the control signal of the model-reference adaptive controller and the classical controller oscillate with an increasing magnitude. From these results, it is seen that the self-tuning regulator can control a system that has a higher order than designed for, but that the control effort creates an incentive to have the order correct when designing the controller. 6.4 Load Error Recall that the transfer function ofthe plant is described by K G (s)- JL p - 2 (B R) RB+K 2 ' S + -+- S+--- J L JL (6.11) as shown in Chapter 1. When using the values given in Equations 1.14, 1.15, 1.16, and 1.17, but letting the value of J vary, Equation 6.11 becomes 0.02 Gp(S)= 2 (2J +0\) 0.2002' S + s+----- J J (6.12) Assuming that the value of J for the motor shaft and load is 1kg '2 m2 ; the transfer function S is then, after plugging the value of J into Equation 6.12, G (s)= 0.02 = 0.02 P S2 + 2.1s + 0.2002 (s+2.000Xs+0.1001) , with corresponding pulse-transfer function as H (z)= 99.3x10- 6 (z+0.9931). pq Z2 -1.979z + 0.9792 81 (6.13) (6.14) Figure 6.7 shows the simulation of the system controlled by the classical controller, a self- tuning regulator and a model-reference adaptive controller. The performance of both the self-tuning regulator and the model-reference adaptive controller are unaffected by the change is system parameters. However, the classical controller's performance is drastically reduced. By virtue of the integrator the steady-state error is zero, but the settling time is greatly increased. At a time of 3s, the output is still only at 93.4% of the final value. The overshoot requirement is met; however, the controller does not reduce the settling time as compared to the open-loop system. It is reasonable to assume that as the load increases, the transfer function coefficients vary more from the unloaded values. It follows that the system response for the classically controlled system will be poorer as the difference in coefficients grows. The most extreme case that will be addressed is when the inertial constant of the motor and the load is 5 kg '2 m2 • Substituting this value of J into Equation 6.12 results in the s transfer function, G (s)- 0.004 P - S2 + 2.02s + 0.04004 ' which has the pulse-transfer function, H (z)= 19.87x10- 9 (z+0.9929). pq Z2 -1.98z + 0.98 (6.15) (6.16) 82 83 The zero of the pulse-transfer function remains in the same vicinity, as do the pole. The main impact that changing the inertia of the load has on the pulse-transfer function is to change the value and magnitude of the dc-gain. Because the dc-gain is so small, it greatly lessens the effect ofthe gain introduced by the classical controller. This decreased effect of gain tends to keep the closed-loop poles in very close proximity to the open-loop poles. The controller has little effect on the damping ratio and natural frequency, and thus little effect on the overshoot and settling time of the system. The presence of the integrator does indicate that eventually, the system will reach zero steady-state error. The self-tuning regulator does not remain unaffected by the change in de gain. While the output remains the same, the control effort is increased by a similar magnitude as the dc-gain ofthe pulse-transfer function is decreased. Figure 6.8 shows the simulation of the system with J =5 kg ·2 m2 . The s classically-controlled system has reached a value that is 5.3% of its final value by 3s. The output of the self-tuning regulator and the model-reference adaptive controller are both unchanged by the change in system parameters. 84 85 CHAPTER VII SUMMARY AND CONCLUSIONS 7.1 Summary In the first chapter a mathematical model for a dc motor was developed, which was formulated as a continuous-time transfer function. Subsequently, a pulse-transfer function was derived as well. The desired characteristics of the output of the plant were used to determine a desired transfer and pulse-transfer function. It was shown that any variation on the load would change the poles and dc gain ofthe transfer function. The classical root locus technique was used to design the controller that was given by D(z) =30.2 z- 0.9800 . z-1 7.1 which exceeds the requirements of overshoot of 8%, a settling time of Is, and zero steady-state error. A self-tuning regulator was designed that had total pole-zero cancellation. This adaptive controller resulted in an output that reached its steady-state in about Is, with an overshoot of only 6% and zero steady-state error. This controller, however, produced a control signal whose value greatly changed from sample to sample, a phenomenon known as ringing. A second self-tuning regulator was designed that did not have pole- zero cancellation. The output of this system has zero steady-state error, an overshoot of / 86 4% and a settling time of Is. The control signal produced by this controller did not have ringing and also had a smaller magnitude. The third type ofcontroller was a one-step ahead adaptive controller. This type of controller met the overshoot and settling time specifications of 15% and Is exactly. Two variants, weighted and unweighted one-step ahead controllers were considered. The unweighted controller resulted in zero steady-state error, however the control signal exhibited ringing and had too great a control effort. The ringing and control effort problems were lessened by weighting the control effort. This introduced some steady state error into the system. The fourth and final type of controller considered , model-reference adaptive controllers, is related to the one-step ahead controller. Rather than trying to follow the reference signal, the controller attempts to follow the output of an acceptable model to the reference signal. This results in the lessening the control effort. In the model reference adaptive controller, the overshoot and settling times were met exactly. As in one-step ahead control, the unweighted output had the greatest control effort as well as some ringing in the control signal. There was a direct correlation between the amount of steady-state error and the weight that was given to having a low control effort. The control efforts of each of the controllers were compared. The lowest control effort was generated by the classical controller. The self-tuning regulator had the greatest control effort, while the model-reference adaptive system had a moderate control effort. Based solely on the design criteria of the unloaded dc motor whose mathematical model was entirely correct and the control effort, the best controller would be the classical controller. Each off the three controllers exhibited an acceptable amount of inherent 87 disturbance rejection, with the model-reference adaptive controller displaying the greatest disturbance rejection, and the classical controller displaying the least amount of disturbance rejection. Several situations in which the assumed model was inexact were investigated with the three different controllers, the classical controller, the self-tuning regulator, and the model reference adaptive controller. The variations from the ideal model were obtained by including an error in the type of the system, the stability of the system, and the order ofthe system. When the plant was of a higher type than the assumed plant, the classical controller remained in sustained oscillation for closed-loop response. The self-tuning regulator and the model-reference adaptive controller remained unaffected by this type of error. The control effort was largely unaffected for all three ofthe controllers. For the second type of plant variation from the ideal case, one of the poles of the plant was moved to the right half plane, resulting in an unstable system. When the classical controller was used, the system remained unstable. Once again, neither the self tuning regulator nor the model-reference adaptive controller were effected by this change. Again, the control effort of the three controllers for the unstable case remained largely unchanged from that of the stable case. The variation from the ideal model was created by adding a pole to the open-loop transfer function, increasing the order of the system. The output of the self-tuning regulator controlled system was unaffected by this error. The control effort was slightly greater with this variation as compared to the ideal case. The classically controlled system, while stable, did not perform within the desired criteria. The overshoot was 71% and the settling time was great. This change had a catastrophic effect on the model-reference adaptive controlled system, which could be 88 avoided by over-parameterizing the model used in design. Both the control effort and the output ofthe model-reference adaptive system grew without bound. The final changes that were made to the system were changes to the load ofthe dc motor, which changed the location of the poles and zeroes of the transfer function from the assumed poles and zeroes of the transfer function. For the self-tuning regulator and the model-reference adaptive controller, the response did not change. However, as the load was increased, the control effort for both the self-tuning regulator and the model reference adaptive controller increased. Increasing the load also increased the control effort of the classical controller. In addition, the settling time also greatly increased as the load to the controller increased. 7.2 Conclusions The classical controller has several disadvantages. The first is that it results in an unstable closed-loop system if the plant is of higher type. Further, this controller cannot compensate for an unstable plant. The most likely situation that is disadvantageous for the classical controller is when the dc motor is loaded, for which the settling time is greatly increased over the open loop transfer characteristic. If the order of the system is known, then the model-reference adaptive controller is the best controller because it can follow a desired output no matter what the load, the type, or the stability of the plant is. However, because of the catastrophic reaction to a system of higher order than assumed, the model-reference adaptive is a bad controller if there is the possibility ofa higher order plant. Designing the controller assuming a higher 89 order for the controller would be a solution for this type of error, but would increase the number of calculation required at each iteration. The increase in calculations should not present any problem because inexpensive high-speed processors are readily available. If the smallest control effort is not absolutely necessary, the self-tuning regulator is the best choice for a controller. It is able to retain its response even if the plant is of a different order, type or even unstable. The load on the motor has little effect on the performance ofthe system controlled by a self-tuning regulator. The work presented here can be expanded by considering experimental implementation of developed controllers using a microprocessor and digital signal processing. An extension ofthe implementation would be to observe how quantization of the process effects the system, and which controller is most effected by the quantization. The dependence of the closed-loop system response on the initial guess for the system parameters could also be observed. 90 REFERENCES [1] Astrom, Karl J. and Bjorn Wittenmark. Adaptive Control, Second Edition. New York: Addison-Wesley Publishing Company, 1995. [2] Chen Jie and Guoxiang Gu. Control-Oriented Sytem Identification, An H'" Approach. Hew York: John Wiley and Sons, 2000. [3] Elbert, Theodore F. Estimation and Control ofSystems. New York: Van Nostrand Reinhold Company, 1984. [4] Example: DC Motor Speed Modeling. Carnegie Mellon Controls Tutorialsfor MATLAB. 16 June 2004. . [5] Feuer, A and G.C. Goodwin. Linear Deterministic Adaptive Control: Fundamental Limitations? Systems and Control Letters 49,2003. [6] Friedland, Bernard. Control System Design: An Introduction to State-Space Methods. New York: McGraw-Hill Book Company, 1986. [7] Goodwin, Graham C and Kwai Sang Sin. Adaptive Filtering Prediction and Control. Englewood Cliffs, NJ: Prentice Hall, 1984. [8] Goodwin, Graham C, Stefan F Graebe and Mario Salgado. Control System Design. Upper Saddle River, NJ: Prentice Hall, 2001. [9] Grewal Mohinder S and Angus P Andrews. Kalman Filtering, Theory and Practice. Englewood Cliffs, NJ: Prentice Hall, 1993. [10] Ilchmann, A. and E.P. Ryan. On Tracking and Disturbance Rejection By Adaptive Control. Systems and Controls Letters 52, 2004. [11] Kuo, Benjamin C. Automatic Control Systems, Seventh Edition. Englewood Cliffs, NJ: Prentice Hall, 1995. [12] Lindfield, George and John Penny. Numerical Methods Using MATLAB, Second Edition. Upper Saddle River, NJ: Prentice Hall, 2000. [13] Mossayebi, Faramarz. Adaptive Control ofChaotic Systems. The University of Akron: Dissertation, 1994. 91 [14] Nise, Nonnan S. Control System Engineering, Third Edition. New York: John Wiley and Sons, 2000. [15] Ogata, Katsuhiko. Discrete-Time Control Systems, Second Edition. Upper Saddle River: Prentice Hall, 1995. [16] Phillips, Charles C and H. Troy Nagle. Digital Control System Analysis and Design, Second Edition. Englewood Cliffs, NJ: Prentice Hall, 1984. [17] Pratap, Rudra. Getting Started with MATLAB. Orlando: Harcourt Brace College Publishers, 1996. 92 APPENDIX A: MATRIX DERIVATIVE AND MATRIX INVERSION LEMMA A.I Matrix Derivative If f(x) is a vector function of the vector x, then the formal definition of the partial derivative of f(x) with respect to x is aJ; aJ; aJ; ax) &2 aX N Bf(x) al 2 al 2 al 2 --= ax) &2 aX N (A.I) ax aiM aiM aiM ax) &2 aX N Two common vector functions that are encountered are f(x) =Ax and f(x) =x T Ax. For the first function, the definition ofthe partial derivative leads to (A.2) (A.3) a(Ax) a = ax ax a l1 x) + a)2 x2+... + a)NxN a 2 )x) +a 22 x 2 + .. ·+a 2N x N (AA) which becomes, upon performing the partial derivatives, For the second function, =A. (A.S) 93 Differentiating x T Ax with respect to Xl yields (A.6) Collecting like terms in Xi results in the equation, Similarly the partial derivative with respect to Xi is If A is symmetric, then Equation (A.9) becomes (A.ID) which is the i 1h entry in the row vector forming the partial derivative. This quantity is twice as large as the i 1h entry in the row vector x T A. Thus, as long as A is symmetric, (A.ll) holds. 94 A.2 Matrix Inversion Lemma If the matrices A, C, and C- I + DA- I B are nonsingular, then the matrix A + BCD is nonsingular, and (A. 12) is true. This is shown by multiplication of A + BCD by its inverse. This yields (A+BCDXA-I_A-IB(C-I+DA-IBtDA-I). The product of the first term of each multiplicand, which is the first term, is the identity matrix, 1. The second term, which is the product of the first term of the first multiplicand and the second term of the second multiplicand, is - B(C- I + DA- I Bt DA- I . The product of the second term of the first multiplicand and the first term of the second multiplicand is BCDA- I , which is the third term. The fourth term, which is product of the second term of each multiplicand, is - BCDA- I B(C- I + DA- I Bt DA- I . The sum ofthe second and fourth term is - B(C- I + DA- I Bt DA- I - BCDA- I B(C- I + DA- I Bt DA- I =-B((C- I +DA-IBt +CDA-IB(C- I +DA-IBt)DA- I =- BC(C- I (C- I + DA- I Bt + DA- I B(C- I + DA- I Bt )DA- I =-BC((C- I +DA-IBXC- I +DA-IBt )DA- I =-BCDA- I The sum ofthe second and fourth term, thus cancels the third term, leaving only the first term, the identity matrix. Thus, A +BCD and A-I - A-IB(C- 1 +DA- I Bt DA- I are inverses. 95 APPENDIXB: LINEAR PREDICTION MODEL A linear discrete-time system can be written as (B.l) where (B.2) and as described in Equation 1.37. The output of the system at time k + d can be written in the predictor form, where ( -I) -I -n+1 G( -I) a\q =a o + a1q +... + an_1q = q and (B.4) (B.5) F(q-I) and G(q-I) are the unique polynomials that satisfy with F( -I) {' {' -I {' -d+1 q =Jo + Jlq +... + Jd-Iq , and (B.7) (B.8) The coefficients are computed in the following manner from Equation B.7. 10 =1, i-1 J; =-"Ilja i - j , j=O and d-l gj =-"Iljai+d-j . j=O (B.9) (B.IO) (B.lI) (B.12) 96 97 APPENDIXC MATLAB CODE Code for Classical Controller Simulation Root Locus Bq=[0.96Ie-4 0.9233e-4]; % Set uncompensated numerator Aq=[1 -1.8850.8869]; % Set uncompensated denominator Ts=O.OI; % Set sampling time sysol=tf(Bq,Aq,Ts); % Formulate uncompensated open-loop system Aqint=conv(Aq,[I -1]); % Determine compensated denominator Bqint=conv(Bq,[I -0.98]); % Determine compensated numerator sysint=tf(Bqint,Aqint,Ts); %Formulate compensated open-loop system rlocus(sysint) % Perform root locus zgrid(0.5I69,0.07738) % Add contours ofconstant damping ratio and natural frequency axis([0.8 1.2 -.2 .2]) % Specify graph size Step Response Kos=42.8; Bq=[0.96Ie-4 0.9233e-4]; % Set uncompensated numerator Aq=[1 -1.8850.8869]; % Set uncompensated denominator Ts=O.OI; % Set sampling time sysol=tf(Bq,Aq,Ts); % Formulate uncompensated open-loop system Aqint=conv(Aq,[I -1]); % Determine compensated denominator Bqint=conv(Bq,[l -0.98]); % Determine compensated numerator sysint=tf(Bqint,Aqint,Ts); % Formulate compensatted open-loop system syscl=feedback(Kos*sysint,1); % Formulate closed-loop system step(syscl) % Find the closed-loop step response title('Matching the Overshoot Criteria') Self-Tuning Regulator Simulation clear clf lambda=O.l; % Initialize forgetting factor T=O.Ol; % Set sampling time k=0:300; %Initialize sample index N=length(k); % Determine the number ofsamples uc=l *sign(sin((2*pi*k)/400)); % Formulate the reference signal % Designate Plant B=[96.le-6 92.33e-6]; % Set uncompensated numerator A=[l -1.8850.8869]; % Set uncompensated denominator % Extract transffer function coefficients brO=B(l); brl=B(2); arl=A(2); ar2=A(3); % Designate Desired Transfer Function Bm=[0.1761 0]; % Set desired numerator 98 Am=[1 -1.920.9231]; %Set desired denominator % Extract desired coefficients bmO=Bm(1); bml=Bm(2); aml=Am(2); am2=Am(3); aOO=O; % Initialize estimation variables e=zeros(1,N); K=zeros(4,N); theta=zeros(4,N); den=zeros(1,N); % Set initial parameter estimate theta(:,1)=[0;0;0.01;0.2]; % Perform first two iterations ofestimation and output theta(:,2)=theta(:,1); P(:,:,2)=diag([100 100 100 100]); u(1 )=uc(I); u(2)=uc(2); y(1)=O; y(2)=brO*u(1 ); % Perform ramaining iterations ofestimation, conttrol signal formulation % and output determination 99 100 form=3:N % Determine Output y(m)=-ar1 *y(m-1)-ar2*y(m-2)+brO*u(m-1)+br1*u(m-2); % Estimate Parameters Pkm1=P(:,:,m-1); phikm1=[-y(m-1) -y(m-2) u(m-1) u(m-2)]'; thetakm1=theta(:,m-1 ); e(m)=y(m)-phikml'*thetakm1; K(:,m)=Pkm1 *phikm1 *inv(lambda+phikm1'*Pkm1 *phikm1); P(:,:,m)=(diag([l 1 1 1])-K(:,m)*phikm1')*Pkm1/lambda; theta(:,m)=thetakm1+K (:,m)*e(m); a1=theta(1 ,m); a2=theta(2,m); bO=theta(3,m); b1=theta(4,m); % Formulate Control Signal den(m)=a2*bO*bO+b1 *b1-a1 *bO*b1; %Determine the S polynomial sO=(bO*(aOO*a2+a2*am1-a1 *a2-aOO*am2)+bl *(al*al+am2+aOO*aml-aml*al a2))/den(m); sl=(bO*(aOO*a2*aml +am2*a2-aOO*a1 *am2-a2*a2)+b1*(al*a2+aOO*am2-aOO*a2 a2*aml))/den(m); S(:,m)=[sO;sl]; 101 %Determine the R polynomial rO=l; r1 =(bO*bO*am2*aOO-bO*b1 *(am2-a2+am1 *aOO)+b1 *b1 *(am1-a1 +aOO))/den(m); R(:,m)=[rO;r1]; %Determine the T polynomial tt=((1 +am1 +am2)/(bO+b1)); to=tt; t1=aOO*tt; Tmat(:,m)=[tO;t1]; u(m)=-rl*u(m-l)+to*uc(m)+t1 *uc(m-l)-sO*y(m)-s1*y(m-l); end %Plot the system response t=k*T; stairs(t,uc,'r') hold on stairs(t,y,'b') title('Output (blue) and Input (red) ofa Self-Tuning Regulator without Zero Cancelation') xlabel('Time (s)') ylabel('Output') Model-Reference Adaptive System Simulation Code % MRAS Weighted clear elf lambda=O.I; % Determine forgetting factor for estimation lamc=O.OOOOOOI; % Determine small control signal weighting T=O.OI; % Set sampling time k=0:300; % Create sampling index N=length(k); uc=sign(sin((2 *pi*k)/400)); % Designate Plant B=[0.961e-4 0.9233e-4]; % Set uncompensated numerator A=[1 -1.8850.8869]; % Set uncompensated denominator % Extract transfer function coefficients brO=B(l); brl=B(2); arl=A(2); ar2=A(3); % Designate Desired Output Bm=[0.00291428474 0.0028375860]; % Set desiered numerator Am=[1 -1.91736448 0.923111635]; % Set desired denominator yml=filter(Bm,Am,uc); % Determine the desired system response ym=[yml yml(N)]; % Increase the size ofthe desired output by one %Initialize estimation variables e=zeros(1,N); K=zeros(4,N); theta=zeros(4,N); 102 theta(' 1)=[-2'1'0'0]' -, , " , % Perfonn the first two iterations ofestimation, control signal % fonnulation, and output detennination theta(:,2)=theta(:,1); P=diag([100 100 100 100]); u(l)=uc(1); u(2)=uc(2); y(l)=O; y(2)=brO*u(1 ); % At each iteration after the first form=3:N % Detennine Output y(m)=-ar1*y(m-1)-ar2*y(m-2)+brO*u(m-1 )+brl*u(m-2); % Estimate Parameters Pkm1=P; phikm1=[-y(m-1) -y(m-2) u(m-l) u(m-2)]'; thetakm1=theta(:,m-1 ); e(m)=y(m)-phikm1'*thetakm1 ; K(:,m)=Pkm1 *phikm1 *inv(1ambda+phikm1'*Pkm1 *phikm1); P=(diag([l 1 1 1])-K(:,m)*phikm1')*Pkml/lambda; 103 104 theta(:,m)=thetakm1+K(:,m)*e(m); a1 =theta(l,m); a2=theta(2,m); bO=theta(3,m); b1=theta(4,m); % Formulate Control Signal u(m)=bO*(ym(m+l)+al*y(m)+a2*y(m-l)-bl *u(m-l))/(bO*bO+lamc); end % Plot data t=k*T; % Plot input and controlled output subplot(211) plot(t,uc,'r') hold on stairs(t,y,'b') title('Output (blue) and Input (red) of a Weighted MRAS GSA-Controlled DC Motor for \lambda = 100* 1Q/\_1\9') xlabel('Sample') ylabel('Output') subplot(212) % Plot control signal stairs(t,u) title('Control Signal') xlabel('Sample') ylabel('uc(t)') 105