A COMPARISON OF AUTOMATIC CONTROL SCHEMES FOR CONTROL OF THE SPEED OF A DC MOTOR USING A DIGITAL nICROCOMPUTER BY: D. R. LYMBURNER AND A. G. ULSOY TECHNICAL REPORT NO. U-tiEAM-84- 26 THE UNIVERSITY OF MICHIGAN DEPARENT OF MECHANICAL ENGEERNG AND APPLED MECHANICS ME600 PROJECT JUNE 1984

TABLE OF CONTENTS 1. LIST OF FIGURES 2. LIST OF TABLES 3. INTRODUCTION 1 4. SYSTEM MODELING 4 5. SYSTEM IDENTIFICATION A. SYSTEM IDENTIFICATION PROGRAM 17 B. ESTIMATE OF OPEN-LOOP GAIN AND TIME CONSTANT 20 C. PARALLEL MRAS ESTIMATOR 23 D. RECURSIVE LEAST SQUARES ESTIMATOR 28 E. TUNABLE ESTIMATOR 32 6. CONTROLLER DESIGN A. DIGITAL PROPORTIONAL-INTEGRAL CONTROLLER 36 B. SELF-TUNING ADAPTIVE CONTROLLER 41 C. ROBUST FEEDBACK CONTROLLER 43 7. ANALYSIS OF RESULTS A. DIGITAL PROPORTIONAL-INTEGRAL CONTROLLER 47 B. SELF-TUNING ADAPTIVE CONTROLLER 52 C. ROBUST FEEDBACK CONTROLLER 56 8. SUMMARY AND CONCLUSIONS 59 9. RECOMMENDATIONS 61 10. BIBLIOGRAPHY 62 11. APPENDIX A - FLOWCHARTS AND SOURCE CODE, 63 SYSTEM I.D. PHASE 12. APPENDIX B - FLOWCHARTS AND SOURCE CODE, 80 TUNABLE ESTIMATOR 13. APPENDIX C - FLOWCHARTS AND SOURCE CODE, 89 DIGITAL PI CONTROLLER 14. APPENDIX D - FLOWCHARTS AND SOURCE CODE, 98 SELF-TUNING ADAPTIVE CONTROLLER 15. APPENDIX E - FLOWCHARTS AND SOURCE CODE, 107 ROBUST FEEDBACK CONTROLLER 16. APPENDIX F - SOURCE CODE, ASSEMBLY LANGUAGE ROUTINES 116

LIST OF FIGURES 1. PHYSICAL SET UP 2. OPEN LOOP SYSTEM 3. AMPLIFIER CHARACTERISTIC 4. DC MOTOR SCHEHATIC 5. TACHOMETER VS. HOTOR VOLTAGES 6. COMBINED OPEN LOOP SYSTEH 7. SYSTEM INPUT SIGNALS 8. SYSTEM RESPONSE 9. ESTIMATION OF DISCRETE TIhE PARAHETERS USING A PARALLEL HRAS 10. ESTIMATION OF DISCRETE TIME PARAMETERS USING A PARALLEL MRAS 11. ESTIMATION OF DISCRETE TIME PARAMETERS USING A RECURSIVE LEAST SQUARES ALGORITHM 12. ESTIMATION OF DISCRETE TIME PARAMETERS USING A RECURSIVE LEAST SQUARES ALGORITHM 13. ESTIMATION OF DISCRETE TIME PARAMETERS USING A TUNABLE ESTIMATOR 14. ESTIMATION OF DISCRETE TIME PARAMETERS USING A TUNABLE ESTIMATOR 15. DIGITAL PROPOTIONAL-INTEGRAL (PI) CONTROLLER 16. STABILITY UNIT CIRCLE IN THE Z-PLANE 17. SELF-TUNING ADAPTIVE CONTROLLER 18. ROBUST FEEDBACK CONTROLLER 19. DIGITAL PI CONTROLLER - EFFECT OF DAMPING ON SYSTEM RESPONSE 20. DIGITAL PI CONTROLLER - EFFECT OF DAMPING ON SYSTEM RESPONSE

LIST OF FIGURES 21. DIGITAL PI CONTROLLER - EFFECT OF USING LOW SPEED 51 PARAMETERS FOR HIGH SPEED CONTROLLER DESIGN 22. COMPARISON OF DIGITAL PI VS. SELF-TUNING CONTROLLER 53 23. COMPARISON OF DIGITAL PI VS. SELF-TUNING CONTROLLER 54 24. COMPARISON OF DIGITAL PI VS. SELF-TUNING CONTROLLER 55 25. COMPARISON OF DIGITAL PI VS. ROBUST FEEDBACK CONTROLLER 57 26. COMPARISON OF DIGITAL PI VS. ROBUST FEEDBACK CONTROLLER 58

LIST OF TABLES 1. MOTOR-TACHOMETER VOLTAGE DATA 2. CONTINUOUS AND DISCRETE TIME PARAMETERS

INTRODUCTION: With the recent advances in computer technology and with the Increasing popularity and flexibility of the digital microcomputer, the implementation of digital control schemes has become very prevalent in the control of numerous processes or plants. In the past, analog control schemes were implemented by "wlring up" the appropriate hardware and in order to change or modify the control algorithm, the hardware had to be completely rewired. However, with the advent of the digital computer, the control apparatus is now a computer program rather than wired hardware. This allows for the Implementation of the control scheme in software rather than hardware. Since the control takes place in the software routine of the computer, a control scheme can be implemented and/or modified quite easily by a few lines of computer code rather than by an extravagant amount of hardware. Due to the ease of implementation of these digital control schemes, an abundance of control algorithms have been devised. Due to the number of these algorithms it is often difficult to choose the "best" control scheme for a.particular application. This report examines three different control schemes implemented on a digital microcomputer to control a particular system. The advantages and disadvantages of each type of control schemes are examined in order to determine the "best" control scheme for the system. The controlled system or plant used for this study is a DC motor and the variable that is being controlled is the motor speed. In tnis study the motor is modeled as a first order system in order to simplify the system for control purposes. This is described in the System Modeling Section of this report. The report consists of four main sections. The first as mentioned previously is the System Modeling Section where the system is modeled for control purposes. The second is the System Identification Section. In this section the discrete time system parameters are obtained using four different methods. The system 1

2 parameters are needed to implement the various control algorithms. The first method uses a plot of the system response versus time to calculate the open-loop time constant and the open-loop gain. The discrete time system parameters are calculated from these values and the known sampling period. The second method of obtaining the system parameters is through the use of a Hodel Reference Adaptive System (iRAS). The third method of parameter estimation used is a Recursive Least Squares Method. The final parameter estimation routine used is a Tunable Estimator whicn combines the characteristics of both the nRAS and the Recursive Least Squares Hethod. The third section of the project is the Controller Design section. In this section the. system parameters obtained from the previous section are used to design the controller for the system. The controller is a computer program written in FORTRAN with Assembly Language routines to read Information into the computer from the system and output information to the system. Three different types of controllers are used to control the speed of the DC motor. The fir'st type of controller used is a Digital PI (Proportional-Integral) Controller. The second type of controller is a Self-Tuning Hodel Reference Adaptive Controller (MRAC). This controller uses a HRAS to continually update the system parameters in ox'er to control the motor speed. The third type of controller design is a Robust Feedback Controller. This is a new type of control scheme designed to be insensitive to changes in the system parameters. The fourth section of this project analyzes the results of the performance of each type of controller and identifies the benefits and disadvantages of each. The final section of the project summarizes the results of the project. A significant amount of work has been done in the control of systems such as this one. The first section of this report concerns the modeling of the system, and the motor in particular, in order to determine the characteristics of the system. Two useful references for the modeling of the DC motor were "Dynamics

3 of Physical Systems" by Robert H. Cannon Jr.(ref. #1) and "Modeling, Analysis, and Control of Dynamic Systems" By. William Palm (ref. #2). These books help develop mathematical models for various physical systems and have some specific Information about DC motors. When designing the Digital PI Controller certain tuning rules were used. The Ziegler-Nichols Tuning Rules were used quite extensively along with some information'concerning pole placement and system response. This information was obtained from a book called "Introducing Systems and Control" written by Auslander, Takahashi, and Rabins (ref. #3) as well as "Digital Control" by Rolf Isermann (ref. #4). Due to the nature of the Robust Feedback Controller information concerning system sensitivity was needed. This information was obtained from "Digital Control of Dynamic Systems" written by Franklin (ref. 85). In addition the class notes from ME561 "Design of Automatic Control Systems" (ref. #6) were used extensively throughout this project. The next section of this report examines the modeling of the DC motor system.

SYSTEM MODELING: In this section the open loop DC motor system is modeled in order to determine the transfer function or characteristics of the open loop system. The open loop system is defined as everything external to the control algorithm in the computer. This includes the digital to analog coverter, amplifier, DC motor, tachometer, and analog to digital converter. Each element of the open loop system is studied individually in order to determine its specific characteristics. The elements are then linked together in order to obtain an overall perspective of the characteristics of the open loop system. The physlcal system Is shown in Figure 1 and the open loop system is shown in Figure 2. It should be understood that the model obtained from this study is only a representation of the physical system. Since it is only a representation, some errors will exist in the model. In order to obtain a model that is convenient to work with certain simplifications or.model modifications are made. These simplifications are discussed during the evaluation of each element of the open loop system. If the actual system results differ from the expected or desired results, the simplifications should be recalled in order to determine any error or to account for differences. The modeling in this section is performed for the continuous time case. Conversion to the discrete time case is described in the System Identification Section of this report. Dlqital to Analog Converter The first element of the open loop system to be considered is the digital to analog converter. This converter takes the analog signal calculated by the control algorithm in the computer and converts it to an analog signal which can be used to drive the motor. This is needed since the DC motor is an analog device rather than a digital device. The D/A converter is nothing more than a simple gain. The value of the D/A depends on the voltage 4

F- DAC r, AMPLER FIGUR.E 1 PHYSICAL SE- UP

M KM. TS+1 D/A NVIR MOTOR TACHMCETER A/D FIGJURE 2 OPEN LOOP SYSTEM

level of the outputs on the computer and the number of bits used for the word size in the computer. Since the computer we are using is a XYCOn which has a 12 bit converter with maximum and minimum output voltage levels of plus and minus ten volts respectively and the maximum word size available is 212, we have that 2047=10 volts and -2048=-10 volts. Since the computer restricts us to these maximum and minimum values, the control value calculated in the control algorithm must lie in this range. Thus the D/A converter has a linear gain of KDAC=(1O/2047) for all values between these maximum and minimum values. Amplifier The second element in the open loop system to be studied is the amplifier. The amplifier takes the relatively small value from the computer and amplifies it in order to drive the motor. The characteristics of a typical amplifier are shown in Figure 3. The graph shows that the amplifier is fairyv linear, however some non-linearity does exist. It also shows that the amplifier may reach saturation. This means that beyond a certain range of input the amplifier ceases to be linear and the output signal stays constant for increasing v..ues of the input signal. This saturation point must be noted so that it is not exceeded. Another characteristic of the amplifier is that since it is a dynamic device there will be some time constant associated with it. This means that when a signal is input into the amplifier it takes a finite amount of time to reach the steady state output signal. If we look at the transfer function of the amplifier including the time constant it would appear as: Eo(s)= Ka Ei(s) Ts+1 where Eo is the output signal, Ei is the input signal, Ka is the gain, and T is the time constant. For most amplifiers the time constant is very small (on the order of nanoseconds), therefore

OILSISJIt.3VUH3 _Biflm dNV 1VOIdL NO~LVW LLVS NOLLV ALVS 03

9 for all practical purposes it can be neglected. This simplifies the model for the amplifier to the simple gain Ka (Eo=KaEi). DC Motor The third element in the open loop system is the DC motor. This is by far the most complex element and the most difficult to model (refs. #1 & #2). Consider the schematic of the DC motor shown In Figure 4. The voltage V is applied across the terminals of the motor. The motor also has some resistance (R) and some inductance (L) associated with it. The voltage drop across the motor (em) is proportional to the motor speed (W) times a voltage constant (Kv). The torque produced by the motor (Tm) is equal to the motor current (I) times a current constant (Kt). The rotor and the load both have certain inertias associated with them. Also, the shaft has some rotational viscous damping (b) and some rotational elastic spring (K) associated with it. The model does not include any frictional effects. Consider the two systems in Figure 4 seperately. First consider the electric circuit on the left half of Figure 4. Applying Kirchoff's Voltage Equation to the DC motor circuit yields: -V+IR+L(dI)+KvW=O (dt) Therefore: I(s)=- V(s)-KvW(s) 1) Ls+R Applying Newton's Law to the mechanical system on the right hand side of Figure 4 yields: Newton's Equation) nhx=(31+J2)(dW)=Tm-bW-Ke (dt) (J1+J2)sW(s)=KtI(s)-bW(s)-KW(s)/s W(s)(S(J1+J2)+b+K/s)=KtI(S) 2) Substituting 1) into 2) yields: w(s) = Kts 3) V(s) s3(31+32)L+s2(R(31+32)+bL)+s(bR+KL+KtKv)+KR

+ R L I Tm=Ktl V em=KvW (ROTOR) J1 (rT1AL LQAD) FIGURE 4

11 This is a fairly difficult equation to work with since it is third order, however some simplifications can be made. The amount of inductance in the DC motor is fairly small so one simplification that can be made is to let the inductance L equal zero. A second simplification that can be made concerns the motor shaft. If we assume the shaft to be rigid we can neglect the rotational elastic spring forces, and the motor and rotor inertia can be combined into a single inertia. The sum of.31 and 32 is denoted as 3. In addition we can assume that the rotational viscous damping is zero. In summary the following assumptions were made: Motor Inductance (L)-O Rotational Elastic Spring.(K)=O Inertia J=31+J2 Rotational Viscous Damping (b)=O With these assumptions the DC motor transfer function in equation 3 can be simplified to: W(s) - (1/Kv) = Km 4) V(s) (RJ/KtKv)s+l Ts+1 where Km=DC Motor Gain *and T=DC. Motor Time Constant From the simplifications made to the DC motor the transfer function-has been reduced from third order to first order, which is easier to work with when designing a controller for the system. However, the simplifications made to reduce the system from a third to a first order system should be kept in mind when working with the physical system. Tachometer The tachometer performs the function of the sensor in this study. The tachometer puts out a signal proportional to the DC

12 motor speed. This signal is fed back into the computer and is used in the control algorithms. The tachometer is modeled as a simple gain Kgen in this study, however some modifications were made to the generator model to obtain this simple gain. First all frictional losses in the gear train of the tachometer were ignored. In addition the time constant of the tach was assumed to be very small so that it could be neglected. with these assumptions the tachometer can be modeled as a simple gain. Analog to Digital Converter The analog to digital converter takes the analog signal from the tachometer and converts It into a digital signal which the computer can understand. Since the A/D converter performs the same function as the D/A converter only backwards, the gain associated with the A/D converter is the inverse of the D/A gain. Therefore KADC= 1/(KDAC). Data was obtained from the actual system in order to gain a better understanding of the system, characteristics. A voltage was applied to the input of the amplifier and the voltages were measured at the input to the motor and at the output of the tachometer. This data gave the overall gain of the motor-generator set including the motor gain, tach gain, gearing gain, and effects of the inertia. This data is listed in Table 1. A plot of thne voltage recorded at the input of the motor vs. the voltage emitted by the tachometer is shown in Figure 5. This plot shows that the gain is fairly linear except at low input (motor) voltages. It also shows the "dead band" or the motor voltage necessary to drive the motor, inertia, and tachometer and produce a voltage at the terminals of the tachometer. For this set up the "dead band" voltage is approximately plus and minus two volts. The combined open loop system Is shown in Figure 6. This figure shows that the open loop transfer function is a number of gains times a first order system. These gains can be combined wlth the first order to system to yield the open loop transfer

13 plifier Voltage Level Voltage at Hotor Terminals Current Tachometer Voltage -9.518 -7.400 -0.61 -6.770 -8.998 -7.772 -0.62 -6.450 -8.006 -7.221 -0.60 -5.230 -6.992 -6.313 -0.60 -4.230 -6.008 -5.425 -0.60 -3.410 -5.004 -4.524 -0.58 -2.770 -4.009 -3.630 -0.55 -2.020 -3.006 -2.728 -0.50 -1.222 -2.900 -2.380 -0.45 -0.480 2.502 2.193 0.75 0.000 2.807 2.485 0.43 0.716 3.000 2.654 0.43 0.817 3.498 3.109 0.45 1.156 4.002 3.563 0.50 1.510 4.503 4.018 0.51 1.893 5.011 4.470 0.54 2.210 5.500 4.910 0.55 2.589 6.005 5.361 0.57 2.950 6.500 5.802 0.58 3.280 7.001 6.252 0.59 3.660 7.498 6.701 0.60 4.180 8.003 7.155 0.61 4.600 8.499 7.601 0.61 5.120 9.002 8.055 0.62 5.570 9.501 8.486 0.63 6.150 TABLE 1 MOTOR-TACHOMETER VOLTAGt DATA

14 Vtach 5 |/ V.Vmotor -8 -6 -4 -2 2 4 6 8 -1 -2 -3 -4 -5 FIGURE 5 PLOT OF TACHOIETER vs. MOTOR VOLTAGE

15 function: Open Loop Transfer Function Y(s) - Kol 5) -i(s) (Tol)s+l where: M(s)-Control Effort Y(s)=State Variable Tol=Open Loop Time Constant Kol=Open Loop Gain The next section of this report examines ways to evaluate the open loop gain and time constant and their discrete time equivalents.

M _K_ Y FIGURE 6 nNT:MRInF nPF4N I rniP Y -IFM

SYSTEM IDENTIFICATION: This section of the report describes methods for obtaining the discrete time system parameters. These values are used in the design of the system controllers in the next section of this report. Four different types of estimation methods are used to obtain the system parameters. The first method discussed involves using a plot of the system response to a step input to determine the open loop gain and time constant. The discrete time parameters are calculated from these values. The second method of parameter estimation involves the use of a parallel Model Reference Adaptive System to calculate the discrete time parameters directly. The third type of estimation procedure is a Recursive Least Squares Method which again calculates the discrete time parameters directly. The final method of parameter estimation involves the use of a Tunable Estimator. This estimator is a more general estimator which can be modified to become either the MRAS or Recursive Least Squares Estimator. However, since it is a general type of procedure, it offers some added flexlbility. All of the estimation procedures mentioned were implemented through the use of a computer program. The majority of the program was written in FORTRAN with Z-80 assembly language routines used to transfer signals to the external DC motor system from the computer and vice versa. An explanation of the computer program follows. System Identification Proqram The flow charts for the computer program used during the system Identification Section are shown in Appendix A along with the FORTRAN and Assembly Language Source Codes. The program performs all calculations "off-line", that is, all the data is collected first and then all calculations are performed. The calculation could have been performed "on-line" (while the data was being collected) nowever no benefits would have been obtained 17

18 from "on-line" calculations so it was decided to use the "off-line" method instead. The program uses preset interrupts to time the transfer of data both into and out of the computer. The interrupt period was preset by setting appropriate switches on a specified board of the XYCOM. For the System Identification Phase the interrupt frequency was set to.100 seconds. This means that data was output to the DC motor system or read in from the system every.100 seconds for some specified amount of time. The computer program uses a main program to perform initialization, calculate the output signals, calculate the amount of time to output the signals and read in the response, and initialize the interrupts. The calculated computer output signal which is the system input signal must be a frequency rich signal so that it sufficiently excites the system. This means that the signal should have some corners on it which are very rich in frequency. In the program the input signal may be a step input, ramp input, or trapezoidal (see Figure 7). The user specifies the maximum magnitude, pulse width, and rise time of the pulse. From this data the appropriate system input signals are calculated. After the interrupts have been initialized in the assembly language code, a subroutine is called which does nothing more than loop for a certain amount of time specified by the user in the main program. This looping occurs only after the interrupts have been enabled. While this looping is occuring the program is being continually interrupted every.100 seconds. When this interrupt occurs the program Jumps to the FORTRAN Interrupt Service Routine specified in the assembly language code. In the Interrupts Service Routine the output signal calculated in the main program is output to the system through the use of an assembly language subroutine and the corresponding system response, measured by the tachometer, is read into the computer through a similar subroutine. This continues until the time specified by the user in the main program expires.

S'IVNDIS lfldi NISAS -1 — I —' 1 VIOZ-kM.L. 11 CIJVl IilN -i

Now that the signal has been output and the system response measured by the tachometer has been obtained, the estimation procedures can begin. These procedures are now presented. OPen Loop Gain and Time Constant Using the the open loop gain and time constant is the easiest method of obtaining the open loop parameters, but it has the disadvantage that it cannot be performed on-line. This means the procedure cannot be used to estimate the system parameters while the control algorithm is running. It is also not suitable for more general, higher order systems. Recall the combined open loop system shown in Figure 6. In the continuous time case the transfer function for a first order system involves one gain and one time constant. These values car be determined by "exciting" the system with an appropriate frequency rich input signal and then measuring the system response. A step input with no ramp was used to excite the system. For a step input the system response can be calculated as: Y(t)=Kol(l - e-t/TOl)M(t) The system input signal along with a typical example of the system response is shown in Figure 8 (ref. #2). It was noted that the response signal did.achieve a steady state value, however the signal was rather erratic and had variations of up to 10, of the steady state value. This "noise" which was of higher frequencies was filtered out of the response signal through the use of an adjustable filter. The filter was a low-pass type which had cut off frequencies of 30,15, and 6 HZ. It was found that the 30 HZ cut-off was very effective at reducing the "noise" in the response signal. Decreasing the cut-off to 15 and 6 HZ did not improve the signal much further. P check was also made to determine the effect of filtering on the open loop gain and time constant. Even with a cut-off of 6 Hz,

Y(t) STEP IhFUT SIGNAL Ymax,.. _ -- -....63 Ymax - I.SYSTEM RESPONSE TO A STEP INPUT TI Tol FIGURE 8 SYSTIEM RESPONSE

22 these values did not change from the case with no filter. Filtering this signal helped in obtaining the open loop parameters as well as improving the stability of the. other estimation procedures as shall be seen later. The open loop gain Kol is determined by knowing the input magnitude and the steady-state response magnitude. The open loop gain is calculated by: Kol=Steady State Response Maqnitude Input Magnitude A time constant is described as the amount of time it takes for a system to reach l/e (where e=2.78 and l/e is approx. 63X) of its steady state value. This point, shown in Figure 8, can be determined given the system response. Now that the continuous time parameters have been obtained they must be converted to their discrete time equivalents. Consider a first order system in the continuous time case (see Figure 6): n(s)= Kol Y(s) 6a) Tols+1 where: M(s)=Control Effort Y(s)=Output Signal Kol=Open Loop Gain Tol=Open Loop Time Constant Multiplying through and taking the inverse LaPlace Transform of both sides yields the state equation: dY/dt=aY+bM 6b) where: a=-l/Tol b=Kol/Tol The discrete time state equation is written as: Y(K+1).=PY(K)+QM(K) 7a) where: P=eart Q=(P-1)b/a ht=sampling(interrupt) period 7b)

23 The appropriate values of P and Q are calculated after the open loop gain and time constant are obtained by equation 7b. As discussed previously the system is somewhat non-linear, therefore different values of Kol, Tol, P., and Q are obtained with different magnitudes of the system input values. These values range from -2048 to 2047 which are the max. and min. word sizes determined in the System Modeling Section. The system non-llnearity due to different magnitude input values is shown in Table 2. Parallel MRAS Estimator The second type of estimation algorithm used in this study is a parallel Model Reference Adaptive System (MRAS) (ref. n6). In this instance the MRAS is being used for identification of the system parameters which are unknown, therefore the unknown system is the DC motor system (fixed system) and the adjustable system is a computer model of the DC motor system. The procedure for using the MRAS for parameter. identification (estimation) follows. Consider the motor and the computer model in the discrete time case: Y(K+1)=P(K)Y(K)+Q(K)M(K) Motor (Fixed System) 8) YH(K+1)=PH(K+1)YH(K)+QH(K+1)M(K) Model (Adj. System) 9) where Y is the motor speed, YH an estimate of the motor speed and M the control effort. The problem is to get the model to follow the fixed system and to get the error Y(K)-YH(K) to go to zero. To calculate this error and YH(K) values of PH(K) and QH(K) are needed. First an'a priori' estimate of YH(K+l) must be obtained. This is performed by: YHO(K+1)=PH(K)YH(K)*QH(K)M(K) 10) Next an'a priori' error is calculated by: EO(K*1)=Y( K*1)-YHO(K1) 11) The error at time (K*l) is calculated by:

TABLE 2 STEP INPUT OPEN LOOP OPEN LOOP P Q MAGNITUDE GAIN (Kol) TIME CONSTANT (Tol) 500 0.39 1.95 sec.950.0195 1000 0.60 1.65 sec.941.0353 1500 0.67 1.60 sec.939.0406 2000 0.71 1.60 sec.939.0430 CONTINUOUS AND DISCRETE TIME PARAMETERS WITH VARYING INPUT MAGNITUDES

25 E(K+1)=ED(K.1)/(l+K1YH(K) 2K2M(K)2) 12) K1 and K2 are gains specified by the user to aid in the rate of convergence of the algorithm. These two gains must be greater than zero for stability purposes. PH and QH at (K+1) can now be calculated by: PH(K+1) =PH(K)+KE(K+1)YH(K) 13) QH(K+1)=QH(K)+K2E(K+l)M(K) 14) The model response is calculate from equation 9 and compared to the motor response to see how well the model follows the actual system. In order to implement this algorithm certain values must be input by the user. The user input values are the gain values K1 and K2 and the initial values of PH and QH. Although it was found that the values of K1 and K2 did not significantly affect the rate of convergence of the algorithm, the selection of initial values of PH and QH did significantly affect the outcome. As can be seen from Figures. 9 and 10 as different initial values of PH and QH were used the algorithm behaved quited differently. This occurred for all values of Ki and K2 and for all three different input signals. If the initial values of PH and QH were chosen to be quite close to the actual values of P and Q (motor parameters) the algorithm converged quite nicely. However, if the initial values of PH and QH were even slightly different from P and Q the algorithm converged poorly. It should also be noted that the HRAS estimation algorithm is a very "alert" estimator. This means that a slight change in the response greatly affects the values of PH and QH. In other words, the algorithm places greater weight on current values of the system response rather than past values of the system response. Filtering the signal did help remove some of the "noise" which affects an "alert" estimator, however this still was not enough to get the estimator to perform as required. The next section examines the Recursive Least Squares Estimator.

"TINITEP'" Of' PH AIND OH'1 L/ING A M"Al'-' """ T~ ~~~~~~~~~26 ~TE. E:,t4 RE $LULT" FOR INPLUT= 10,0' /gi = t100 h'0 K.2 1?0,:0, TNIE PH X62,\ XIt ERRR 2. 9~30.050 7.0 0.0 7.0.'0'5, ". 0 0.:0 J., 3.0 1. 31.05%-r4 5 4.0 54. 0.0,,, ~ C c...~,.',:,w o.'.97.0 97.0 -.0 5J 9m. 140.0 140.0 0 900.0550 18 1!.0.0 7.90~7.054 217.0 217. 0 0.0,-0 1 ~.58 254.0 254.0.0. 0 5 7 286.0 286. 0 0.0.057 3~7jI 15.0 165.0 0.0.05-1 1~,9 36 J I0 34,3.0.0 -0 4.0 90.1.036.1? 394.0 394, ~30. FIGURE 9 -,O,)- 414.0 414.0 I'IRAS Estimator wi ~~~~~~~~~~~~~~~,.' Jr J' 7 I:-0: 0 Initial Values of:;Y53~~0 457.0 4/ 0.' and QHi slightly d. J i ~ ~ ~ ~ ~ 440 471, 4 0.0 from Actual Value.,.1 IS. W 90 I 0 ~~~4 9.0 * -,J,-...60 5 0.0 5.0 -.0.063 517.0~ ~ 51- Io 0.0 15290 5" 0.0.~ 5.:.0 54" 0 0.0.I. 5, 4 0 0.0 "'- ~~~~' -',:.,= 58.0' 5Z83.0 0.0 C ~ ~ 59..0;1. 0,.3... F It.,~3 0 5 12.0 6 12.. 0.- S 614.0 6~~ 5114.1I0 -.0 0 0I,210 6&1 0 ~. 26 0.0 ~, 0..,, 4 4 ~f.u 1,3 ~ ~~~~ F'ZO'''7 0 9:'',~.'O. " 0 0 6':'''.: "' 0.......~'~~ 645=.0, 7 ~:'45 5 70 0,'21,;53 9.:' 0 0.0'.'0 0....,. 4':640 O, &. m' - -,-,~ m 3....'::'-''::* L::':',"~ 5 0 6 d,'-. 010.~.,".3':'~Z 0~~ -.'>~~~~~~~~~':-:'.: 0.:'.,: 0 c, 61'7 ( 1'~. — ~ 0, -" 06 =' ~ ~~"

ET 1 il MATES F P/j' AND LTh' LIS2ii3 4. RSAS 27 ST E,LL *.S FO R INiPLUT= 1000 A'I= ~0 00 K2t, 100. a00 Ti',1,E sPH i:,' X{ )H ERROR;P r (i-} E Ff i H x.5.040 7.0 0.0 7.0 -,-@.:.!r0, ~ Jfi, 0 3.0 3 0 ~l ~.05 54.0 5 4.,'' -6.1 i 9770 97.0 - 0 %,.95,04: 140.0 140.0 I 0 f, I'4.;.0S I. ~ 16.'., 0.0.045..217,0 0.0.04 @, 254.0.0 ~,.''~1.0,,.';' —'5r. e _54 4, ",.t,:,. ~ 11.,,.0~4':'4;.0 23-';.~ 0...! c.,.e e~, ~~ -* 4't ". 4 0 S4,: ~.,.,"... 3., m ~, C,;!3? 30 9 -' 45 -.0 394.. FIGURE 10.,,., 0,0 1j4.9'4' C. 41 41I 4.0 414.0 e -. MRAS Estimator with.15..09 4.36.0 433",0 6.0,., Initial Values of PH..... 3. 457.0 45 7.0 -. 2f7 - and QH close to the.;;17..'. v f, c. 4.4 47, 4; 47 40 - Actual Values,L;,'. 48.t 0 4! 490. 0 49 0.0 -. i? - 038. 502 0 502. - 0.;'0."0.-. r 4,', i: 41 5,7 0.` 77, 0 0.0'::'" r 9/,52. 0 9 0.' 53..0... 0, 0. 5 6 0 64. 0 0........r r! -# i ii ~.; sv to w Q..t ~. =.:;..- c:, 7f,E;] 4'2..0 5' --.- ^"'" 57':},-w ~ r' 0 L Z. 0 -. r ~ c r' 6C''' co.X. t %,Ji. 0, 0..' 50:, j ~).$ ~j LG 1 =5,> i - 0 _':-','/'.0.~2 61 0 611, 0 -, 0:...4'.: tc,?3C ~,7'-" 2, ______________________.',,..,..;;..,r.., _. C.'.Z9 653' 0 65'Z 0:. 0 J f~.-,.94:*., Z 9 6 49. 66..'' 5 E. 0 *'i m *'J;, *; * * -.2 ~; L "-"". -.;t —;; _. -, L!.,}., r.! l#; #R - - t.L' - * -. S ~ * ".-.'.*.,.- -.- S.': 7;-' 0''':,':"' -;,:.9,., ~ 6.:'-.' 0,_,.; 7'' *~ --. --.a, -,... _,

28 Recursive Least Square Estimator The third type of estimator used in this study is a Recursive Least Squares Method. In this procedure it is desireda to minimize the square of the error between the actual measured speed and the estimate of the speed. In other words: min J(K)=Z(Y(K)-YHO(K))2=ZEO(K)2 15) where YHO(K) and EO(K) are'a priori' estimates of the state (speed) and error values respectively. From equation 11 in the MRAS section it was found: EO(K+1)=Y(K+1)-YHO(K+I) 11) substituting equation 10 into 11 yields: EO(Kt1)=Y(K1)-o0T(K)a(K) 16) where: GT(K)= (-PH(K) QH(K)) 17) &T(K)= (-YH(K) M(K)) 18) Substituting 16 into 15 yields: J(K)=Z(Y(K)-OT(K)A(K))2 19) In order to optimize the algorithm the error must be minimized with respect to the parameters PH and QH, therefore: aJ(K) = 0 20) COT(K) After taking the derivative the following result is obtained: B(K)=F(K)(XY(K)a(K-1)) 21) Tnis ls the Dasic Least squares Solution. F(K) must be continually updated at each new time increment. This is performed thru the Matrix Inversion Lemma which allows for:

29 F(K41)=F(K) F(K)(K)AT(K)F(K) 22) T(K)F(K)A(K) The basic Least Squares solution is modified to get a Recursive Least Squares solution by: (K+1)=(K)F(K1),(K)EO(K+1) 23) AS in the case With the MRAS estimator, certain user. input values are needed in order to start the Recursive Least Squares Estimator. Initial values f PH and QH are needed as well as initial values of the matrix F. Once the user specifies these values, F(K) is calculated by equation 22, EO(K+1) is calculated by equation 16, and the new estimates of PH and QH are calculate in equation 23. If tne adaptation gain F(K) or the error EO(K) are large the values of PH and QH change quite a bit. AS the adaptation gin decreases and the error goes to zero the algorithm converges to the correct value of PH and QH. ter numerous runs wit the Recursive Least squares Estimator it was found that it was also very sensitive to the initial values of PH and QH. If these values were close to the actual values of P and Q the algorithm performed quite nicely, but as was the case with the MRAS estimator, if the initial values of PH and QH were significantly different from the actual values, the algorithm did not perform well. See Figures ii and 12. While the MRPAS estimator was found to be a very "alert" system. the Recursive Least Squares Mle*,.hod was found to be fairly insensitive to fluctuations in the system response. Once the. algorithm "locked on" to a value for PH and QH, which seemed-to occur in the f irst few steps, the algorithm stayed at that value. The performance of this system was not adequate. Since neither the HRAS or Recursive Least Squares Estimator performed up to expectations or requ irements, it was decided to

RE-CUFS(IVE LEPST SOUPRFE S E ST IMAT1ON PROCEDLURE 30 S:YS3TEM RESULLTS FOR INPUT STEP= 1000 INITIAL P11=.94 INITIPrL 01H=.03 TIME PH OH I 9 43".034 2. 9319. 0 3V 85 3.,939.038 4.9371.040 5 ~.938.039 6 IV.941.036 7.940.3 - ~~~~.937.040 9. 939, Os36'.10.938.0 3'9 12 S98.3 13 IFI938151.039 FIGURE 11.14. 938-51.039 Recursive Least Squares Est." I15.9139. 03811 with initial value's of' PH ari A C,.939. 03816. close to the actua-1 -values 17.940.037 18.039.00 21. 940.03 2 4.9, 38.;0319 265 94 0.037 27.9319 I.036'-1.26'..939.038 3 0.938,.0139 938,.0 39 34.940.~~~~~~~~~0 3763-7 4.5340 0 38.09 41. 939.~~~~~~~~~0 36' 42.3.03 43.9~~~~~5385.0 39;1 4 5 93.039 46 97.040

RECULRSIQE LEAST'SOUARES ESTIMATION PROCEDURE 31 SYSTEM RESUL TS FOR INPLUT STEFP= 1000 INITIAL PH=. 90 INITIAL 2rH=.05 TIIME PH QH 1.,.00 50 2.912. 03 _', 0. 9 3.911.039 4.908.042 5,.90S.042 6.911.03,9 7.909.041 8.ei907. 043 9.90:8.042~ 10.9. 6. 044 Il.906.044 1'2.906.0 4 4 13.905.0 45 FIGURE 12 14 9084.046 Recursive Least Squares Estimato 1S,90a5.D045 with initial values of PH and QH 16.90"5.045 slightly different from actual 17'.*90(5'.045 values 18-;.903,.703, 4 7 19.9.,48 ~'g. /.';~:', 2.1 1903.047 22-. 903. 047 2'3.9, 0,4', 24.901.049 2~5,.901 049 ~26.90"'2. 0 4 8 28 ~91.049 V 900 1050 30. 99.9,51 33.:-:99. ~051 4 f.899. ~9, 051 35.'98 0 5.. 36,89-. 052 9.9.3::,053 40,86. 0754 41.97.0 5 3 3 9.',.'7'' 4,:,J;b.054 43 c' 6 0, 5.9.4/4.:9, 9 5.54 5:.'" 5 I = =, 46. 894 o 4i9.95.,5 5 3,,'":'.0'", k 56 A4.f.'.'S._ 57

32 "lock on" to the values like the Recursive Least Squares estimator. This procedure is now explained, Tunable Estimator AS was the case with the MRAS and the Recursive Least Squares Estimators the goal is to get the error between the system and the model to go to zero. First an'a priori' estimate of the speed is calculated by: YHO(K+1)=PH(K)YH(K)*QH(K)n(K) 24) Next an'a priori' error is calculated: EO(K+1)=Y(K+i)-YHO(K+l) 25) Next an adaptation error is calculated by: E(K+l)=EO(K+1)/(1+aT(K)F(K)&(K)) 26) where a(K) and F(K) are the same as in equation 22. The next step is to calculate the updated adaptation gain matrix F(K) by: F(K+1)=l (F(K) - F(K)(T)6T(K)F(K) ) 27) L1( (L1/L2)+aT(K)F(K)a(K)) where L1 and L2 are tunable gains which help to yield the desired estimator. For stability purposes O<Lll1. and O0L2<2. The final step is to calculate the parameters PH and QH at the new time increment. This is the same as with the Recursive Least Squares Estimator In equation 23 except that E(K+1) and F(K) should be used rather than EO(K+l) and F(K+1) respectively. The gains L1 and L2 can be used to effectively tune the estimator to a NRAS estimator, Recursive Least Squares estimator, or some combination of the two. If Ll=L2=1 then the estimator is a Recursive Least Squares estimator. If L=l1 and L2=O then the MRAS estimator. is realized. It can be seen from equation 27 that if L1 and L2 are both small a larger adaptation gain F(K) will be obtained. Thnis will yield a more "alert" system. If L1 and L2 are around 1 then the

33 system will "lock on" to the value like the Recursive Least Square estimator. The object is to choose L1,L2, and F(O) so that the system is very alert during the first few steps and then locks on to the estimated values. In order to get the desired tuned estimator, L1 was chosen to be 1 and L2 was chosen to be greater than 0.5. with these values the algorithm was found to converge very well. The algorithm converged to the correct value of PH and QH regardless of the initial values of PH and QH. These results are shown in Figures 13 and 14. Since the tunable estimator performed the best, it is the on-line estimator used in the Self-Tuning Adaptive Controller and the Robust Feedback Controller in the next section of this report.

P k ill~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- 11'4 ~-:.w 4. 1= t~~~~~~~~4 -~~~~~~~~~~~~~~~;t ZA~~~~~~~~~~~14 l ~ -fijf 41 4I4441414144~~~~~~~~~~~~~~~~~~~~~~~~~~~~441~~~~4\ ~ J1 A!&i *4 -i -. aA.:.4l..4 M M,.Z4,,;:4 4,,.~,....._... -4 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 14 8..i,, o. ~4 1 Al. I-...'.-.:. ~'.:.; -..:..:.4.. —:. -.; -:.), IZ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~i~~~~~~~~~~.,a.,a4'.-,4 -.4-'.,.a.:.-.. K"- M,'i V4 -"'- t'..4 "-a k' A 4 —'4'.a:t -:-:.'S -., ~.I.4 ~~~~~~ 85)~.4 4 ~-.~~~~~~~~~~~~~~~~~~~~~~~~1 i.t-.1 It. it~ Il 1:: 493 l l:1.'4.'-; 8).4NA~ -Z- -*.j0 44 L.J~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-i ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~.4 11 4,',5 ii 1*-. j II 14.1~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ L.tJLtj )- S-,.- i. -.............: 8-....8.5 5.5 4.5 ~..~ 4:...7. i:4 4.4... 44::*;.: i.8~: 4.'; *..~ 8 a.;: ~-,8 *.j 8 88~.;... *..~ ~5.. 4,..J 4.. --:7.':::.CJ li,: ~ ~' 4.,,,~,,'*,,, *,, *,~,,,, ~,,,,,:,.~, ~.~.,. 4.,8:...........,..,..J,,;.j.j ~':'-.'-..'I:-':'..:." i',Z:~.: ~.~'?.,"~, — ~?:..,. L-:...'','',: ":i:::,-';:-..=:; z:...:'''-:.'-.. ".:.....:'.i.'" -'"~ "'-'"';~.: ~::i:".:.-i:": ":;'','~''

ol. aso,[o Hb pure Ha $o sanuIVA: ie,~ ~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~,..;..?',. I~~~~~~~~~~~~~~~~~~~~~~~~.:.7. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'" i..-.''-'..'T' ~'~,:.;-:-4'":~~."; j~ ~ ~ ~ ~~:,-? z,.';.'';...'.,.,...;.;" CY'6 000~~~~~~~~~~~~~~~~~~~~ J,,. _.;_...... Jr",0~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~..,:;,.-.,7 -,-' -'."P.... ~.. 0 -. k:1 ".' 0~~~~~~~~~~~~~..:'::i::!,:-.,.. " r::....,: ~... 0~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1.::!::iT,'" A..'Q:...........~..... ~.~~~~~~~~~~~~~~~~~~~~.-...77,.'.~'? X...7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.' ~'~~ ~ ~ ~~~~~~7'.N'4 4T-8.:;":3::~:,':":';.."'....... ~;..'....... ~......-_.....~~~~~~~~~~~~~~~~~~~~7 0.'.::~:-.*,'.~~.~'. T,' ~'''"".~':~'''..''"':'.. -47 J 4......:....... -. ~.. ~...:... ~ 1........~~~~~~~~~,,- ~.. -,.....-,:. L..'.. {.~~~~~~~~~~~~-l {;$:1,:-.:~..,::.. A... %,...;..:'.7..~....0. f. 7'~':-' 4.~':'X'~...,'~:. ~'..::. of?~~~~~~~~~~~~......' 4:...-J.;......

CONTROLLER DESIGN This section of the report details the design of the system controllers. The purpose of the controllers is to control the speed of the DC motor to some steady state value chosen by the user. The three types of controllers that are used to control the motor speed are a Digital Proportional-Integral (PI) Controller, a Self-Tuning Adaptive Controller, and a Robust Feedback Controller. The Digital PI controller uses the discrete time system parameters obtained from the previous section directly in order to obtain the appropriate controller gains. Both the Self-Tuning Adaptive Controller and the Robust Feedback Controller use the Tunable Estimator from the previous section in an on-line manner to control the motor speed. As with the System Identification Phase, all the controllers were implemented through the use of computer programs. Most of the programs were written in FORTRAN with assembly language routines used to transfer data to and from the controller. The next section details the Digital PI Controller Design. Dilgital Proportional-Inteqral Controller The first controller considered is the Digital Proportional-Integral (PI) Controller. This controller is sometimes referred to as the proportional plus reset action controller because the integral action "resets" the position of the proportional band (ref. #3). A schematic of the Digital PI controller is shown in Figure 15. As shown in Figure 15, a reference value R(Z) is input by the user. The actual motor speed Y(Z) is subtracted from the reference value to produce the error value E(Z). This error is then multiplied by an proportional term Kp and an integral term (KiatZ/(Z-1)) where the At term is the sampling frequency and Ki is tne integral gain. In the continuous time case an integration is denoted by 1/S, but in the discrete time case an integration corresponds to Z/(Z-1). Also, in the discrete time case an integration refers to the past value, therefore the manipulated 36

,5 10~~TflONDXO (Id 1V15IN 1VNO J~OdO&I 1VDIT ~~~~~~~~~,r...d-Z -7,....... - _ Ed-I,'K No% A ~ tV-ld -- INVid 8I1~IO

38 value M(Z) is equal to the current error multiplied by a proportional term (Kp) and the integrated past error. The manipulated value M(Z) is then used to drive the system. The plant or DC Motor was modeled in the System Modeling Section as a first order system (see Figure 6). The relationship between the continuous time and discrete time parameters was ther discussed in the System Identification Section of this report. In the discrete time case the representation of a first.order system is given by Q/(Z-P) where Q and P are the discrete time parameters discussed in the previous section. The manipulated value H(Z) then drives the system to produce the desired motor speed. The motor speed Y(Z) is continually fed back and the procedure repeated. The only values which may be chosen by the user to control the motor speed are the reference value R(Z) and the proportional and integral gains Kp and Ki respectively. Once the reference value has been selected, the values of P and Q of the system are fixed, therefore the only way to control the system is -through the selection of Kp and Ki. In order to determine the values for Kp and Ki the closed loop system shown in Figure 15 is examined. The transfer function is given by: Y(Z) = QZ(Kp.- K &t) - QKp 28) R(Z) Z2 +(QKp' QKit - 1 - P)Z + (P - QKp) and the characteristic equation is given by: Z2 + (QKp+QKIt-1-P)Z + (P-QKp) = O 29) This equation can be solved using the quadratic equation: Z = -B/2 * 1/21B2-4o where: B=QKP*QKiat-1-P 30) C=P-QKp The restriction for Z is that the magnitude of the value of Z must be less than one for stability purposes. In the s-plane the poles must be on the left-hand side of the plane for the

39 system to be stable and in the Z-plane the magnitude of the pole must be less than one for a stable system (see Figure 16).. This allows for the poles to be all real, all imaginary, or both real and Imaginary. Including some imaginary part in the selection of poles introduces some damping into the system which causes oscillation. If the pole magnitude is less than one this oscillation dies out eventually, but if the magnitude is equal to one the oscillation will continue (ref. # 3). A small amount of damping in the system may be desired since it can actually speed up the convergence of the speed to the steady state value. Appendix C contains the flowcharts and source code for the Digital PI Controller program written to control the motor speed. In the program the user inputs the desired speed, pole locations, and values for P and Q. This means that the user must have measured the system parameters P and Q previously for the desired reference speed. From the pole locations and the values of P and Q entered by the user, the proportional and integral gains are calculated using equation 30. The proportional and integral gains are then used to calculate the gains for the control law where the control law is: M(K)=M(K-1)+(Kp+Kiat)E(K)-KpE(K-1). In the control law at is the interrupt period preset by the user, E(K) is the current speed error and E(K-1) is the previous error, and M(K) is the manipulated value or control effort output to the system. The error is measured in an Interrupt Service Routine similar to the one used in the System Identification Programs. The control effort is also calculated in the Interrupt Service Routine and output to the system. This procedure occurs for a certain amout of time predetermined by the user. When completed the user may print out the system response to the control, repeat the control procedure, or quit. The problem with the Digital PI Controller is that since the values of P and 0 change for different output speeds and reference values, calculating a single set of gains based on one particular speed may control the system very well for that particular speed, but may do a poor Job of controlling the system

zw~~~~~~~~~~~~~~~~~I 0+g~~~~~~~~~~~~~~~~~~~~~~~~~0

41 at a different speed. Therefore, a single set of gains may not control the system for all speeds due to the non-linearities in the system. The next section of this report examines a way of using a parameter estimator to overcome the problem of non-linearities in the system. Self-Tuning Adaptive Controller. The schematic for the Self-Tuning Adaptive Controller is shown in Figure 17. This controller is the same as the Digital PI Controller except that it contains one additional loop. This is an Adaptation Loop which continually measures the system output and calculates the system parameters P and Q through the use of the Tunable Estimator described in the System Identification Section. These system parameters are used in the control laws for the Digital PI Controller to calculate the proportional and integral gains needed to obtain the desired performance. An explanation of the program to control the system using a Self-Tuning Adaptive Controller follows. The flowcharts and source code are listed in Appendix 0. The user inputs the reference speed and the desired pole placement in the Z-Plane along with information pertaining to the Tunable Estimator. From the pole placement, values of B and C can be calculated from equat on 30. This data is then transferred to the Interrupt Service Routine where the control takes place. First a signal is output to the system and the system response is measured. The system response measurement is used in the Tunable Estimator Algorithm to calculate the system parameters. The Tunable Estimator is included in the Interrupt Service Routine of the Self-Tuning Adaptive Controller so that the system parameters P and Q can be continually updated. After every updating of P and Q, the proportional and integral gains for the Digital PI Controller are calculated and used in the control law just like in the Digital PI Controller Design Section. Due to the time limitations imposed by the interrupt period,

CONTROLLER PLANT z-.i# I - P FIGLRE 17 SELF - TUNING ADAPTIVE nTF.TTAI DPIflCnlTTnl1 - _1NTRDAI (Dln r("'lTfnl I

43 the Tunable Estimator in the Interrupt Service Routine was modified to save time. As seen from Figures 13 and 14, the off diagonal terms of the adaptation gain matrix F are initially zero and remain zero for all time. By eliminating these two terms in the ISR of the controller, quite a bit of time was saved. In addition, it was found that the estimator performed best when the gains Lambda 1 and Lambda 2 were found to be 1.0 and 0.5 respectively. By Including these values directly in the estimator calculations, additional time was saved. The advantage of the Self-Tuning Controller is that the system parameters are calculated on-line so that any reference value can be used without determining P and Q prior to implementing the controller. This controller compensates for non-linearities in the system by calculating the discrete time parameters on-line and using them directly in the control laws. Robust Feedback Controller The third type of controller used in this study is a Robust Feedback Controller. This controller is designed to be insensitive to changes in the system parameters P and Q. Since it is insensitive to parameter variations, the non-linearities in the system do not affect it as greatly. Considering initially only a proportional controller, the basis of the Robust Feedback Controller is the assumption that the manipulated value H(K) can be calculated by: M(K)=-klY(K)-k2Y(K+1) 31) From equation 7 we know that Y(K+1)=PY(K)+QH(K) Plugging this into equation 31 yields: (l+Qk2)Y(K+1)=(P-Qkl)Y(K) 32) Solving for the elgen value yields: = (P-Okl) / ( 1+k2) 33) In order to determine the sensitivity to changes in P and Q, the partial derivative of the eigen value wltn respect to these two parameters is needed.

44 di/dP = (1Qk21 (this equals 1 for k2=O) 34) d Q = -(k1PK2)(1+QK22 (this equals -K1 for -zK2=o) 35) B selecting a large value for k2 it is possible to reduce these sensitivity measures and still select k1 (given k2) to achieve the desired eigen value (response). The problem is that (K) Is not available at time step K therefore an'a prlorl' estimate of Y(K+) must be used. Therefore the control law becomes: M(K)=-klY(K)-:2YH(K+l) 36) where YH(K1)=PH(K)Y(K)*QH(K)M(K) Te values PH an Q are estimates Of P ana Q wnicn must be obtained from an on-line estimator. In this case the modified Tunable Estimator discussed previously in the Self-Tuning Cfor te RbUSt FeeacK ontroller section is used. Tne case considered above for the Robust Fee-aback Controller is a Proportional action case. If this is extended to the Proportional-Integral case the controller becomes: where: K3=Kiat and Kl=Kp once again k2 can be used to reauce tne sensitivity to changes in P and Q and ki and K3 can be used to assign pole placement given k2. The Digital PI Robust Feedback Controller Is shown in Figure 18. Consider tne Robust FeeODaCk Controller In Figure 18. Tme transfer function is given by: Y(Z) = KlttQZ 38) R(Z) Z( 1+2)ZQitK2Q+KpQ-1-P)+(P-KpQ) And the characteristic equation is: Z21*KQ (QitK2 p -1P (-Kp)= 9

Y)I...............!.......I + ) INVId WNOD

Z=-B/2~.5 -fC where: B= (g,t-K2Q+Kp-1-Pj 40) (1*K2Q) C=(P-KpQ)/(1.K2Q) The Tunable Estimator is used in this controller to again update the values of P and Q. With the values of P and 0 and the user specified value of K2 and pole locations, the integral and proportional gains can be calculated from equation 40.The flowcharts and source code for the Robust Feedback Controller are given in Appendix E.

ANALYSIS OF RESULTS This section of the report analyzes the performance results of the three different types of controllers used in this study. As mentioned earlier, the maximum voltage that can be applied is ten volts which corresponds to an output signal of 2047. From Table 2 it was found that the gain at high speeds was approximatly 0.70. This means that the controller can control references speeds where (Ref. speed/.70)247. Therefore for this analysis all reference speed values will satisfy this condition. The results for the Digital P Controller follow. Digital Proportional-Inteqral Controlle The Digital PI Controller was found to work very well for all cases where P and Q were known except at low speeds (less than 400). The first results that are shown examine the effect of damping on the response of the DC motor system. Figure 19 shows the results of changing the pole locations from Z=~Oi to Z=.5_.5i for a speed value of 650 which is a mid-range speed. This graph shows that both pole locations seem to yield good performance and the error (difference between desired and actual speed) approaches zero at about the same rate. However, if the data is examined closer it can be seen that some difference do exist between the responses. Figure 20 shows the same data as Figure 19onyit examines the data between 1- and S seconds on a more detailed scale. This plot shows that the response of. the Controller with poles at Z=0~Oi. is much more erratic than t-he response of the system with poles at Z=.5~.5i. Placing the.'poles at Z=Q~Oi is called a "dead beat" controller. This method is the fastest way of obtaining the steady state value with no overshoot. It does however have the disadvantage of requiring high effort values. This high effort causes the system to be smewha..4-of fterra. 4 tic orP %41 %I jupy PaIng then% % poes t =5~

48 C,) z Z~,..r-. UN LA. +1~ +1 II II..J N I N..J CL LA~...................................... LA UO~.... iM ~~~~~~~ ~~~~ 1-'''''''''''''''''-'''''-'1' m {~~~~~~~~~~~..................................@ e.......@we...................... -.............. G E 1~~~~~~~~.............................................................................. LA CD~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ CaJ ~~~~~~~~':............................;...................................................................................4 ~................... L -LJ LD ~~~~ ~ ~ ~ ~ i, *' ~~~~~~~~~~~~~~:..........................~.......................................................................... CC CX~~~~~~~~~~~~~~~~~~~C o 0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~':',..d ~u t'.: 0, 0.

Z,,.I t- a~~~~i +1.J N N tL J'"...,' t ~~~~~~~~~~~~~~~ ~ ~ ~~~~~~~. Cl....: mY:... ~~~~~~~~ ~ L ~~.:.,:. *'* I~ ~ I::: I' -' 1:~ ~ I~ -~~~~~~~~~~~ ~: **'' ~ *~'.~ ~~~~~~~~~~~~~~~~~~~~~~~ u~j * * *.mp.~ q~. i:. ru: * ~ tn ~~~~~~~~~~' ~ i t'N ~~~ ~ ~ ~~~~~~~~~~ ~ ~ ~~~~~~~~~~~~~~~~~~~ i:: r r ~ ~ ~~~~. (.~~~~~~~~~~~V,,~i + U1 ~~~~~~~~~~~~~~~~:, Q:I O~~~~~~~~~~~~~~~~~~~~~~~~~~~~:6 LtJ: r.: I...~. ~ OW~~~~~~~."' tJ~I i~~ e~~~~~~~~~~~~~~~~~~..... r~~~~~~~~~~~~~:cn:~~~~~~: ~~~~~~~~~~~~~~~~~~~~ *: - ~ ~ ~~~~~~~ ~~~~~~~~~~~_..d-,,.... 0~, Y ~ CI~ ~ r ~ ~: ~ ~ - ~~~~~~~L ~ ~~~~~L ~ ~~' ~~ ~~ ~~I ~:~ ~:~ 0 o o ~ r ~ ~U o o ~ ~ ~ ~~~~~~~~- ~ r ~ ~ ~ " ~ r L~ ~o i~z CCl I ~ ~ ~ ~~~~~~~~~~~~~~~~~~ r'~ 1.2.1~ CT~~~~~,. I-'4 t/'J~ LY ~ Lt ~ ~ ~. ~ ~~ ~ ~ ~ ~ ~ ~ ~ ~~ ~ ~ ~ ~ ~ ~ ~ 1 ~ ~ ~~~,J~ ~ ~ ~~ ~ ~, u

50 magnitude of the poles is less than one, the system eventually converges to the desired steady state speed. Since there is some damping present, the system approaches the desired speed in a much gentler manner and thus the steady state error is much less erratic than with the dead beat controller. As was shown in the System Identification Section, the values of the open loop gain, open loop time constant, and discrete time parameters P and Q were not constant for all speeds due to non-linearities in the system. Problems can occur with the controller and system response if the parameters are assumed to be constant for all speed ranges. Consider the problem of using the parameters for a speed of 200 to design a controller for a speed of 1340. From Table 2 it can be seen that for an output speed of 200 (input signal of 500) P and Q are found to be 0.95 and 0.02 respectively. If tne desired pole locations are at Z=0~Oi and uslng values of P and Q for a speed::f 200 it can be found from equation 30 that Kp=50.0 and Ki=526.3. If these values are used for a controller to Control a speed of 1340 problems can arise. From Table 2 for a speed of 1340 (input signal of 2000) the actual values of P'and Q are 0.939 and 0.043 rather than 0.95 and 0.02. Plugging the values of P and Q for a speed of 1340 along with the gain values for a speed of 200 and working through equation 30 it can be shown that the actual pole location is Z=3.78,-1.98. Clearly both poles nave magnitudes greater that one therefore instability will result. This instability is shown in Figure 21 where the system response of a Digital PI Controller for a high speed range application using low speed parameters is compared to a high speed range application using high speed parameters. when low speed parameters are used for a high speed controller design instability can result. Since a single set of parameters cannot control the system over all speed ranges, alternative controller- designs are needed which compensate for changing parameters. The results for such a controller are examined next.

51 W X i.. X. -- J I"' -I Ct C: t J U'.................... ~: 3 C-, CL ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ C C:. ~ ~ c) h 0L.I i: ~~~ ~ ~~~~: i

Self-Tuning Adaptive Controller Since the parameters are not constant over all speed ranges and system Instability can result, there is a need for a controller such as a Self-Tuning Controller which uses an on-line method to measure the discrete time parameters directly and use them in the controller. Figure 22 examines the response of the DC motor system. to a Digital PI Controller and a Self-Tuning Adaptive Controller. This figure shows that both controllers-have basically the same response with the Self-Tuning Controller being approximately one step (0.100 seconds) behind the Digital PI Controller. This slight lag in the response of the system using the Self-Tuning Controller could possibly be caused by the parameter estimation algorithm in the Self-Tuning Controller. As mentioned previously, the Digital PI Controller does a rather poor Job of controlling the system at low speeds. Figure 23 compares the response of the DC motor system at low speed with a Digital PI Controller and a Self-Tuning Controller. As can be seen from Figure 23, the response of the system with the Self-Tuning Controller is far better than the response with the straight PI Controller. The Self-Tuning Controller is able to obtain a stable steady state speed while the Digital PI Controller response is very erratic. The erratic response of the system using the Digital PI Controller is probably due to system non-linearities such as the dead band shown in Figure 5. The Self-Tuning.Controller is able to compensate for these system non-llnearltles and control the speed better. Figure 24 shows the result of using the Self-Tuning Controller on a system where instability can result with a Digital PI Controller. As mention before; if low speed parameters are useO to design a controller for a high speed Digital PI Controller instability can result (see Figure 21). However, if a Self-Tunining Controller is applied to the system under the same circumstances the system is not unstable and the

i ji Z C~,..Z H1 U' >J 11 +1........,,.. -.......................,.......... _ LI I.,....................................................................................,.. 0 0N..... LiiCL ~ ~ ~ ~ ~ ~ ~ ~ ~ ~~~~C C, CDL~~~i..................................................................

I-c O-. "D 1 C 00 0 o................................................................... Age T~o....H~ _....................................... U N N I O J I —q LuJ " 0 u cL D"""""'"""" "~ t,...-. —---—..-........3~~~~~~~~~~~~~~~~~~~~~~~ ~YR~ ~SCCD~~~~~~

55 Z 1 - o o. I 0i 0 - 0 CDI I" - ~ o / o M 1 B -"'"'''''''"- -''........................................ *-.................................................... Z 0 WZ C 8. Q 0 0 0 v, ~ D

56 speed error converges to zero. Robust Feedback Controller The Robust Feedback Controller was found to perform quite well when compared to both the Digital PI Controller and the Self-Tuning Controller. Figure 25 shows a comparison of the Digital PI to the Robust Feedback Controller. The graph shows that both controllers control the system quite well, but as was the case with the Self-Tuning Controller, the Robust Feedback Controller appears to be approximately one step (.100 seconds) behind the Digital PI Controller probably due the the Tunable Estimator in the Interrupt Service Routine of the Robust Feedback Controller. Figure 26 shows the performance of the Robust Feedback Controller for a low speed application. The Digital PI Controller was found to perform rather poorly for low speed applications, but the Robust.Controller performed very well. While the Digital PI Controller performance was very erratic, the Robust Controller performance was very good. It was even better that the Self-Tuning Controller for this low speed application (see Figure 23). Due to the continual updating of the system parameters and its insensitivity to changes in these parameters the Robust Feedback Controller appears to be the best controller for low speed applications. Runs were also made to determine if the Robust Controller could control the system when the system was unstable with the Digital PI Controller. This could not be completed due to conversion overflow errors in the software routines during high speed applications. It is believed that the Robust Controller can control the system where the Digital PI Controller failed, but due to these errors this data Is not available.

57 0L L J_ J o0 -o. _. c4 I'''i' - - - - I - -- I i l........... =.8I..........I.....i.... z C~ -00 00 I —

58 o-I z U' IIr i~ tl~~~~l~ 0 0 1J~~~~~~~~~~~~~~~~C o...-.oo no~~~~~~~~~..=I C/)L I — 0..,~~~~~~...........................................w:............ 0 o ~~~~S.: Z 2 z 0 ~~~~~~~~~~.....................................................................".............................................. O.. ~~~o~~~~~~~~~ i CI 0)L CD..................................................................r. -JJ cn~~_I 0 L LI................................"........................................................... F- C~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ ~ ~~~~~~~~~~~L ~~~~~~~3~~~,~~~~~I ~LI.J 0) L c a v: ~ ~ ~ ~ ~ ~ ~...................................................................... L A l -................................................................................................ z Li~~~~~~~~~~~~~~~~~~~ Ll. [ 0 V.......................................................... Z rl u:~~~~~~~~~~~~~~~~~~~C oI Io. IZI~~~~~~l 0LIi

SUMMARY AND CONCLUSIONS This final section of the report summarizes the results for the three diferent controllers used in this project. Digital Proportional-InteQral Controller 1. The Digital PI Controller still appears to be the fastest way of obtaining the desired steady state speed (see Figure 22). 2. Increasing the damping yields better steady state error and eliminates much of the erratic steady state behavior (see Figure 20). 3. Instability can result if the exact values of the discrete time parameters P and Q are not known (see Figure 21). 4. The Digital PI Controller does not appear to be the best controller for controlling low speeds (less than 400) due to erratic steady state behavior (see Figure 23). Self-Tuninq Adaptive Controller 1. The Self-Tuning Adaptive Controller is good for applications where the discrete time parameters are not known exactly or are changing. 2. The Self-Tuning Controller appears to be slightly slower than the Digital PI Controller (see Figure 22). 3. The Self-Tuning Controller appears to be better than the Digital PI Controller for low speed applications (see Figure 23). 4. The Self-Tuning Controller can control a system which is unstable when a Digital PI Controller is used (see Figure 24). Robust Feedback Controller 1. The Robust Feedback Controller is good for applications where the discrete time parameters are unknown or changing. 2. The Robust Feedback Controller appears to be slightly slower than the Digital PI Controller (see Figure 25). 3. The Robust Feedback Controller appears to be the best for 59

60 controlling the system at low speeds (see Figure 26). 4. It is suspected that the Robust Feedback Controller can control a system which is unstable when a Digital PI Controller is used, however this cannot be verified at this time due to some minor software errors.

RECOMMENDATIONS The following recommendations are made: 1. Some additional work should be done to locate the conversion overflow error which can occur in the Interrupt Service Routine of both the Self-Tuning Controller and the Robust Controller during high speed applications. 2. Different sampling periods should be used to determine the effect on controller performance. 3. Different size inertial loads should be used to determine the effect on controller performance. 4. A gain schedullng algorithm should be implemented to determine its effect on performance. 61

BIBLIOGRAPHY 1. DYNAMICS OF PHYSICAL SYSTEMS, Robert H. Cannon Jr. McGraw-Hill, 1967 2. MODELING, ANALYSIS, AND CONTROL OF DYNAMIC SYSTEM, William 3. Palm III, John Wiley & Sons, 1976 3. INTRODUCING SYSTEMS AND CONTROL, Auslander,Rabins,TaKahashi McGraw-Hill, 1974 4. DIGITAL CONTROL, Rolf Isermann, Springer-Verlag, Berlin, Heidelberg, 1981 5. DIGITAL CONTROL OF DYNAHIC SYSTEMS, Franklin, Addison-Wesley Publlshing Co., 1980 6. ME561 CLASS NOTES, A.G. Ulsoy, University of Michigan, 1983 62

63 SYSTEM IDENTIF CATION PHASE MAN PROGRAM LEVEL 1 FLOWCHART UqlTI1ALEZATION SEND A ZERO TO THE MOTOR USER TuPrU VALLES PRINT BACK VALES IL. -rVLE I CORRECT? YES ICALCUATE THE TlHE VALUE CA~, INTI.L. SEND OUT PLLSE OiL0 TO WASTE IPlE ~~J.... ~IP ESTMAT('cI ~ ~)AIO i'CEUR ~ oSTrlT "~!

APPENDIX A SYSTE IDENTIFICATON PHASE FLOWCHARTS AND SOURCE CODE

65 SYSTEM IDENTIFICATION PHASE SUBROUTINE TO ESTIMATE LEVEL 2 FLOWCHART OPEN-LOOP GAIN AND TIME CONSTANT START INITIALIZATION PRINT OUT < DECISION SYSTEM RESPONSE I RETURN

SYSTEM IDENTIFICATION PHASE SUBROUTINE TO LEVEL 2 FLOWCHART WASTE TIME START INITIALJZ ATION ENABLE IITERRUPTS KILL TIME NO I DONE? YES DISABLE INTERRUPTS I RETURN

66 SYSTEM IDETI'FICATION PHASE SUBROUTINE TO ESSTIMATE LEVEL 2 FLOWCHART SYSTEM PARAMETERS USING A MRAS START INITIALIZATION INPUT USER VALUES PRINT BACK VALUES NO V UES CORRECT? AGAIN CALCULATE AND PRINT DECISION OUT SYSTEM PARAMETERS RETURN

67 SYSTEM IDERNTICATION PHASE SUBROUTINE TO ESTIMATE LEVEL 2 FLOWCHART SYSTEM PARAMETERS USING A RECURSIVE LEAST SQUARES MIETtOD START,...TU. INPUT USER VALUES PRINT BACK VALUES VALUES NO CORRECT? YES SPECIFY INITIAL YVLUES CALCULATE E(K+1) CALCULATE PH & QH PRINT OUT VALUES

6a SYSTEM lDERTIFICATION PHASE INTERRUPT SER'nCE ROUTINE LEVEL 3 FLOWCHART FOR DATA COLLECTION START INITIALIZATION READ THE VALUE FROM THE TACHOMETER I RETURN

C 69 C 4 C * C * ME600 PROJECT * 6 C * COMPARISON OF AUTOMATIC CONTROL SCHEMES * C * Z S C * SYSTEM IDENTIFICATION PHASE * 9 C * O C * RESEARCH ASSISTANT: DAN LYMBURNER * C * RESEARCH AIDVISOR PROF. CG ULSOY,2 C * *;3 C ****+******* **+**** ** t*tt****t* ****** 4 C 5 C THIS PROGRAM IS USED TO DETERMINE THE OPEN LOOP 6 C TIME CONSTANT AND THE OPEN LOOP GAIN FOR A DC MOTOR SO 7 C THAT DIGITAL PI AND PIrD CONTROL ALGORITHMS CAN BE IMPLEMENTED, 8 C THIS PROGRAM ALSO USES A MODEL REFERENCE ADAPTIVE SYSTEM 9 C (MRAS) SO THAT SYSTEM PARAMETERS CAN BE ESTIMATED IN ORDER O C FOR AN ADAPTIVE CONTROL ALGORITHMI TO BE IMPLEMENTEDo. FINALLY,?1 C THE PF'OGRAM USES A RECURSIVE LEAST SQUARES METHOD TO OBTAIN 2 C ESTIMATES OF THE SYSTEM PARAMETERS,'3 C 4 C THE PROGRAM SENDS A SIGNAL OUT ON DAC CHANNEL ZERO AND!5 C READS THE VALUE FROM THE TACHOMETER ON ADC CHANNEL TWOD C 9 C *. C * MAIN PROGRAM il C * - 2 n C #r r I 4. **- I *r** * ** * i F* * k * VP * Yr * * * * * * r * * ** Vr4.$**** 3 C 4 C 5 C'k * X; *vr* *;. %.. C, *- w v w * *4F* * l M C C INITIALIZATION 57 C * 4 4 4- 4 4 4.' 4 * *..... X C DIMENSIONt ADICVAL( 300), ADCHN( S), DACHN( 4), U( 300) O IN'TEGCER AICALD IIACVAL I LOGI CALi NADC %, N Cr ACH N rDACHN COMi1ON./I SRBLK/I J' COMONI/Drt CB LK,' IAC K / I DCHN 4 C t0ftr I0C1 q.'LC! L,,' IL AC 9 C H }dt C O(riCOM MMO N/A 1 /A, rDCL I U. I SE C I MAX 6 C.OMMOHON,/:r, I T I H ADI(CH-l( I )=O N tAC=I 1 I IJ-C =0 2 C 4 C, SENlI A ZERO TO THE DMOTOR * C O C CALL DAFC( O) 3 C C PROGRAM EXPLANATION *

C WRITE(3 1O) 10 FORMAT(/' THIS PROGRAM IS TO BE USEDt DURING THE SYSTEM'/ C' IDENTIFICATION PHASE OF THE ME600 PROJECT "A COMPARISON'/ C' OF AUTOMATIC CONTROL SCHEMES FOR CONTROL OF THE SPEED OF A'/ C' DC MOTOR USING A DIGITAL MICROCOMPUTER".'/ C' THE PROGRAM CONSISTS OF THREE SEPERATE SECTIONS WHICH ARE'/ C' LISTED BELOW:'/ C' 1. ESTIMATION OF THE OPEN-LOOP GAIN (K) AND OPEN-LOOP'/ C' TIME CONSTANT (T) TO BE USED IN A DIGITAL PI AND PID'/ C' CONTROL ALGORITHM.'/ C' 2. ESTIMATION OF THE SYSTEM PARAMETERS USING A MODEL'/ C' REFERENCE ADAPTIVE SYSTEM (MRAS) SO THAT AN ADAPTIVE'/ C' CONTROL ALGORITHM CAN BE USED.'/ C' 3. ESTIMATION OF THE SYSTEM PARAMETERS USING A RECURSIVE'J/ C' LEAST SQUARES METHOD.'1/) 8 r15 FORMAT(I1 ) WfRI TE( 3,20 ) 0 ^20 FORMAT(' PRESS RETURN TO CONTINUE') 1 REArt(2,15) KL 2 WRITE( 3,30 ) 30 FORMAT(/' FIRST THE SYSTEM RESPONSE MUST BE OBTAINED. THIS WILL'] 4 C' BE DONE BY PUTTING OUT A STEP OUTPUT ON THE DIGITAL TO ANALOG'/ 5 C' PORT. THE USER WILL NOW SPECIFY THE MAGNITUDE AND DURATION OF'/ 6 C' THE STEP FUNCTION.' 7 35 FORMAT(I5) 3 C O C * INPUT THE USER VALUES - C 2 C 3.O.40 WRITE( 350 ) 4 i50 FORMAT(/' INPUT THE MAGNITUDE OF THE INPUT FOLLOWEDi BY A'/ C' COMMA ( -2048.:X<(2047) AN INTECER VALUE') 6t FREADr(2,35) IMAX 7 5 WRITE( 360 ) 8 60 FORMAT(/' IINPUT THE PULSE WIDTH OF THE STEF' VALUE IN SECONDS.' C' FOLLOW THIS VALUE WITH A COMMA ( 1'X<25 )') REAr(A2 35) ISEC ~I ~WR ITE( 3,65)'2 65 FORMAT(/' INPUT THE TIME IN SECONDS TO REACH THE MAXIMUM'/ C' VALUE FROM ZERO. FOLLOW THIS VALUE WITH A COMMA.' 4 >READ(.735 v5) IR 7 C P'INT BACK THE VALUES. k3 C o. o f. *P Or 0. 0.1 ~ 1 4, r or 1 r.. fl *f1' 41, o. "P 1 9 C O kIWRlITE(3,70) IMAX 1 70 FORMAT(/' THE MAGNITUDE OF THE STEP INPUT IS',I5 ) 2 l4WRITE(3,80) ISEC 80 FORMAT(/' THE PULSE WIDTH IS',I3' SECONDS' ) 4 WtRITE( 3,85 ) IF 5 8 FORMAT(/' TIHE TIME TO REACH tMAX. MIAGNITUlDE IS',I5,' SECONDS') C C *: ARE THE VALUES CORRHECT?.98~~'"' C~".''""'"""''C* "" r. Y*'; * * " "" "' *r'*" "':$* *: * o C

., 31n, N OI. 1IISB3.=0 3.1J1 H3IF I1 3 01.;.o,.,., ~., J.$'t,,., J, -.,.o,-J,..J, i 3 6L V Cli 3 8L:. ( 0 )3V:i 9qV3 Z TIc, 3 9 Lt.3 5L 1: (. * 010W.3H J!0 H1.HS 01 O.3 H NS 0, 3 tL, IT ~4....** t.,4 t.~ *. 1.i ""'.'1 "4. "" X~ 3 /; 1 i 31SVM llV3 T1:1 3 O V(;., * 3WI1. 31SVM 01 3N1IIROlJPaS 11Y3, 3 E'V: 3 t.t,, t..t 6.1.6.,.i t..1 +.. $ - it,,-. T.........,.:, 3 9?7 t 1NI1.1I 11 3 3.....1:S' 3. ~ $ S~ ~ dRBB~1@N31U 3H 1 3 " 1:; ( / YOIO.L0 3H1 540.EJ trlVfiI 3HL 1331~~3 133150 J~n~3,tJ Cd N id n 8 8 /1 31J7.Y ~ 3ZI1VIIINI 01 3N u. ('a Os )31VO, 3 T9: f9 1:C 3 6;1Q ( >Oi014W 3Hi. WN-J3 VLV'di 3Hi 1331103 01 N>JnR3>' SS3;,d,/)iW0LV_ 001 &I:C *$:******* *-, *A.* 4 -,* o * * 4,,.,,.. A, -*, 010WN 3H1 W0O8.A VLVil 1331103 * 3. T C. 3. I CI 3flNI1.N03 L6'[ T' ( I' XS T //)LVJrO 6 6: (6)1 I (96 1 )3 ISM1 8I, TC 1' 1=N 6 0Z OiltO 3RNIINOO S.6?tY (; ~I-( T-N )nI=( N RI?o6 S'I' X 0 r=( N n7I ) 6 f tC ~6 01 03 (N'' 19 ) I Ot C; T6 01 03 (W 1'11 0 ) * I 6*1) r O+( W/XVWI )l~Oq~=H I C Z, 01 03 (0 L'034 W) SI L~C 9 ZP =N i0l 9T1: o=( I )RI _ I (- 9=N t~ I 0 WI01;I=N ~~t~ OT1'3SI= 1 C'*T/33SI *0* O~'-RI1 I 3 65 "Iv 4'44''4''44' 4*' 4'*4*4* 4 * *4%'4**' ~ $;*4 3 8_1.0 ~ s31RVN 3w1II1 3HJ. 3IVl31q VO3 * 3 LcTO.~,4,.~,4,.~.~.~*~~~3 O 9C t: C 3 & 1: C Ot 01. 03 (Z *t3' r'..I A' ( (' 1 )l1~V3O 06 l (,) ( ON=J'SRA=I ) iL~3Y.RM3 S3R9.1d 3Hi 3MYV / )VNMIIO: 06 gg l C

1. C 2$*t*t ***tt**t$$$ 3 W.> RITE( 3110 ) 4. 110 FORMAT(/' THE DATA HAS BEEN COLLECTED AND IS READY TO BE'/ 5 C' PROCESSED TO DETERMINE THE PARAMETER ESTIMATES,'/).5 1 115 WRITE(3 1i20) 7 120 FORMAT(/' WHICH DO YOU WISH TO PERFORM?'/ 3 C' 1=ESTIMATION OF OPEN-LOOP GAIN AND TIME CONSTANT'/ 9C' 2=ESTIMATION FOR USE IN AN ADAPTIVE CONTROLLER'/ O C' 3=RECURSIVE LEAST SQUARES ESTIMATION METHOD'I/ C' 4=OBTAIN ANOTHER SET OF DATA FROM THE MOTOR'/ 2 C' 5=QUIT' / 3 C' ENTER 1 - 5' ) 4 READ(2y15) IE 5 IF (IE,EQl 1) CALL KTAU 6 IF (IE,EQR 2) CALL MRAS 7 IF ( IE EQ' 3) CALL RCLS B IF (IE.EQ. 4) GO TO 40 9 IF (IE EEQ, 5) GO TO 150 0 GO TO 115 1 150 STOP 2 END C 4 C C r'"* *" * *' V 4 w Ic 4 6 C * 7 C i: SUBROUTINE TO WASTE TIME WHILE SC * INTERRUPTS OCCUR 1 C C SUBROUTINE WASTE COMMON/ISRBLK/I J 4. CiOMMONl'/A2//ITIM 5'WFRITE(3 600) %6.'6 00 FORXMAT(/' THE DATA COLLECTION PROCEDURE HAS BEGUN' ) 7 IJ=O 8 C ~~9 C * r'- 7% Xr, o. #., rrl ~. y,%- 4r 4 4 4 * * 4 4 4 4, f * O C * ENABLE THE INTERRUPTS CALL EN.ABLE C 5 C "'*:** ** * r C. C WASTE TIME,'?~ $:: ~,~.~ $'' *r r " A" l "' 4. 4''"'~, %%'. %''~' 4' 4'' *',,' ~' & % 4'k 7 C C 9 D0 700 I=1..ITIM C D10 6 _,O 5.3= 1 14- 25 1 6.0, CONTI 1' IUE 7 00 CON T IL UIE 5 C IDISABLE THE INTERRUPTS $ 6. C 4 r **; 4 **1;'. w.'r ^)r.; e,l',, C; q'.. e * 1*** * * * ** 7 C 8 CALL IISABL 9' RhETLli'RN 0' EtD'l

0241 C' 242 C 0243 C *I* *r ******** 0245 C Z INTERRUPT SERVICE, 02-46 C ROUTINE FOR DATA COLLECTION X 024.7 C $ $ 024.8 C t:**%******$***'*********''*,,,,**,*r~ *$*;*Y 024. C tJ, ir O, C 0250 C 02151 SUBROUTINE ISR 0252 DIMENSIONt AlDCVAL( 300 ) ACHN( 8) ), DACHN( 4), IU( 300) 0,25,3 INTEGER ADCVAL YDACVAL 0254 LOI CAL*1 tNA;ttC, NDAC, AtICHN DACHN v0255 COMMON/ISRBLK/IJ 0 256 COMMON /AD'"BLK/NAlDC Y AItCHN 0257 CfOMMciN/I;4, ttL K/NDACI DACHN 0258 COMMON/A1/ADCVAL IU ISEC, I MAX 2"259 C 0260 C ***"*', * *- * * *:***' * *' *' 4: *4 ) 4 4 - 0'26 1 C * GET THE VALUE FROM THE TACHOMETER, 02 6 2 C ****** 4 4' * *. 4. *,,,.'9 C 0264 I= I J+1:)265 CALL ADC( ADCVAL( I J)) 0266 CALL IDAC( IU( IJ ) 026?7 RE" URN 0- 2 68 Et4lENI 02' 69 C ~,'270 C:272 C, J273 C $ SUBROUTINE TO ESTIMATE OPEN-LOOP GAIN AND *:274 C % OPECN-LOOP TIME CONSTANT *,_75 C * 2n77 C?"79 C I t' I TIALI Z ATION, _ %C- w 4. 4.,, w',;.'' * *';* *.,.,,; * w * *, 4: f; 4.,,. 44. a,. 4'..'2..-. U *,a~. c!ROU-E ~l K'TAU ":237 ACr [ "? C I N T E.; E.. C.. I.. OT=ISE C* 10. 23 5 FORA I' YOU H/E -"' -J90 ~. ~,.,, * 4 t *,;-J;;**,.X.. qX.;,;......-.. *1 k 4,,, 1...,,,- *....-,,'. w X v X, a..'291 C:'294 C' OPEiN-LOOP GAIN AND TIME CONSTANT * YOU AY:' NOW:'/ 7295 C' =RETUfRN TO THE MAINt PROGRhAM'i:':;96 C' 2=PrRINT OUT THE S'YSTEM RESF'Oi'SE FOR THiS PRkOCEDURE'/:.;' C' Et'lER 1 OR 2' ) a'1,3. 1.2 FORMATiT(I1) "'299 REsAD(2 2152 )LJ?''.00 IF (;LJ.EQ. 1) GO TO 190

I. IF ("LJ -. EQ. 2) GO TO 153 7 2 GO TO 149 3 C 4C 4 C Ft% 01% q% for. 111%1 * * ~?,,~., *.% a, 0 o,.-I - ~ ~,,?, n-,*. 4,, t. or- *, OT. o r-* 5 C * PRINT OUT THE SYSTEM RESPONSE * 6 C'* " "* or',F * ~'*** * * q*~' P ** * *'' q'* *' & * V * *'* o' * * % or,* 7C 48 1153 WRITE( 1154) 9 154 FORMAT( ///,i5XP OUTPUT FOR SYSTEM IDENTIFICATION PHASE') O I;WRITE(1, 155) IMAX 1 M155 FORMAT(20X,' SYSTEM RESPONSE TO INPUT=',I5 ) WRITE( 1156) 156 FORFMAT(8X,' USE FOR CALCULATING OPEN-LOOP GAIN AND.TIME CONSTANT') 14 1WRITE( 1 160 ) 5 160 FORMFAT( /1/ 4vX' TIME ItlNCREMENT'r'l,6X' TACHOMETER VALUE',6X'INPUT' ) DO 1O 80: I=1IOT 7WRITE( 1 70) I rADClVAL (I ) IU(I ) *3 1.'70 FOiRM AT ( 20X?. I 3 s.1 X I 5i 9X I5 ) 180 CONTINUE 0 WWRITE( 1. 185 ) 1. ~185 FOtRMAT(/I' PRINT OUT COMPLETE') C2 GO TO 149 I3 190 RETURN.4 EtNDl C 4 C 7 C 8 C t; S.UBERkOU-TINE TO OBCTAIN PAR METER ESTIMATES 9 C: USING A HiODlEL REFERE'NCE ADAPTIVE S'.STEHi ( tiRAS) 0 C, C 2 C 3 C *'"",,"'"*r* % * * R"l""f''r *' *''': 4 C * INITIALIZATION * J C 4 or *r r; o *r- P; P -6-n or,- r, % p.ii% n' -P,r~ fr, P or' "r~ 47~ 01~ P' or~ 10,r. F. *. #P *. P P P 1. ~,,,o,.p or, C 7 cSUBROUTITE MRAS I MER tS " I T ADCV t4 300) I U(00) DfTpc I;.N 1H X, 300), XHQ(3O C'); )' PH(300 ) 3 F- 0 ) QH(300) DIIMENS.'.ION E0( 3030 ) IEN(' 300) E( 300), ER'( 300):. I1NTEGER ArCVAL.,C DACVALt 2' C OA CIE JN././iD C V' AL P' I EC' AX 3, C C.:. sX.:, %k 1,, A Z,,- *X- /4 4 *- tk s; k 5r C U tSE Ir:' U.T VVALUES' tt: or.'r. wr'1 wrb r wr #t r #t Sr + ~ r or. or, r rr' 1' or *r P orI' or - 11, r 1 Ir l 7 C C' COIMPLEE TE TE EST~iMATION PsROCEZUFE.' ) 3; 7210 FFORSAT (Fl o ) " 215 IWR I'TE( 3 I22 ) 220 FORHMAT(/' INPUF'T THE CAIN t{I. INCLUDIE Ai F'EERIO') READI( "'~10 ) AIK1 ~7 tJfRITE( 3. 2 30 ) 2 30 FORMHAT" /' ItNPFUT THE GAI"''2. INCLUIDE A'ERIIOD') 3 f;RE ADT( 2 0) At'2 t RITE( 3'271 )

',361 271 FORMAT(/' INPUT THE INITIAL VALUE OF THE COMPUTER MODTEL'./!;3362 C' PARAMETER "PH". INCLUDE A PERIOD' ) Z0363'- READ(2l21 0) APH ~ 364 "WRITE( 3,272 ) 0365 272 FORMAT(/' I-FNPUT THE INITIAL VALUE OF THE COMPUTER MODEL'/ 0366 C' PARAMETER "QH". INCLUDE A PERIOD' ) 0367 READ( 2,. 210 ) ARH 0368 WRITE(3, 273 ) 0369 273 FORMAT(/' INPUT THE INITIAL VALUE OF "XH". INCLUDE A PERIOD') 0370 READ(2,2102 ) XA 0371 C 0373 C * PRINT BACK THE VALUES $ 037 4 C * * ";" * *,, "; * * % * * r'*''k *,,* 375 C 0376 WRITE(3,275) AKI 0:377 275 FORMAT(/' THE GAIN K1 IS' F83+2 ) 03378 WRITE( 3,280 ) AK2 0379 230 FORMAT(/' THE GAIN K2 IS' F8.2 ) 0380 WRITE( 3,301 ) APH 0381 301 FORMAT(/' THE INITIAL VALUE OF "PH" IS',,, F7.4) 0382 WRITE(3,302) AQH 038~3 302 FORMAT(/' THE INI'TIAL VALUE OF "QH" IS' FF7.4) 0384 WRITE( 3,303) XA 0385 303 F ORMAT(/' THE INITIAL VALUE OF "XH" IS F7.4) 0386 C'" 8 7 C` r. r.`...; 9 **."..~.`~.`. ~;..`. 3. m``v *,4..4 *...`,`k. *. * 4ov w v` *k ~. 387 C 0388 C * ARE THESE THE CORRECT VALUES? * 0)389 C *".;. *""1" *r. *':* I,3C.90 C,3,91 WRITE( 3:310 ) 039'2 310 FORMAT(/' ARE THESE THE CORRECT VALUES-? ( =YES =.NO")' ) 0393 320 FORMAT(II) 0394 REAI( 2,320 ) LP C395 IF (LP +ER 2) GO TO 215 0396 C 39 C'''''!5 50393 C * DECISION 03C9' C,. 7.,~. IF,,~.,%.,.,~. r. dr-r.r.,r P r, r -,v or., r v #r, ~ or. or. or. *P. — *. 41r. r- or 0400 C 40-1 32"1 WRITE( 3,32 ) 0402 322 FORMAT(/' YOU' AR.E NOW,READY TO OErT"AIt" F"ARi;iETE; EST -.1hES., 04 03 C' DO YOU WISH TO:'/?tw AO4 C' 1}R;ETUFRtN TO THE rMAIN FROA'....::05j C' 2=REPEAT THIS ESTIrATE PfT;'CE'tUF E "! 06 C' IPR INT OUT THE ESTIMA"iTES %,'`. l-;5OCE UiE' ) 0407.323 WR I TE(3 3 24 ) t'0f 5324 FORtMAT(' ENTER' 1,2 OR 3` 409e REAID( 2,320 )L]J I;410 IF (LJ.E. 1) GO'TO 360 -- 11 IF (LJ EQ* 2 ) GC TO 215 412 IF ( LJ *E. 3) GO 0TO 325 0413 GO TO 323' 414 C - 4-I5 C *, J... ~...r r.r, / r.r. ~.,,,. rL. *,:: ~;e,...,,;.,,: ~;,-.- -. -; 04 1.6 C * SPECIFY INITIAL VALUE OF THE RESPONSE S 0 417 C * AND COM;'PUTER MODEL P'ARAMETERS S = *t 1 8 ~ ~r ~ fr.';- ~ ~' ~t'. t. qr,It. r. ~1~r'" f/ J' 1';' *r" \t.'/ X 1~ r';)* *f fr Y.; ~ *; *r' *',1q. <tF - r el; ". 419 C "..O. 20 "5 XH( 1 )=XA

PH( 1 )=APH Rtl( I )=AQH C 4. C * *~v*oo*t******,4***;4 **. z*** * **,.* W4*** C CALCULATE COMPUTER MODEL PARAMETERS * C *1% 01% q#I, Fs% f * q% * f or #. 1%'' 1%q or.* Ill ***** C IOT=ISEC*10. DO 330 K=IIOT X( K )=ADCVAL( K ) X( K+1 )=ADCVAL( K+I ) 2- XHO( K+I )=PH( K )*XH( K )+QH( K )*IU( K) 3 EO( Kt+ )=X( K+l )-XHO( K+I ) 4 DEt=N( K )=( 1 +AK1 *XH( K )**2 o )+( AiK2*( IU( K ) )**2 ~ ) E( K+l )=EO( K+l )/DEN( K ) v6 PF'%H( K+l )=F'H( K )+AKI* E( K+I )$-XH( K) 7 R0H( K+1 )0=H( K )+AK2 *E( K+ )*IU(K ) S XH( K'1 )=PI'I( K 1 )*XH( K )+QH( K''+1 )*IU( K ) 9 EER ( K )=X( t )-XH( K ) 0 330 CONTINUE 1 C 2 C:**'*.*. -******** ****** * - - 3 C PRINT OUT THE SYSTEM RESULTS $ i C 6 W WRI TE( 1,S 33) 7 335 FORMAT( //,1S5X' ESTIMATES OF PH AND QH USING A MRAS' ) ~ WRITE( 1336) IMAX z 36 FOPMRH"AT( 15X' SY'STEM RESULTS FORF ItF'UIT='IS ):) W'T IRITE( 1:3Z7) A1: IA K2 3.,37 FIR-tAT( 23X t',K C71 F, K2'/ t F7*" 12 IWRIlTE( 1 -339) 339 F FORMAT( //3X,' TIME',7X,'F'H' 8X / H' 7X X' p9X XH',6X'ERROR' ) 4 r 350 K=1.IOT 5;WRITE( 1 340) K PHI ), H K ) X K ) XH( K ),ER( K 6 340 F OF RT(iAT3X, I 3, 2,X F83,2X, F8,3 2X, FS 1,2t F8. 1,2XF8 1 ) J7 350 C.ONTINUE 8 1WRITE( 1 355 ) 9 355 FORMAiT( /' F'F: I T 1OUT CO M'LETE' ).0) GO TO 321 360 RETURN 2 EtN'Dr 3 C A C + 6 SUBROUTiNE FOR F<'r.tETE.R ESTIrMATION lT.LIZItS A * C *: R ECURSI'E LEAST SVUARES HETIHOD 8 C C C C -2 SUDROUTINE RCLLS i3 T1FDIMENSION7 AttCVAL( 300) THdETi( 300), IU( 3;0 ) Y'Ht 300) 4r fDIMENSION THET2( 300 ) F12( 300 )v Fl 1( 300 ) _ DfBIMEENSIONf F21( 300) F22( 300), Cl1(300) C12(300), C21(300) 6 DIENSION C22(30t0),-DEN( 300) EO( 300) F'H(300) 7 >INTEGER ADCVAL 3 CO.MON/A1/ADCVAL, I U, SECT IM:A^ O ~ IOT=ISEC *10. O C

i c * 4 >5; * * 4 *- * * * it * $** 4* * 4* w P'h. * * * 4* * 4.4 * t * S4; * $ * 77 4 C 395 WRITE(35v400) 400 FORMAT(./' YOU ARE IN THE SUBROUTINE TO DETERMINE THE SYSTEM'I C' PARAMETERS USING A RECURSIVE LEAST SQUARES TECHNIQUE. THE'V C.:C' USER NOW HAS THE OPTION OF0 9 C' i=RETURNING TO THE MAIN fIROGRAM' O C' 2-ESTIMATING THE PARAMETERS' ) 1 405 WRITE(3Y410) 2. 410 FORMAT( /' ENTER 1 OR ). 411 FORMAT(I1 ) ~ h'READ(2Y411) IL IF (IL EQ I 1) GO TO 560 5 ~IF ( tL'EQ 2) GO TO 412 7/&Ct Ta 405 C C ****** * * * *** *DECSO.1 C * * ******' "' s't'~ ~''~ $':. 2 C i 41 2 WRITI E( 3T413 ) 413 FORMAT(/' INPUT AN INITIAL ESTIMATE OF "H'"R. INCLDE A PEIROD') 41. FORMAT( F10 ) READ(2'r414) P A7 WRFITE( 3F415) RF I T E( 3 2 41 41 ) WRITTE3sF409) 1 409 FOTFRMAT(' INPUT THE INITIAL VA;LUE OF THE "F" MATRIX. INCLUDE /.' C' A PERIOD1 ALL INITIAL VALUES AR'E ASSUMEDt TO EE THE SAME. REA Ilk.(74 14) F 4. C 1 C. F'RIN.T.UACI THE VALUES -" q'' t"'"'41". t' $; %r 4' 4"',' V' V,, 4' ~'''' "' 4'!,v 4'~" $'* 4' S' 4' ~' *' 4' %1 C:( C I) 4 WRITE (3 41 ) P 2> 416 FORMAT(/' THE IN'ITIAL ESTIM ATE OF "FPH" IS' F4*2) WRITE( 3,417 ) 0' 417 FORMAT(/' THE INITIAL ESTIMAT'E O.F "RH" ISN' F F4. UPRITE( 3C409 ) F 4408 FORMAT( /' TTHE INITIhL V VALUE QF "FT" IS' FLfUE: 7 C A P VALES CAORRE'S TE R1tIf TE(: 3 2 418 ) 418 FORMtAT( /' AhE THE VALUES CORRECTCTv (t=YESF2t-NtOt))' )'I REAttIt(2-' F411 ) IH IF (IH *EQ. 2) GO TO 412 C C ir 4. rr *t, *i'7 o or 0.'T or il'1> T. r r. al Y" *r r -.,,'.,T..r 0 r. C SPECIFY INTIAL TVAiUES.F THE C 7 CO*PUTEF:' MCODEL F'A.RH-METER.,. -I~ C,rt','r.;r r. r,,i,*t;r r. Ar., r. r or, r.'.r. i r.''. or,,r. 1.et l,...', o i,. or,r C > PT( 1 )F=P

10I O =l 1 %06' Oil C I,-Y 0 HH i4) iVM, 0- XV+ I (OL''I- )3lf+ i )H ( O k-' I )3L 1I:`"'. S3nlt-1 ~nf 0MIIn'ot' 3 1.=9,;0 3:;I3:,,.3:M.: ~ 11z,,' -'.[ 3,,3 i.S3i1. ",A 3H1. li10 3 Hi: d, t 3 9 -IoO -Jl* "to: ~l:. J, -A %1,-J:,:.l t. -.U:~ 0 (- to ~.. l4:., G-,-:.t,:, -. l:.. I,, -.b:J..l -~ t, A.o:~ b --.f -~:" A ( ++ ),'-13-H=( It+i )HO 3 ) H ( t+>I )T13H~-=( t+'.4 )H3 3; J Ci.T IY 1VH W13H1 31A n3'3 IL 3 ( 0 3. I t(!{ )C 13> H-( M'.'- ) I( > )' 1.3H1 +( ) +" )' ('4 =( t'+ )03 6 (>4 ( +HIÆ3H )093 )*v1n( t 3 ( 3 ) 3 0 ( M~ )t%1, ( ri!i't ( ).$ ('1 T I(t+ )Nt 3 +)-( 3 )" =( I8. ) (\.N N!'32 f-I T' L-PO A 4 Z.Z 3: "IC I T)-('5 T PI( 3+T )cI o 8 3, N 3 1....: C C N )lI* ( T >.3: I ) +( )T T3 )-( Zd T 3=( I+ )T I3 Z 3 a;, c N)2 ~:~~~(' ( )Z3 +-() T3: It 1)N3I t 3 t (,.., t n i \ )Z;.+( N )I )- )T('I+ \ ):3ZO ~ (!l tu(~ uI 33O4t )e T( ( >, ),:+ \ )IO )3=S( N TN ZI )1 n n I( ( t )nI,( HE, 1+( ( H-)'' )'- T (( ( N> )HA- ),( ( N. )RI: N ( )lC ) 3S ( ( Z TH, - ):(. N I )g )=(T N )T TS ( 3 6 T t+N3N)l 31V'n:3:3 3 O 8 3 A (,3Mfnl113 0O.,d NOI~1Y 1SBT S3.s ~1]S IS~3 1I'flV31 3A OBM Nin33. I,/)INON:) 0' 0 Z'&' t 3i )Z1I 8Md Z ~% A,' -,'.;% -..4% -,.p-'.h.1 -',.1 -'. i'h -..%.9. -,. 4:%. b.1%.4.t.4..T%.-.1 -~..1.% T'0 =( I )Hi Z O=( tI ) B j=( I )gZ 1,=( T )113HI, } ~~~~~~~~A-=( T)t13Hl

:?.601 1WRITE( 1 480 ) K FPH( K ) THET2( K ) 79 "!60-~ 480 FORMAT( 20 oX, 3,2XF83,n2XF8,3)'6,03 490 CONTINUE:i: 04. WRITE( 1 495 ),:C65 495 FDORitAT( / PRINT OUT COMPLETE -I' 60Of 6 GO TO,3.5. 6t07 560 RETURN:'S68D EtlEND'-OF

3o0 ~ONflOS aNV S~LVHWOMOUL O~VVI1Sj3 31Vn.l o (IxCCicCCrtCC~~CC~dCCcjCCv

80 SYSTEM IDENTI'CATION PHASE SUBROUTINE TO ESTIMATE LEVEL 2 FLOWCHART SYSTEM PARAMETERS USING A TUNABLE ESTIMATOR START INMTALIZATION DECISION INPUT USER VALUES PRINT BACK VALUES VALUES NO CORRECT? YES SPECIFY INITIAL YfiALUES CALCULATE EO(K+) CALCULATE EK+ 1) CALCULATE F(K+1) CALCULATE PH & QH_ j PRINT OUT VALUES

/ _ HI.bA i.iiL U N iJ.,ilU..iibII Vii U 1 b l W i JU;i: bll,I l (.'. ( OI. )'3. I;'.i l J, ~, 1. 2. 1. 1 J 1 1 1, *. I,1.. J, 1. 1, 4,, ^,, l 4. 4.41.,,. 6.b.A T, 4. J t.1.4' NOI.N'Vld8X3 Wv+YJ.a0,, It J.4'~.'~ 4t' 4't'1 "t' I' % t %.1 * t.. or, C 1 s f.1.'ft 4,.t O,r Ct /1,I ~ 1,'1%.'1. is 1'' ~/ 1 3 r 17 U? 1'! 1 NH3 IV' 3I;0,'3"; = I O U 3..J *NH*3** * ** * *r **'"-~,-it3;_'" *,I, I'4 ~ IJ *3 f.H1 4: "' rN rI/t(;2It. I//lto Jt:_;'" I fl/ 1J N'~HOOHLd I I ZN' H'Ob I3NN 3 OH3.L 3O 3fl1O H 3H1 1. S; 1 3 3 3, v w I Z I, I v 3, V 1 D, INV O. C3Z I3NNIH3 3V3I NO 8i0 4 fl - NI V S'IN3S Nl d,'D.d t;:3H 3 0 3 ~ bS.~3i3WV,1. WN44*J tb,3J4.L SXS 3NoW4 fI 313 3SII3 3I DH1. NIVL]O 01.,313n1 SI,OLVWNI~S3 39Th N1 Vt *,,S3WHS 1O.LJINO3 3 L 31 Wo.LnwV AO NOSIVdNOW.03 V,, i33~'08d 0093W 3H~I V O 3SVHIV 3J9 NOIIV3UI~IN3'1I W3~SAS 3H~L SNIfl','13sn sI:7Od SIHI 3 & 3. xosqc,,nI' 4.44,4.I 4....4444,1A0 U OI U A O4,4 H3.4S 3 4, ~~ ~ ~ -J%%O162 o4*00&%'J l -.%%,4. 3 * Ct o t 4- _t _11. C "i J$ -11%.*+. If t -it -t 4v rr 4% ID -t 4t.1% Tt wl JI Ct 3r ep IP ^ ^ t 1 3 1% 3 T * S3W3H3S OtL.LNO3 3IiVWOIOV XO NOSP O *I ~, 3 9 3 4 313WVlY'Od 00931W 4 3 & 3 ~t 3 X aNV 0YYl37 NoY if 3 J) 3 6 oiivwoinv JO NOS 13V OV 133PO8 0093 3HI AO *SVY 3 9 L 4 3 r ) 3 0 6

82 0.61 C', IDENTIFICATION PHASE OF THE ME600 PROJECT "A COMPARISON,/ 0'0-62:; C' OF AUTOMATIC CONTROL SCHEMES FOR CONTROL OF THE SPEED OF A', 0J63 C'.DC MOTOR USING A DIGITAL MICROCOMPUTER"*'/ 0,o64 C' THE PROGRAM CONSISTS OF TWO SEPERATE SECTIONS WHICH ARE'/:!30365 C' LISTED BELOW*'/ 0066 C' i. ESTIMATION OF THE OPEN-LOOP GAIN (K) AND OPEN-LOOP'/ 0067 C' TIME CONSTANT (T) TO BE USED IN A DIGITAL PI AND PID:.068 C' CONTROL ALGORITHM.'/ 0069 C' 2. ESTIMATION OF THE DISCRETE TIME SYSTEM PARAMETERS THRI::070 C' THE USE OF A TUNABLE ESTIMATION PROCEDURE,'///) 0," 071 15 FORMAT(I 1 ) 0 072 WR I TE ( 3 20 ) {!.:073 20 FORMAT(' PRESS RETURN TO CONTINUE ) 0'.074 READ( 2w,15 ) KL 0,75 t WRITE( 3 v30 )'.:07.6 30 FORMAT(/' FIRST THE SYSTEM RESPONtSE MUST BE OBTAINED, THIS WIt >0077 C' BE DONE BY PUTTING OUT A STEP OUTPUT ON THE DIGITAL TO ANALOI 0)078 C' PORT. THE USER WILL NOW SPECIFY THE MAGNITUDE AND DURATION 0 079 C' THE STEP FUNCTION,' ) O:80 35 FORMAT( I5) C II'-/3~2 -'~ - q'* q" Ck'7 J~ 3) J~- % jl %,P, sip u,.- * q,, w' r,, q. 4,-, qt. %' Sel 4- % " %" 4" 4? 4" al l,, q'w eL ~'Ct,8 ( C INPUT THE USER VALUES * r nm,a,'- m* 4, mm,, 4, *, ~.v * em- raL,, *~, m P-,,v mv e m 0.0 5 C;-:.,,.,4. 0'. F:ITE( 3 50 ) c,-7 5: FOR,.T(' INPUT THE.AGNITDE OF. T/HE INPUT FOLLOWEDl DY A r /.),o. C'' ACOMiA ( -204 o'.S'.247) A N INTEGER VALUE' ) R,,35 ) I AX v0.0 55 IJRI TE( 3 _6.0 ).t09'v 606' FOFR:MAfT(,/' IV":N-UT THE PULSE WIDTH OF THE STEP VALUE IN SECONDtS. V00?2 C' FOLLOtW THIS VALUE WITH A COMMtA ( < 25 0Q O3 REAr:(2V 5 ) I SEC J0094 WRITE( 3 65 ),...,,095 65 FORMAT(/' INF'UT THE TIME IN SECOC'NDrS TO REACH THE MAXIMUM'/ ~:::?~6S C':ALL!E FROM ZEFRO. FOLLOW THIS VALUE WITH A COMMA...09, f:EAr(2r35 ) IR 0 r% 4, 40 4, 4J 4J;P 4, J,, 4,, /4J, 4, d 3, 4 * J44- 4p 4 W,*v* sV %1 J, w 4,4r 4'"00: C PRIF'R T BACK THE VALUES C.f.'....''-'. *, t~3K-'IT t 3 5T ) 7 J.I;7., F"O;fThAT(/' THE M,CNI:TUErL OF THE STEP INPUT IS'I5 "'F:i E 3 3 ) ISEC.3 FF:, AT /' THE PULSE W-IDTH IS'WTI3' SECONt' ) " " RITE( 3s 85) IF,. F-:'rM"TT"/' THE IE T RECH MAX AGNITUDE IS /I' SECONDS,\-,,-, s T E T ME T I ETO,'E A C H? APXi M i G N I T U 11 E I Y I5 ED ~.L; l * T. I'I ~ r. - q' el" *''1' ^ 91' e' *' 1'"' el 1' Jl ej' ~'11. el' e # l, flr~ el~, fp el~ es C """"0 FORCAT' A;RE THE VALUESES CORRECT? ( -=YES 2N) 7.F ( 3.E -. 2) G 404.4p4.. I' rC ~:' FF,'C CALCULAT E THEL TIE VALUESC 2=)

",&ffU.:I,..:I,:: UL ft."i'l UdU l., J.L ll,/ L'-.-.i.J J -'. T. ( OZ-T' ) 31I:'l [ S. T (/,'S31VWI1S3 N.3.1.3WV"..d 3H1 3N11Nt31312 01'13SS33:J0d,3) 1, 39 01.kriV3? SI IlN 1 11313317 13 UN330) SYH 33I l 3N1,/)~:3J3 H I' 0 T T I IE A I -J. Jo % 4, %,t,, ~ ~ i,. I ~,,,., 4,.I, J.1,,J, %,.4, %,,.,I % 4 -.I -A J. I J 4,J J..,;.,! % 1 Os -.1. -.It.J",4 4 4%,,~ 4. 4. 4~, 4,,. t.o.....,,.'.t ~. ". t 4,%. 1.,,,J -1 * 1 3 -31lY NOUI.LtWIS3 I1 0 3 dA1 HO 3I.t 3.4 ( o )3'Vi1 ii'7. I ^4% A + t ~ L 4 t - t.9 4l.'9'% 4~..~'9.I -~ k.1. -ft *.''t.~ ".'''' 3.,YQ010N 3H jjO ilnHS 01 0.'13TZ;,l13S "" 3 - t *1 t ^% J1. + ~s *t * * 4% * 1 * 7 \t d1 J7 *'h -t *I~ - t?% *t1.1 + S *t%'' *i'. ft'> + 3 31iSii 1t"3.5..~,(4it4lr tL 3l4 tI tt,*L ts#tvlitvtt,., 5,....5 bS,t,.lt J %.4' 3WI1 31SVM o31 3tIalnO,q S 99J, 3 4% -3'.1- ~'t - ~..1'.~ t ^6 -t%.~ ~ - -t.'' 4%'..1.,.1,f.1%.t l, t.i 3 1UNIINI 11' 3 - Sldf l.313NI 3RHL * 3 3ZIIVIIINI 01 3NIfl O)a nS V~.* 31 1.4 4.4 it -J I. 5, -.5 J1,.. e -.4,5.5,.. L 4., 5. %.4.4 o5... J'14'4. L 4 4 4. 4 4,.4t 3 3 qf'( S T' )I Z- I3. ( N A010N 3Hl WO'.3 VVlbll 3H1L 1331103 01 NYnni 13 SS3Md.1 )I" UVW'u0 OV T ( 001' ~ )31:t'M 3 j 3 3'T-N L O L ~3flNLN3 r, c tI-( V- ) I =( )fI ~6 ~6 01 05 VI+( T-N )11I=( > )11nI 1T6 G6 01 05 XVWI=( N )0nI Z6 ~6 01. 0 (N 1* ) 1I T6 01 03 (0 N'i' 4') 41 g' 0+( W/XVWI )iVOl-l=VI Z6 01 05 (0 0*U3 N) AI Z" =N ~6 01 0=( T )XI W-1=N ~ O.33.S I= ~5T/33S1 * 0Z.=NII o****** ****++ *o +** + ^ * + ** * **.** **:,****,* 3 — ~:, --

S181 C' 1=ESTIMATION OF OPEN-LOOP GAIN ANDt TIME CONSTANT'/'182 C' 2=ESTIMATION USING THE TUNABLE ESTIMATION PROCEDURE-'./.'183. C' 3=OBTAIN ANOTHER SET OF DATA FROM THE MOTOR'/ 1' 84 C' 4=QUIT' / 2 185 C' Et'TER I - 4').!186 READ(2 15) IE 08.7, IF ( IE.EQ. 1) CALL KTAU,.188S IF (IE.EQ. 2) CALL RCLS? -189 IF (IE #EQ, 3) GO TO 40 )19O0 IF (IE.EQ# 4) GO TO 150 0191 GO TO 115 0192 150 STOP o0193 ENrD "1 94%/5 C 2? C f1 r C' 197 C * v 2'98 C. SUBROUTINE TO WASTE TIME WHILE:)179? C, INTERRUPTS OCCURF'"200 C':23 l s o. S7 or o1 02 o r n of% q fr Jr Ol q% tr 01 w r OF l Sr q or qr In S r o r, or r1 1r 01% or 0 r- or- or or VP 0wr 01 3r "I, q,..V-2 C:203 SUBPROUTINE WASTE 0'2 2)04A COMMON/I SRELK/I J 0205 COMMOtN/Ao2/ITIM %'205 WRITE( 3, 00 )''7207 600 FORMAT( P THE DATA COLLECTION F'ROCEDURE HAS BEGUN'),,208 IJ=O0 2 10 C "11 C ENABLE THE INTERRUFTS.. 21 C >' ~' ~* 3''' 7- ~'"'"""~'" ~ "''; F CP ~'"": ("'* 4,+ ~ 2194 CALL ENABLE'! 215 C,1 16 C:2!7 o C Op WASTE TIME'>' 0 C 4,.444 -'* -4, 4,'4kI 4'Jf * / v W*S r 4,4, 4- 4''4'? 4 4,'4i L U ~ Ct~ ~)*'P'P CT. C'-. Li W.,,r'r`1.,,,'IN,,'rrr-,'',P *T' r%''T'r-oroTr,',P'7,','?"21?" C''-220 DO 700 I=1 ITIM;:2 2 3D1 r o.0 J=1 14525 A: X'" 5 0 COltT I NUtE 700 CONTINUE -~'.. C _""'" 5' ~' "" "~' "' ~'~ ~ ~'" ~ }.r:. 4 4,' 4-4O.', 4 " -4'' 4- 4, 4',,4-' Q *,4,,' 4 4, ~ l~'~ q* -n.,r or Or -'T - q" qI In, J, Or. or, O, -yP o,,~`1 on, q T %,,, o, ~, * p n r 1 er % erI q% fi 226 C, DISA LE THE INTEFRRUPTS,-,?~.', V, C,{ 4..'j,,4-4 4. 44, ~4.',,. 4, 4-, 3, 4- *4,. 4,, 4- I-.-,4- *- 4, - 4' 4'r V', nN'7 "'rO.O "I In 7' o r' O 2C7 C.'~.:! 27 CALL DISABL *30::'3 RETURN.;.31 END...,LL ~..35 C: * ":' C 4 IN TERRUF'T SERVICE *';237, ROULTINE FOR DATA COLLECTION *._3. C'''240 C

3 * 3SN0dS3, W31SAS 3H1. iLl itIIiJ. 3 3 6 T O.L 03 ~vrt 01 OS (Z'*03' 1' ) JI 061 01 03 (I *'03 rl) JI ( II )T i'1 )O1 3:"J (, LQo I T31NI3,33 I/ 3nG3f30N.:J SIH1 0A 3SNO.dST3 W3.LSAS 3H.L lGRO INI..d= /3,/, WNOI~J:.d tNIYN 3Hr1 01 NIYi131=-I,3 I/,:1MON kAVw noo. *'IV~SNO3 J 3BWIl J.IN NTIVO,dOG1-U.0.3 /,.3H1 3N IW M31.3i 01 3NIlh1f3 0 lS 3Hi 13.II31N3 31 Y3H iLO k,- ).1,J S T ( ISt ~ )-'i. c' r:, * NOISI33 - 3% 3 NIVA'311.3 i. nVLL;4 3 N3Iif ~n S 3 E X NOIAvI VZI IN I 3 3 *3 * INVLSNOY3 3WI1 d00l-N310 *3 JO ~* IXIN NIV3.I00T-N3d0 31VNILS3 01~ 3.Ilnf0>lS, 3. 3 1.:BHO13 C 3 Nnl3.3Y E ( (I )lV )il )3k1il Y1V3 T+C'I=fI * )4313JWOH3VIl 3H. WOY;I 3i1VAS 3Hil 13 * 3 3 XVWI'33SI'flI lVA3VtV/I/NONW03 NH3Ol i' 3OIIViN9Y/3fQII3'NOW03 NH3IV' 3']IVN/..N]3'I /NOWWO3 rI/.Na S I /NWONCO3 NH3 VI' NH3'IV'3VIN' 3flVN T.~119 I J0 1 1 A31li' 1V(A3,V.Y3331PiI 1 3SI 3NIlnOY'lS 58ss ~~~~~~~~3

w301 WtRITE( r 155)' IMAX.3.2 155 FORMAT(20X'w SYSTEM RESPONSE TO INPUT=',I5 ) 0 303 WHRITE( 1 156 ) 0'304 156 FORMAT( S8X' USE FOR CALCULATING OPEN-LOOP GAIN AND TIME CONSTAN 0 305 WRITE( 1,160) 0306 160 FORMAT(//,14X,' TIME INCREMENT' r6X,' TACHOMETER VALUE',6X,'INPU 0307 tDO 180 I=1,IOT 0)308 WRITE( 1,170) IvADCVAL( I)IU( I) 0309 170 FORMAT( 20XI,3 v19XI59X,I5),310 1 80 CONTINUE 0?311 WRIT E( 1, 185) 0312 185 FORMAT(/,' PRINT OUT COMPLETE -') 0313 GO TO 149 0)314 190 RETURN 0315 END 3 16 C:3.17 C 4, + * c. 4 **** * * ***:,, 318 C * * 03w19 C * SUBROUTINE FOR TUNABLE ESTIMATION PROCEDURE * 03 20 C * -Z7321 C * It, r**4*0****** r*:;***$*If *.***** ****"* f4%0r**7 *** 0322 C:0323 C 03,b. 24 SUBROUTINE RCLS 30.325 DIMENSION ADrCVAL(300), THET1( 300), IU( 300), YH(300) 0326 DIMENSION THET2(300), F12(300), F11(300) 0i327 DIMENSION F21(300), F22(300), C1I(300)v C12(300).-C21(300) 0!328 DIMENtSION C22(30) EN(300) E3) H( 300 )) 0329' D:IMENSION YHO( 300)) ( 300), E( 300), IDF(300).'330 INTE'EGER ADCVAL )3 31 COMMON/A1/ArtCVAL IU, ISEC, IMAX 0332 I OT = I SE C* 1 0 0333 C "334 C *;6 4z; *,. 4. * **** * *. * v 4* C 35 C DECISION "~1 ~3365 C' ~'4 41'' ti Q/, %XI''/ %;I. 41 %"ll 44 *'' 4.'~ 3.'1~ 6 C -'11% el%"OP'1 P ~I%'q. IVI lq-'' n% In In% 7..'7m q` q'. " % l q % q'' IN *P 07% e 1 "I,I P 17 qt. q r ~'~ 01 e. 0'337 C i3 3,'"o;?. WRITE( 3400):339' 400 FORMAT(/' YOU ARE IN THE SUBROUTINE TO- DETERMINE THE SYSTEM'/ 034 0 C' PARAMETERS USING A TUNABLE ESTIMATION ALGORITHM. THE'/.,."341 C' ULSER NOCl1 HAS THE OPTION OF:'/:342 C' 1 -=RETURNING TO THE MAIN PROGRAM'/ t"'0343 C' 2=ESTIMATIN"C THIE PAF'RAMETES ):'.44. 405 W'FRITE( 3.-410 ) 10 Fe:-4AAT( /' ENTER Oh' 2 6')I C411 FOPM.AT(I1I)'.-, REArD A2 v 4 11) IL'348 IF (IL ERQ. 1) GO TO 560'"3:49 IF ( IL EQ. 2) GO TO 412 GO r TO 405:5si. C':375 C G USER INPF'UT V'ALUES ),.354 C r %.?* #* **'* *t J' ** *** * +.'0 "5 C.- 412 I WRI TE( 3v413),,...7 1. 3 FORMAT( /' ItF'UT At INITIAL ESTIMATE OF "PH" ItCLUDE A PERIOD.', 3. 60t 1 W ITE(3 41 5 )

1 415 FORMDAT(/' INPUT AN INITIAL ESTIMATE OF "QH". INCLUDE A PEf:ID') READ(2 414) Q 3 WRITE( 3, 409.) 409 FORMAT(/' It4PUT THE INITIAL VALUE OF THE "F" MATRIX. INCLUDE'I S C' A PERIODt ALL INITIAL VALUES ARE ASSUMEDl TO BE THE SAME.' 6 READI(2,414) F 17 WRI TE( 350 ) 3 350 FORMAT(/' INPUT THE VALUE LAMBDA 1* INCLUDE A PERIOD' 9 READI('2t,414) ALl 0 352 W.RITE( 3,354) 354 FORMAT(/' INPUT THE VALUE LAMBDA 2. INCLUDE A PERIOD') 2 REA1t(2,414 ) AL2. C C * PRINT BACK THE VALUES * 6 r. "I. vrll 1% 0e -P,% q%1p15 % q r n o#%'l, 0-: q6norq* If # 5%s* #5 #I n%#5.-ns, 5P or C'S WRITE(3,416) P ~' 416 FORMAT(/' THE INITIAL ESTIMATE OF "PH" IS' F4*2) 0 WWRITE(3,417) P 1 417 FORMAT(/' THE INITIAL ESTIMATE OF "QH" IS' F42 ) WRITE( 3,408 ) F 408 FORMAT(/' THE INITIAL VALUE OF "F" IS',FS.3) -, W'I;RRITE( 3,300) ALl 300 FO'RMAT( /' THE VALUE LAMBDA 1 IS'F6.4) tWRITE(3 310 ) AL2 3/ 10 FOFRMAT(/' THE VALUE LAMBDA 2 IS' F6.4) 8 C t 4#C * "' * 3*' *' 40' i' 0' " o' ~' Pr* fr " " v ~' ~' n' "'*,* *In%***** O Y''RALUES CORRhECT? * 1 &P q% ors ~CC q"W #t ~14 ~P tr wr e #ts eF qq C;3'WJRFITE( 3 418 ) 4~ S418 FORMAT(/' ARE THE VALUES CORRECT? (1=YES,2=NO)''5 READ(2, 4111 ) IH 6uS IF ( IH *EQ. 2) CG TO 412 7 C'8 C * * *r **'I'*: w r % % 4 4 Q 4 4 4 - * 4, e *. %. *, *, 4 4, -, *. % 9 C;,SPECIFY' IN4ITIAL VAUES OF THE.0 COMPUTER MOlfEL PARAMETERS t C:.,.,,, ~ ~. ~. L J~ ts -,,, ~.~2/ ~o ~ Jt ~,,- Jr~,6rJ ro. ~ ~, ~.* I C. C 3X ~ F'H( I )=F; THETI( I )=-P %J THET21( I )=Q 6 l: FI( I )=F * F 1( I )=0. ~8 ~F2 ( 1 )=0,. F22( )=F 2 BYH( I )=0. 3 C * ESTIMATION PROCEDURE $ 6 WCWRITE( 3,420 ) 7 4,20 FfORMAT(/' STARTING RECURSIVE LEAST SQUARES ESTIMATION PROCEIDURE'' tDO 425 K=1 IOT):i YYHO( K+1 )=( F'H( K )*YH( ) ))+( THET( K )IU( ) ) rt ~Y( tK )=AITltUAL( K )

'.421 Y K+1 )=ADrCVAL( K+) 88 0422 ED( K+1 )=Y( K+I )-YHO( K+1 ) 0423 C 2;424 C * CALCULATE E( K+tl)'~5 C O-26 Cl 1 K )=( F11( K )( -YH( Kt )+ )fF12( K )*U( K ))*( -YH( K ) 0427 C12( rK )=( Fl ( K)*( -YH( K))+tF2( t )*IU( K ))*IU(K ) 0428 C21( K)=( F21( K)*(-YH(K) )+F22( K)IU( K ))( -YH( K)) 0429 C22( K )=( F21( K )( -YH( K ) )+F22( K )*IU( K )*)IU( K) 0430 DEN( K )=C1( K )+C22( K )+1. 0431 E( K+l )=EO( K+l )/DtEN( K ) 04 32 C 4 33 C * CALCULATE F(K+I ) 0434 C 0 43. 5 DF( K )=Cl 1( K )+C22( K )+( ALI/AL2 ) -Ar 6 Fll( iF l )=( FII K )-( Cll( K )*Fll( K )+C12 K )F21K))/DrF( K ))/ALI F12( K+l )=( F12( K )-( Cll( K ),F12( K )+C12( K )*F22( K )/ )rl( K ) )/ALl 0438 F21( K+1 )=( F21( K)-( C21( K)*$FI( K )+C22(K )*F21( K ))/IF( K ) )/AL 0439 F22( K )=( F22( K )( C21( K )F1 2 ( K )+C22( )2 K )*F22(K) )/DF( K ) )/AL 04..40 C 0441 C * CALCULATE THETA HAT AT K+1'AIr42 C 3.-43 THET I( K+1 )=THETl( K )+( Fll( K )*( -YH( K ) )+Fl2( K )IU( K ) )E( K+l ) 0444 THET2( Kil )=THET2( K )+( F21( K )$( -YH( K ) )+F22( K )4IU( K) )*E( K+l) 0-445 C }-4.46 C * CALCULATE F'H AND QH * ~ A.. 47 C 1483 F'H( Kif1 )=-THETI( K+ ) 4- C QH( tK+l )=THET2( K+t ):~r50 YH( K+1 )=PH( K+l )*YH( K )+THET2( K+l )*IU( K ) 0r51 C.52A CA A. r l V "' %"' 4': w **' * *'''' * 4 r'04 53 C * WRITE OUT THE VALUES $ 0454 C'-,' * *** * nA55 C 0.4,56 425 CONTI'NUE. 457'FRITE(, 430 ) 0.53 430 FORMAT (/ ESTIMATION PROCEDURE COMPLETE. PRINTING OUT VALUES'):'459 WRITE( 1, 440 ) 0-4.60 440 FORhIAT/,/, 18X,' TUNABLE ESTIMATOR ESTIMATION' PROCEDURE' ) 4-r61 WRITE(1,450) IMAX ~ -....., 450 FORMAT(2" X., SYSTEM RESULTS FOR I4NPUT=,I5 ) -'.. I'RTE( 1 4-LO) P:p 0, F':.4 460 -rFCRffhiAT( iX~ s' INITIAL F-'H=',F4.2,' INITIAL QIH=':F4.2 I F =' F83 )....,.1. WtsRITE( 1' L4.L5Z ) L1, AL2 "..6' 4"'' FOFRHAT('"X['L hPD" 1P' A F6 4IO0XP'LA KBDA 2=' 0F6,4) ~i.167 Wt171RIT.E( I 470 ) 6 7' FORMlAT( //,2 2X TIE' 7X,'H' IX 8 H ):DO 4.90 K- P 1IOT ";.70 Li'1TE(.4 j0) KP'H( ),THET2( K )F1( K )FI2( K ),F2I( K ),F22(K ) ": 7J1 ~4r'"3 FCr"HAT( 2' XI 3,2XFS.3, r2XFS,3,F2XFF10 3,f2X, FI0.3,2X F10.3 2XF10, 1 ".472 4C0t C.ONT I %NUE - ".; 173!RITE( 1, 495 ) -74 4.95 FORtiAT(/,' PRINtT OUTr COMPLETE' ) " 475 GOCO TO 395'..176 560 RETURN i'77 EIND I F

APPENDIX C DIGITAL PI CONTL I FLOWCHARTS AND SOURCE CODE

89 CONTROLLER DESIGN PHASE MAIN PROGRAM LEVEL 1 FLOWCHART DIGITAL PI CONTROLLER START INITIALIZATION INPUT USER VALUES PRINT BACK VALUES NO OY LUES CALCLATE CONTRO VALUES CALL INTONL CALL WASTE PRINT OUT VALUES PIECISION RETURNA

9o CONTROLLER DESIGN PHASE SUBROUTINE TO LEVEL 2 FLOWCHART WASTE TIME DIGITAL PI CONTROLLER INITI ALZATION ENABLE INTERRUPTS LOOP TO KILL TIME NO DONE? YES DISABLE INTERRUPTS IRETURN i,! i Ki..

91 CONTROLLER DESIGN PHASE INTERRUPT SERVICE ROUTINE LEVEL 3 FLOWCHART DIGITAL PI CONTROLLER START INITIALIZATION CALL ADC (GE TACH VALUE) CALCULATE TIE ERROR CALCULATE THE CONTROL CALL DiAC (OUTPUT THE CONTROL) RETURN

.i:13 Lr I u.t'1 d:i 3'W't'30, 3 C) 3 3 Y3 ( 0 )3V'I 11 -i. 3 9.~:,~,%.h.;I..'~,.''. AN.. %.V,;,.,',-.1' b.':,,.-;' -'%.' -'.',',.d'.'14 - 1...,'~.'. ~.'.'N h. [,., -, *'h V t 3, l *:IiO1O 3H1I 01:. W 1;IU13S' 3 4*.,'I.- J.;r.'~..,;.,-.'$.'~..'..;'.:%.;,'X. -%...G.$ ~ -X tJ.'t..,'.'*.'l.O..G. O. -i.J'..t..;: %'..'..%I. e-/ 3 T=3yIu *1> G-t'1. 1:.NHO';I _=( I )I'V l'.3;lV *9'' ";,/)l L 1I90 / O1l1!4 J J3 HI H.;GI' ~:3;I'J"t',,' I I,' J' =o 03? I;lI 1 )11 LfS ~ I /' Y4 0 "' Tt'ntf J`0' I HI3l I 3 te, t I 3;1' I1T 1 i I 3 /, NowJ rr tr., SI N OV0d 3 I A,', n.%~' J'~4.) II J ~ J'3 1 I I (O0~ )I (: )>NW'(. r.JN; t ('5 )Ht~3'' 00 C )1YA,31I)! U0 SN3WI"I 6 3...X.-A* -A.-J.dv 4, -A IN.v. Z *%. J4 -.; -l j.'Je'o'J e'b.*. -'J 4,... l ~.UJ,. -., -' J -J to.A,, - NOI iVZI4~IIINII. 3 S.~'.6.%...-TL.;%.%-.7.1 -t.'B.>..'.'t -~'. t. 4 4, -..'. -.~..t?.~. %. f.-'' NV:O33-.d.t{IYW, 3 ^6 t ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~3 d 3 4., -.,,.,........,.,.......,... *.l., %U o.,,.,.4:., 4.4.-.to.-A.,.-.U.,... *..:'I~~~~, * ~.'""'""'"' ""'"3 T 3 OMi1 I13NNVH3 331V NO 8313WOH3VL 3H1 W0}8 3TlVtA 3BrI SG1V3Y 3 IINV OY3Z 13-NNWH3 3Vs1 NO no lIVN5IS V SIN3S IWSOY30,,: 3HI 3 8'.310YlINO3 (Id) 1S'33iNI-.)VNOOIilOd00d8 7VlIl3I;1 V SI WNVS30H 3 MVfl3ROI V. SIHI NI I3Snr WHI.IO3:1V 3HI',,l31R3WO3m3Iw 3 l~I3i 1 V 3t NIS1fl 8O1Ow 3;1 v O 1;33dS 3Hi:O'1O INO103 3 )OA S3W3H3S OMLIN03 3IIIVwOivW O NOSI.VdWO03 Vu 1i33Of' d 3 0093W 3H1~. JO 3SVHd NOIS3I1 831081i1 NO3 3H1 3'3NITf;nI.')OION 3:1 3 V AO'133"dS Ml00.L 4 3H1 1O NM!N03 1. *'1303S SI -14V MOO8 S tHI *X~ ~ ~~~~~ X+~~~~~ 3 *, A.osin'9 *'OA8d:O0SIA9IV H38V3S38. 3.'3N'1fi4nA'1 NV;I:INVLSISSV HM3>JS393 M 3 *.3 )J3T130A.L NO3 Idl 7'1I3I3I I. 3 * * 3 ~ ~,SV ~SHd. N31S3;1 33T0'1O N03 N * 3.,., 3 * S3B3HH3S OOYiNQ3 3lW1N1O~ti dO NOSIWAd!S03. 3 $ 133fOYd 0093W 3 ~ *. 3 *t26* " ~.? * - $ - $.$.S.'..$.'~.~.'t'.'~.-3

Oo0 1 C -&''t'* tS 4 4 $t; W; * 4 93.062 C 0063 WRITE( 3 10 )'. 4. 10 FORMAT(/' THIS PROGC^AM IS TO BE USE-D IURItNG THE CONTROLLER'/ O.065 C' DESIGN PHASE OF THE ME600 PROJECT "A COMPARISON OF AUTOMATIC VV6 6 C' CONTROL SCHEMES FOR CONTROL OF THE SPEED OF A iC MOTOR USING 0067 C' A IIGITAL MICROCOMPUTER". THIS PROGRAM UTILIZES A PF'ROPORTIONA 0063 C' INTEGRAL (PI ) CONTROLLER TO COONTROL THE MOTOR SPEED.') 0069 12 WF:ITE( 313 ).07 0 13 FORMAT( /' THE USER NOW HAS THE OPTION OF#'/,V7 1 C' 1=QUITTING'/ 0072 C' 2=IMF'LErENTI4NG THE CONTROL ALGORITHM'/ 0073 C''/ 007 4. C' ENTER 1 OR 2') 0(075 15 FORMAT( I ) 3076 READ( I15) KL 0077 IF (KL.E. 1) GO TO 150:307 8 WRITE( 3 30 ) 0079 30 FORMAT( YOU HAiVE ELECTETD TO IMPLEENTT T HE F'I COT'R;OL.'80 C' ALGORITHM. THE USER WILL,NOW BE ASK-ED TO INIUT THE'/ 0031s: C' NtECESSARY CONTROL VALUES,'):0832 3k5 FORMAT( 5) ~03S t C 0084. C ** * v'''*':' **. * o.*'' "" %' on o.':.'*'.. 03.,5 C I TNPUT THE USER VALUES 008,6 C'' **:*'*'~**''* * ** 0,087 C 0083 40 WRITE(3 50) 008 50 FORMh'AT( /' INPF'UT THE MAGNI TU DE OF THE SFPE-ED VALUE FOLLOWED BY A 00 0 C' COMMA (-42043-X<2047) A'N INTEGER VALUE' ) 009 1 READ( 2 35 ) IU,092 55 LWRITE(3b60) 0093 60 FORMAT( /' INPUT THE TIME TO CONTROL THE MOTOR SPEED IN SECONDS. 0094 C' FOLLOW THIS VALUE WITH A COHMA ( 1 <X- 25 )');^00955T READ( 2.35) ISEC 03096? 6. F ( IEC GT" 25) GO TO E5 009 7 WRITE( 3 s 62 ) 009,8 62 FOR'MAT(' IN UT THE rEAL PART OF Z1 I CLUDet A F'ERiOD');0-?: 6}'. 4. FORMAT(FiT( O. ),10.0 REA.D( 264 ) 6 ZR'101 ~R I TE( 3 66, )'02' F? iAT( /' I i'F'T T LE i iA'i' F'AZT OF Z. 22". ItNCL UE Ai F'R I OD?lr. ffI.. lJFUITE(T E 3 6'-'!67 FORHPAT( i' INPU -FT T HE RFEAL ARF''RT OF Z' &22 INCLUDE - I'ERiORD ") "' Ait ^64 ) IN'"107'*RI TE(3 6- ) 1.'~.. 74' FORFiAT(/' INlF'PUT TH.-E RT'OERAFLl F'AFA;MET EO I SE-"0.iLCLUUIDE A f'ER i'OCiT 0I 0,: REAIT( 2,64) }Z:'1.:. WRI T'E( 36) "108 *8, FORF'MiAT(/' IA F'NPUT THE C.,TEtRR F'AT Pi ER10 "IN SC.i UC LU!E A F'ERFI Ot 1l].~'^ R<EAiI(C 2 C f64 )' C,11- C PORM' INT T kEt, HE V'AL L'ES

WRITE( 3,70 ).IU 94 70 FORMAT( ///' THE MAGNITUDE OF THE SPE'ED VALUE IS I5 ) i WRITE(3,80) ISEC 80 FORMAT(/' THE CONTROL TIME IS',I3,' SECONDS ) WRITE(3 S82) Z1R * 82 FORMAT(/' THE REAL PART OF Z1 IS' rF7*3 ) W;RITE( 3,84 ) ZI 84 FORMAT(/' THE IMAGINARY PART OF Z1 &k.2 IS',F73 ) WRITE( 385) Z2R 85 FORMAT( /' THE REAL PART OF Z2 IS' F+.3 ) 1 WRITE(3,86) Z 12 86 FORMAT(/' THE INtTERRUPT PERIOD IS',F7.4,' SECONDS' );K3 WRITE(3,87) P #4- 87 FORMAT(/' THE MOTOR PARAMETE3R "P" IS' F7,3 ) WRITE(3t,88) 0 6 ~88 FORMAT(/' THE MOTOR PARAMETER "Q" IS' F7.3 ) C # C wl *% *P o o #r or * ~ VP. OI. r, or q s' T- r- or. In" q * or 0 or C * ARE THE VALUES CORRECT? /O ) (: *5~~~. 4 4 ~ 34. 4, %L - 4-4, 4" 4-4.:~ *.;?1 C IC 2 WR(ITE(3 O ) 90 FORMAT(/' ARE THE VALUES CORRECT? (i=YES, 2=2N) 1 ) 4 IREAD(2,15) J 5 IF (J.EQ. 2) GO TO 40 C - ~.~~. ~ ~4-4 v*: — ~- ~-*~ ~~~.. k.,. -ve~ ~-, w lip I- -.. ~ - - V.... ~. V.:. 4,.. s C *: CALCULATE THE TINlE AND THE O C' C ONTROL PARAMETERS r0 r w ~., r 4 o. - r~ # lr. or:.- lro fil I'. V, 011. t',. w q'. q o)z OP o,q qv or. wl',. q4 I C ITIM=530 4ISEC/15 %: 0 IOT-ISEC10. 4 B=-( Z1R+Z2R ) z5 IF ( ZI.EQ. 0 ) CO TO 92 6 C=(( n 2 ZI )''2 12+B *2 )/4. GO TO ~4 8 92 X=AiS( Z 1-Z2R ) 8 C.C=( B?,:4 -X*2.2 )/4. O ~94 WRI TE( 3,96 ) B, C 6. FORtiAT f,',, F T7.4, 5X 7 F7 ~ 4 ) APF'=( F'-C )/QO 3 AtAKI=( B+'1I. +P-F[,A;;F )/( Z:f: ) PJ. I TE(' I A ) APtF' At I"I 97 FO F, A T'.5X', S F 1 C'. l'F13)' I- 1 Dr= 1 C C A C'LL SUOTIE T INTIT AI E I:7 C j C * START THE CONTROL C#v)r4. cr.,. ~l.; ~/. 4C.. wi t......'..,t.

0181 C 95 J 012 WRITE(, 3 100):)133 100 FORMAT( /' PRESS RETURN TO BEGIN HIOTOR CONTROL' )..18-4 READ(,215) KA 0185 C.:'I8 B 6 C "'"'Z* *'~'~'""'~' ~'"' ~~"~"~"~":"~"~"~"%' 4 4 4 X' 4-' w' X' v''* 4 * wv''* 01187 C * CALL SUBROUTINE TO WASTE TIME $ 0189 C.10?O CALL WASTE 0191 C 0172 C D 1 9 I7'121 C In% o 4 9;; y t 4, -t, I, t %,,- 0,,-*, -. * -,. q. #1. I.., ".,,, 1. *- f. q. q. q. &. r. q. 019 3 C + SEDIt A ZERO TO SHUT OFF THE MOTOR' O195 C 0197 CALL DAC(O) "1 8 C 01I9 C:2 200 C'A,4 *: U, 4' P 4: * I-:*.**;.t * 4,":201 C, TRY AGAINT? "Ls' w} ~~~~'O 2 C 4'* r' O - 7 T' O' q; O O' q' O' q'' J''" O' or;-* 0'r or.' or on %' 0203 C 0204 125 WRITE(,1 30 ) 0205 130 FORMAT( /' THE MOTOR CONTROL IS COFMPLETE. YetU NOW HAVE' / 0206.. C' THE OPTION OF:'/ 20207 C' l=F'RIRNTING OUT THE CONTF:OL DATA'.'20 C' 2=REPEATINtG THE F'l CrONTROL F'POCEIURE /.0''9 CC' 3=UITTING ) 3210 O 135 WRITE(3 "14.0)'.;211 140 FORMAT(/' EN'TER 1 2 OR 3:'21 2 RE A it( 2 15) 3 r'021,"_T IF (.IID EQ. 1) GO TO 14Z2 321 4. IF (.rD EQl. 2) GO TO 40 021 5 IF (' E. 3) GO TO 1 50./21o6 CGO TO 1,35'.217 14 2 WiRITE(1 143):;!'21-8 143 FOiRMAT( //'S,','A'5 YSTEM RESF'ONSD'E -:" R CONTROL USiNG A PI ALGOR RITHM:1'.? W Ei'UI TE( 1? 414 ) IUUAtKF AQl'22 1 4A. FtOR Hi PT( 20XXr' SF'EEII=',I' F'=' K, s' 2t, FI=' FF8.'s ) L'1 R ITE. 1 F4. ) ZR lF Z2'R^ 0-222 1:41 FARfMsAT( 20; sF' 2EAL Z'= FA5'3"3 " r F' 5 3Sr 5 I'I-G Z' F5 3///' ):21. RITE(1,14'... I UE 1 r 145A ) >* 24., 145n FOR M~O~A T( SX''F T IM5E' SI X S' CNT'.IqF L E FORT' "J AC i' " SEF;RRO ":1.; TIE10 I 14A7 L=1 I'T I::TE IE 1 1 4 ) Li L )r Ai!D CVAL: L )s Et( L );?.:.' 14'5 FF'RAT(5; T:( 6X s'ThE',S'' I I E I "5,AUA S' 1, I r, XR ) ~223 147 CONtITINtUE.22-...GO TO 1i25 "2"1. END -O s — Or:23r.6' C ~ SUr.(O.UTiN rE TO WAllSTE TI.ME..ILE:237 C % INTEf'RRUF'TS OCCUR *:' 2,', C *;..,:40I.. - r,,,r,r,,.,,',,,,-,,,.,,,,, P,,,,, ~C ~.,,,';,'- -4~. C

.OD'O3 3HnL 3[.L'J IL' * 3 %t.:.:.'o.,:.:.,;'1:.'.;.;,0...:,:.,t 4,.;X.',:.:.;.;..~ 4:.?:..".., Of:.: ~t:1,:.:..:;.:-:%.~..:.....:A s 3 *( iY3 13'4:3'. 31i II JlI' 331 1 3 -11 13 ~;' 4 I'B.'...,','.."..6.',%....; "...I....'.....l.....':,- i.;, -?I.';..~ 4',%-,-."..-,'.~..T'%.,'.... O-( I:l')I 3HI 0" C4;(=( I ) I' i' I=( T );;13 33S I' 31 i'!']:J;T:.h;L /I'I/N'!CJJ;'J JN J —A, to'n - - f t " s'.1 l', t t 4-o t 3 1: 3 3 0I' -' I II J, _,:'U L U:,3, NH'l 6 T' TNH 3' 3 I' O);I.' I.''3 V I CO1 0 ( 0o~ )>\_'(. 3 J' - i n;'( I 8 UH3' I ( H' )1':l,J; I. NO IS'3WI;'.I *MS I 3N I niO:ar zS 3 9,,4.b. 4. 4. 4,,* 4,..,...,. 4,.A..,...1.,..,....N......-..~.k.,..4,,, * w *, f, 4. 4...~...,: -,....,..,..~..,....,..,...,....~.(.........:%.:4 -,t WHI I * 0 -1 V 1 33 -\3 Id 3 0 1 J / 4r i \ 1.1. 3 3 NR33 9.'J~~.1 ~.'''J *A %AP -Jo4o,-A -A# *X J# 4J, A -* 4* b -Ai 1 lt %1v J* -l*4a A# -t -r6 s4, +L, Ap Lb q**J* -Jo %if 3 ~^ ~ fr~~'C ~.9.-I.-'s..,.4...."-. 4.4.'1 -t 4"...9...~.1."%.. J SldRMY 3II 3r 41 33"']uSI. 3 iY.-% -~.9 -,t..%% -, -. t 1..1%.9 *t -f t-.1%.I.k'.,%.-ts4% -1.~ -9.4..4% -9.,L -$.% -?.I M. -~%. 3 E 3 3n;I, iN 3O oo0.z SGdfPA)AN0 3 H 0 k W. III IT=~' 009 OIl 96*t ~~~~~~~~~~~~~~I3WI1 3SJ t 3 ~,.0Df 3 T *L ~t *} *t~ *t~ *t *t JI *t *t~ *k~ 3I J~' 4~.~.'.% % *t *t *t.~...?..r..'~'~ 3 3-19EN3 T9V3.O )3I,.~.,.... -...a..,,.. SIJIq' 3J.NI 3Hi, I 3' N ~ 6,.E 3

03 0 2 EK( I )=IU-ADCVAL( I ) )303% C.30 4 C: 34. $.-;.. z.-. q.4 ~.;.;. ~.;,.*..~..4 l... W..305 C * CALCULATE THE CONTR'OL:2 06/.~ C *4`~`~`~`:*`:*`*`~.~.~`t'**`~`~~.~.~.~ ~ W 3.'VO 6 C lr.,Fr.,fr, 47-q%'11% 4pr. Irl VP % i% O l' C X: 0 *,l" ": - r # d'* * e. d, r. t- 01;`P OFfF,1'* u; "#I;;r- -f,.,307,C 030M8 or( I )=( MK( I M )*Dt+CO0:EK( I )-C1:EK( IMT )),3,09 IF ( Ht;( I ).GT 2047 ) Mtr,( I )=2047, 10 IF ( MlH( I ) I LT -2048) Mt%( I )=-2048:311 1 CALL AC(MK( I)) 03,1 2 RETURN 03.1 3 END ~31 4 ErtF

APPEN D S F-TUNING ADAPTIVE CONTROILER FLOWCHARTS AND SOURCE CODE

98 CONTROLLER DESIGN PHASE MAIN PROGRAM LEVEL 1 FLOWCHART SELF-TUNING ADAPTIVE CONTROLLER START INIln AIZATION INPUT USER VALUES PRINT BACK VALUES / NO VALUES YES CALCULATE CONTROL VALUES. RETURN ( KALL ITNL r CALL WASTE ) PRINT OUT VALUES DECIS10A

99 CO'NTROLLER DESIGN PHASE SUBROUTINE TO. WASTE TIME LEVEL 2 FLOWCHART SELF-TUNING ADAPTIVE CONTROLLER START INITIALIZATION ENABLE INTERRUPTS KILL TIME NO DONE? YES DISABLE INTERRI PTS IRETURN

100 CONTROLLER DESIGN PHASE INTERRUPT SERVICE ROUTINE LEVEL 3 FLOWCHART SELF-TUNING ADAPTIVE CONTROLLER START INMI UZATION SPECIFY INITIAL COND'ONS CALCULATE CONTROL GAINS CALL ADRC. (GET TACH VALUE) CALCULATE THE ERROR CALCULATE THE CONTROL CALL DAC (OUTPUT THE CONTROL) CALCULATE NEW VALUES OF P AND Q FOR NEXT OUTPUT! RETUR

L C 101 C 4 C * * D C * ME600 PROJECT t: S C * COMPARISON OF AUTOMATIC CONTROL SCHEMES * 7 C * * C * CONTROLLER DESIGC PHASE *C t O C * SELF-TUNING ADAPTIVE CONTROLLER: IC * * 2 C RESEARCH ASSISTANT: ELAN LYMBURNER t 3 C t RESEARCH ADtVISOR: PROF. G.. ULSOY 4C $ g C 7 C THIS PROGRAM IS USED TO CONTROL THE MOTOR SPEED OF A 8 C DC MOTOR'DURhIN THE CONTROLLER DESIGN PHACSE OF THE HE600 9 C PROJECT "A COMPARISON OF AUTOMATIC CONTROL SCHEMES FOR 0 C CONTROL OF THE SPEED OF A DC MOTOR USING A DIGITAL 1 C MICROCOMPUTER". THE ALGORITHM USED IN THIS PARTICULAR 2 C PROGRAM IS A SELF-TUNING ADAPTIVE CONTROLLER. 3 C 4 C THE PROGRAM SENIDS A SIGNAL OUT ON DAC CHANNt'EL ZERO AND 5 C READS THE VALUE FROM THE TACHOMETER ON ADC CHANNEL TWO. 6 C 7 C 9 C 0C C: MAIN PROGRAM I C* * C C o o - *: o* ** *-:, o * * o o * o * *o I* * ** * * o o: 3 C C4.I.~.,.,Q W~ ~, -.,,.a. -4 —k% 4 4-4,I-~4 4. 4- 4- 4-4~. 4-.,: 6 C11 * IINITIALIZATION or, 7 r'::. ~ "'' " " ~ ~'''' ~''"' ":: s: C' *''.' c or. o ~- wSr g lop% or. erl- or n, or r or- or or Mr -,o v o/r, or'. 0r. M~ M VP o, 3 C 9 IDIMENSIO.N Y(3300), ADCHtN(3), IDACHN(. ), EK(300), MHt( 300) 0 -i'TEGER Y rM t,EK.1 LOGI CAL*1 NAD, N'DAC, ADCHt DACHN',MMO1 I SPLN/R I,B C YF YQ F A3 0 C,,'/A1J/Y, IU, ISEC 4 C.DCMMo/c'4AIl C B.LK/tt'AD1C ADCH ti JS COMMONf5tL,/ AFs/C)/Il/hAC DACHtNi 6; rC GI tO/ A 7 / I T I H COMiMION/OUT PLK/t, ME; 3 ADCH,( 1 )I2 ~ IlAACHN( 1 )=0 tNADrC= 1, C= 4 C t SEtND A ZEROD TD THE MODTOR: 3 C CALL DAC( O) 3 C C PFF: OGCF A'. E:PLANAT' 1 OD X

00t062 C 0063 WRITE(3l10 ) 0064 10 FORMAT(/' THIS PROGRAM IS TO BE USED 1DURfING THE CONTROLLER'/ 0065 C' DESIGN PHASE OF THE ME600 PROJECT "A COMPARISON OF AUTOMATIC 0066 C' CONTROL SCHEMES FOR CONTROL OF THE SPEED OF A DC MiOTOR USING 0.^ "'7 C' A DIGITAL MICROCOMPUTER". THIS PROGRAM UTILIZES A SELF TUNING 0^8. C' ADAPTIVE CONTROLLER TO CONTROL THE MOTOR SPEEDI. ) l0f%69 12 WRI TE( 3 13 ) 0070 13 FORMAT(/' THE USER NOW HAS THE OPTION OF:.'/ 0071I C' 1=QUITTING'I 0,072 C' 2=IMPLEMENTING THE CONTROL ALGORITHM'I 0073 C''7 0074 C' ENTER 1 OR 2') 0075 15 FORMAT(I1 ) 0076 READi(2,15) KL 0077 IF (KL.EQ. 1) GO TO 150 0078 WRIT E( 3 30 ) 0079 30 F:ORMAT(/' YOU HAVE ELECTED TO IMPLEMENT THE PI CONTROL'/ 08O0 C' ALGORITHM. THE USER WILL NOW BE ASIED TO INPUT THE'/ 0081 C' NECESSARY CON'TROL VALUES. ) 0082 35 FORMAT( I6) 0083 C 0084 C *~**~*~ P:*~:~ ~:** ~ 0085 C * INPUT THE USER VALUES * CY.6 C ********r'*0' * * q T q 1 **' ** *****'' o'''.'', 87 C 0033' 40 WRITE( 3,50) 3089 50 FORMAT(/' INPUT THE MAGtNITUDE OF THE SPEED VALUE FOLLOWED BY A 0090 C' COMMtA (-2048:X'.047" ) AN INTE-GER VALUE' ),9: L PRE.i( 2 D 35 ) IU.~92, 55 WR ITE(,6 0) 03093 60 FORMAT(/' INPUT THE TIME TO CONTROL THE MOTOR SPEED IN SECONDSI 0094 C' FOLLOW THIS VALUE WITH A COMMA ( I <X 25 ) ) 0095 REA1D(2,35 ) ISEC 0096 IF (ISEC.GT* 25) GO TO 55'D05097 WR I TE( 3, 62 ) 0098 62 FORMAT( /' IN'UT THE REAL PART OF 71* INCLUDE A PERIOD ):9 5 "2 REAI!( 2 9,64 ) Z1R 0100 64 FORMAT(F10.0) 010 1 WRITE( 366 ) t0102 66 FORMAT( /' ItNPULIT THE IMAGINARY PART OF Z1 & 2. ItC:LUDE A.FPERIOI 0 10:3 REAtD( 2 64 ) ZI 104. WRFITE( 3. ) 105C: 6,7 FHORMAT(/' INPUT THE REAL PAFRT OF 22. INtCLUDE A PERIOD') I'2 6 READ( 2 A64 ) Z2R 17 LJWRITE( 3,68 ) d:>10'8 63 FORMAT(/' INPUT THE INTERRUPT FERIOD IN SEC. I NCLUDIE A F'ERIOD.'1 0'9 REAIt D( 2 4 ) Z'2. 1L0 LRITE(3,200 ). 011'1 200 FF:.RMAT( /' INPUT THE INITIAL VALUE OF PH' I NCLUDE A FERIOD.' ) J 112 READ( 2,4 ) F:113 FWRITE( 3 210 ) )114- 210 FORMAT(/' INPUT THE INITIAL VALUE OF OH. INCLUIDE A PERIOD.' ) 011.5 REAlD(2,64) 0 0116 RWRITE( 3,220) 0117 220 FORMiAT(/' INPUT THE- INITIAL' VALUE OF THE MATRIX F. INCL.UDrE'/ )1183 C' A PEFRIOD' ) 0119 REATD(2,64 ) F " 1'0 C

C *t*ti *r*t~*tt*'*'* ti'& X4. t4'4 4- l, * 4 st'& 103 C PRItN T BACK THE VALUES $ 3C as * W 4 * 4' * w* * * I* * 4': * 4 4, 4 4 C WRITE(3,70) IU 6 70 FORMAT(///' THE MAGNITUDE OF THE SPEED VALUE IS',I5 ) 7 WRITE(3,80) ISEC 8 80 FORMAT(/' THE CONTROL TIME IS', I3,' SECONDS')?9'2WRITE(3,82 ) Z1R O 82 FORMAT( /' THE REAL PART OF ZL IS SF7.3 ) 1 WRITE(3y84) ZI 2 84 FORMAT(/' THE IMAGINARY PART OF Z IS',F73.) WR I TE( 3 S5 ) Z2R 4 85 FORMAT(/' THE REAL PART OF Z2 IS' F7?3 ) 15 WRITE(3,86) Z 6 86 FORMAT(/' THE INTERRUPT PERIOD IS' F7.4,' SECONDS );7 WRITE( 3,230) P 8 230 FORMAT(/' THE INITIAL VALUE OF PH IS' rF74 ) of IJRITE( 3240) 0 240 FORMAT(/' THE INITIAL VALUE OF QH IS' FF7+4) J1 tc WRITE( 3, 250) F 72 N2r50 FORMAT(/' THE INITIAL VALUE OF F IS',FF8*3 ) C 4 C 5 C ARE THE VALUES CORRECT? ~ 7 C'8;3 WRITE( 390 ) 9 >90 FORMAT(/' ARE THE VALUES CORRECT? (1 =YES 2=tl) ) 0 h'E Ar( 2 15 ).J 1. IF (J.EQ. 2) GO TO 40 2 C * 4- 4. 4.. -z.,. 4.4, *q. $ 4. - 4-4.4. V..'.- &.'z- -43 C *.,.-, 4 C * CALCULATE THE TIME AND THE'5C: CONTROL PARAMETERS 6> C 7 C 8 ITIM=530*4ISEC/15. 9 IOT=ISEC*10. O I=1.,i.=-( Z1R+Z2R ) IF (ZI.EQ. 0. ) OC- TO 95 63 C=( ( " rZI )::2, t B-; t _ )/4 A c4 GO TO 98 15 95 X=E S( Z1R-Z2R ) 6 C=( B,,:,+ -X~:4:2. )/4. 7 98. WIRITE(396S ) BC 8 96 FORMAT( /,' 5' X F7. 4, 5X>: F7.4 ) 0 C C r v < v v q z v v * <; < v u v v:'"'"" < * 4 w u < v u ^ 2 C * CALL CUBROUTINE TO INITIALIZE *"3 C THE I NTERRUPTS 4 C',C., ~. ~.,,,..,~.:~: ~. ~.,~.,~.,-,.,:e 4, %,.- X.,.4- -.. 4. 4' u,4, 4 4;. $.4. w 14. %- O. t, C C 6n CRLL i T I TL 7 C' r, l~,r. Mr, *l~ i,,.,T......'1" Mr, C START THE CONTROL C) C r w'- Mr " r -~ - C',",'''l- /'' r"

C)81 { 1 C 104 0)182 WRI TE( 3 100 ) 0183 100 FORMAT(/' PRESS RETURN TO BEGIN MOTOR CONTROL') 1: S4 READ(i 2 15 ) tKA 1S5 C!1 8 6 C **:**r * * *:: *z * t 018 7 C * CALL SUEBROUTINE TO WASTE TIME $ 2153 C m I *$t.t'4 * %& w 4 4X:.v 4, t 4 4 it 4,, %t. I, 4e, 1 -'189 C )3190 CALL WASTE 0191 C C, 15-2 C ov q pO 1 q' q% q or VX Al- ql-,p o!, * V-,,, elI% 1. e, 0193 C: SEND A ZERO TO SHUT OFF THE MOTOR * O19 S4 C " *,'4" 4'*4 *4 4"'**4:*,* * *'''; * * s * * t: " *' *' - 0195 C'3196 CALL DISAEBL.I197 CALL DIAC( ) -1983 C {)199 C 2201 C * TRYACGAINT;20 2 C, i: ~"' -, 4' " 4'"4'''"" * 4" 4- *"" 4' 4- &- $4''"" q $4"'. 20;3 C <:)204. 125 URITE(3 1l30 ) 02205 130 FORMAT(/' THE MOTOR CONTROL IS COMPLETE. YOU NOW HAVE' / 020 6 C' THE OPTION1 OF: // 0207 C' 1=PRINTING OUT THE CONTROL DIATA' <:20~ C' 2=REF'EATING THE SELF TUNIN'GlC, CONTROL F'ROCEDtURE /:.:209 C' 3=QUITTING' ) 0210 135 WPRITE( 3,140) 3211 140 FORMAT(/' EN4TER 1,2 OR 3 D2'1 2 READ( 2rlt.15 ) JID 20213 IF (JD.*EQ. 1) GO TO 142'021 4. IF ( JI * E. 2) GO TO 4.0 )21 5 IF Jt. EQ 3) GO TO 150 132166 GO TO 135 0217 142 WRITE( 1 14.3):218 143 FDFORMAT( /, s15X,' SYSTEM RESPONSE USING A SELF TUltINCtG CONTROLLER" ):: 1'9 WR ITE( lp144) IUZ1RZ2R,'FZI "2"0 144 FORMF AT(13X,';SPEED=',I5,' REAL Z=', F5;3,2,,,F5.3,' IM Z=', F5.'"'7:L lRh IE4-,-1 145 ) ).22 1 45 FORMAT( 5X I' TIME', 5X,' CONTROL EFFORT' - J)X ACCTUAL SPEED' r 5X,' ERRC'., 2 > tCSDO 1 4 7 L=1 IOT.',,2 W Ri'TE( 1 T,14-6 ) LM{l( L ),Y( L ),Et( L ) 146 F0RM' ATA( 6":s 1X, II 11'X, 1 5,7, 18I7 ) -,2- 147 C ONTI NtU E,!,'22'7 C'GO TO 12.22 150 STOP 9.L."'"? END 23_() C; 231 C 233' C:::234 C: SLUEROUTINE TO WASTE TIME WHILE $ ~235 C: I'NTERRUPTS OCCUR''. 0236 C: *'"2~:7 C mir m', m. Xr'~ ~'' ~. to,. j ~,,e, m-.,,$,, J ~p,It.'.., Ldq'T'5'Iq.', i l'.,q.'r.','.4a'.'l.'f'r'T'Y*'1~' ~ mp'q *r' *a*'F''I''F''1' 0:39 C i.239 SULICROUTIiE WASTE'"4 20 CO i'iiOit N/ A/I T I M

WRITE( 3,600 ) 105 2. 600 FORMAT( /' THE MOTOR CONTROL HAS BEGUtN' ) 3 C 4 C -% or: ot% *v*,- *.* or, 4q " u "% o o " #" v1~ P qr`r v' ~'* 5 C ENAEBLE THE INTERRUPTS 6 C * * * u v w. * * s * * *** W 4 W *4 W. W. *Z W 4- q - 7 C S CALL ENABLE 9 C O C 4*' $' 4,:** *'* $. * * 4' ** 4 4- 4 4 -*.**'4* C WASTE T IME 2 C * 4 W 4 " * $ * 4 t4 * W * x'I.,4 3 C 14 iDO 700 JX=-1ITIM O0 650 J3=114.5 6 650 CONTINUE 7 700 CONTINUE 8 RETURN 9 EENID 0 C C 3 C:: 4 C: INTERRUPT SERVICE * 5 C:: ROUTINE FOR SELF TUNIN G ADAPTIVE CONTROLLER 6 C* 7 C t 4 4?* i ** r4*$: * 4; oe * * ** g * * *. 44'X;. 4 w. 4;4 $. w &- w P *. % w w %.,,- 4 w C 9 C 0 SUEROUTITE ISR 1 tDItIHENSION Y(300), ADCHN(A), tCHHN(4), EtK( 300) Klt( 300) 2 INTEGER YMKEt{ 3 REAL KPNt KIN 4 LOGICALS*1 NADIC tINDAC, IACHNti ACHN ~ COiMMOCt-/ISRB'LtK I,B, CPQtF 6 niCO MtHON4/AtCBLK,/NADC, ALDCHN 7 COiM /'DAi C ONLt/ t IIAC /AC, IACHN MCtMON,4/Al/, IUISEC COi-iD"N/J itOLTLts/Mk, t EK 0 C C c 1or. e- "~ ~. q'.~ r. MI~ I,. r. In'. or.'T- or* Pt, or- o r.,1% o. I* Mr - q% Mr. or 0 7 " Mr. or Mr. or M7% qI - 2C SPECIFY IINITIAL VALUES "7' "T- "I',,P. q.~'' "P "r,, "1 ~~ d/. "1. "q'" ~' "l..''". "'. %i'.,, 4,I 4, % v.It. r1,, d 3 C 5 IF ( I E. 1 GO'TO 500'6, t11t;( 1 )=2047 7 \YPf0' —O. 3 (.;RN H P=CQ FlIP=F 1. FF2'P=F CALL AB'C Y( 1 )) 3 ChCLL ItAC( tMK( 1 )) 4 Et.( 1 )=IU-Y( 1 ). a00 I=I+1.Z. J=I-1 7 KPUIF'=( F'HF'-C )/C4HP.3 E(I t~=KI ( B+ P l. +PHP-&'HF" }F'N ),/(, 1IFQHP ) J C ), 4 %. a. ~,- t:.* -.,-:-<. - h.- -4-A-4- <: C ~- - s- X

0301 C * — GET THE VALUE FROM THE TACHOMETER * 106 >3 i;) 2 C Y:YtLW*tS~tZ~~Otrt~t~~t~4 * * 4- 4-4-' 4' 4- t W 4 It- 4- It' 41 @4 * *sL;30c3 C:'304. CALL ADEC( Y( I)) 0305 EK( I )= I U-Y( I) 0306 C 0307 C * *****' o v * o n" q' **' i"v'*"* ~' "' "'% "~'r r' "" n' 0,308 C * CALCULATE THE CONTROL o 309 C ***** *** * * " " - * "*' " 4 4"$" 4' 03 1O C 031 1 tMK( I )=( Mti'( J )t( KPNt+KIN/10. )*ElK( I )-KN*EK( J ) ): 3.12 IF MK( I ),CT. 2047 ) iMK( I )=2047 0313 IF (MK( I) *LT* -2048) MK( I )=-2048 0314 CALL DIAC(MK(I )):.315 C -;31, c..v..w.1% 01% q% lr v q% or, orp q% oil sIr or *1, q- o 7.~. ~. q% 1.. q- o- q- o- o r". -- m- ~- or, o-* f. ~-~-:31 6 C *'*''''" 4' ~' "'" "' ~"'' *" * 031i7 C o CALCULATE PH AND OQH (:3 1 8 C W i? 4 * * 4 ***r 4 4 * 4 4: k s - " "31 9 C 0:320 C 321 C. CALCULATE EN'3 22 C'":32'3 C1 1 P=( F 1 F'*( -YHP ) )*( -YHF' ) 43245 C22P=( F22P Mt ( J ) )*K( J ) 0!325 E- E=( Y( I )-cPHP,.tYHP-QHPF'K( J ) )/( Cl IP+C22F'+ 1 ) 0326 C 0327 C * CALC:ULATE FN:;328 C 32 ItFF =C1 1 P+C2 P+. 330 F1 1 t=( F 1i 1 P-( C i PF1iP )/DFP) 0;331 F22N=( F22P-( C22PF22P )/DrFP ),332 C 03333 C 4 CALCULATE N4EW VALUES OF F'PH ArD [OH 0'3 4 C 0335 PHN=F'HP-( F1 1P( -YHPF ) )qEN 0336 OHt4=CHP'+( F22Pt*MK( J ) )*:EN 0337 Y H t'= F t Y H YHP+Q HN*M( J )'0.338 PHF=PHN )033'9 C HP= QHN'34.0 FI1P=F111N':.341.J F22f= F22tN'34'2" Y~= H i'YHtN R E T LIR ti,. 4l E N t

APPENDIX E ROBUST FFDBACK CONTRO-LLER FLOWCHARTS AND SOURCE CODE

107 CONTROLLER DESIGN PHASE MAIN PROGRA'AM LEVEL 1 FLOWCHART ROBUST FEEDBACK CONTROLLER START |IN11.ALIZ ATION. INPUT USER VALUES PRINT BACK VALUES NO VALUES CORRECT? YES CALCULATE CONTROL VALUES CALL NTINL ~ CALL WASTE ) PRINT OUT VALUES - DECISION

108 CONTROLLER DESIGN PHASE SUBROUTINE TO. WASTE TIME LEVEL 2 FLOWCHART ROBUST FEEDBACK CONTROLLER START INITALIZATION ENABLE INTERRUPTS OOP TO KILL TIME NO DONE? YES DISABLE INTERRUPTS IRETURN

109 CONTROLLER DESIGN PHASE INTERRUPT SERYICE ROUTINE LEVEL 3 FLOWCHART ROBUST FEEDBACK CONTROLLER START INITIALIZATION SPECIFY INITIAL CONODONS CALL ADC (GET TArCH VALUE) CALCULATE THE GROR CALCULATE THE CONTROL CALL DAC (OUTPUT THE CONTROL) CALCULATE NEW VALUES OF P AND Q FOR NEXT OUTPUT I RETURN

-lb 3 OIi "I"! 1v 1.X 3' O i, * O.~ 3:A#::': -: t:.t, t;:: t -G'','I,:'';:';;':: J:,f:f:t::f'',::: -.'';':t:-.f;:3.: t 3 A (0j)3V11 11V3 _ 3 -3 3.*,,.*.L,, J,,,,.,..,.....8.,,,., *,. J.S.....o.t..........,..,.. to..,,.,.; ~. A..t::.1,.......1,,.,..-..t -,* -:, -J, *t Ith.71% A...16.10ft -'N %.1%."',,'.; 4.."?'t.;*':..'.'~ 4,.h T.,. -.;,,. 3 H=311V:'Z (0 3VI q'I ~3;' 4 O=f'/ I )1463B'J ~NH31VZ=( I )-H3~Y -L iL' i 1 I 9'! O:;'LV..,..,..,.....,'' 11'" 1'' 11' I I, "' " I.. "''I' 3 * 0'017- Ye I W. I' 4'4'*~ 3 I~ 4N "'J'4~ 4 I'' 4 EH 4i4' V 4.1'k'. I 4'' 4 4'1" 3 W N:\4' j r U' d J 3 I I v II/'; I.' IL iWI03;> 1H 30;I % 40H -JV -%I l' 3-A, 4f -,1', -:J,3 I -;o1 -C 3.; *v+.* 3 1 * WV'ASO>3.; $ 3 0'. * 3,'7',of.;~.?..4 -t.%t I',.~ -T. -t.'..'%,'t'- M' 4'''; 4'4';1' 1' 4'"'*4 " l'"'4% -4'A' *' "' "'.' 44-' -' 3 9,~ / 0 0I11010~) l3 O3'~JW33AiSf lH11. V WI N(00c'IW 3 " dO3t3 u133d.1 S tO0 3'nl 10~N. O3N 01 13Sfl SI W,'.SO H., 3 L 39 4'4'..-.1,.4.4.f, 4,4, i Y:4'" "' "' 4''A'"' 3.3 9 *QJ; ~ M3M11 0NiM3 N3S VqI33N31 i11SO SI o3 d 3. ~ Wivioi; W 5Nisn n010 0; WHJO iI33-AS 3 HI _10 )0 IN0 4 0 0093W 3fHI JO 3Si3HNd 0 WIS3*I 831.0:11N0303H~ oNI*mR; Moiow 3 a V J 0 11 3"dS". %'O.NOW OT' 01 ~]3sn sI WYV. M,:D SIH I O *t;~; ~~~~~~3 9 011 0 ~ ~ aOs9'0'sOnd:4MOSIA1IIV H3MV3S3~ ~. ZI~MYI\Y3NMRl 1 49 ll ~ I:INlSlSSV HOSV3S38.~ O ~ $ S3NBHOS 90MINOO 0IiV~Q lNOI ~0 NOSP.,W 0.'A- 3.f.~,~~:~ O',, *.~ ~.~.'~ ~'"'" "'" ~''"'",.I~'" ""' "'"'"....~,,-,..,~.~. ~,.-,..,.,~,.~$~'""'

OO 6 C 24 1 44 4w4**- 41s $ 14I ns 111, 0% Ir. or- or-S VP op or- T. d' % ~ q. r p or. fr o~C r r ot r.' r 4- qrrop.:063 W'RITE( 3 r 10 ) 0I064 10 FORMAT(/' THIS FROGRAM IS TO BE USED ItDURING THE CONTROLLER'/.1065 C' DESIGN' PHASE OF THE ME600 PF'ROJECT "A COMPARISON OF AUTOMATIC 006 S6 C' CONTROL SCHEMES FOR CONTROL OF THE SPEED- OF A DC MOTOR USING 0067 C' A DIGITAL MICROCOMPUTER". THIS PROGRAM UTILIZES A ROBUST'/ 0 6-8 C' FEEDBACKt; CONTROLLER TO CONt"TROL THE MOTOR SPEETD. ) 0069? 12 WRITE(3r13) 007 0 13 FORMAT( /' THE USER' NOW HAS THE OPTION OF:'/ 007 1 C' 1=QUITTING 0072 C' 2=IMPLEMENTING THE CON'TROL ALGORITHM'/ 0070 3 C' 0074. C' ENTER 1 O F(') 007 5 15 FORMiAT( I1 )'!'076 hREAD( 2 15) KL 0077 IF (KL.EQ. 1) GO TO -150 0078 kl'WRITE( 3 S 30 ) 0.079 30 FORMAT( /' YOU HAVE ELECTED TO IMPLEMENT1T THE CONTROL'/. O080 C' ALGORITHM. THE USER WILL NOW EBE ASKEDi TO INPUT THE'/ 0081 C' NECESSARY CONTROL VALUES. )!)0 2 35 FORMAT(I 6) 0"'083 C 0 C084 C. * 4' ** V 005s C I NPUT THE USER VALUES 00v 9 6. q r. *r- *- - -. -- *. - f. V- o 0.; o 01; C.. *r-o *:..o*r. 0 —* -. 00887 C 40 vJ WR ITE( 3, 50 )'t3?'1O 50 FORHAT(/' INPUF'T THE MAGNITUDE OF THE SPEEt VALUE FOLLOWE1D BY A 00910 9' C' COMMA ( 48. 0 X 2047) hNi' I-NTEGEhR ALE / )?0091 READ( 2,35) IU 00?2 5' W;RITE(3,60) 0093 60 FOR'MAT(/' INPT TE TE TO CONTROLUT THE ME TO CO OL THMOTOR SPEEDI IN SECONDS 009.54 C' FOLLOW THIS VALUE WITH A COMA 1 X'5 )' ) 0095 REA D(2 35) ISEC!^956 IF ( ISEC.GT. 25) GO TO 55' 1009?7 64- FORMAT( F1O.)!0' C WI RI TE( 3 65 ) 00?7 65 FORh'iT(/' IN'PUT THE REAL PART OF Z1. INC"LUDE A P'ERIOD' ) 1:00 hEAr(2 64) Z1R 03101 W RITE(3 66 ) 102' 6. FORM1AT(' INP'UT THE IMAGINARY FART OF Z1 & 22. I'CLUDE A F'ERIOI 0103~ READi(2;64 ) ZI "J5.'i FiRITE( 3r. s6. ) 67 F ORTr AT' i. F'U THE EAL PfART OF 22. IiCLUDIE A PERIOD' ):., REA D(2 964 ) 2 R 010 7 WZR,,TE(3 39, 6 ) 0108 68. FORf;iAT( /' ItPF'UT THE TINTERRUF T F'ERIOD INt- SEC. IiNCLUDIE A PERIOD....,)0?'ERAD(254 )' -011)0 h'-RITE( 3,69 ):11 1 69 FORiiAT( /' INF'UT THE SEWSITITI VITT GAIiN. INCLUDEE A F'ERID.' ),.1.1..,,,' READi( 2' 64 ) AP2 0;113.% "RIITE( 3 200) 011-4- 20> FOR.AT( /' INfPUT THE INITIAL VALUE OF FH. INCLUDIE A P'ERIOI.' ) 011.5 READ(2,64) P.,.0"'116z,-', WRITE(3,210) 0117 210 FORMAT(I' INFPUT THE INITIAL VALUE OF CH. iNCLUDE A PERIOD.' ) 011:8 R F:E(,AD1( 2s64 ) O'311? 9 URII'; E( 3, 220 ) 13120 220 FORIAT(/' ItNP'UT THE: IENITIAL VALUE OF THE ir.ATRIX F. INCLLUDE'

1 C' A PERIOD 112 R2 EADr 2,64 ) F C PRINT BACK THE VALUES S C $ is * $ 4; 4' $ 4' i; * s $ 4 & r V * 4 4$ 4 0: 4. *: 4. ~' *. 4' 4 4 C B U)RITE(3,70) IU a 70 FORMAT(///' THE MAtGNITUDE OF THE SPEED VALUE IS',I5 D WRITE(3,80 ) ISEC 1 80 FORMAT(' THE CONTROL TIME IS',I3,.' SECONDS') 2 WRITE(3,82) ZiR 82 FORMAT(' THE REAL PART OF Z1 IS' F7.3 )'4 WRITE( 384 ) ZI 5 84 FORMAT(' THE IM AGINARY PART OF Z IS',F73 ) WR I TE( 3,5 3 S ) Z2R 85 FORMAT( THE REAL PART OF Z2 IS'F73 ) S WRITE( 3245) AK2 f <245 FORMAT(' THE SENlSITIVITY GAIN IS' F.*3 ) 0 WRITE(3,86) Z 86 FORMAT(' THE INTERRUPT PERIOD IS' F7.4' SECONDtS' 230 WRITE(3,23O) P 2 3O FORMAT(' THE INITIAL VALUE OF PH IS' F7.4 ) 4 w'R'ITE (3I 240) Q 240 FORMAT(' THE INITIAL VALUE OF QH IS',F7.4) 6R ITE(3, 250) F 7 250 FORMAT(' THE INITIAL VALUE OF F iS',FS+3 ). C 9 C O C or ARE THE VALUES'CO'RRECT? i 9 C X~ X.~ * ~ ~ ~r~ o nT: n'.r -; ~1' orr. l or w,'. r or- o q; o i e r P 1r e% e 4% l o e'o or/ 0 q or, or o o 1 C W;RI TE(3 90 ) A4 90 FORMAT( /' ARE THE VALUES CORRECTE C T =Y'ESS 2=i0)' ) - READ(2n15) J 6 IF (J 3E. 2) GO TO 40 C l C. e. 1-. r.- o. *,, o r. *'.:r $-1 ~ 01.... 1#'. 01'. l'. el'. 1'.... o.,. -.'' #". ~' *' "' #' "'.'":~' ~' or ~' ~'~: ";";' ~' $ 9 AC X:. ULATE THE TI,IE A -,-,tt T.' E al > C oO Cl T c1or. 01% or. q' o. or. e el' - r % et - o" l o lr. # if * C T'H=.3 $1~CEC/15' I r 7 r, T, r,, ) r'j TO Ci5.L'F'(ZI EC'. L )T g TO 5 GO TO 93,.: X=AB(.; 31R'-Z2R ).~. C.-( P -:':2. -X,.;:'.. )/4. Co WURITE(3, 6) BC?. FORF:r'~AT(/,5 F7 4,5",F7,4) C 7 C ~: CALL SUBROUTINE TO INITIALIZE $ 3 C * THE INTERRUPTS 4 ) C

Ilk J C~~~c 13~:*.~~~~~~H1,3O1 3S1. SI:I MIW i " 3,J (2...~IN~ 3NIJl.31.S':J, 01 3NJi[I'IO;JP IIi:~, 3 6Z~2': *3~~~~~~1H~~~~~~~~~~1~..:. ~ 9.'.~.1~ 3 Z, 2,. 13 9'~3 C Y'I-'~" O lI3'S'~ ct C &.01 CS. *'3,S 01 0~I' 0;" I:.. T (. 0' i-3, L,. r u" C ~~~~~~~~~~~~~~~~, 5IiifO,3" 93X( 9)i~(q))J*'9 r' 5-r T )31Ici Zf,., C 3I f't04 3 I3N.L "0I1'r 3d=' 7 3 ~20 / = q3XS71 3.:]v, 0 rIO'3i1,3.: iN1U t03,,011 3"'3I )V " O 32.4'..~~~~~~~~~~;~'1r?'.L )S~.?.:J,? j.; =7 141~~~.0I'~,)1 *3 9~ j-~/' X' I ) L'.~~" t I ""r 1f T~~S)- ~r C;'Or Z-~~~~ 36tC'r~~j d!4! r1. r' i CL...i -~.,3!I 7 I,-JS,.L,'J? 0'"" I -p I j'. r01W BHI.AO "' l,S 01,' 13-ZZ- I T IL ( T 0" I' -C\ ~~~J r II" C7 1,_o "$;3_I V'3 3 j,'Z' 0 Z 1 T 3 i 1 3A 96tC Z1399"''' I'"~!? "~i9"1 " "',3,J ~3 TIT n,"JN 03 3v..,J I0 ~0:'.X 0"' "'''l 3"""n- 2 o 3I0-I 33 ~ -T 31S7 0i3 Itfl ~lr 7'C 3 6 * ~ ~~~'.4. b~~~~~~~..J.'.b'.4..J~~~~~~~~~~,'-.4 -0,**oil' 30,I.:IN3' Si TX; )'~;JJo -, ~ ~ ~ ~ ~ ~ ~ ~ c I'~ f ~?,'?_tC l: I~c )3.IL9'" 0 0T1: ) 3II03 "'3.-l~, _ L C, V''.1.~t 1 O ('~'.4.'3 6 8 4'- 0 ~ O0(I'3'.L~'1 3l'. 3 8I ~0'~'I 831'"",',,-'.'A -- --, IIJoUM-3 -9I "-J %I7. Aft.,T 1%It41 71." 41 4 4 t AA -J T.k I.'ik t-l?L.1%4%I. 33 LQ 3 3 I3 C VETr I300M 90MINOO JIOVE;=3 H 14'" --'-' _ ~.u~ =I fL 90;~!NO0,~01 3H~~ I.C, - )I O3 0~I v C l, ~1 -1% 4,.1,.. -.L 4N O,,.?..,.-;-...;.%.1%.%.7%44 ~.1 _.1%.~ %.-T.. -T..)..." 4A.11.?.%If ~11:.1,.'/-..,-.lh.) %., (~ I~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1~4%"4'..."',. 4,.1% -I.~ -,':,..," I, "..-.%."t.1.;'.. -..1%',T -it -'V,.,'.I',.,'~ -t~4 4.. I.~.t -h.~6.~r.9 46' ( 0 ) l 99t%3 OC, 3 IIVSI;I'I:Z..:: 3 OO~0e: -b. U *d,%, %U d, - Jo,b %& Oo,b d, d b -.b -A* -,b -lo -b,b* -Jb;, -J, -J -A, 4, *% -3, -.4,..u %: o,4, 4%.7~ HHO^ IRHS 0~.,'_P I,3.* - 3 I610 (03IWM 99U3'~iC,(3; O 3 O-&lO.,5r rcc 2ui~ 3~tSM 01 3NI O;~ER r tlS 99 0 O )61 ~b. ~,. ~\..-.,,5.,.~.'1. -,.;~. ~..-z.~~.'.~~.-,,~CI.~\.~. ~, ~.~.t ~.$ ~'s~f'14,~. ~'r~,A~'~' 3 0'610 V)I( t' J )I'd3 - ~ 6T 8 l (, ]OMINOO MOZON NIO3E 01 N,~RI3M SS3~ ~ ~ ~~3~fi~,d,/INO Ol 8 3.J. 3. ~~~~~~~~~~~~~~~~~~L ~L 3~~~~~~~~~~~.,~~, ~ t.,, G.1,,,e.,, 3.6 ~.,,'2 — 81, ~:Jt~ ~I.' " 1' O 3HI 1,~~m IS~ ~,~lTS77r,' ~ S" I:.'.,,,,,,,,,,..,.,.,,,,,,,.,,.,,,.,,,.,,,,,,,.,,,,.,,..-,4,..~,.~,~,,:~.. ~ I.,' 4,.~.~.~ -'1.,t 4, 4, ~ 4'...~.~.,I.~.~..,~.~.'~ ~ "~'~''& ~~'~''"~~~ "' "':'-,,o.z,,, ~ 8t 3 C,T.C 8 IC. *I~ J~ ~~~~~~~~~~~~ ~q~ T~!L N6 TI'"-.Hj T ~.T.,",~3~r~I k3 ~~ I ~3~~3 I~~~ ~3 t r ~3 Zr~

I C 114 rl. J4 C r SUBLR OUTINE WASTE CO)H ON/A2/I ITIM. t.,6 WRITE(3, 600 ) 7 600 FOR'MAT(/' THE MOTOR CONTROL HAS BEGUN' ) C ~~~~3C * f**r X,;Xe. -,.,. r ss o X *44 *, * ~1;-.., r,,,$.... l. Ae L.....-., 4 4. Or C * ENABLE THE INTERRUPTS *4"'"'4.*w'4"4' "' " s"'*.4'.'""'*' A- q''4' ia' -A-'4...........'..- 4.:.4. 4' 4.".'' 4'.4. 4.4 IM o' - 0)- op P. 1' e' o'.'rr. f?- o'o,~ Mh or IMP O. op, q O f ~ MP. -, #P ql el, Mt- *Po #P VP0" rT, CALL ENABLE.4 C 5 C ~':'.' $ a.5r 3 4' & tt* *. a 4:,.4.... 4.,.,,'!,, 6r C WAST E TIME "'7'-4- 4- 4, - 4 -',I,,, i'4 % 4-., -" - 4',''',,''-4 — 4''.., -,,-4- 4p.-4: - 4. 4,- 4..4 Of C oW- or, erk #P 01% or- *P 07% et'r, / T,. or. ofr. Jj.,,, or. or. oi,., o'lrV. 1~ q'" Or or..r. of. or. o'T q 3 C 0 DO 700.JX=1 IT.IM 0 IDO 650 J=1 1425 1 660 C1ONTINUE' 0 CONTIN'UE 3 HRETURN 4 END C 3 C C or r- re Set r~ or. or. or. J r- j7% Or- r t or. 9' oit or- r-n % o r - r. r *% t r. * L or r or, n% of-. o- or *I- r #- o- 0rb *~ q. o. a.' IC TSB U N I NT::SU PT.:VI C F:ROUTEIN' FOR CELF TU'"INtCG )i ADAPT I V E CONTRO 0 LLER 7J INTECEF; r7t \ I A C. C.X & 5 S U RSUBOLiT I tI'E IF:t A Iti EHSIlON Y'.(0)', AHr C AH. 8) EC H<( 34 4 00), I(3 )00 *f I fIt' E.~i- r' Y M Et'. FE rA L t 1P t t3 9 L;OG I CAL ~:1 IttAC: A rIACA s CH,H r C CO'li? CrN' I SF:BLt / IB r C, F' 1, F AIt72 COMrMON/ TIfCBL t/" DC AC DtCHN C riSF-E'C YlI II TI~ I I ISI 9- C CO C.r/A ti/ P, L, l fI iLUES C 0, IF (I ftE. 1) Co TO 5E00:1. AA( I )=204P7.... HK, 3 C OF' UTHQ S FllP=F F A 2 r —F''F 7 CA'L.L AIDtCL H L'( i)) s C&,'CL. L DrLC( ML( 1 )., Et( 1 )=lJ-Y( 1)

'330 2 KPN=( PHP-C*:( 1 + f'A2*QHP ) )/QHP 0303 KS3=( EB+AKt;2*QiFHP( B+ )+1 +PHP-KPNC'*nUHF' )/( QHP) 0.3 4 C!> sh 0 5 C ~ t 41; * "'*'''>1"':*:''"' ~.,-:'; 4, *;* ~'% $ -*,:' -"':"* A- W"; W' 4' W; X' 4" ~t". 0N305 C or *1.,J or,..,r. ~. r. Of*o *M., o. ~. ~tlr. e/. el, q''* q', 03 06 C G CET THE VALUE FROI THE TACHOMrERTE * C30 C; *'' ~'' $ *'.* -'* X' ~' ~' * ~4'''''.'''''*"' ~'~' ~' 30B C 0309 CALL ADC( Y( I)) 0i1 0 Eli( I )=IU-Y( I) 0331: C 031 2 C 4. r314 C r. el, or, er IT. VP'. ~r,. l'* 0S1'5 C 0316 S=At 2;( 1-F'IP )-;f'P-K3,317 T =KPNtY( J ) *03i t Kt( I )=( MtK(.3 )+,SY( I )+K,31IU+zT )/( 1 +t(2t M J' ) 731 9 IF ( MtK( I ) GT "2047 ) MKt( I )=2047 0.20 IF (tlt;( I) *LT. -2048) M'(K I )=-2043 032 1 CALL IPAC( MtK( I ) ) "' -32 C 323 C 4r 0 #P * o; n;. e*; a; 4; o fb% * "`32 4 C * CALCULATE PH ANDtt QH 0j2' C.4-4`.*..4.*.``'4`.`.4 4 44*W....v..'4`..'-4.':. 4 ~4-~.4-..4-.` 4@.W. -4. -.'-' 4$- C 032 3 C CALC ULATE EN "^'' "; C C 0,'30 C1 1F'=( F 1 1P*( -YHP ) )( -YHF' ) 331 J. C22P=( F22PMit (.3 ) ),:HP( J ).~33"2 El'=( Y( I )-F'HP*IYHP-QHP#* MKN( J ) )/( CI PF'+C22F 1 * );334. C C. CALCULATTE FN *; 33 5 C 2)33 6 tFF' C1 1 Pi C22P+2 033 Fl1 1N=Fi F1P -( C.1 1FF'Fi /DF1F' ) I,:_;)3-3 F 22N= F22PF'- C'22P'*F:'P )/I'FP ) 0340 C C ALCU:'LATE NEW VALUES OF F'H AtNtI H,'.4:L C::5-2i2 F'HtN= F'HLPR-( Fl 1 1';( -YHF' ) )* Ei'3S4., H,,- n ti-+ F"2 F': "at st. ) )*:EtN.r; 47 - < > i... YH- F'H'' \;:. tF':f5 L4H f.' t: t; K( J )':'.L" Fl 1 P -F 1 N1 0.',4. / F F' r7'" 2 tH,..;C,-;-"':."6 Y(HF' I - HN::S5 C) RETURN I:. Etli.'

APPENDIX F ASSEtMLY LANGUAGE ROUTE ES SOURCE CODE

1t; 116 4 F ASSEMBLY LANGUAGE CODE FOR ME600 PROJECT 6; —-- ----- 7; 9; o; INTERRUPT CONTROLLER CONTMMLLERAND WORDS 3 ICW-I EQU 010H;INTERRUPT INITIALIZATION. 4 ICW2 EQU OllH; COMMANID WORDS 7 C 6 OCW1 ERU OLiH;iNTERRUPT OPERATION 7 OCW2 EQU 01OH;CONTROL WORDS 9 MASK EQU OFEH; r!TERRUPT MASK 0; _:VERTHING BUT CLOCK) EOI EQU 020H;ENtB OF IlTERRUPT 3 CLKEOI MACRO 4; 5 This nimcro issues the inrterru;.t a;tnc;kwledIe; ccminm;and to the real timne clocK, nd is desigrned to 7 i be'hs'siclls last in an interru.t service routine 9; O PUSlH A F I LD AEOI;ISSUE At' ED OF INTERRUPT 2 OUT (OCW2),A; TO THE CONTROLLER 4 F'OP AF 5; EI; ENAtLE INTERRUF"TS 6 RETI;AND FRETURN 7 EENI tM o; 9 i 0; THE PEAL TIME CLOCK A3 ASEG: F' PUPL - -'B' T'INTV'EC ORO 04000H;MUST START AT A 64 BYTE j6 i;O U NARYI H ER E IT IS 7;LOADED li NI tHi GH HE'ORY 9; INTERRUPT VECTOR 0; 2 I'ITVEC: i;D"LYP' FUNCTTIOCI IS TO 3..P SERVICE;.JU.;FP TO SERVICE ROUTINE 7? 4 7 CSEG 8 PUBLLIC SERV'ICE, Ii4TINL EtNABLE iI ISABL 9 EXT ISR 0;

117 3 INTINL:' PUSH HL PUSH AF 5; 7; INITIALIZE THE INTERRUPT FACILITY AND; SET THE MASK REGISTER TO ENAPBLE THE REAL TIME: CLOCK (BIT O = CLOCK) i 2 LrD HL INTVEC;INTERRUF'T VECTOR -> HL 3 LID AL;LOWER ROUTINtE AIDDR -> A 4 AND 11100000B;MASK OFF BITS 0 - 5 5 OR OO0010010B;MERGE SO VECTOR INTERVAL =-8 BYTES 6 OUT ( ICW1 ),A;INITIALIZE 7 LLD AH i INTERRUPT 8 OUT.(I CW2 ),; ADIDRESS 9; 0 1 Lit AMASK(;INITIALIZE MASK 2 OUT (OCW1 ),A;FOR REAL TIME CLOCKt 3; 4; SETS INTERRUPT MODE 0 FOR THE CPU 5; THE USER MUST ISSUE A ENA'ALE INtTERRUPTS c.'5 i COMMANiD TO ACTUALLY START THE CLOCK 7; 9 Jf o; EI i.; 2; Clock is ticKing fronm this Point on 4; 5; 6 IM 0 -7 B; RETURN FROM SUBROUTINE o FPOP AF.1 POP HL 2 hRET -v i 7; B;`SElICE ROUTINE THAT JU;ST RETURNFS AFTER AN INTERRUPT 9; COCCURREII THIS iEAtNS THAT AFTER'$YOU ENAHELE INTERRUPTS O; AiJND YOU ISSUE A HALT COitMMANr THE F'ROCESSOR STARTS 1; EXECUTItCG ArCAIN AFTER 100 iL' LISECO'NDS RELOAWDS THE CLOCK 2; li)ANDr EXECUTES THE NEXT STATE MENT AFTER HALT 5 SEHRVICE:CALL ISR;CALL INTERRUF'T SERVICE ROUTINE 6 CLOCLEOI; ACtKNtOWtLEGE INTLERh'UP'T 7;i 0ANDt RETURN' 7 i

0 3. 21 ENtABLE: EI 0122 RET 012:3; 0124; 01275 IISABL: DI 0126 RET 0127; 0128; 0129 TITLE AtDC SUBROUTINE 0130 SUBTTL DOCUMENTATION 0131; 0132; 0133; This routine is desisned to be called 0134; from s FORTRAN Prosramn and will Perform analog 0135 i to digital conversions using the XYCOM 1850B 0136; board, The mode of operation is randomn channel 0137; -ddressing with interrupts disabled. The 0138; number sand order of addressinS is sp-ecified bV 0139; the labeled common blick /AIDCBLK/. The sub0140; routine returns vaolues in an INTEGER.2 arras 0141; which is the arcumernt to the' call. 0142; 0143; A samrrle calling secnuence is. 0144 7 0145; INTEGER*t2 AICVAL( 27 ) 0146; LOGICAL*1 NADCADCHN( 8) 0147; 0143 i 0149; NAD C =3 0150; AIDCHN( I )=0 0151; AErCHN( 2 )=3 0152; ADCHN( 3)=2 0153; 01 54; 01 5; 0156; ro 100 I-1V27r3 0157; CALL AI'C( ADCVAL( I)) 0158 i CONTINUE 0159; 0160; 0161 SUBTTL COMiiQON /ArICBLK/ NADC, ADCHN( 8) 0162 COMMON /A1DCBLK/ 0163 NAC: DEFS- 1 NUMBER OF CHAPNNELS 0164 ALCHN t: IDEFS; CH ANi7NELS SELECTIEDI 016 SUB TTL ADC CODE 0166 CSEG:167 P U LLIC ADlC 0163 -— ~-' 17 0; SYBOL S 0D174; 0175 SLOTNO EQU OFF70H;SLOT CODE H.ERE 1850B IS. 0176;INSTALLEII A N IS THE BASE 0(177;.FOR THE FOLLOWING: 0173; 0179 STATUS EQU SLOTNO;STATUIS 4CORDF;I 0180 iMULPLX' EQU SLOT O+I;MULT 1IP'LEX AlDF;RESS

1 IATAl EQU SLOTNOf2;AADiRESS OF FIRST DATA BYTE 1ig 2 IATA2 EQU SLoTNH+3;ADDrrREs OF SECO1'ND DATA BYTE 4; 5; 6 ADtrONE -EQU 7;BIT SET WHEN DONE; 2; CODE'4 7; SAVE REGISTERS ON EtTRY 9 ADC: PUSH IX O PUSH IY I PUSH HL 72 PUSH DE 3 f'PUS H BC 4 PUSH AF JS i!7; ASSUME DESTINATION ADDRESS OF IDATA IS S FPOINTED TO BY HL 9; 0 72 rL AF( NADC) >;NUMBER OF 3 LIt BiA;CHANNELS IN B 4 LII IX, ADCHN;IX FOR MULTIPLEXING S LtL IYSTATUS;IY TO CHECK STSTUS 6 i7 S; iTHE FOLLOWING LOOP MULTIPLEXES, WAITS, & STORES 9; 0;.1 Lit A,(IX);ACCUMULATOR HAS CHANNEL 2 ADCLP: LLI (M ILPLX ) A;ADiIDRESS A CHA, "NEL & INC IX;INCREMENT FOR NEXT TIME 4A,.: tLi1 A,( IX);ACCUMULATOR HAS CHANNEL I? ~ 6; WAIT' BIT rADlEtNE( I );IF THE DONi.'E BIT t4NOT SET JR ZWAIT; WAIT TIL IT IS LD IE DE,(DATA1);( i1ATA1) - E 2 V;(DATA2) -> DI S LLD (HL),D;STORE HIGH BYTE INC HL;ANID ItNCRE.ENT R L1 ~Li (HL )E;STORE LOW BYTE 3 tINtC HL;AND ICFT<EtET HL

2~41 1 120 0242; 0243 IJNZ ADCLP;LOOP IF MORE CHANNELS 0244; 0245; 0246; RESTOR REGISTERS 0247; 0248 0249 POP AF 025,0O POP BC 025 1 F'OP DE 0252 POP HL 0253 POP IY 0254 POP IX 02515 RET 0256 TITLE DIAC SUBROUTINE 0257 SUBTTL DiOCUlMENTATION 0258; 0259; 0260; This routine is desitned to be called 0261; fron s FORTRAN Progranm rnd will rPerformn di'ital 0262?; to mnrlos conversions usin, the XYCOM 1850B 0263; bc.ard. The nmode of o'eration is randoni ch-nnel 0264; mddressin' with interrupts dis-bled. The 0265; nu-iber and order of addressins is specified bu 0266C; the l obeled conmmon block /IDACBLK/. The sub0267; routine sendrs values in n IN1TEGE R:2 orr:s 02 68, which is the Oer-unient to the call. 0_270; A sanrle cllinmL sec.uence is''71; 0272; INTEGCERt2 IDAC'VAL( 27 ) 0273; LOGICAL*1 NIDAC r ACHN( 4) 027 4. i COMMON /IIACBLK/ NDAC, DACHN t..5; 7 0276 i 0277 Ni tDiAC =2 0278; DACHN( 1 )=0 027 9; l DACHN( 2 )=1 0281; 02E2; "'"".3; r'O 100 I=1 2 7, 3 0.. 24.; CALL ItAC( Irt;C''AL( I )) v,.TC.,; CONt'T I tNUE 6287; SUBTTL COHHOtiN,/' tACiC tL-LKtC NAC: DACH CN( 4) 289 COK.,CON / DACBL(K/ 0290 N DAC: D EFS 1 s; itNUMtiER OF CHANNELS:29:L.D ACHN: DEFS 4;CHAtPNN1ELS SELECTElD 0292 SUBTTL IDAC CIODE 0293 CSEG 029 4 PUBtL IC lDAC 0295; 029 6; 029 7; 0298;,: 0300;

i; CODE 121 4; 6 SAVE REGISTERS ON ENTRY 7; 8 IAC: PUSH IX 9 PUSH HL O PUSH liE 1 PUSH BC 2 PUSH AF 3; 4.; 5; ASSUME SOURCE ADDRESS OF DATA IS 6; POINTED TO BY HL 7; 8; 9; o LID A,( NDAC);NUMBER OF I Lit BA;CHANNELS IN B 2 LID IX IACHN;IX FOR MULTIPLEXING 3; 4; 5 IDACLPF: L DI( HL);GET LOW BYTE 6 INC HL;AND INCREMENT 7 Lrt AOFH.;MASK FOR BITS 4-7 8 AND (HL);WITH RESULT IN A 9 INC HL;AN'D INCREMENT O LI' EA;AlNDt MOV TO E i; 2; CHECK FOR ODD OR EVEN CHANNEL 3; 4 BIT O,(IX);CHECK BIT ZERO 5, JR ZSENDIT;IF EVEN,SEND NOW 6 SET 7,E;OTHERWISE SELECT IDAC1 7; 9 SENDIT: LIr (DATA1 ),DE 0 It4C IX I; 2; 3.IIJNZ DACLP;LOOP IF MHORE CHANNELS 4' 5; 6; RESTOR REGISTERS 7; 8 9 POP AF O POP BC 1 POP IDE 2 POP HL 3 POP IX ~ RET S EtND 6

UNIVERS"T OF MICHIGAN 3 9015 03483 4070