IMPLEMENTATION AND EVALUATION OF AN INTELLIGENTTUNER FOR AN ILL-DEFINED SERVO-MOTOR SYSTEMByShimshon BarlevB.Sc., BEN-GURION UNIVERSITY, Israel.A THESIS SUBMITTED IN PARTIAL FULFILLMENT OFTHE REQUIREMENTS FOR THE DEGREE OFMASTER OF APPLIED SCIENCEinTHE FACULTY OF GRADUATE STUDIESMECHANICAL ENGINEERINGWe accept this thesis as conformingto the required standardTHE UNIVERSITY OF BRITISH COLUMBIAApril 1992© Shimshon Barlev, 1992In presenting this thesis in partial fulfilment of the requirements for an advanceddegree at the University of British Columbia, I agree that the Library shall make itfreely available for reference and study. I further agree that permission for extensivecopying of this thesis for scholarly purposes may be granted by the head of mydepartment or by his or her representatives. It is understood that copying orpublication of this thesis for financial gain shall not be allowed without my writtenpermission.(SignatureDepartment of ^(- a-C r► The University of British ColumbiaVancouver, CanadaDate Mali le, 13,2-DE-6 (2/88)ABSTRACTThis research deals with automated, knowledge-based tuning of servo motors. Con-ventional adaptive techniques can perform unsatisfactorily when the controlled system iscomplex and incompeletly known. Furthermore, they cannot directly capture and utilizethe knowledge of experienced human operators, in tuning a servo system. The tuningtechnique developed and implemented in this work can overcome these shortcomings.To integrate the controller of a high speed servo-motor with the tuning knowledgeof experienced system operators, a hierarchical control structure is developed in thisresearch. Specifically, the programmable hard controller of a servo-motor is tuned auto-matically in the lowest level. In the highest level, tuning knowledge expressed as a set oflinguistic rules is generated and mathematically formulated using fuzzy set theory andfuzzy logic. This leads to the development of an off-line decision table in which tuningactions are matched with the servo-motor performance. A computer implementation of aservo expert is used in the intermediate level to update the controller parameters so thatthe actual response would meet a set of predefined performance specifications expressedin terms of the performance of a reference model.Learning and self-organization, as well as automated specification updating, if neces-sary, are used to improve the performance accuracy and system robustness.The intelligent tuner is implemented on a commercially available servo-motor system,and experiments are carried out to demonstrate its performance when implemented on thephysical system. Furthermore, simulation results are used to evaluate the performanceof the intelligent tuner when implemented on an ill-defined process.iiTable of ContentsABSTRACT^ iiList of Figures ixList of Tables^ xiiNomenclature xiiiACKNOWLEDGEMENTS^ xvii1 INTRODUCTION 11.1 Overview of the Thesis ^ 11.2 Background ^ 21.2.1 Servomechanism and Servo-Motor ^ 21.2.2 Adaptive Control ^ 31.2.3 Expert Systems 81.2.4 Expert Control ^ 91.2.5 Generality, Uncertainty, Vagueness, Ambiguity and Imprecision ofKnowledge ^ 111.2.6 Fuzzy Logic 121.2.7 Fuzzy Control ^ 121.2.8 Fuzzy Tuning 131.2.9 Learning Systems ^ 131.3 Objective of the Research 14iii1 .4 Motivation ^ 141.5 Relevance of this Research ^ 151.6 Literature Review ^ 161.6.1^Adaptive Control 161.6.2^Expert Systems and Expert Control ^ 171.6.3^Fuzzy Sets and Fuzzy Logic 181.6.4^Control Application of Fuzzy Logic ^ 182 FUZZY LOGIC 202.1 Introduction ^ 202.2 Fuzzy Sets 202.3 Membership Functions ^ 212.4 Logical Operations 232.5 Fuzzy Relations ^ 242.6 Composition and Inference ^ 303 SYSTEM DEVELOPMETNT 353.1 Introduction ^ 353.2 General Hierarchical Structure ^ 383.3 Servo-Motor Level ^ 413.3.1^Physical Servo System ^ 413.3.2^Simulated Servo-Motor 453.4 Servo Expert Level ^ 493.4.1^Performance Specification ^ 513.4.2^Response Preprocessor 553.4.3^Performance Evaluation ^ 573.4.4^Performance Index Classification ^ 59iv3.53.4.5^Tuning of the Controller Attributes ^3.4.6^Mapping the Attributes of the Controller to its ParametersFuzzy Tuner Level ^6163673.5.1^Fuzzy Ruleset 703.5.2^Membership Functions for Performance and Tuning Variables 733.5.3^Fuzzy Relation between Condition and Action Variables ^ 753.5.4^Decision Table ^ 784 EXPERIMENTAL STRATEGY AND PROCEDURE 814.1 Introduction ^ 814.2 Experimental Strategy ^ 814.3 Performance Requirements 824.3.1^Model Parameters ^ 824.3.2^Acceptable tolerance 834.3.3^Test Signal ^ 834.4 Base-Line Servo-Motor System^ 844.5 Generation and Evaluation of Tuning Rules ^ 864.6 Experimental Procedure ^ 954.6.1^Tuning of the Simulated Servo-Motor System ^ 954.6.2^Tuning of a Commercially Available Servo-Motor System ^ 965 SIMULATION AND EXPERIMENTAL RESULTS 975.1 Simulation Experiments ^ 985.1.1^Slow Servo-Motor System ^ 985.1.2^Oscillatory System 1005.1.3^Increased Motor Inertia ^ 1025.1.4^External Torque without Integral Compensation ^ 104v5.25.1.5^External Torque with Integral Compensation ^5.1.6^External Spring ^5.1.7^Voltage Source Amplifier Model ^Experiments using a Commercial Servo-Motor 1061081111155.2.1^Slow Physical Servo-Motor System ^ 1165.2.2^Physical Oscillatory Servo-Motor 1185.2.3^Motor with Increased Inertia ^ 1206 RULE GENERATING BY SELF LEARNING 1226.1 Introduction ^ 1226.2 Self Generated Rulset Development ^ 1236.2.1^Approach ^ 1236.2.2^Controller Presetting ^ 1246.2.3^System Perturbation 1246.2.4^Response Sensitivity Index ^ 1266.2.5^Response Sensitivity Classification ^ 1276.2.6^Rule Pattern ^ 1286.3 Experimental Procedure and Results ^ 1296.3.1^Procedure ^ 1296.3.2^Results 1296.4 Summary 1347 CONCLUSIONS and RECOMMENDATIONS 1377.1 Introduction ^ 1377.2 Summary of Accomplishments ^ 1377.2.1^The Development of the Experimental System ^ 1377.2.2^Rule Base of Tuning ^ 138vi7.2.3 Tuning Simulated System ^ 1397.2.4 Implementation on Physical System ^ 1397.2.5 Self Learning ^ 1397.3 Main Contributions of the Research ^ 1397.4 Advanatges and Limitations 1407.5 Future Developments ^ 141Bibliography^ 142Appendices^ 151A The Physical Servo-Motor^ 151A.1 General Specification of the Servo-Motor System ^ 151A.2 Motor ^ 152A.2.1 Specifications of the 50/1000 DC Motor ^ 152A.2.2 Mechanical Drawing of the 50/1000 DC Motor 153A.3 Specification of the DMC400 Controller ^ 154A.4 Specification of the Interconnection Board 155A .5 Interface and Communication Soft ware ^ 156A.5.1 Inerface to C ^ 156B Programs Listing^ 170B.1 Main Program coded in ACSL ^ 170B.2 Servo-Expert sub-programs listing 175B.2.1 Sub-Program MODEL ^ 175B.2.2 Sub-Program PREPROCESS 176B.2.3 Sub-Program EVALUATION ^ 178B.2.4 Sub-Program CLASSIFICATION 181viiB.2.5 Sub-Program TUNING ^ 184B.2.6 Sub-Program DESIGN 188B.2.7 Print Out ^ 189B.3 Fuzzy Tuner Program listing ^ 192B.3.1 Main Program DECISION 192B.3.2 Sub-Program DATA ^ 194B.3.3 Sub-Program CNDMF 197B.3.4 Sub-Program ACTMF ^ 199B.3.5 Sub-Program RULESET 201B.3.6 Sub-Program RELATION ^ 209B.3.7 Sub-Program DECISION 212B.3.8 Sub-Program DEFUZZY ^ 214B.4 Subprogram LEARN ^ 215List of Figures1.1 Block Diagram of Gain Scheduling ^51.2 Block Diagram of SOAS ^61.3 Block Diagram of MRAS ^61.4 Block Diagram of Self-Tuning Regulator ^71.5 Block Diagram of a Knowledge-Based Expert Control System ^ 112.1 A Fuzzy Set ^ 222.2 Relations in Two Dimensional Space (plane) ^ 252.3 Cartesian Product of A l x A2 (relation) ^272.4 A Mapping from a Product Space to a Line ^ 292.5 The Cylindrical Extension ^ 323.1 The Experimental System 373.2 Hierarchical Structure of the System ^ 403.3 The Hardware of the Physical Servo-Motor System ^ 423.4 Block Diagram of the Simulated Servo-Motor 453.5 Block Diagram of the Servo Expert Level ^ 503.6 Mapping from Performance to performance Index ^ 603.7 Controller Attributes Definition ^643.8 Fuzzy Tuner Block Diagram ^ 693.9 Membership Functions for the Performance Variables ^ 743.10 Membership Functions for the Tuning Variables 75ix4.1 Time Domain Response of the Base-Line Servo-Motor System ^ 854.2 Effect of Phase Lead Angle at Cross-over Gain Frequency ^ 874.3 Effect of Cross-over Gain Frequency ^ 874.4 Effect of Cross-over Gain ^ 884.5 Effect of Cross-over Gain when External Load is Applied ^ 884.6 Effect of Low-frequency at Cross-over Gain when External Load is Applied 895.1 Tuning of initially Slow Servo-Motor: Time Response ^ 985.2 Tuning of an Initially Slow Servo-Motor: Controller Attributes ^995.3 Tuning of an Initially Oscillatory Servo-Motor: Time Response ^ 1005.4 Tuning of an Initially Oscillatory Servo-Motor: Controller Attributes^1015.5 Tuning a Motor with Increased Inertia: Time Response ^ 1025.6 Tuning a Motor with Increased Inertia: Controller Attributes ^ 1035.7 Tuning for External Torque without Integral Compensation: Time Response1045.8 Tuning for External Torque without Integral Compensation: ControllerAttributes 1055.9 Tuning for External Torque, using Integral Compensation: Time Response 1065.10 Tuning for External Torque, using Integral Comensation: Controller At-tributes ^ 1075.11 Motor Block Diagram for External Spring ^ 1085.12 Tuning in the presence of an External Spring: Simulated System Response 1095.13 Tuning in the Presence of an External Spring: Controller Attributes . . . 1105.14 Tuning of a Slow Servo-Motor with Voltage Source Amplifier: Time R,esponselll5.8 Tuning of a Slow Servo-Motor with Voltage Source Amplifier: ControllerAttributes ^ 1125.9 Tuning for Oscillaory Servo-Motor with Voltage Source Amplifier — TimeResponse ^ 1135.9 Tuning of an Oscillatory Servo-Motor with Voltage Source Amplifier: Con-troller Attributes ^ 1145.10 Tuning of a Slow Servo-Motor: Time Response of the Physical System ^ 1165.10 Tuning of a Slow Servo-Motor: Controller Attributes of the Physical System1175.11 Tuning of an Oscillatory Servo-Motor: Response of the Physical System . 1185.11 Tuning of an Oscillatory Servo-Motor: Controller Attributes of the Phys-ical System ^ 1195.12 Tuning for Increased Motor Inertia: Physical System Response ^ 1205.12 Tuning for Increased Motor Inertia: Physical System Controller Attributes 1216.1 The System in Learning Mode ^ 1256.2 The Response of Preset and Perturbed Systems ^ 1316.3 Tuning of a Slow Servo-Motor using a Self-Learning Ruleset ^ 1356.4 Tuning of an Oscillatory Servo using a Self-Learning Ruleset ^ 136xiList of Tables3.1 Development^Fuzzy Relation Table^RISTM^PHCOF)of a (for^—4^ . 773.2 Fuzzy Composite Relation Table for RISTM and PHCOV 783.3 Decision Table for the Servo-Motor ^ 804.1 Condensed Form of the Ruleset 946.1 Self Generated Ruleset ^ 133xiiNomenclatureMost of the symbols used in the text are defined in the sections in which they occur.Math italic type style is used for the servo-motor parameters and variables.In the servo-expert level calligraphic letters are used for the performance parametersand Greek letters for the tuning actions.Fuzzy performance parameters and tuning actions as well as performance and tuningquantities in the fuzzy tuner level are denoted by capital text letters and are arranged infuzzy arrays indicated by the tilde math accent -.T^Sampling time interval of controller[s]AT, Communication time interval of servo-motor tuner [s]t^ time [s]Po motor position [rad]K^torque constant [N • m I amp]V, supply voltage to the stator in voltage source amplifier [volt]J moment of inertia of the rotor [kg m2 ]L inductance of the field winding [mH]R^resistance of the field winding [ohm]B motor mechanical damping [kg I s]Ti^ external load [N • m]Laplace variable'1^supply current to the stator in current source amplifier [amp]A effective gain of the current source amplifier [amp I volt]Vmax^maximum voltage input to the amplifier [volt]Imam^maximum current output of the amplifier [amp]Y measured position of the motor (encoder output) [counts]N number of pulses per revolution of encoderGe^transfer function of the encoderG transfer function of the controllerGcl^ transfer function of the lead-lag branch of controllerGcs transfer function of the integrator branch of controllerGp^transfer function of the system, excluding the controllerC controller output [volt]Y;^required motor position [counts]K1^lead-lag compensation net gainK integrator compensation net gainZr^frequency of the lead-lag zero [rad/s]P1 frequency of the lead-lag pole [radl s]z^ Z'-transformGm transfer function of the reference modelYm^position response of the reference model [counts]Wn^ undamped natural frequency of the reference model [rad/s]damping ratio of reference modeldeterministic error (offset) of reference modelnondeterministic error of reference modelamplitude of response peakstiming of response peaks [s]P^number of response peaksxivREDROSPRERR7-1-1ICcobwwcogOco flk co fwlcog0(1)PIPV(;)JPQ(,)kRISTMDMPFRDMPRTrise time of response [s]average damped natural frequency of response [rad I 8]average damping ratio of responseovershoot of responseoffset of responseaccuracy of responsenormalized error vector between the performance parameters of servo-motor avector of performance classification thresholdsvector of performance indexfrequency bandwidth of servo-motor [rad' s]cross-over gain frequency of servo-motor [rad/s]phase lead angle of controller at wcog [rad]gain of controller at wcoglow frequency at Ocof [radIs]vector containing the controller attributesuniverse of fuzzy performance variablescardinality of fuzzy performance spaceindex of fuzzy performance variablesfuzzy subspace in the universe of performance variablesindex of fuzzy performance quantityelement in P (; )index of membership function of performance indexfuzzy form of REfuzzy form of DFfuzzy form of DRxvOVSHT^fuzzy form of OSOFFST fuzzy form of O.FACCUR^fuzzy form of ACT^universe of fuzzy tuning actionsL cardinality of fuzzy tuning action space1^index of fuzzy action variablesTV( i ) fuzzy subset in the universe of tuning variablesm^index of fuzzy action quantityTQ(m)^element in T(,)n index of membership function of tuning actionPHCOV^fuzzy form of OcofFRCOG^fuzzy form of weogGNCOF^fuzzy form of OcofLFCOG fuzzy form of wlcogRU^array of fuzzy rulesPM array of performance membership functionsT M^array of tuning membership functionsRL array of fuzzy relationsDT^decision table arrayACKNOWLEDGEMENTSI would like to thank Dr. C.W. de Silva for his constant supervision and guidancethroughout this research. Special thanks also to all my fellow students and friends fromthe of Industrial Automation Laboratory (IAL) for generous help and support, whichmade the whole experience more enjoyable.I would like to thank RAFAEL for sponsoring my graduate studies and the IndustrialAutomation Chair of the Natural Sciences and Engineering Research Council (NSERC),held by Dr. C.W. de Silva for partial funding of this research.Last and not least, I would like to thank my family for their constant support andencouragement.xviiChapter 1INTRODUCTION1.1 Overview of the ThesisThis thesis presents a study of the analysis and practical implementation of an in-tellegent tuner for a servo-motor. A method to automate the tuning actions taken byan experienced process operator in a complicated (complex) system that is found to bebeyond the capability of conventional adaptive techniques, is considered. While a num-ber of studies have considered the use of fuzzy logic in control applications, the majoritywere employed in low level direct control rather than high level controller tuning. Also,fuzzy tuning has been implemented in simulated systems only.An experimental system has been developed to explore, evaluate, implement andillustrate the tuner performance.It has three hierarchal levels:• Simulated servo-motor system consisting of a programmable controller, D.0 motorand encoder has been developed in the lowest level of the hierarchical structure.• In an intermediate level, called the servo expert level, an intelligent evaluator eval-uates performance index using the responses of the actual and reference models.A design mechanism updates the controller parameters using tuning actions whichwere provided from a decision table, using a preformance index as a contex.• In the highest level of the hierarchy, knowledge of the effect of each tuning actionon the performance parameters is generated and mathematically formulated using1Chapter 1. INTRODUCTION^ 2fuzzy sets theory and fuzzy logic operations to calculate a decision-table. Herethe performance indices are matched with the tuning actions. Learning and self-organization is also used in this level to modify the decision table automatically.The tuner has been implemented on a commercially available servo-motor and itsperformance has been examined. Further experiments have been conducted by graduallyspoiling the simulated servo-motor far below the simple system model.The thesis is divided into seven chapters. Chapter 1 presents the basic concepts,background, objectives, motivation, relevance of the work and literature review. Chapter2 gives a brief review of fuzzy sets and fuzzy logic theory as this is necessary to understandthe mathematical representation of human knowledge. Chapter 3 describes the systemstructure and development. Description of the experimental strategy and procedure isin Chapter 4. Experiments on simulated and physical systems are described in Chapter5. Chapter 6 lays the foundation for future work by introducing a learning and self-organizing tuner system. The work is concluded in chapter 7.1.2 BackgroundIn this section the key terms that are used throughout this work are briefly explained.In particular servomechanism and servo-motor, various adaptive control methods, expertsystems and expert control, knowledge base, fuzzy knowledge, fuzzy logic, fuzzy controland fuzzy tuning are explained.1.2.1 Servomechanism and Servo-MotorServomechanisms are widely used to drive processes in industrial, transportation, aero-nautical and space systems as well as domestic applications. The term "servo-mechanism"Chapter 1. INTRODUCTION^ 3has been used in the literature with a variety of meanings. We shall call a device a ser-vomechanism if it satisfies the following description:The device controls some physical quantity by comparing its actual response with itsdesired values and uses the difference (or error) to drive the actual response into corre-spondence with the desired value.Electrical (stepper, DC, AC or synchronous) motors, pneumatic or hydraulic actuators[24]might be used to drive the process. Digital or analog controllers are used to controlit. In both cases the parameters of the controller are chosen such as to meet somepredefined performance specifications. The actuator of a digital D.C. servomotor is anelectrical direct current motor and it has a digital controller. In this work the term"servo-motor" stands for DC brushless motor having a digital servo controller.1.2.2 Adaptive ControlIn everyday language, to "adapt" means to change a behaviour to conform to newcircumstances. Intuitively, an adaptive controller is a controller that can modify itsbehaviour in response to changes in the dynamics of the process and the disturbances.Adaptive control is a special type of nonlinear feedback control in which the statesof the process can be separated into two categories, which change at different rates. Theslowly changing states are viewed as parameters. This introduces the idea of two timescales: a fast time scale for the ordinary feedback and a slower one for updating thecontroller parameters.A Brief HistoryIn early 1950's there was extensive research on adaptive control, in connection with thedesign of autopilots for high performance aircraft, which operate over a wide range ofspeed and altitude. It was found that a constant parameter controller would work wellChapter 1. INTRODUCTION^ 4in one operating condition but a change in operating conditions led to difficulties, and amore sophisticated controller was therefore needed [4].Theories for state space modeling, stability analysis and stochastic control, and tech-niques of system identification, parameter estimation and dynamic programming weredeveloped in the 1960's and this also contributed to the understanding of adaptive pro-cesses. Many applications were reported in the 1970's when different estimation schemeswere combined with various design methods.In the early 1980's rapid and revolutionary progress in microprocessors has made itpossible to implement adaptive methods simply and cheaply. Several commercial adap-tive controllers based on different ideas are appearing on the market, and the industrialuse of adaptive control is growing slowly but surely.Adaptive SchemesThere are many schemes of adaptive control. Most of them are based on either priorknowledge of a system model or identification/estimation of a model of the process to becontrolled. These methods can be classified as direct and indirect methods [4]:• Direct methods:In direct methods the adjustment rules tell directly how the controller parametersshould be updated.• Indirect methods:An indirect scheme is obtained if a process model is identified, its parameters areestimated and the controller parameters are updated through the solution of adesign problem.Chapter 1. INTRODUCTION^ 5ControlOperatingconditionCommandsignal ^6.GainscheduleProcessRegulatorparametersRegulatorOutputyFigure 1.1: Block Diagram of Gain SchedulingGain SchedulingIn gain scheduling the parameters of a closed loop feedback controller are adjusted in afeed-forward manner, in an open loop with known operating conditions. A block diagramof system with gain scheduling is presented in Figure 1.1 [4]:Self-Oscillating Adaptive SystemA self-oscillating Adaptive system(SOAS) has high loop gain and its bandwidth isautomatically adjusted to be as high as possible by introducing a relay in the feedbackloop. This results in a robust system over a wide bandwidth. A limit cycle oscillationis presented and the system is always excited. A block diagram of a SOAS is shown inFigure 1.2[4]:Model Reference Adaptive SystemsModel Reference Adaptive Systems (MRAS) consist of two loops: an inner loop, whichis the ordinary feedback loop and an outer loop to adjust the controller parameters in sucha way that the error between the output of the process and a reference model becomessmall.A block diagram of MRAS is shown in Figure 1.3[4]AdjustmentmechanismChapter 1. INTRODUCTION^ 6Model Lead-lag Process—1Figure 1.2: Block Diagram of SOASYmModel^alRegulator parameters ^ucRegulator PlantFigure 1.3: Block Diagram of MRASDesignProcessRegulatorRegulatorparametersu•^EstimationChapter 1. INTRODUCTION^ 7Process parametersFigure 1.4: Block Diagram of Self-Tuning RegulatorSelf-Tuning RegulatorThe Self-Tuning Regulators (STR) are a family of methods based on the idea of sep-arating the on-line estimation of unknown parameters from the design of the controller.These methods differ either by the design or estimation algorithm.The following belong to this family :• Linear Quadratic Self-Tuning Regulator (LQS).This make use of an optimal feedback law that minimizes a quadratic function(positive semidefine) error between the actual and model responses and also thecontrol effort.• Adaptive Predictive Control (APC).This algorithm is based on an assumed model of the process and on assumed sce-nario for the future control signals. This gives a sequence of control signals. Onlythe first one is applied to the process, and a new sequence of control signals iscalculated when a new measurement is obtained.A block diagram of a typical STR is shown in Figure 1.4[4]Chapter 1. INTRODUCTION^ 8Auto TuningAuto tuning is based on an experimental phase in which test signals are injectedinto the system. The controller parameters can be determined from the experimentsusing standard rules for tuning if these rules exist (for example Ziegler-Nichols rules forPID controllers). The main advantages of an auto tuner are that it requires little priorinformation on the process, is very robust and can generate good parameters for a simplecontrol law.[79][18][54]1.2.3 Expert SystemsAn expert system attempts to model the knowledge and procedures used by a humanexpert in solving problems within a well-defined domain. An expert system consists of aknowledge base, inference engine and one or more data bases which may be linked to auser interface. [38]Knowledge BaseThe knowledge base consists of data and rules. The data are facts and goals. Datais introduced into the database by the user or via the real time knowledge acquisitionsystem. A rule base contains production rules of the type:" If premise then conclusion do action".The premise represents fact or condition from database. The conclusion can resultin a new fact being added to the database or modification of an existing facts. Theaction activates control, estimation or tuning algorithms. The rules are introduced bythe knowledge engineer via the knowledge acquisition system, which assists in writingand testing rules. In control applications the rules represent knowledge about the controland estimation problem that is built into the system.Chapter 1. INTRODUCTION^ 9Inference EngineThe inference engine processes the rules to arrive at conclusions or satisfy goals. Itscans the rules according to a strategy which is decided from the context (current databaseof facts and goals) and decides which production rules are to be selected next. This canbe done according to different strategies:In forward chaining it is attempted to find all conclusions from a given set of premises.In backward chaining the rules are traced backward from a given goal to see if it can besupported by the current premise. fUser InterfaceThe user interface can be divided into two parts. The first part is the developmentsupport that the system gives, such as rules editor and rules browser for developmentof the system knowledge base. The other part is the run time user interface. Thiscontains the explanation facilities that make it possible to question how a certain factwas concluded, why a certain estimation is executed, etc. The user interface can alsocontain facilities to deal with a natural language.1.2.4 Expert ControlThe idea of expert control is to have a collection of algorithms for control, supervisionand adaptation that are orchestrated by an expert system. A block diagram of suchsystem is shown in Figure 1.5[4] . A comparison with Figure 1.4 on page 7 shows thatthe system is a natural extension of a self-tuning controller. Instead of having one controlalgorithm and one estimation algorithm, the system has several algorithms. It also hasalgorithms for excitation and for diagnosis, as well as tables for storing data.Apart from this it also has an expert system which decides when a particular algorithmChapter 1. INTRODUCTION^ 10should be used. The expert system contains knowledge about particular algorithms andconditions in which they can be used.Chapter 1. INTRODUCTION^ 111.2.5 Generality, Uncertainty, Vagueness, Ambiguity and Imprecision ofKnowledgeGenerality, Uncertainty, Vagueness, Ambiguity and Imprecision are terms which areoften used in the contents of fuzziness but strictly speaking these terms have meaningswhich differ from the formal definition of fuzziness [23][25]. Generality can be associatedwith the use of a single symbol to represent more than one element. Ambiguity is at-tributed deals with the presence of more than one interpretation for a particular situationor quantity. Uncertainty is associated with probability. Precision is defined in terms oftolerance.In developing facts and rules for expert systems, it becomes clear that data and rulesobtained from experienced specialists are somewhat uncertain. They may describe somerules in linguistic terms like "maybe", "sometimes", or "often". Some method is neededto handle these types of possibilistic statements. Furthermore, expert systems, like hu-man experts, may need to draw inference based on unavailable, unknown or uncertaindata. These data are expressed in linguistic form like "tall", "fast", "beautiful", etc.Chapter I. INTRODUCTION^ 121.2.6 Fuzzy LogicFuzzy logic deals with fuzzy sets. A fuzzy set has no sharp boundaries and thepossibility of an element to belong to the set is given by a membership function. Fuzzylogic uses logical operations like AND, OR, NOT which operate on the membership func-tions of fuzzy sets. Fuzzy sets weres found to be useful in uncertain data representationand fuzzy logic in uncertain rule representation.[77][78][29][52]The relevant concepts of fuzzy logic, particulary those useful in fuzzy control areoutlined in Chapter 2.1.2.7 Fuzzy ControlIn fuzzy control, linguistic descriptions of human expertise in controlling a processare represented as a fuzzy rules or relations, and this knowledge base is used, in con-junction with some knowledge of the state of the process (say, measurement response ofvariables), by an inference mechanism to determine control actions at a sufficiently fastrate. [12] [19] [70] [46] [53] [41][3]A formal procedure in fuzzy control can be summarised in the following steps [23]:I. Knowledge Base Development1. Develop a set of linguistic control rules (protocols).2. Develop a set of membership functions for process output variables and controlinput variables.3. Using fuzzy implication on each rule in 1 and using 2, obtain the multi-dimensionalarray of membership values for that rule.Chapter 1. INTRODUCTION^ 134. Combine the array using fuzzy operations to obtain the overall fuzzy rule base.II. Real Time Control Action1. Fuzzify the measured process variables, as fuzzy singletons.2. Match the fuzzy measurements obtained in 1 with the membership array of thefuzzy rule base (obtained in the previous Step 4), using the appropriate fuzzy logicoperations.3. Defuzzify the control inference obtained in Step 2.There are several variations. For example, a much faster approach would be to developa crisp decision table by combining the four steps of fuzzy algorithm development andthe first two steps of control, and using this table in a table look-up mode to determinea crisp control action during operation.1.2.8 Fuzzy TuningTo combine the advantages of low level control for nonlinear, high-order coupled dy-namic with the knowledge of an experienced process operator, a high level fuzzy tuneris used to tune the parameters of a low level controller . This structure results in aconventional, high bandwidth inner control loop and a slow outer closed loop soft tuningalgorithm.1.2.9 Learning SystemsIn their most ambitious form, learning systems attempt to describe or mimic humanlearning abilty. This goal is still far away. The learning systems that have actually beenChapter 1. INTRODUCTION^ 14implemented are simple systems that have strong relations to adaptive control. Suchsystems are neural nets, connectionist models, parallel distributed processing models,et c. [4]1.3 Objective of the ResearchThe objective of this research is to use fuzzy logic to develop implement and evalu-ate a knowledge-based auto-tuning mechanism to automate the tuning actions taken byexperienced operators in complex and partially known servo-motor systems.1.4 MotivationWhat is the motivation for trying "nonconventional" tuning approaches? Why usefuzzy logic? Why tune controller parameters rather than generate the control actionsdirectly?• Motivation for Trying another Tuning ApproachTo design a controller in a "conventional" adaptive technique we have to haveeither a prior known model or estimate/identify a suitable process model and pa-rameters (see Figure 1.4 on page 7). Furthermore if the structure of the process isunknown it should be identified as well. Identification and estimation algorithmsbecome unfeasible when applied to very complicated, manually tuned, real systems.In practical applications the knowledge of an experienced operator is concerningthe effects of each tuning action on the performance rather than the knowledge ofthe model of the process. In this work the approach followed is to take advantage ofthis knowledge to automate these tuning actions directly without using estimationor identification algorithms.Chapter 1. INTRODUCTION^ 15• Motivation for using Fuzzy LogicAn existing knowledge of an expert process operator is expressed in terms oflinguistic rules of the form "if the performance is such and such then the tuningaction is such and such", where the condition and actions are inaccurate, vagueor fuzzy quantities that can be formulated mathematically using fuzzy sets andprocessed using fuzzy logic.• Motivation for Tuning rather than Direct ControlDifficulties in the implementation of direct fuzzy control on a low level of a high-bandwidth system motivate tuning rather then direct control. One drawback ofdirect fuzzy control is that human observation, interpretation, decision making andaction are not fast enough for real time, closed-loop direct control in high band-width systems. Another drawback is that using fuzzy inference in closed controlloop introduces errors directly into the control signals. Another argument againstthe conventional, low-level implementation of fuzzy control is that in high speedprocesses, human experience is gained not through manual, on line generation ofcontrol signal in response to process output, but typically through performing pa-rameter adjustments and tuning (manual adaptive control) operations. [23]1.5 Relevance of this Research• Conserving and Spreading Knowledge of Expert Process OperatorSince human experts are hard to come by, it is not economical to dedicate a humanexpert for every same process. Automating the tuning actions of an expert operatorprovides a means for the conservation and distribution of knowledge.Chapter 1. INTRODUCTION^ 16• Evaluation and Comparison with other TechniqueThis work provides means for performance evaluation and comparison with otheradaptive techniques.• Implementation on Real SystemsImplementation of the tuner on a commercially available servo-motor demonstratesthe feasibility of the proposed tuner in the presence of physical factors and effectsof a real environment like noise, friction, backlash and so on.1.6 Literature Review1.6.1 Adaptive ControlMany papers, books, and reports have been written on adaptive control. Some ofthe earlier developments are summarized in Gregory (1959) [35] and Mishkin and Braun(1961)[58] in flight control applications. Reprints of 44 fundamental papers in adaptivecontrol are found in Gupta (1986)[37].A good introduction to modern adaptive control is found in Astrom and Wittenmark[4]. Later developments in adaptive control are also treated by the same authors[8] in1983 and [9] in 1987.The following are some fundamental references on the different adaptive schemes:Gain scheduling is described in NASA report(1977)[60], by Stein(1980) [68] andby Whatley and Pott (1984) [73] . Self-oscillating adaptive systems are discussed byGregory(1959)[35] and Mishkin and Braun (1961)[58]. The model-reference adaptivecontrol based on the MIT rule is given by Osburn, Whitaker and Kezer (1961) [61]Another book dedicated to MRAS is by Landau (1979)[49].Stability problems in MRAS are treated by Parks(1966)[63]. Narendra and Lin(1980)[59] discussed different generic error model for MRAS.Chapter 1. INTRODUCTION^ 17Further details on MRAS can be found in Kornblugh(1984) [48]The self-tuning idea and its asymptotic properties were first derived by Clark andAstrom(1973)[7]. Gawthrop(1986) [33] used a unified approach to continuous-time self-tuning regulators.Linear Quadratic Self Tuning Regulators which combined least square estimationand minimum variance control was presented by Peterka(1970) [64], Wieslander andWittenmark (1971)[74] and Grimble(1984)[36]. Application to robotic manipulators canbe found in de Silva and Van Winssen (1987) [25]Adaptive predictive control is discussed by:Clarke and Gawthrop (1975)[15] Clarke, Mohtady and Tuffs (1987)[16] [17], Ydstie(1984)[76], De Keyser, and Van Cauwenberghe (1985) [28]1.6.2 Expert Systems and Expert ControlA good source for knowledge about expert systems is the Handbook of Artificial In-telligence by Barr and Feigenbaum (1982)[11]. Another source is Hayes, Watermann andLenat (1983)[38].Expert systems research is done by many workers including Duda and Shortliffe(1983)[30] and by Rich (1983)[65].Knowledge Representation in artificial intelligence is found in Brachman and Smith(1980)[13]and Davis and Lenat (1982)[21].The notation "Expert Control" was introduced by Astrom, Anton and Arzen (1986)[6] and elaborate by dArzen (1987) [2] and Francisand Leitch (1986)[31].Artificial intelligence in process control can be found in Goff (1985) [34].Chapter I. INTRODUCTION^ 181.6.3 Fuzzy Sets and Fuzzy LogicFuzzy sets were first discussed in 1965 by Zadeh [77]and in 1973 [78] for the purposeof defining a fuzzy relation between elements and their sets. Further discussion maybe found in Dubois and Prade (1980) ,[29], Hirota (1979)[40] and Kaufmann (1975)[42],Braae and Rutherford (1979)[12].1.6.4 Control Application of Fuzzy LogicFuzzy control as a new approach to the analysis and implementation of a controlstrategy of a human beings has been analysed by many researches. Kloeden (1982)[45],Kiszka Kochanska and Sliwinska (1985)[47] and Tong(1980)[70] are examples. Fuzzyprocess identification was investigated by Czogala and Pedrycz (1981)[19] and also in1982[19]A partial list of researches in the field of fuzzy control is given below:Assiian and Mamdani(1974)[3], Holmblad and Ostergaard (1981)[41], Kickert andNauta (1976)[43], Mamdani and Gaines (1981)[52], Mamdani (1974)[56] and (1983)[53],Tong (1976)[69].Industrial application of fuzzy logic reported by Larsen (1980)[50] and Mamdani,Ostergaard and Lembessis (1984)[55] and King and Mamdani (1975)[44].Application of fuzzy control in mining can be found in Carter and Rutherford (1976)[14]for a sinter plant.Kickert and Nauta (1976)[43] report the use of fuzzy controller to a warm water plantand Ostergaard (1976)[62] to a Heat Exchanger Process.Tong, Beck and Latter 1980[71] in activated sludge wastewater treatment process andVan Amerongen, Van Nauta Lemke and Van der Veen[72] in application on an autopilotfor ships.Chapter .1. INTRODUCTION^ 19Many applications on robotic manipulators were reported: de Silva and MacFaralen(1989)[23], Mandic, Scharf and Mamdani (1985)[57] , Scharf and Mandic (1984[67] areexamples.Tuning of a PID controller in servo-motor systems has been done by de Silva (1989)[26]and de Silva and Barley 1992[27].Learning and self organizing systems can be found in Hiraim, Asai and Kitajima(1968)[39] , Procyk and Mamdani (1979)[66], Scharf and Mandic (1984)[67], Yamazakiand Mamdani (1982)[75] and many others.Chapter 2FUZZY LOGIC2.1 IntroductionFormalisation of the concept of fuzzy sets and associated fuzzy reasoning (approximatereasoning) is due to Zadeh (1965,1973)[77][78].In this chapter fuzzy logic is reviewed, as this is necessary to understand the mathe-matical representation of human knowledge , used in the next chapter. First the conceptof fuzzy set and membership function, which represents the uncertainty in the humanknowledge, is introduced as well as the fuzzy logic operations which operate on thesemembership functions. Next the relations of fuzzy sets are discussed and finally theideas of composition and inference of fuzzy relations are explained.What is presented here is the interpretation and geometrical illustration of de-Silvaand MacFarlane (1989)[23] to the theoretical considerations described by Dubios andPrade (1980)[29].2.2 Fuzzy SetsFuzzy logic deals with fuzzy sets. A fuzzy set does not have a sharp boundary. Considera universe of discourse X whose elements are denoted by x and a subset A in X. A is afuzzy subset in X if there is vagueness associated with the membership of x in A.20Chapter 2. FUZZY LOGIC^ 212.3 Membership FunctionsIn universe X, the possibility of each element x belonging to the fuzzy subset A isrepresented by a membership function IL,. This assigns a number ii,(x) in the interval[0,1]. If pA (x) = 0 then the element x definitely does not belong to the subset A. IfAA (x) = 1 then the element x definitely belongs to the subset A (or: x E A). A gradeof membership greater than 0 and less than 1 corresponds to an element which falls onthe fuzzy boundary of the set A. In other words, the membership function maps theelements of the universe X to numerical value [0,1].X 14 ) [0,1]A fuzzy set is demonstrated in Figure 2.1 [23]. A Venn Diagram of the subset A inX is shown in Figure 2.1 (a) and a typical membership function p A (x) is demonstratedin Figure 2.1 (b).Fuzzy set may be specified using a convenient form of notation due to Zadeh, in whicheach element is paired with its grades of membership in the form of:A = E^izA(xi)V X^Xifor discrete universe, or:A =-VX^xfor continuous universe.Equations 2.1 and 2.2 are symbolic shorthand forms of notion only .(2.1)(2.2),-^....••• ■-■ .....". \,^ --./ .-7 Z \11 /^A /l k /\ -^, -,FuzzyBoundary14 Fuzzy k FuzzyElement x(b)MembershipGrade µA(x)Chapter 2. FUZZY LOGIC^ 22(a)UniverseXFigure 2.1: A Fuzzy Set(a) Venn diagram(b) Typical Membership FunctionChapter 2. FUZZY LOGIC^ 232.4 Logical OperationsIt is well known that "complement" ,"union" ,"intersection" and "implication" of setscorrespond to the logical operations NOT, OR, AND and IF - THEN respectively. Theselogical operations of fuzzy sets are used in fuzzy knowledge representation. In fuzzy logicthese connectives have to be expressed in terms of membership functions of the sets whichare operated on.Complement (NOT) A'Consider a fuzzy set A in a universe X. Its complement A' is a fuzzy set whosemembership function is given by:IL A,(s) = 1 — I A ( )^Vs E X^ (2 .3)Union (OR) A U BConsider two fuzzy sets A and B in the same universe X. Their union is a fuzzy setA U B . It membership function is given by:Au„ B(x) max[p.A (x),^Vs E X^(2.4)The rationale for the use of "max" is that since the element x may be in one set orthe other, the larger of the two membership function grades should apply.Intersection (AND)^An BAgain consider two fuzzy sets A and B in the same universe X. Their intersection isa fuzzy set A l B. Its membership function is given by:L^(x) = min[pA (x),A n B Vs E X^(2.5)Chapter 2. FUZZY LOGIC^ 24The rationale for the use of "min" is that since the element x may belong to bothsets simultaneously, the smaller of the two membership function grades should apply.Implication (IF - THEN) A —> BConsider a fuzzy set A in a universe X and a second fuzzy set B in another universeY. The fuzzy implication A —> B is a fuzzy relation in the cartesian product spaceX x Y and the membership function of the fuzzy implication is given by:ILA–B(m,Y)= min[11A( 1),ILB(Y)] Vx E X, try E Y (2.6)2.5 Fuzzy RelationsConsider two universes X 1 = x 1 and X2 = x2 . A crisp set R consisting of a subsetof ordered pairs (x 1 , x 2 ) is a crisp relation in the cartesian product space X 1 x X2.Analogously, a fuzzy set R which consists of a subset of ordered pairs (x 1 , x 2 ) is a fuzzyrelation in the cartesian product space X 1 x X2 and the relation R will be representedby the membership function x2).This concept can be extended in a straightforward manner to fuzzy relations in then-dimensional cartesian space. An example of a fuzzy relation is shown in Figure 2.2[23}Chapter 2. FUZZY LOGIC^ 25X2Crisp Rf(x1 ,x2). 0xi WpR(xi ,x2)Figure 2.2: Relations in Two Dimensional Space (plane)(a) A Crisp Relation(b) A Fuzzy Relation(a)(b)Chapter 2. FUZZY LOGIC^ 26Cartesian Product of fuzzy SetsConsider a fuzzy set A l in the universe X1 and a second fuzzy set A2 in the universeX2. The cartesian product A l x A2 is then a fuzzy subset of the cartesian product spaceX1 x X2 and its membership function is given by:/14 1 x42 (si, x 2 ) = min[AA, (xi ), AA2(x2)] VX1 E X1, VX2 E X2 (2.7)Note that the "min" combination applies here because each element (x i , x 2 ) in acartesian product is formed by taking both elements x i and x 2 and not just one or theother. This concept can be directly extended to more than two fuzzy sets. An exampleof a cartesian product of two fuzzy sets is shown in Figure 2.3[23]Chapter 2. FUZZY LOGIC^ 27(a) Crisp SetA2It^ >i^x2Crisp SetA lYCrispAi xA2x1(b) x iFigure 2.3: Cartesian Product of A l x A2 (relation)(a) Of Two Crisp Sets(b) Of Two Fuzzy SetsChapter 2. FUZZY LOGIC^ 28Extension PrincipleThe extension principle was introduce by Zadeh to give a method for extending stan-dard (non-fuzzy) mathematical concepts to their fuzzy counterparts. Consider the crisprelation:y .F(x i , X2, --)xr) (2.8)where y are elements in the fuzzy set B and x, are elements in the universe X,. LetA s be fuzzy subsets in X. According to the extension principle, the fuzzy set B to whichthe element y belongs has a membership function given by:Na (y) = sup„ ...„ {minDIA , (xi ),I1 A2 (x2)) • •• AA,.(X*)1} (2.9)Note that the "min" operation applies first because the relation among A s is thecartesian product. The "supremum" is applied over the mapping on to B, because morethen one combination of (x 1 , x 2 , ..., Xr) in the fuzzy space A l x A2 x ... x A. will be mappedto the same element y in the fuzzy subset B and the most possible mapping is the onewith the highest membership grade. An example of a mapping from a two-dimensionalcrisp and fuzzy space A l x A2 on to a one dimensional fuzzy set B is shown in Figure2.4 (a) and 2.4[23] (b) respectively.^>x2y (x1 - 1)2 + (x2- 1)2 0.5CrispA lx1Crisp A l X A2Crisp B ' I0 0.25^1.25YChapter 2. FUZZY LOGIC^ 29(a)^CrispA2^>I1 2(b)^Fuzzy A2^> x2FuzzyAFuzzy BrrI I^I Iy (x1 -1)2 + (x2-1)2Figure 2.4: A Mapping from a Product Space to a Line(a) An Example of Crisp Sets(b) An example of Fuzzy sets(Extension Principle)Chapter 2. FUZZY LOGIC^ 302.6 Composition and InferenceApproximate reasoning is used in fuzzy inference and control. In particular, the com-positional rule of inference is utilised. We have already introduced the concept of fuzzyimplication. We shall start the present section by introducing the terms projection,cylindrical extension, and join, which will lead to the concept of composition. Finally thecompositional rule of inference will be discussed, incorporating all these ideas.ProjectionConsider a fuzzy relation R in the cartesian product space X 1 x X2 x ... x Xn . Supposethat the n indices are arranged as follows:1,2,...,n^22) •••jr).i1).i2)•••)im^ (2.1 0)Note that n = r m and that i and j denote the newly ordered set of n indices. Theprojection of R on the subspace X„ x Xi2 x x Xi,. is denoted by:Pr oj [R : X,„ X „, ..., X ir ]This is a fuzzy set P and its membership function is given by:ip(xii xis, • • • , xir) =^sup^R(Xi X2) • • • Xn)6 :71' °32 ' ••. 'XjniThe rationale for using the "supermum" operation on the membership function ofR should be clear in view of the fact that we have a many-to-one mapping from ndimensional to r dimensional space, with r < n .Cylindrical ExtensionConsider the cartesian product space X1 x X2 x ... x Xn and, suppose that n indicesare arranged as follows:Chapter 2. FUZZY LOGIC^ 311,2,...,n —> 21 2 2) •••) 2r271)..i2) --)jmAgain note that r -Fm = n and that i and j denote the newly ordered set of n indices.Now consider a fuzzy relation R in the subspace Xt1 x X. 2 x x X„. .Its cylindrical extension is denoted by:C R^Ex], X S2 X ... X xnFR(Xil)Xi2) •••) Xir)Xi, X2, ..., Xn(See definition in equation 2.1 )Note that a cylindrical extension is a fuzzy set in the n-dimensional space and is theconverse of projection. An example is given in Figure 2.5 [23] Here a fuzzy set R in theuniverse X1 has been cylindrically extended to a fuzzy set in the cartesian space X1 x X2Chapter 2. FUZZY LOGIC^ 32k^ >IFuzzy Rgc(F) (xi ,x2)C(R)Figure 2.5: The Cylindrical Extension(a) A Fuzzy Relation (Set)(b) Its Cylindrical Extension(a)(b)Chapter 2. FUZZY LOGIC^ 33JoinConsider a fuzzy relation R in the subspace X 1 x X2 x ... x Xr and a second fuzzyrelation S in the subspace Xn, x Xm+i x ... x Xn such that m < r + 2Note that the union of these two subspaces gives the space X 1 x X2 x ... x Xn . Thejoin of the fuzzy sets R and S is a fuzzy set in the Xi x X2 x ... x Xn and is given bythe intersection of their cylindrical extensions; thus:Join(R, S) = C(R)nc(s)^in^Xi x X2 X ... X Xn^(2.11)AJoin(X1 X X2 X ... X Xn ) = Min[tie R) (Xi X X2 X ... X Xn ) , tIC(5. ) (X1 X X2 X ... X Xn )1 (2.12)Note that "min" applies here because the intersection of two fuzzy sets is considered.Compositionconsider a fuzzy relation (fuzzy set) R in the subspace X1 x X2 x ... x Xrand a second fuzzy relation (fuzzy set) S in the subspace Xn, x X7n+i x ... x Xnsuch that m < r + 1 . Note that unlike the previous case of Join, the two subspacesare never disjoint and hence their intersection is never null. But, as before, the union ofthe two subspaces gives X 1 x X2 x ... x XnThe composition of R and S is denoted to by R o S and is given by:S o R = Proj[J oin(R, S) ; Xi , ..., X,n _ i , Xr+i , ..., Xn]^(2.13)Here we take the join of the two sets, as given by equation 2.11 and then project theresulting fuzzy set on the subspace formed by the disjoint parts of the two subspace inwhich the fuzzy sets R and S are defined.Chapter 2. FUZZY LOGIC^ 34The membership function of the resulting fuzzy set is obtained from the membershipfunctions of R and S, while noting that "min" applies for Join and "supermum" appliesfor projection. Specifically,SoR^SUPxm,^[min(yR ,^ (2.14)Composional Rule of InferenceRules of the form:"If output Y1 is y i then if output Y2 is y2 then control C is c" are linguistic statementsof expert process operators knowledge in which y i y 2 and c are fuzzy quantities. Theserules are fuzzy relations that employ the fuzzy implication If-then.If we denote the fuzzy relation form of such rules as a fuzzy set R, the output databy a fuzzy set D and the control action by the fuzzy set C, then the composition rule ofinference states that:C=DoR^ (2.15)Given the membership functions of the data and of the rule base we can determinethe membership function of the control action:= suPy[min(,aD, AR)]^(2.16)This result follows directly from equation 2.14. Note that Y denotes the space inwhich the data D are defined. Furthermore, since R consists of fuzzy implications, itsmembership function can be formed by the constituent membership functions using the"min" operation.Chapter 3SYSTEM DEVELOPMETNT3.1 IntroductionTo implement and evaluate the tuner performance, an experimental system was de-veloped for tuning a commercially available servo-motor system. A computer simulationwas developed as well.First, the general hierarchical structure of the system is described in Section 3.2 .Next, the servomotor level is described in Section 3.3 . The hardware of the servomotoris introduced, and the simulated servomotor is developed. Section 3.4 describes theperformance evaluation and the controller parameter updating in the servo expert level.Finally, the fuzzy tuner level is described in section 3.5 .Servo-motor simulation, input/output considerations, graphics and file managementare programmed in ACSL (Advanced Continuous Simulation Language)[1]. Subprogramsof the servo expert level are written in FORTRAN. A separate program for the fuzzytuner was developed in FORTRAN and executed run off line to generate the decisiontable. Subprograms for the communication between the controller and the servo expertlevel are written in C.The same program is used for tuning both the physical and the simulated servosystems This enables us to switch the servo response and the tuning action from onesystem to the other in the same execution.The system software was developed and executed on a PC 386 33[MHZ] equipped35Chapter 3. SYSTEM DEVELOPMETNT^ 36with a mathcoprocessor. The PC 386 serves as an interface between the user and thephysical servomotor system.The description of the experimental system is based on Figure 3.11. C interface2 FRI:rTaRc,r(FORTRAN)1. Preprocessor2. Model3. Evaluation4. Classification5. Tuning6. Mapping7. LearningHARDWAREGALILS DK(Servo Design Kit)DMC-400MOTIONCONTROLLER (Plug-en)t ICB-933INTERCONNECTBOARD1LINEARAMP.EN PITMAN0^50/1000D DC MOTORE 50 Oz on^3750 rpm /RSoftware(FORTRAN)1. Ruleset2. Membership3. Relation4. DefuzzyingFuzzy Tuner Level SubroutinsServo-E)rpert Level Subroutins(ACSL)1. Initial2. Dynamic3. Terminal4. I/OServo-Motor Level SimulationHOST COMPUTER.x1000pulses rev + 2 APOWERSUPPLY12VFigure 3.1: The Experimental SystemChapter 3. SYSTEM DEVELOPMETNT^ 37Chapter 3. SYSTEM DEVELOPMETNT^ 38The lefthand block in this figure represents the hardware of the system. Particularlythe motor, encoder, amplifier, power supply, controller and the controller.The righthand block represents the software of the system. It is arranged in threelevels as will be described in the next section.Communication programs interface these two blocks. Particularly, the measured po-sition of the servo-motor is transfered to the servo-expert level subroutines, and theupdated controller parameters are returned from that level to the hard controller.3.2 General Hierarchical StructureTo combine the advantages of the high bandwidth, crisp characteristics of a hardcontroller in the servomotor system with the merits of a soft knowledge-based tuning ahierarchical structure was developed.The lowest level is a closed-loop servo-motor system consisting of a D.C. motor to becontrolled, and a digital controller which can be programmed to compensate for strongnonlinearities, dynamic decoupling, high-order dynamics and unknown disturbances, asin the case of a robot [23]. A test signal is injected into the controller and the motorresponse to this signal is entered into the higher level.In the intermediate level, servo-expert algorithm evaluates time domain performanceindices out of the difference between the servo-motor response attributes and a set ofpre-defined specifications. These indices trigger tuning actions from a decision (look-up) table. In the same level well-known frequency-domain attributes of a controller areupdated and the new parameters of the controller in the lowest level are designed usingthese updated attributes.In the top level, knowledge expressed in terms of fuzzy rules is formulated mathe-matically using fuzzy theory and fuzzy logic operations to generate a decision table inChapter 3. SYSTEM DEVELOPMETNT^ 39which the actual performance indices are matched with tuning actions in the interme-diate level. A learning and self-organization algorithm may replace or modify the fuzzylogic operation in the generation of the decision table.A block diagram of the hierarchical tuning structure is shown in Figure 3.2Notice the conventional inner loop of the low level, hard controller and the outer loopwhich contain the high level, soft tuner algorithm.Chapter 3. SYSTEM DEVELOPMETNT^ 40The Hierarchial Tuning StructureKnowledgefunctions FUZZY TUNERLevel 3 1 PerformanindexDECISIONTABLETLac pingtionceLevel 2SERVO EXPERTSpecificationsEVALUATION^MAPPINGTestsignalServo responseUpdatedparametersROCESS^CONTROLLER^< SERVO-MOTORLevel 1External loadCommandFigure 3.2: Hierarchical Structure of the SystemChapter 3. SYSTEM DEVELOPMETNT^ 413.3 Servo-Motor LevelIn the following subsections physical (commercially available) and simulated servosystems are described and developed.3.3.1 Physical Servo SystemThe servo-motor system supplied by "GALIL" consists of the following components:• Motor• Amplifier• Encoder• Controller• Power supply• Interconnected board• Communication SoftwareA picture of the GALIL servo-motor hardware is shown in Figure 3.3Chapter 3. SYSTEM DEVELOPMETNT^ 42Figure 3.3: The Hardware of the Physical Servo-Motor SystemChapter 3. SYSTEM DEVELOPMETNT^ 43The general specification of the servo-motor system is given in appendix A-1.Motor A DC motor, type PITMAN 50/1000 , of torque ranging 50[oz-in] is used. It has apermanent-magnet stator and 3-poles rotor. Its specifications and mechanicl drawing arelisted in Appendix A-2.AmplifierA linear amplifier is used to drive the motor at constant gain of 0.2[A/11 with adynamic range of +10[11.EncoderIncremental optical encoder is used. It generates 4000[pu/ses/rev] to measure themotor position.ControllerThe digital controller is a general-purpose, programinable controller of type GALILDMC-400. It consists of parallel, forward route lead, and integral compensation nets.The controller operates in numerous modes, including point-to-point positioning andjogging. Several commands are provided, including instructions for specifying the motorposition, velocity and acceleration.The controller specifications are listed in Appendix A-3Chapter 3. SYSTEM DEVELOPMETNT^ 44Interconnection board A GAUL ICB-933 is used. It connects the DMC-400 controller to other systemelements (motor, encoder, amplifier). The interconnection board specifications are listedin Appendix A-4.Communication SoftwareThe communication programs provide an interface between the servo expert softwareand the servo-motor hardware . They translate and send the controller parametersthat are computed at the servo expert level, to the DMC-400 controller, and returnsthe actual actuator position to the main program. In addition they enable the user tointerrogate and send commands using the computer keyboard. Two linked sub-programswere developed for communication:• Sub-program written in FORTRAN, to interface with the FORTRAN coded tuner.• Sub-program written in C to interface with the C coded GALIL system.Both programs are listed in Appendix A-5.Y 4NsrCONTROLLER-- cwarrArFLIER ZO.HYk;(1,AMP. D.0 MOTOR"NWKI(Z-a)+Z-b Z-1C■1110. 11;:gTi2ENCODER24Chapter 3. SYSTEM DEVELOPMETNT^ 45Figure 3.4: Block Diagram of the Simulated Servo-Motor3.3.2 Simulated Servo-MotorThe simulated servo block diagram is shown in Figure 3.4It consist of the following modules:• Motor• Amplifier• Encoder• Controller• Digital to Analog Converter and Zero Order Hold.Chapter 3. SYSTEM DEVELOPMETNT^ 46Amplifier and MotorThe mathematical model of the motor-amplifier unit depends on the type of the am-plifier. The two types are represented by different transfer functions. Both of them areexmined in the experimental work.(1)^Voltage source amplifierFor a voltage source amplifier the position Po is given by [24]:Po =s • KL • s + R) • (J • s + B) -I- K 2 ]^s - (J - s + B)where:K - Motor torque constant[N* 771/ amp]V - Supply voltage to the stator[volt]J - The actuator moment of inertia[Kg • m 2 ]L - Armature inductance[mH]R - Armature resistance[ohm]B - Motor mechanical damping[Kg/s]Ti - External Load[N • m]s - Laplace variable(2) Current source, Current feedback amplifierA current source, current feedback amplifier results in a different transfer function[32] for the actuator/amplifier, as given below:K • V^ T1 (3.1)(A • K • li — TOPo = j^ . s2 (3.2)Chapter 3. SYSTEM DEVELOPMETNT^ 47here Ii is the input current to the motor. A, the effective gain of the current sourceamplifier is:/maxA = v?7, —,.. [amp/volt]^ (3.3)in which Vmas is the maximum available input voltage to the amplifier and 'm isthe maximum output current to the actuator:EncoderThe encoder generates N pulses per revolution, with two signals in quadrature giving4N pulses per revolution. For N = 1000 the effective gain, given by the ratio of theencoder output in pulses to the actual motor rotation in radians (P) is:Ge = Integer (--Y) = Integer (4 • 1000N)P^2ir^)ControllerThe digital controller consists of a lead compensator with a single zero, single poleand an integrator in parallel route.Its transfer function Gc(z) in the discrete time domain is given by:CK1z • (z — Zr2 )^KizGc(z)= (Yr — y) = ^(z — P12 ) ^+ (z — 1) (3.5)where:C - Position command to the amplifier[counts]Yr - required position[counts]K12 - Lead compensator gain.Kiz - Integrator gain.(3.4)Chapter 3. SYSTEM DEVELOPMETNT^ 48Zr,, - Zero location in z domain.Pl - Pole location in z domain.z - Z transform variable.Using bi-linear transformation s = 21-L-1) the equivalent continuous transfer functionTs (z+1)in s domain becomes:(s Zr,) Ki sGc.( , ) = Kl, (a + ^swhere:Kli, = Klz (i+Zrz)(i+Plz )Zr =a^2 (1—Zr z )Ts (1+Zr.)pia = 2 fl — Plz ) Ts (1+Pl 2 )Ki =a^Tsand Ts is the sampling time.Digital to Analog Converter (DAC) This is 8-bit DAC quantizes the full range output (20[V])of the controller to 256[bit].The quantization is 1-[vo/t/bit].(3.6)(3.7)Chapter 3. SYSTEM DEVELOPMETNT^ 493.4 Servo Expert LevelThe servo-expert level interfaces the hard controller of the servo-motor in the lowestlevel and the soft, knowledge-based tuner in the top level. An adjustment mechanismautomatically tunes the parameters of the programable controller using measured re-sponse of the actual servo-motor and the decision table, so as to meet a set of desiredperformance parameters within a set of acceptable pre-defined tolerances.This level consists of eight functions as shown in Figure 3.5:PerformanceindexControllerattributesTuningactionV ATTRIBUTETUNINGPERFORMANCEATTRIBUTEDESCRETIZATIONSPECIFICATIONUPDATINGDesiredperformance.f3ttribute VREFERENCEMODELChapter 3. SYSTEM DEVELOPMETNT^ 50Fuzzy tuner levelAAttributeerrorEVALUATORUpdatedmodelparametersModelparametersMeasuredresponseActualperformanceattributeRESPONSEPRE-PROCESSORTESTSIGNALGENERATORATTRIBUTEMAPPINGUpdatedparametersServo-motor levelTestsignalControllerattributesFigure 3.5: Block Diagram of the Servo Expert LevelChapter 3. SYSTEM DEVELOPMETNT^ 51• Test signal generator.• Performance specification.• Response preprocessing.• Performance evaluation.• Performance classification.• Controller attribute tuning.• Controller-parameter mapping.• Specification updating.Test signal is injected simultaneously to both the servo-motor and the referencemodel. The servo response to this signal is preprocssed to obtain time domain perfor-mance parameters. These parameters are compared with those of the reference modelperformance parameters and the error between them is classified to form performanceindex which triggers a tuning action by means of the decision table. The developementof the decision table is described in the next section.The tuning actions update the frequency-domain controller attributes from which theupdated controller parameters are calculated using crisp, conventional mapping. Thereference model may be modified automatically, if necessary, when the limits of thecontroller attributes are reached and the tuning process terminated unsuccessfully.3.4.1 Performance SpecificationSeveral time domain parameters are useful for performance specification. These de-sired time domain performance parameters are represented in terms of a reference modelwith a set of acceptable tolerances.Chapter 3. SYSTEM DEVELOPMETNT^ 52Even though the user specifications can be expressed directly in terms of time do-main performance parameters, a reference model is used to determine these parametersindirectly for the following reasons:Since the tuning knowledge base is determined through response observation, it isfound visually more convenient to evaluate the response of the actual system relative tothat of a reference model rather than evaluate an "absolute" performance of the system.Furthermore the model provides some buffer against unreasonable requirements. Finallyusing reference model make the tuning process similar in a way to the Model ReferenceAdaptive System (MRAS) technique.It is important to realize that this model represents the desired performance only,and it is not a the model of the system. Furthermore, unlike MRAS technique,the goal of the tuning process is to bring the performance parameters and not theresponse itself close to those of the model.The order, structure and parameters of the model can be chosen and adjusted eitheranalytically or by trial and error so as to meet the performance parameters specificationin the time domain, and can be updated automatically, if necessary, during the tuningaction.To save real time computation either closed form analytical expressions or off-linenumerical solution should be used to calculate the time domain parameters of the model.Reference ModelThe dynamics of the reference model in this research is represented by a second ordertransfer function, specified by the undamped natural frequency (cen ) and the dampingratio (C). The static behavior of the model is represented by a deterministic steady-stateerror (8) and can represent the undeterministic error as well.The model transfer function is:Chapter 3. SYSTEM DEVELOPMETNT^ 53Ym^w2GM( g) = Yr = s2 2cwn • scvn2 ° (3.8)The solution to step input Yr is:Yrn = Yr [1 — a• e-b.t • sin (c • t d)+ 9+ E]^(3.9)where:a=^b = • wnc = wn • N/1 — C2d = cos -1 (C)The subroutine MODEL is listed in Appendix. B.2.1Time Domain Performance SpecificationsThe following time domain parameters of the model are used to define the desiredservo-motor performance.• Rise time• Damped natural frequency• Average damping ratio• Overshoot• OffsetThese parameters are calculated analytically from equation 3.9 and compared withthose of the servo-motor to form performance parameter error.Chapter 3. SYSTEM DEVELOPMETNT^ 541. Rise-Time - R.7",„The time taken to pass 0.95 of the steady-state response value for the first time.2. Model Damped Natural Frequency - D.F77,D.F„, = con • 1/1 — (2^(3.10)3. Model Average Damping Ratio - D'TemDR,. = 1 • EP lfm(p+i) "Ym(p)P p=17m(P) - 'Ym(P-1)^(3.11)where the p'th peak level -ym(p) of under-dumped model (( < 1) is calculated ana-lytically using:-y„,,(p) = Yr • [(1 — a • e-bi m(P) • sin (c • Tm(P) + d)]^(3.12)in which the time T,,,(P) of the p'th peak is:P •Tm(p) =^ for^p = 1, 2, ...., P^(3.13)wy, - V(1 r — C2 )and a, b, c and d are as defined in equation 3.9Peaks smaller than a predefined value are neglected.4. Model Overshoot - OS„,The level of the first peak-7r • C— exp 0 _ c2OSm = -Ymo) (3. 14 )Chapter 3. SYSTEM DEVELOPMETNT^ 555. Model Steady State Error (Offset) -The difference between the desired and the actual response at steady state.OF„, = 0^ (3.15)These desired performance are arranged in vector Pm( i ):3.4.2 Response PreprocessorPm(,) = RTMPm (i) = DimPm(i) = DR,„Pm(,) = OS„,Pm( i) = Oim(3. 16 )The preprocessor calculates the time domain performance parameters of the servo-motor measured response.Peak detector observes the response to find P peak level -ys(p) and timing T$(p) usingthe sign change between any two consecutive pairs Y( t+i ) — Y( t )^and^17(t) —where Y( t ) is the servo-motor response at the communication time interval.Peak levels which are found to be less than a predefined value are ignored, and thesign changing is checked for continuity.Time domain performance parameters are evaluated out of the servo-motor response,the peak levels and peak times. These parameters are compared later with those of thereference model to form the error of the performance parameters. Furthermore, theseparameters may be compared with those used in other tuning techniques.Time domain performance parameters of the Servo-motor are calculated as follows:Chapter 3. SYSTEM DEVELOPMETNT^ 561. Rise-Time - RT,The time taken to pass the 95 % of the steady-state response value for the firsttime. A high 'RT, indicates slow response.2. Average Damped Natural Frequency - D.F„The average damped natural frequency is calculated using consecutive peak times:1^rD.F = —EP ^P p=1 T — Ta(P)^s(P-1)(3.17)for all:-yam > 0.02 • Yrwhere P is the number of peaks having magnitude greater than a predefined value.A high average damped natural frequency indicates a fast response.3. Average Damping Ratio - DR,The average ratio of each consecutive pair of response peaks gives:DR. , 1 vi I" l'a(P+ 1 ) — l'8(P)^(3.18)P -`'1:7=1 'Ya(P) — "ra(p-i)Average damping ratio less then 1 indicates oscillatory convergence. Averagedamped ratio over 1 indicates unstable, oscillatory response.4. Overshoot - OS,The level of the first peak:OS, = -y,(i)^(3.19)Small overshoot indicates less oscillatory response.Chapter 3. SYSTEM DEVELOPMETNT^ 575. Steady state error - 01;The normalized, systematic (deterministic) deviation of the steady-state valuefrom the desired value:= ^1^Et' (Ys( t ) — Yr) • At (3.20)tf — Tuy) 70')^Yrwere ti is the duration of the input test signal and At is the communication timeinterval.These actual performance are arranged in vector Ps( ; ):3.4.3 Performance EvaluationPs( i ) = 7ZT,Ps(2) = D.F,Ps(3) =Ps(4) = OS,PS(5)=0.P,(3.21)The time domain performance parameters of the servo-motor are now compared withthose of the model and normalized to form a set of nondimensional performance param-eter errors which takes values in the interval [—co,1]:Negative error indicates a servo performance better than that of the model.Zero error indicates a servo performance equal to that of the model.Positive error indicates a servo performance less than that of the model.The following normalized, nondimensional errors are calculated using the actual servo-motor and model performance parameters:DR,DR,DR., -= 1 (3.24)Chapter 3. SYSTEM DEVELOPMETNT^ 581. Rise Time - RT,Rre = 1 R.7",„RT,Error approching 1 indicates non responding system (RT,^co)(3.22)2. Damped Natural Frequency Error - DieDie = 1 Di, (3.23) Error approaching 1 (7).F,^0) indicates critically, over-damped, non-oscillatingsystem.3. Damping Ratio Error - DR eError approaching 1 (DR.,^oo) indicates unstable, oscillatory system.4. Overshoot - OS,OSe = 1 OS„,OS,5. Steady State Error (offset) - Oie(3.25)Oie =1 ^(3.26 )These normalized, nondimensional errors of the performance parameter are arrangedin a vector ERR.(,):Chapter 3. SYSTEM DEVELOPMETNT^ 59E'TZT?..0) = R.TeERR( 2 ) = D.FeERR(3 ) = TYReETZ1Z( 4)= OSeeiZR.( 5) OFeRise Time ErrorDamped Natural Frequency ErrorAverage Damping Ratio ErrorOvershoot ErrorOffset Error(3.27)3.4.4 Performance Index ClassificationSince in the present application the knowledge on the response behaviour is expressedin terms of discrete and finite number of performance quantities, the input to the decisiontable should be discrete with a finite cardinality. Therefore the performance parametererrors are now assigned discrete performance indices. Let us define an /-dimensionaluniverse of performance, in which each dimension i represents a performance index storedas vector K(,).We obtain these indices by classifying each of the i performance parameter errors intoj subsets, separated by j — 1 predefined thresholds stored in vector Tli(3) , and assigningan integer number (index) to each subset.Given the performance parameter error at every communication time, as calculatedin the previous subsection, a performance index is computed for every condition variable.Notice that since the performance parameter errors are computed accurately the resultingperformance indices are crisp and not fuzzy variables (or fuzzy variables having unitymembership grade).Performance(i)SpecificationPerformance indexChapter 3. SYSTEM DEVELOPMETNT^ 60ERR(i)1THOLD(3)THOLD(2)THOLD(1)R (i). 1 - :P"'"`" (1)erformance0)5Figure 3.6: Mapping from Performance to performance Index54^0 DECISI ON index TABLE^,Tuning^ actionFigure 3.8: Fuzzy Tuner Block DiagramChapter 3. SYSTEM DEVELOPMETNT^ 69Chapter 3. SYSTEM DEVELOPMETNT^ 703.5.1 Fuzzy RulesetExperts in system tuning usually learn and gain tuning knowledge by performingtuning actions and observing the response of the system to these actions. Often thetuning actions are expressed in linguistic fuzzy terms like "Turn the knob a little bit tothe left" or "Raise the lever slightly".In a similar way, the system performance is expressed in linguistic fuzzy terms as"The speed is too slow" or "High offset is existing in the system".Suppose that actions like "Turn the knob" and "Raise the lever" are fuzzy tuningvariables of the system, and "A little bit to the left" or "Slightly" are their fuzzy tuningquantities. Furthermore, let performance variables like "Speed" and "Offset" be the fuzzyperformance variables and "slow" and "High" be their fuzzy performance quantities.To formulate this knowledge mathematically we define an /-dimensional universeof fuzzy performance variables denoted by P, in which the i'th dimension representsperformance parameter variable PV (;) . Let the elements of this universe be the actualperformance indices, as calculated in the servo-expert level. Divide each performanceparameter PV(i ) to j fuzzy subsets in which the j'th subset represents fuzzy performancequantity PQ ( , ) .In the same manner we define L dimensional universe of tuning actions T, in whichthe Pth dimension represents a tuning variable TV (/) , each of which is divided into mfuzzy subsets TQ (n., ) , representing m fuzzy tuning quantities.Now define the performance variables and quntities as well as the tuning variablesand quantities in the fuzzy form of crisp variables and quantites, as has been definedfor the servo-expert level (see equation 3.27 on page 3.27.Chapter 3. SYSTEM DEVELOPMETNT^ 71Fuzzy performance variablesPV( i ) = RISTM for the fuzzy form of Rise Time error (RTe )PV(2) = DMPFR for the fuzzy form of Damped Natural Frequency error (D.Fe)PV(3) = DMPRT for the fuzzy form of Damping Ratio error (DR.,)^(3.42)PV(4) = OVSHT for the fuzzy form of Overshoot error (OVe )PV( s) = OFFST for the fuzzy form of Offset (0.Fe )Each condition variable is assigned one of the following fuzzy quantities and storedin the vector PQ (3) :PQ(1) = OVRSP (Over specification)PQ(2) = IN-SP^(In-specification)PQ(3) = MODRT (Moderate)PQ(4) = POOR (Poor)PQ (5) = UNSTF (Unsatisfactory)For analytical convenience assign a numerical integer to each quantity:( 3.43 )PQ(1)=PQ(2) -PQ(3) -PQ(4)-PQ ( 5 )12345(3 .44)Similarly define vector TV (l) of the fuzzy tuning variables as the fuzzy form of theincremental changes of the controller attributes (see equation 3.39:(3.47)Knowledge is gained by observing the effect of each tuning action on the performanceand expressing these effects as a set of rules of the form:TQ(2) = —1TQ(3) 0TQ (4) = +1TQ (5) = +2Chapter 3. SYSTEM DEVELOPMETNT^ 72TV( i ) = PHCOFTV(2) = FRCOGTV(3) = GNCOGTV(4 ) = LFCOGEach tuning variable is assigned onein the vector TQ (m) :the fuzzy form of &ofthe fuzzy form of w cogthe fuzzy form of T cofthe fuzzy form of C21 cog(3.45)of the following fuzzy quantities which are storedTQ(1) = NEGHITQ(2) = NEGLOTQ(3) = NOCNGTQ(4) = POSLOTQ (5) POSHIfor high, negative incrementfor low, negative incrementfor no changefor low, positive incrementfor high positive increment(3.46)For analytical convenience each subset is assigned an integer value:TQ (1) — —2If P V ( i )^is^P Q (1)^then^TV( /)^is^TC2 („, )Chapter 3. SYSTEM DEVELOPMETNT^ 73Using these definitions the condensed form of the rules are stored in a three dimen-sional array as:= m^ (3.48)For example: RU(4,3,2) = 1^is the condensed form of the rule:If OVSHT is MODRT then FRCOG is NEGHIThe default value is RU(,,3 ,0 = 3 (Tuning quantity is unchanged for all combinationsof performance variable, performance quantity and tuning variable). Modification of thetable is done by typing the three indices i, j, 1 and the value of the desired tuning quantity(m index). The effect of each tuning variable on each performance variable, and the rulegeneration based on these effects are described in the next chapter.3.5.2 Membership Functions for Performance and Tuning VariablesSubroutine SUB-PRFMSFSubprogram SUB-PRFMSF generates the three dimensional array PM(,,,, k) member-ship function for the performance quantity in which i stands for the performance fuzzyvariable, j stands for the performance fuzzy quantity and k is the performance index.For example, P M- (1,2,3) = 1 means that PQ (1) (Rise time) with performance index equal3 is definitely in the fuzzy quantity subset IN-SPC (see definitions in equations 3.42 ,3.44 , 3.45 , and 3.47 .Currently subprogram SUB-PRFMSF assigns 1 to the representative value and uni-formly decreasing membership grade to the other performance indices. The membershipfunctions of the performance variables are shown schematically in Figure 3.9Chapter 3. SYSTEM DEVELOPMETNT^ 74Figure 3.9: Membership Functions for the Fertormance variablesModification of the table is done by assigning values to the i, j, k indices and a mem-bership grade to the desired element.Subprogram SUB-PRFMSF is listed in appendix B-3-3.Subroutine SUB-TUNMSFSubprogram SUB-TUNMSF generates three dimensional array TM( / ,„,,„) of member-ship functions for the tuning quantity in which 1 stands for the fuzzy tuning variable,m stands for the tuning fuzzy quantity and n is the tuning action index. For example,TM(,,2,3) = 0 means that PHCOF (fuzzy phase lead angle at cross-over frequency) withquantity index 3 is definitely not in the fuzzy quantity subset NOCNG (no change)(See equations 3.45 ,3.46 and 3.47 ).Currently subprogram SUB-TUNMSF assigns 1 to the representative value and uni-formly decreasing membership grade to the other performance indices. The membershipChapter 3. SYSTEM DEVELOPMETNT^ 75IFigure 3.10: Membership Functions for the Tuning Variablesfunctions of the tuning variables are shown schematically in Figure 3.10Modification of the table is done by assigning values to the 1, m, n indices and amembership grade to the desired element.Subprogram SUB-TUNMSF is listed in appendix B-3-4.3.5.3 Fuzzy Relation between Condition and Action VariablesSubprogram SUB-RELATION computes a four dimensioned array RL (0 ,k ,n). Thismatrix is a condensed form of the fuzzy relation between each fuzzy performance variable(PVC ;)) and each fuzzy tuning variable (TV( l)). The i,l,k and n indices are as definedpreviously.First, using the rules in RU(,,,,i) (equation 3.48 on page 73) an INTERSECTIONoperation (see equation 2.5 on page 23) is applied by taking the minimum of the mem-bership function grade PM ( ,,,,k) of each element k in the performance quantity subspaceChapter 3. SYSTEM DEVELOPMETNT^ 76PQ (3) belonging to the fuzzy performance variable PV(,) and the membership functionTM( / ,,„ 0.,) of each element n in the fuzzy tuning subspace TQ (,„ ) , that belongs to thefuzzy tuning variable TV( / ), for every i, j and 1 in RU(,,,, / ).This results in a temporary five dimensional matrix BARLEV(0 ,3 , k ,n) , which standsfor the fuzzy relation:If PV(,) = PQ (3) then TV(z) = TQ („, )For example a typical fuzzy relation table relating the fuzzy performance variableRISTM and the fuzzy tuning variable PHCOF is demonstrated in Table 3.1Chapter 3. SYSTEM DEVELOPMETNT^ 77Table 3.1: Development of aIFFuzzy Relation Table^RISTM^PHCOF)2(for^---+RISTM = UNSATF Then PHCOF = NEGHI-2^-1^0^111 1.0^.8^.6^.4 .221 .8 .8 .6 .4 .231 .6^.6^.6^.4 .241 .4 .4 .4 .4 .251 .2^.2^.2^.2 .2IF RISTM = POOR^Then PHCOF = NEGLO-2^-1 0^1 211 .8^.8^.8^.6 .421 .8 1.0 .8 .6 .431 .8^.8^.8^.6 .441 .6 .6 .6 .6 .451 .4^.4^.4^.4 .4IF RISTM = MODRAT Then PHCOF = NEGLO-2^-1^0^1 211 .6^.6^.6^.6 .421 .8 .8 .8 .6 .431 .8^1.0^.8^.6 .441 .8 .8 .8 .6 .451 .6^.6^.6^.6 .4IF RISTM = IN-SPC Then PHCOF = NOCHG-2^-1^0^1 211 .4^.4^.4^.4 .421 .6 .6 .6 .6 .631 .6^.8^.8^.8 .641 .6 .8 1.0 .8 .651 .6^.8^.8^.8 .6IF RISTM = OVRSPC Then PHCOF = POSLO-2^-1^0^1 211 .2^.2^.2^.2 .221 .4 .4 .4 .4 .431 .4^.6^.6^.6 .641 .4 .6 .8 .8 .851 .4^.6^.8^1.0 .8Chapter 3. SYSTEM DEVELOPMETNT^ 78Table 3.2: Fuzzy Composite Relation Table for RISTM and PHCOV-2 -1 0 1 211 1.0 .8 .8 .6 .421 .8 1.0 .8 .6 .631 .8 1.0 .8 .8 .641 .8 .8 1.0 .8 .851 .6 .8 .8 1.0 .8Next, UNION operation (see equation 3.4 on page 47) is applied by taking the maxi-mum membership grade of BARLEIii,/,3 ,k,n) over index j for every i, 1, m, k and n. Thisoperation results in a four dimensional Matrix RL(0 ,k ,,i) which is the Composite FuzzyRelation between the fuzzy performance variable PV(i) and the fuzzy tuning variableTV( / ).For example a typical composite fuzzy relation table relating the fuzzy performancevariable RISTM and the fuzzy tuning variable PHCOF is demonstrated in Table 3.2Subprogram SUB-RELATION is listed in appendix B-3-5.3.5.4 Decision TableThe subroutine SUB-DECISION generates a three dimensional matrix DT(0 ,3) bymatching the composite relation matrix RL(, , i ,k ,,,) with the membership function matrixPM(so ,k) of the performance quantity matrix PQ ( ,,j ,k) that belongs to the performancevariable subset PV(,,,,k ).First, INTERSECTION operation (see equation 2.5 on page 23) is applied to PM(,,,, k)and ITL(0,k,n), to form the temporary matrix SHAKY,- to,,,k,n)•Next, UNION operation (see equation 3.4 on page 47 ) on SHANY is applied to formChapter 3. SYSTEM DEVELOPMETNT^ 79the temporary matrix YAEL (0 ,3 ,„ ) , the membership function matrix of the action 1 dueto the performance variable i with fuzzy quantity j.Finally, subprogram SUB-DEFUZZY is called to compute the crisp value of the tuningquantity, using the Centre of Gravity Method, In order to obtain a crisp value for thetuning action. Specifically, we weight the elements in the universe of the tuning actionusing the membership grades of the action, and then take the average. This value is theentry for the tuning action in the decision table, and stored now in the decision tablearray DT(,,,j), to be used on-line in the servo expert level.For example, in:DT(1,2,3) = 0.6the Rise Rime (TZTe ) having a performance index equal to 2 is the entry point to thedecision table and it triggers the gain increment at cross-over frequency 0 (3) to be 0.6as can be seen in Table 3.3A typical crisp decision table is shown in Table 3.3Chapter 3. SYSTEM DEVELOPMETNT^ 80Table 3.3: Decision Table for the Servo-MotorTable for Performance Parameter: 'RE e0 co f Wcog lb co f W 1 cog11 -1.0 1.0 1.0 .021 -.6 .6 .6 .031 -.2 .2 .2 .041 .0 .0 .0 .051 .2 -.2 -.2 .0Table for Performance Parameter: D.Fe&o f Wcog 11) co f W 1 cog11 .0 .0 1.0 .021 .0 .0 .6 .031 .0 .0 .2 .041 .0 .0 .0 .051 .0 .0 -.2 .0Table for Performance Parameter: DiZe&o f Wcog 711 co f W 1 cog11 -1.0 1.0 1.0 .021 -.6 .6 .6 .031 -.2 .2 .2 .041 .0 .0 .0 .051 .2 -.2 -.2 .0Table for Performance Parameter: OS,&o f^Wcog^VI co f Ci) 1 cog11 1.0 -1.0 1.0 .021 .6 -.6 .6 .031 .2 -.2 .2 .041 .0 .0 .0 .051 -.2 .2 -.2 .0Table for Performance Parameter: 01e&o f Wcog Ow f CV lcog11 .0 .0 1.0 1.021 .0 .0 1.0 .631 .0 .0 .6 .241 .0 .0 .6 .051 .0 .0 .4 -.2Chapter 4EXPERIMENTAL STRATEGY AND PROCEDURE4.1 IntroductionThis chapter describes the experimental testing strategy and procedure both in the sim-ulated and the physical servo-motor system.The experiments were designed for three purposes. Firstly, it is desired to studythe performance of the tuning mechanism with regard to its parameters. Secondly, itis desirable to evaluate the performance in comparison with those of other conventionaltechniques. Finally, and most importantly, it is important to determine if a fuzzy tuneralgorithm is a practical means of automating the tuning the actions taken by an expertoperator, by implementing it on a commercially available servo-motor system.The results of these tests are shown graphically in the next chapter.4.2 Experimental StrategyGiven a commercially available servo-motor system the starting point of the experi-mental work is the designing of a controller for a simulated, well-defined and simplifiedlinear servo-motor system at the lowest level, using well known "classical" design tools tomeet a set of frequency and time domain specifications. This step results in a well-tunedbase-line system.Next, the algorithms of the servo-expert and the fuzzy tuner in the higher levels areintegrated with the simulated servo-motor system, and the knowledge-based ruleset is81Chapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^82established by observing the effect of each tuning action on each performance parameter,thereby simulating the knowledge of an expert operator. Then the system is tested whenthe simulated base-line servo-motor is gradually spoilt toward an ill-defined servo-motorsystem, leaving the two upper levels unchanged. Finally, the tuning algorithm isimplemented and tested on the commercially available servo-motor system.4.3 Performance RequirementsThe required time domain performance parameters are derived from the actual appli-cation of the servo-motor system, considering several limitation factors such as as mini-mum available sampling time of the controller, maximum execution speed, or maximumavailable acceleration of the servo-motor system.Often a compromise among these requirements is needed. Such an /settle/ example,between the speed (typically represented by the rise time) requirement and the oscillation(typically represented by the overshoot) requirement.4.3.1 Model ParametersConsidering the given system limitations (of the motor, amplifier, controller and com-puter) the dynamic performance parameters are chosen (see definitions in Section 3.3.1):1. Rise time (R.Tm) 33[rnsec]2. Average damping ratio (DR,,,) = 0.0953. Average damped natural frequency (D.T„,) 75[hz]4. Overshoot (OV m ) = 10[%]and the static performance parameters:Chapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^835. Offset (O.F,n ) = 2[%]A reference model that satisfies these requirements (see equation 3.8 on page 53) is:• Cm = 0.55 (Model damping ratio)• Wm = 75 (Model undamped natural frequency)• B = 0.02 (Model offset)4.3.2 Acceptable toleranceThe following acceptable tolerances are used for the dynamic performance parameters.1. Rise time tolerance = 0.12. Overshoot tolerance = 0.13. Average Damping Ratio tolerance 0.14. Average Damped natural response = 0.1and for the static performance parameters.:5. Offset tolerance = 0[%[4.3.3 Test SignalThe magnitude of the square wave test signal should be far above the noise and thequantization levels of the servo-motor system. The frequency of the square wave shouldby small enough to let the system response settle down. Amplitude of 200[counts] andfrequency 2[hz] is used.Chapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^844.4 Base-Line Servo-Motor SystemDenote Base-Line servo-motor system as a simulated, well-defined, well-tuned system.Well-defined system reflects accurate and complete knowledge of the mathematical modelof the system. Well-tuned system reflects a controller design procedure based on well-defined system, and results in "in specifications" performance.The values of specific motor parameters (see equation 3.1 on page 46 are:K = 0.076[N • [M -m/A]- torque constantR = 1.59[ohm] - resistance of the field windingL = 2.5[mH] - inductance of the field windingJ = 2.6 * 10 -5 [Kgm2 ] - moment of inerta of the rotorB = 0.0037[Nm • sec] - motor mechanical damplingand for current supplay amplifier (see equation 3.2 on page 46:A = 0.2[amp/volt] - effective gain of the current source amplifierVmax = 10[volt] - maximum voltage input to the amplifier'max = 2[amp] - maximum current output of the amplifierThe well-tuned controller attributes (see equation 3.39 and equation 3.40 on page 66)of the base-line system are designed to be:1. Phase lead Angle at cross-over frequency: 0(cof )^1 [rad]2. Cross-over gain frequency: w( cog ) = 200[rad/sec]3. Cross-over gain: V.)(cof ) = 12[db]4. Low frequency gain :wt (cog) = 0.Time domain response of the reference model as well as that of the base-line servo-motor system to a squared wave input is shown in Figure 4.1 . Notice that all the actualresopnse parameters are in or over specification.Chapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^85Refe-re ,nce Mode lSera.° A4 efer1.r.,d4EIcfi ._ _.TIME CSEC]Figure 4.1: Time Domain Response of the Base-Line Servo-Motor SystemChapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^864.5 Generation and Evaluation of Tuning RulesTo simulate an expert knowledge in tuning a servo-motor system, the effect of each con-troller attribute on each performance parameter is examined by applying the servo-expertlevel algorithm on the simulated servo-motor system. These effects are demonstrated inthe following figures:The effect of the cross-over phase lead angle 0 (cof) is demonstrated in Figure 4.2.The effect of the cross-over gain frequency co (cog) is demonstrated in Figure 4.3.The effect of the cross-over gain ihcof) is shown in Figure 4.4.The effect of the cross-over gain (0 (cof) ) when an external load is applied is shown inFigure 4.5.The effect of the low-frequency gain (w/(c09) ) when an external load is applied is demon-strated in Figure 4.6.Observations of these effects are now expressed as linguistic fuzzy rules to form theruleset of the high level fuzzy tuner. Notice that since the knowledge on tuning actions aregained by looking at these graphs rather than actually measuring (crisp) performanceparameters they become fuzzy variables. Furthermore, we can "pretend" that the tuningactions that have been taken are not known accurately, to simulate tuning actions takenby an experienced operator, and therefore they become fuzzy variables as well.8z QQQQQQLNOChapter 4. EXPERIMENTAL STRATEGY and PROCEDURE^8780.00^0. 1.0^0. 20^0.30^0.40^0. SOTIME C5EC3Figure 4.2: Effect of Phase Lead Angle at Cross-over Gain Frequency1^k-7 $/—\/ \,.--, , —_ ,is\1,,/111. //•,,//ii;\illI\0.10^0.20^0.30^0.40^0.50TIME C SECFigure 4.3: Effect of Cross-over Gain Frequency8OOChapter 4. EXPERIMENTAL STRATEGY and PROCEDURE^88.0-8/'^rs li \ %c,0/1\1(^•PIN/...c.^" ..., ... \ .... ....._ Z"--'---"-‘-''.•.^,1 W,co t,.........-• ..,0 .0 ;• ,1^11 /BJ6_ __20^0.30^0.40^0.50TIME [SEC]Figure 4.4: Effect of Cross-over Gainj\'i 1.,\,^......../...„.".........–.................*,*if^\i .,.. ,^''',......—.lir\ •II/^S.',..._....* ^ ........,^.........^...........---........ ........^,/IixiT. 00^0.10^O. 20^O. 30^0.40^O. 50TIME [SEC]Figure 4.5: Effect of Cross-over Gain when External Load is Applied88MO0.00Ce3•0. 40^O. soTIME CSEC30.80^1.000.20Chapter 4. EXPERIMENTAL STRATEGY and PROCEDURE^89Figure 4.6: Effect of Low-frequency at Cross-over Gain when External Load is AppliedChapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^90Rules for Tuning the Phase at Cross-over FrequencyBased on Figure 4.2 the following rules are established for tuning PHCOF.RISTM dependence on PHCOFIf RISTM is UNSTF then PHCOF be NEGHIelse if RISTM is POOR then PHCOF be NEGLOelse if RISTM is MODRT then PHCOF be NEGLOelse If RISTM is INSPC then PHCOF be NOCNGelse If RISTM is OVRPC then PHCOF be POSLOend ifDMPRT dependence on PHCOFIf DMPRT is UNSTF then PHCOF be POSHIelse if DMPRT is POOR then PHCOF be POSLOelse if DMPRT is MODRT then PHCOF be POSLOelse If DMPRT is INSPC then PHCOF be NOCNGelse If DMPRT is OVRPC then PHCOF be NEGLOend ifOVSHT dependence on PHCOFIf OVSHT is UNSTF then PHCOF be POSHIelse if OVSHT is POOR then PHCOF be POSLOelse if OVSHT is MODRT then PHCOF be POSLOelse If OVSHT is INSPC then PHCOF be NOCNGelse If OVSHT is OVRPC then PHCOF be NEGLOend ifChapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^91Rules for Tuning the Frequency at Cross-over GainBased on Figure 4.3 the following rules are established for FRCOG.DMPRT dependence on FRCOGIf DMPRT is UNSTF then FRCOG be NEGHIelse if DMPRT is POOR then FRCOG be NEGLOelse if DMPRT is MODRT then FRCOG be NEGLOelse If DMPRT is INSPC then FRCOG be NOCNGelse If DMPRT is OVRPC then FRCOG be POSLOend ifDMPRT dependence on FRCOGIf OVSHT is UNSTF then FRCOG be NEGHIelse if OVSHT is POOR then FRCOG be NEGLOelse if OVSHT is MODRT then FRCOG be NEGLOelse If OVSHT is INSPC then FRCOG be NOCNGelse If OVSHT is OVRPC then FRCOG be POSLOend ifDMPFR dependence on FRCOGIf DMPFR is UNSTF then FRCOG be NEGHIelse if DMPFR is POOR then FRCOG be NEGLOelse if DMPFR is MODRT then FRCOG be NEGLOelse If DMPFR is INSPC then FRCOG be NOCNGelse If DMPFR is OVRPC then FRCOG be POSLOend ifChapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^92Rules for Tuning the Gain at Cross-over FrequencyBased on Figure 4.4 the following rules are established for GNCOF.RISTM dependence on GNCOFIf RISTM is UNSTF then GNCOF be POSHIelse if RISTM is POOR then GNCOF be POSLOelse if RISTM is MODRT then GNCOF be POSLOelse If RISTM is INSPC then GNCOF be NOCNGelse If RISTM is OVRPC then GNCOF be NEGLOend ifDMPRT dependence on GNCOFIf DMPRT is UNSTF then GNCOF be POSHIelse if DMPRT is POOR then GNCOF be POSLOelse if DMPRT is MODRT then GNCOF be POSLOelse If DMPRT is INSPC then GNCOF be NOCNGelse If DMPRT is OVRPC then GNCOF be NEGLOend ifDMPFR dependence on GNCOFIf DMPFR is UNSTF then GNCOF be POSHIelse if DMPFR is POOR then GNCOF be POSLOelse if DMPFR is MODRT then GNCOF be POSLOelse If DMPFR is INSPC then GNCOF be NOCNGelse If DMPFR is OVRPC then GNCOF be NEGLOend ifChapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^93Rules for Tuning the Gain at Cross-over Frequency when External Load isAppliedBased on Figure 4.5 the following rules are established for tuning the GNCOF.OFFST dependence on GNCOFIf OFFST is UNSTFelse if OFFST is POORelse if OFFST is MODRTelse If OFFST is INSPCelse If OFFST is OVRPCthen GNCOF be NOCNGthen GNCOF be NOCNGthen GNCOF be POSLOthen GNCOF be NOCNGthen GNCOF be NOCNGend ifRules for Low-Frequency at Gross-over GainBased on Figure 4.6 the following rules are established for LFCOG.OFFST dependence on GNCOFIf OFFST is UNSTF then LFCOG be POSHIelse if OFFST is POOR then LFCOG be POSLOelse if OFFST is MODRT then LFCOG be POSLOelse If OFFST is INSPC then LFCOG be NOCNGelse If OFFST is OVRPC then LFCOG be NEGLOend ifThese tables may be rewritten in condensed form as in table 4.1:Chapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^94Table 4.1: Condensed Form of the RulesetRules for Condition Variable:OFFSTPHCOF FRCOG GNCOF LFCOGUNSATFI NOCHG NOCHG POSHI POSHIPOOR^I NOCHG NOCHG POSHI POSLOMODRATI NOCHG NOCHG POSLO POSLOIN_SPCI NOCHG NOCHG POSLO NOCHGOVRSPCI NOCHG NOCHG NOCHG NEGLORules for Condition Variable:DMPRTPHCOF FRCOG GNCOF LFCOGUNSATFI POSHI NEGHI POSHI NOCHGPOOR^I POSLO NEGLO POSLO NOCHGMODRATI POSLO NEGLO POSLO NOCHGIN_SPCI NOCHG NOCHG NOCHG NOCHGOVRSPCI NEGLO POSLO NEGLO NOCHGRules for Condition Variable:RISTMPHCOF FRCOG GNCOF LFCOGUNSATFI NEGHI NEGHI POSHI NOCHGPOOR^I NEGLO NEGLO POSLO NOCHGMODRATI NEGLO NEGLO POSLO NOCHGIN_SPCI NOCHG NOCHG NOCHG NOCHGOVRSPCI POSLO POSLO NEGLO NOCHGRules for Condition Variable:OVSHTPHCOF FRCOG GNCOF LFCOGUNSATFI POSHI NEGHI POSHI NOCHGPOOR^I POSLO NEGLO POSLO NOCHGMODRATI POSLO NEGLO POSLO NOCHGIN_SPCI NOCHG NOCHG NOCHG NOCHGOVRSPCI NEGLO POSLO NEGLO NOCHGRules for Condition Variable:DMPFRPHCOF FRCOG GNCOF LFCOGUNSATFI NOCHG NOCHG POSHI NOCHGPOOR^I NOCHG NOCHG POSLO NOCHGMODRATI NOCHG NOCHG POSLO NOCHGIN_SPCI NOCHG NOCHG NOCHG NOCHGOVRSPCI NOCHG NOCHG NEGLO NOCHGChapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^954.6 Experimental ProcedureThe off-line tuner level program is executed to compute the decision table to be usedby the servo-expert level algorithm. To examine the tuner performance degradation whenapplied on a more realistic system, the simulated base-line servo-motor is now changed,leaving the servo expert level algoritms and the decision table unchanged.Two types of changes are made:• Initially ill-tuned controller controls a well-defined system.• Initially "base-line" controller controls an ill-defined system.In the first type of changes tuning of an initially ill-tuned controller is demonstratedon slow and on oscillatory servo-motor system. In both cases the controller initial at-tributes were chosen intentionally to bring the well-tuned system response to an underspecification performance.In the second type of changes the performance of the tuner is examined when theservo-motor differs from the well defined system which was used to generate the knowl-edge base, leaving the initial controller attributes as those of the "base-line" servo-motor.In other words the system is tested when the base-line system is spoilt gradually towardan ill-defined system. The tuner was tested when applied on both simulated and com-mercially available servo-motor systems.4.6.1 Tuning of the Simulated Servo-Motor SystemThe following cases were tested in the simulated servo-motor system.Tuning for ill-tuned controller• Tuning for initially ill-tuned controller that has a slow response.Chapter 4. EXPERIMENTAL STRATEGY AND PROCEDURE^96• Tuning for initially ill-tuned controller that has a oscillatory response.Tuning for system parameter changing• Tuning for increased motor inertia.• Tuning for external torque - without the integrator branch.• Tuning for external torque - with the integrator branch.Tuning for additional dynamices• Tuning for external spring.• Tuning an initially slow servo-motor with voltage source amplifier.• Tuning an initially oscillatory servo-motor with voltage source amplifier.4.6.2 Tuning of a Commercially Available Servo-Motor SystemIn a similar way to the experimentation with the simulated servo-motor system, exper-iments were carried out on a commercially available servo-motor system to demonstratethe implementation of the tuner on a physical system. The commercially available servo-motors are generally ill-defined systems, since accurate mathematical models are notavailable when the system is developed.As in the simulated system, the system is tested when the controller is initially ill-tuned, and when the process is changed.The following cases have been tested with the phyisical servo-motor system.• Tuning for an initially slow system.• Tuning for an initially oscillatory system.• Tuning for increased motor inertia.The results of these tests are shown graphically in the next chapter.Chapter 5SIMULATION AND EXPERIMENTAL RESULTSIn this chapter the experimental results are shown graphically, to demonstrate theperformance of the fuzzy tuner when applied to simulated and physical systems. Eachexperiment is described briefly followed by two pages showing the results:The responses of the servo-motor as well as the reference model to a square wave areshown in the first page using three frames. The uppermost frame shows the responsebefore tuning, the middle frame shows the response while tuning, and the response afterthe tuning process is shown in the bottom frame.Different time scales have been used in the three frames.The second page shows how the controller attributes are changed while tuning.978.. 00^1.30^2.608. RESPONSE AFTER TUNINGmL..._,..,,3.90 5.20 6.50Chapter 5. SIMULATION AND EXPERIMENTAL RESULTS^985.1 Simulation Experiments5.1.1 Slow Servo-Motor SystemThe use of excessive phase lead & of as well as low cross-over gain frequency at wc09results in slow, over-damped response.The response before, while and after tuning are shown in Figure 5.1 and the controllerattributes while tuning are shown in Figure 5.2S RESPONSE BEFORE TUNING8.^7 0. 00^0. 10^0. 20S. RESPONSE WHILE TUNING0.30^0.40^0.50Cr)876.000TIME [SEC] 6. 300 6.400 6.5006. 100Figure 5.1: Tuning of initially Slow Servo-Motor: Time ResponseChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^ 99Ocof[bit/counts ]Wcog X 102[rad/s]^e-j8Ocof^U7[rad]0.00^1.30 2.80^3.90TIME [SEC] 5.20^6.50Figure 5.2: Tuning of an Initially Slow Servo-Motor: Controller AttributesChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1005.1.2 Oscillatory SystemInsufficient phase lead Ocof as well as too high cross over gain frequency w cog resultsin an oscillatory response. The time response is shown in Figure 5.3 and the controllerattributes in Figure 5.4RESPONSE BEFORE TUNING.53.To_ 00^o_ to^o_ 20^O. 30^O. 40^0 . 50.50= RESPONSE AFTER TUNING%Es6.100^6.200^6.300TIME [SEC]6.400^6.500Figure 5.3: Tuning of an Initially Oscillatory Servo-Motor: Time ResponseChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^ 101 ^11■••■=1lkeof[bit/counts]Ci0^, i n2^Ei^W cog '■ 1 u 6[Tads]Sd8r..1Ocof[rad]8=;1 0.00^1.30 2.80^3.90TIME [SEC]5.20 8.50Figure 5.4: Tuning of an Initially Oscillatory Servo-Motor: Controller Attributes878Chapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1025.1.3 Increased Motor InertiaAdding inertia to the motor leads to sluggish and oscillatory response. The responsebefore, while and after tuning is shown in Figure 5.5. The controller attributes are shownin Figure 5.6n nn^n i n^^ 20^0_ SO^O. 40^0RESPONSE WHILE TUNINGCO6 RESPONSE BEFORE TUNINGct4. 50hL%E.r r rI O. 00^4.00^_8. 00 _ _^_ 12.08 RESPONSE AFTER TUNING16.0^20.0m=. :. :8\. ...._._..___.___...I 1. 950^1. 960^1. 70^1. 98^ .000TIME *lot [SEC]Figure 5.5: Tuning a Motor with Increased Inertia: Time Response...r ..„ a...1 ......"......0"^a......."."".....e'.."...cChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^103wOco.f^E!.;[bit/counts]CICIC:::8S•4:1wcog x 102 8..4[rad/s]88L-4■■ r.....r r L'9.■""..o.■,....„......... .....—•A ^Ocof[rad]8gmi1 0.00 4.00 8 00^i2. 0TIME [SEC]16.0 20.0Figure 5.6: Tuning a Motor with Increased Inertia: Controller AttributesChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1045.1.4 External Torque without Integral CompensationWithout using the integrator compensation of the controller, a constant externaltorque in the system results in a steady, deterministic error (offset). The time responseis shown in Figure 5.7 and the controller attributes in Figure 5.8B RESPONSE BEFORE TUNINGCr)cs.61 E* —8.^7 0. 00^0.10^0.20RESPONSE WHILE TUNING0.30^0.40^0.501114= r 1 17 r r8)=I 1== 1=....,0.00^2.70^5.40^.10E; RESPONSE AFTER TUNINGCr)3.5Ec=1. 300 1.310^1. 320^1. 330TIME .sot CSEC31.340^1.350Figure 5.7: Tuning for External Torque without Integral Compensation: Time ResponseLOcof^8[bit/counts] L6oI=0ECN:Iwcog x 102 8[rad/s]dOcof[rad]1 0.00 2.70 5.40TIME (SEC]8.10 10.8 15.5Chapter 5. SIMULATION AND EXPERIMENTAL RESULTS^ 105Figure 5.8: Tuning for External Torque without Integral Compensation: Controller At-tributesChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1065.1.5 External Torque with Integral CompensationIn the presence of integral compensation, the steady state error in the response toa constant load will approach zero. How fast the error decays will depend on the D.0gain. The error decay toward an acceptable error within the test signal duration isdemonstrated in Figure 5.9 and the controller attributes in Figure 5.108 RESPONSE BEFORE TUNING70. 00^1.00^2.008 RESPONSE WHILE TUNING3. 00^4.00^5. Crn,87 0. 00^0.33^0.66^O. 998 RESPONSE AFTER TUNING.0021.32^1. ECO1. 610^1. 620^1. 630TIME .10 2 [SEC]1.640^1. EFigure 5.9: Tuning for External Torque, using Integral Compensation: Time ResponseChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1071Pco f[bit I countswcog x 102[radls]15.f[rad]ED6R==..... ID ' Al Ok OA A ID.^.TIME [SEC)0.00S . 0Figure 5.10: Tuning for External Torque, using Integral Comensation: Controller At-tributesZO.H— 151G1TArFILTER KI(Z-a)+Z-b Z-1 1I+ T2Law INERTIA1 POJSANTTKaENCODERY I I^4N211Chapter 5. SIMULATION AND EXPERIMENTAL RESULTS^108CONTROLLER^AMP. D.0 MOTORFigure 5.11: Motor Block Diagram for External Spring5.1.6 External SpringWe can further complicate the servo-motor system by relating the external load to theactual response. For example let the external torque be a function of the motor position:Tl(t) = —Kp * Po( t )^ (5.1)where Kp is a "spring" constant and Po is the actual motor position. A simple blockdiagram of this configuration is shown in Figure 5.7 . It can be seen that the plantdynamics now become a simple oscillator:A • K/JPo =^s 2 K • Kpwhich should be compared with equation 3.3 on 47.The response before, while and after tuning is shown in Figure 5.12 and the controllerattributes are shown in Figure 5.121. 460TIME 1. 470 CSEC71. 480 1.50Chapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1098. RESPONSE BEFORE TUNINGmc•,.1,==*4■1870.00^O. 10^0.208 RESPONSE WHILE TUNINGO. 30^0.40^0.50II1 _O. 00^3.00^6.008 RESPONSE AFTER TUNING5. 0Figure 5.12: Tuning in the presence of an External Spring: Simulated System Response=0Ocof[rad]Chapter 5. SIMULATION AND EXPERIMENTAL RESULTS^ 110wOcof^P[bit/counts] R=1°O°wcog x 102 ©[rad/s]^1 7'c;8r-.1 C^--1—r"--8=I1 0.00 4.00 ei. 00^12.0T I ME16.0^20.0Figure 5.13: Tuning in the Presence of an External Spring: Controller AttributesChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1115.1.7 Voltage Source Amplifier ModelAs described in Chapter 3, the motor-amplifier transfer function depends on the typeof the amplifier. Figures 5.14 to 5.9 demonstrate the tuning process when applied toplant with higher dynamics and initially ill-tuned controller.8 RESPONSE BEFORE TUNINGmE , i _,'—'.-----------------------=--. 121,7„........„.....„--O. 30 0.40 0.50RESPONSE 4JHILE TUNING8.7 0. 00^2.20^4.408. RESPONSE AFTER TUNINGrr -IF F'1- --. t-6. 60^8. 80^11.0cn87 1. no 1 . 060^1.070^1. 080TIME .iot [SEC]1.090Figure 5.14: Tuning of a Slow Servo-Motor with Voltage Source Amplifier: Time Re-sponseC^Chapter 5. SIMULATION AND EXPERIMENTAL RESULTS^112Y7VIcof[bit/counts] m2‘1,;Loco,[radis]86Ocof[rad]- .00^2.20 4.40^8.80TIME [SEC]6.60^11.0Figure 5.15: Tuning of a Slow Servo-Motor with Voltage Source Amplifier: ControllerAttributesChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1138 RESPONSE BEFORE TUNINGc.47 0.00^0.10^0.202 RESPONSE WHILE TUNING0.30^0.40^0.500.00^1.00^2.008 RESPONSE AFTER TUNINGm•■■■•••■a7 4.500 4.600^4.700^4.800TIME [SEC]4.900^5.00Figure 5.16: Tuning for Oscillaory Servo-Motor with Voltage Source Amplifier - TimeResponseOcof[bit/countswcog^Ei 0^[rad/s]^a^Chapter 5. SIMULATION AND EXPERIMENTAL RESULTS^ 114Ocof[rad]1 0.00^1.00 2.00^5.00TIME (SEC] 4.00^5. CFigure 5.17: Tuning of an Oscillatory Servo-Motor with Voltage Source Amplifier: Con-troller AttributesChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1155.2 Experiments using a Commercial Servo-MotorThe same first three experiments in the simulated system are replaced using the com-mercially available servo-motor system.Chapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1165.2.1 Slow Physical Servo-Motor SystemThe response before, while and after tuning an initially ill-tuned physical controller isshown in Figure 5.18. The controller attributes are shown in Figure 5.19B RESPONSE BEFORE TUNING0.1.1•=■e..1^•* —7 0. 00^O. 10^0.208 RESPONSE WHILE TUNINGO. 30 0.40 O. 50cgE8.^7 o. oo^0 60^1 20RESPONSE AFTER TUNING1.60 2.40 3.00cr,Ea_ - -^-2. 50^2.60TIME [SEC]. 00Figure 5.18: Tuning of a Slow Servo-Motor: Time Response of the Physical SystemChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^117&cof[bit/counts]wc,,9[rad/ s]^4.%1Ocof[rad]Ul0.00^0.60 1.20^1. eoTIME [SEC)2.40^8.1Figure 5.19: Tuning of a Slow Servo-Motor: Controller Attributes of the Physical SystemChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1185.2.2 Physical Oscillatory Servo-MotorThe response before, while and after tuning an initially ill-tuned physical controllerare shown in Figure 5.20. The controller attributes are shown in Figure 5.21 .3. RESPONSE BEFORE TUNINGCO=0. 10^0.20= RESPONSE WHILE TUNING0. 30 0.40 0.50 r...1mission.R.10. 00^0.50 ^1.00^1.50^2.00^2.50RESPONSE AFTER TUNINGM00.—;00•TIME [SEC] 2.30^2.40^2.50Figure 5.20: Tuning of an Oscillatory Servo-Motor: Response of the Physical SystemChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^119 fq 1lkco i[bit I counts] Ei, 1■E8"cog[rad I s]60in1. 60^a.TIMEOcof[rad]00^O. 80 .0Figure 5.21: Tuning of an Oscillatory Servo-Motor: Controller Attributes of the PhysicalSystem0.40O. 00^O. 10^0.20E. RESPONSE WHILE TUNING0. EO. 30Cr)87 3. 00 3.40 3. E3. 10 3. 20^3.30TIME [SEC]E.70.00^0.70^1.40E. RESPONSE AFTER TUNING3.!2.802. 10Figure 5.22: Tuning for Increased Motor Inertia: Physical System ResponseChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^1205.2.3 Motor with Increased InertiaAdditional inertia to the physical motor leads to sluggish and oscillatory response. Theresponse before, while and after tuning are shown in Figure 5.22 (a) . The controllerattributes are shown in Figure 5.238 RESPONSE BEFORE TUNINGChapter 5. SIMULATION AND EXPERIMENTAL RESULTS^121Ocof[bit/countswcog^..-:[rad/s)8...ILIlaz&of^-.[rad]8t. 00 I 0.70 1. 40^2. 10TIME [SEC]2. 80^3.50Figure 5.23: Tuning for Increased Motor Inertia: Physical System Controller AttributesChapter 6RULE GENERATING BY SELF LEARNING6.1 IntroductionThe knowledge presented in the previous chapters simulates tuning actions taken byan expert operator and are expressed as a set of linguistic rules. This knowledge mightbe replaced or modified by a set of rules generated automatically in a preliminary phaseof the learning process to be used later in the the fuzzy tuner level.The learning process might be useful in the following scenarios :• Compensating for total lack of tuning knowledge ( for example when implementedin a new process.)• Adding to an incomplete tuning knowledge base.• Modifying incorrect rules.• Deleting unnecessary or irrelevant rules.A learning process is demonstrated in this chapter by replacing the knowledge- basedruleset that was introduced in the previous chapters.122Chapter 6. RULE GENERATING BY SELF LEARNING^ 1236.2 Self Generated Rulset Development6.2.1 ApproachLearning process results either in tuning rules similar to those generated by a humanoperator, or directly in a decision table. The first approach is adopted in this researchsince it enables us to integrate an already existing knowledge with new automaticallygenerated rules. Furthermore, when the new and self-generated ruleset is available, wecan use an already developed algorithm to calculate the decision table, leaving the fuzzytuner unchanged in the highest level, by just switching from tuning to learning mode.In both the learning and tuning modes, the servo-motor and the reference modelare excited by test signal. The measured response is evaluated to perform the samenormalized performance parameters as described in Chapter 3.First, the controller attributes are preset corresponding to a set of reference perfor-mance parameters. Next the system is perturbated by changing the controller attributes(one at a time), and the difference between the performance parameters of the preset andperturbed systems is calculated and classified to form a sensitivity index. This indexis used to trigger a rule out of a predefined rule patterns.A complete mathematical treatment includes the computation of the sensitivity ofeach performance parameter to each tuning action in the entire working space (all thecombinations of the components of the controller attributes). This treatment is beyondthe scope of this research. However, a much simpler algorithm is obtained if we assumethat each performance parameter is changed monotonously when the system is pertur-bated. This assumption is justified over a wide range (see Figure 4.2 throgh Figure 4.6)for the particular system.Based on this assumption, the sensitivity is computed when the system is perturbatedfrom a single, representative working point. Further simplification is obtained if weChapter 6. RULE GENERATING BY SELF LEARNING^ 124define a finite number of patterns for the rules, and then trigger an appropriate patternaccording to the sensitivity index.The learning system is based on the same servo-expert algorithm used in the tuningmode as described on Chapter 3.4. Here, however, a sensitivity index triggers rules outof the rule generator while in the previous case a performance index triggers a tuningaction out of the decision table. Once the new, and self-generated rules are avialable, thesame fuzzy tuner algorithm, as described in Chapter 3.5, is used to calculate the decisiontable.A block diagram of the system in the learning mode is shown in Figure 6.1The code of the subprogram LEARN is listed in Appendix B-3-86.2.2 Controller PresettingThe presetting of the controller attribute can enrich the system response with informa-tion. For example, the system should be oscillated if we want to generate rules relatingany tuning action to the damped natural frequency, or a steady error will be present ifwe generate rules relating offset to any tuning action.Even though an automated presetting process might be applied by systematicallyscanning the controller attributes and using the performance parameters as a feedback,a manual, trial and error process is used in this research for the sake of simplification.6.2.3 System PerturbationAs in the presetting process, for simplicity, a trial and error process was adopted ratherthan an automated one, to perturb the preset system. Each of the controller attributes ischanged, one at a time, leaving all the remaining attributes unchanged (having the presetvalues). This process results in L sets of response parameters, each of them representingChapter 6. RULE GENERATING BY SELF LEARNING^ 125CONTROLLERATTRIBUTEPRESETTINGCONTROLLERATTRIBUTEPERTURBATIONPresetattributes-^>[ SERVO MOTOR CONTROLLERertu bedesponsePresetresponseRESPONSEPREPROCESSINGPresetresponseparameter6\7RESPONSE SENSITIVITYCALCULATIONResponsesenseitivitySENSITIVITYCLASSIFICATIONerturbedparameters sensitivityindexResponseRULEPATTERNS RULE TRIGGERINGRulesevFUZZY TUNER LEVELFigure 6.1: The System in Learning ModeTEST SIGNALGENERATORPerturbedattributesChapter 6. RULE GENERATING BY SELF LEARNING^ 126the change in the response due to change in one controller attribute near the presetvalues.6.2.4 Response Sensitivity IndexThe performance parameters, for both the preset and the perturbed systems, arecomputed using the response preprocessor and evaluator as described in section 3.4, andthe difference between them are classified to form the sensitivity index.The preset system is denoted the superscript °. Let 0 ° be a vector containing thecontroller attribute of the preset system, (see equation 3.29 on page 62) and the vectorP° be its response (see equation 3.21 on page 57).Let Q be the perturbed attribute vector. We define the normalized l'th perturbedattribute:(3)and the normalized change in the performance parameter i:P(t)^P(i) ^61)(,)^P(t)(i)The performance sensitivity Sit is computed as follows:so _ 8130) _ P(t) P(i) 0(1)^(11) — 80(1)^— C41) P(i)for all i and all 1.The superscript ° was added to the performance sensitivity to emphasise that it iscalculated near the preset attribute.Rearrange equation 6.3 as:- (3) 6.0(t) = (6. 1)(6.2)(6.3)Chapter 6. RULE GENERATING BY SELF LEARNING^ 127P(1) — Pei) d(t)0 ( 1 )^0 (1) +^So ./9(c)i)(6.4)Scanning over all of the components of 0° in the range from 0 (/)__ to 0 (1)ma. ( seeequation 3.30 on page 63 ) we can map the sensitivity for all i and 1 and generate ruleswhich are based on this performance sensitivity array.However, as mentioned earlier, an automated scanning process, using appropriate res-olution is beyond the goals of this research. For simplicity we compute this performancesensitivity at one point only (the preset values of the controller attributes).Recall that a smaller P(2) value indicates better performance. We see that negativeSki indicates improvements of the i th response parameter due to the 1 th controllerattribute, while positive sto , indicates decreasing in performance relative to the presetsystem.S(o ) = 0 indicates that the performance parameter i is not sensitive to the controllerattribute 1.6.2.5 Response Sensitivity ClassificationThe response sensitivity is classified now according to J predefined thresholds TH(3) ,resulting in J +1 subsets. Each of these are assigned an integer value /.9 (, ) and will beserved as a sensitivity index. For simplicity two threshold values are used in this researchto form three subsets:/s (i) =—10+1ifififTH(1) #include #include #include char comm(in, val)char far in[13];long far *val;{char res;int i, j, k, n, b, c;int tl, t;long t2, total, d;k = 0;n = 1006;t2 = 0;total = 0;d = 1;res = inp(n);/*labl: b = inp(n+1)/4;*//*^if (b/2 == b/2.0)*/Appendix A. The Physical Servo-Motor^ 157/*^goto labl;*/lab2: b = inp(n+1);c = b/2;if (c/2 == c/2.0)goto lab2;j = 12;for (i=0; i20 OR LU>20 !!',LO,LUSTP=.TRUE.ENDIFY2 = Y1Y1 = YRETURNENTRY INTEGRAL (T,Y,YM,TMDLY,TMRIS,RISINM,RISINS,OFSINS)YRMYRO=YR-YROYSN=FLOAT(Y +YRMYRO)YMN=FLOAT(YM+YRMYRO)IF(T.LT.TMRIS)THENRISINS=YSNRISINM=YMNELSEIF(T.GT.PI2OWM)THENOFSINS=OFSINS+(YSN+YSO)*CINT2ENDIFYSO=YSNYMO=YMNRETURNENDB.2.3 Sub-Program EVALUATIONSUBROUTINE EVALUATIONDIMENSION PIK0(20),PIKU(20),TPIK0(20),TPIKU(20)LOGICAL STPINTEGER Y,YM,YR,YRO,Y1,Y2,DY1,DY2,DYYY,DYYYM1,LO,LU,# PIKO,PIKUCENTRY INIT1EVAL(CINT,PIKMIN,YRO)STP=.FALSE.CINT2=CINT/2.Appendix B. Programs Listing^ 179RETURNENTRY INIT2EVAL(K,YR,PIOWDM)Y1 7 YRY2 = YRDYYY = -YR0*(-1)**KDYYYM1= (-1)**KLO^= 1LU^= 1PEAKS = 1.MM=OYS0=0YM0=0RISINS=O.RISINM=O.OFSINS=O.PI2OWM=2.*PIOWDMRETURNENTRY PEAKCHECK(LO,LU)1 IF(LU.GT .LO)THENLU=LU-1GO TO 1ENDIF2 IF((LO-LU).GT.1)THENLO=L0-1GO TO 2ENDIFRETURNENTRY SDMPFR(LO,LU,TPIKO,TPIKU,DMPFRS)IF(LU.EQ.1) THENDMPFRS=O.RETURNELSEIF(LU.EQ.2.AND.LO.EQ.2) THENDMPFRS=3.14/(TPIKU(2)-TPIK0(2))RETURNENDIFCAppendix B. Programs Listing^ 180IF(LO.EQ.(LU+1))THENDMPFRS=6.28*(L0-2)/(TPIKO(L0)-TPIK0(2))ELSEENDIFRETURNDMPFRS=3.14*(2*L0-3)/(TPIKU(LU)-TPIK0(2))ENTRY SDMPRT(LO,LU,PIKO,PIKU,TPIKO,TPIKU,DMPRTS)IF (LO.LT.3)THENDMPRTS=0.RETURNENDIFJJJ=3N=0 ,PIKD=FLOAT(PIKU(2)-PIKO(2))40 CONTINUEIF (JJJ.GT.L0) GO TO 41JJ1=JJJ-1PIKN=FLOAT(PIKO(JJJ)-PIKU(JJ1))IF(PIKD.EQ.0.)PRINT*,'PIKD=0.!!!'DMPRTS=DMPRTS+ABS(PIKN/PIKD)N=N+1IF (JJJ.GT.LU) GO TO 41PIKD=PIKNPIKN=FLOAT(PIKU(JJJ)-PIKO(JJJ))IF(PIKD.EQ.0.)PRINT*,'PIKD=0.!!!'DMPRTS=DMPRTS+ABS(PIKN/PIKD)N=N+1PIKD=PIKNJJJ=JJJ+1GO TO 4041 IF(N.EQ.0)PRINT *,'N=0!!!'DMPRTS=DMPRTSINENTRY SSTLTM(LO,LU,TPIKO,TPIKU,STLTMS)IF (LU.LT.2)THENSTLTMS=0.RETURNELSEAppendix B. Programs Listing^ 181IF (LO.EQ.LU) THENSTLTMS=TPIKU(LU)RETURNELSEIF (LO.EQ.(LU+1)) STLTMS=TPIKO(LO)ENDIFENDIFRETURNENTRY SOVSHT(PIKO,YR,YRO,OVSHTS)IF(PIK0(2).NE.0) OVSHTS=ABS(FLOAT(PIKO(2)-YR))/YRORETURNENDB.2.4 Sub-Program CLASSIFICATIONSUBROUTINE CLASSIFICATIONDIMENSION THSPD(3),THOSC(3),THOFS(3),THOVS(3),THDFR(3)#,PIK0(20),PIKU(20),TPIK0(20),TPIKU(20),PRFORM(5)INTEGER CNDQNT(5),PIKO,PIKU,Y,YRO,YRENTRY FOFFST(OFSINS,OFSINM,THOFS,CNDQNT,PRFORM)PRFORM(1) = -(OFSINM - OFSINS)/OFSINMIF(PRFORM(1).LE.O.^ ) GO TO 15IF(PRFORM(1).LE.THOFS(1) ) GO TO 14IF(PRFORM(1).LE.THOFS(2).AND.PRFORM(1).GT.THOFS(1)) GO TO 13IF(PRFORM(1).LE.THOFS(3).AND.PRFORM(1).GT.THOFS(2)) GO TO 12IF(PRFORM(1).GT.THOFS(3) ) GO TO 1115 CNDQNT(1)=5RETURN14 CNDQNT(1)=4RETURN13 CNDQNT(1)=3RETURN12 CNDQNT(1)=2RETURN11 CNDQNT(1)=1RETURNAppendix B. Programs Listing^ 182ENTRY FDMPRT(DMPRTS,DMPRTM,THOSC,CNDQNT,PRFORM)PRFORM(2) =-(DMPRTM - DMPRTS)IF (DMPRTS.EQ.O.) GO TO 24IF(^ PRFORM(2).LT.O.^) GO TO 25IF(PRFORM(2).GE.O. AND.PRFORM(2).LE.THOSC(1)) GO TO 24IF(PRFORM(2).GE.THOSC(1).AND.PRFORM(2).LE.THOSC(2)) GO TO 23IF(PRFORM(2).GE.THOSC(2).AND.PRFORM(2).LE.THOSC(3)) GO TO 22IF(PRFORM(2).GE.THOSC(3) ) GO TO 2125 CNDQNT(2)=5RETURN24 CNDQNT(2)=4RETURN23 CNDQNT(2)=3RETUR$22 CNDQNT(2)=2RETURN21 CNDQNT(2)=1RETURNENTRY FRISIN(RISINS,RISINM,THSPD,CNDQNT,PRFORM)PRFORM(3) = (RISINM - RISINS)/RISINMARISIN=ABS(PRFORM(3))IF( PRFORM(3).LT.O.^ ) GO TO 35IF(ARISIN.LE.THSPD(1) ) GO TO 34IF(ARISIN.LE.THSPD(2).AND.ARISIN.GE.THSPD(1)) GO TO 33IF(ARISIN.LE.THSPD(3).AND.ARISIN.GE.THSPD(2)) GO TO 32IF(ARISIN.GE.THSPD(3) ) GO TO 3135 CNDQNT(3)=5RETURN34 CNDQNT(B)=4RETURN33 CNDQNT(3)=3RETURN32 CNDQNT(3)=2RETURN31 CNDQNT(3)=1RETURNENTRY FOVSHT(OVSHTS,OVSHTM,THOVS,CNDQNT,PRFORM)PRFORM(4) = -(OVSHTM - OVSHTS)/OVSHTMAppendix B. Programs Listing^ 183IF(OVSHTS.EQ.0) GO TO 45IF(PRFORM(4).LE.O.^ ) GO TO 45IF(PRFORM(4).LE.THOVS(1) ) GO TO 44IF(PRFORM(4).LE.THOVS(2).AND.PRFORM(4).GE.THOVS(1)) GO TO 43IF(PRFORM(4).LE.THOVS(3).AND.PRFORM(4).GE.THOVS(2)) GO TO 42IF(PRFORM(4).GE.THOVS(3) ) GO TO 4145 CNDQNT(4)=5RETURN44 CNDQNT(4)=4RETURN43 CNDQNT(4)=3RETURN42 CNDQNT(4)=2RETURN41 CNDQNT(4)=1RETURN,ENTRY FDMPFR(DMPFRS,DMPFRM,THDFR,CNDQNT,PRFORM)PRFORM(5) = (DMPFRM - DMPFRS)/DMPFRMIF(DMPFRS.EQ.0) GO TO 55IF(PRFORM(5).LE.O.^ ) GO TO 55IF(PRFORM(5).LE.THDFR(1) ) GO TO 54IF(PRFORM(5).LE.THDFR(2).AND.PRFORM(5).GE.THDFR(1)) GO TO 53IF(PRFORM(5).LE.THDFR(3).AND.PRFORM(5).GE.THDFR(2)) GO TO 52IF(PRFORM(5).GT.THDFR(3) ) GO TO 5155 CNDQNT(5)=5RETURN54 CNDQNT(5)=4RETURN53 CNDQNT(5)=3RETURN52 CNDQNT(5)=2RETURN51 CNDQNT(5)=1RETURNENDB.2.5 Sub -Program TUNINGSUBROUTINE TUNERDIMENSION CNDQNT(5),ATRNET(5),CNGATR(5),DECTBL(5,5,5),PRFORM(5)Appendix B. Programs Listing^ 184CHARACTER*5,CNVAR(5)CHARACTER*6,CNQNT(5)CHARACTER*5,ACVAR(5)CHARACTER*5,ACQNT(5)INTEGER CNDQNTENTRY DECISION (DECTBL)OPEN(UNIT=64,FILE='DECISION.TBL')do 5 i = 1,5DO 5 j = 1,5READ (64,14) (DECTBL(i,1,j),1=1,5)14 FORMAT(5F10.2)5 CONTINUECLOSE(64)RETURNC^ MAXIMUM PHASECENTRY TUNEPHMAX (CNDQNT,CNGATR,IPHMAX,ATRNET)C^IF(CNDQNT(2).EQ.1)THENC IPHMAX=2C^ELSEC IPHMAX=3C^ENDIFC^IF(CNDQNT(3).LE.CNDQNT(2).AND.CNDQNT(2).NE.4)THENIF(CNDQNT(2).LT.CNDQNT(3))THENIPHMAX=2CNDM=CNDQNT(2)ELSEIPHMAX=3CNDM=CNDQNT(3)ENDIFC^IF(CNDQNT(4).LT.CNDM.AND.CNDQNT(4).NE.4)IF(CNDQNT(4).LT.CNDM)^IPHMAX=4IPHMAX=4ATRNET(1)=ATRNET(1)+CNGATR(1)*DECTBL(IPHMAX,CNDQNT(IPHMAX),1)IF (ATRNET(1).LE.0.5 )THENATRNET(1)=0.5Appendix B. Programs Listing^ 185ELSEIF(ATRNET(1).GE.1.5 )THENIF(ATRNET(1).GE.1.5 )THENATRNET(1)=1.5ENDIFRETURNC^ FREQUENCY AT MAXIMUM PHASECENTRY TUNEFRMAX (CNDQNT,CNGATR,IFRMAX,ATRNET)C^IF(CNDQNT(2).LT.4) THENC IFRMAX=2C^ELSEC IFRMAX=5C^ENDIFC^IF(CNDQNT(2).LE.CNDQNT(5).AND.CNDQNT(2).NE.4)THENIF(CNDQNT(2).LE.CNDQNT(4))THENIFRMAX=2C^CNDM=CNDQNT(2)ELSEIFRMAX=5CNDM=CNDQNT(5)ENDIFIF(CNDQNT(4).LT.CNDM) IFRMAX=4ATRNET(2)=ATRNET(2)+CNGATR(2)*DECTBL(IFRMAX,CNDQNT(IFRMAX),2)IF(ATRNET(2).LE.20.)THENATRNET(2)=20.ELSEIF(ATRNET(2).GE.600.)THENATRNET(2)=600.ENDIFRETURNC^ HIGH FREQUENCY GAINCENTRY TUNEHIFGN (CNDQNT,CNGATR,IHFRGN,ATRNET)c^IF(CNDQNT(2).EQ.1)^THENAppendix B. Programs Listing^ 186IHFRGN=2c^ELSEIF(CNDQNT(5).NE.4)THENIHFRGN=5c^ELSEIHFRGN=4ENDIFC^IF(CNDQNT(2).LE.CNDQNT(4).AND.CNDQNT(2).NE.4)THENIF(CNDQNT(5).LE.CNDQNT(4))THENIHFRGN=5CNDM=CNDQNT(5)ELSEIHFRGN=4CNDM=CNDQNT(4)ENDIFIF(CNDQNT(3).LT.CNDM) THENIHFRGN=3CNDM=CNDQNT(3)ENDIFIF(CNDQNT(1).LT.CNDM)IHFRGN=1ATRNET(3)=ATRNET(3)+CNGATR(3)*DECTBL(IHFRGN,CNDQNT(IHFRGN),3)c!^IF(ATRNET(3).LE.0.1)THENc!^ATRNET(3)=0.1c!^ELSEIF(ATRNET(3).GE.10.)THENc!^ATRNET(3)=10.c!^ENDIFRETURNC^ LOW FREQUENCY GAINCENTRY TUNELOFGN (CNDQNT,CNGATR,ILFRGN,ATRNET)ATRNET(4)=ATRNET(4)+CNGATR(4)*DECTBL(1,CNDQNT(1),4)IF (ATRNET(4).LT.0) ATRNET(4)=0.RETURNENDAppendix B. :Programs Listing^ 187B.2.6 Sub-Program DESIGNSUBROUTINE DESIGN(ATRNET,CNTRLC)DIMENSION CNTRLC(5),ATRNET(4)SPHMAX=SIN(ATRNET(1))ALFA=(1.-SPHMAX)/(1.+SPHMAX)SQRALF=SQRT(ALFA)CNTRLC(3)=ATRNET(2)*SQRALFCNTRLC(4)=ATRNET(2)/SQRALFCNTRLC(1)=1/ALFA*ATRNET(3)CNTRLC(2)=ATRNET(4)CNTRLC(5)=0.C^PRINT 100,CNTRLC(1),CNTRLC(2),CNTRLC(3),CNTRLC(4)C 100 FORMAT(1X,'GNC=',F5.0,5X,'GIC=',F5.0,'ZRC=',F5.0,5X,'PLC=',F5.0)RETURNENDSUBROUTINE ZTRANS(DTSMP,CNTRLC,CNTRLZ)DIMENSION CNTRLC(5),CNTRLZ(5)POZ = CNTRLC(4)/CNTRLC(3)EXDTPZ=EXP(-DTSMP*(CNTRLC(4)-CNTRLC(3)))CNTRLZ(1)^= CNTRLC(1)*EXDTPZCNTRLZ(2)^= CNTRLC(2)/7.8EXSPL = EXP(-DTSMP*CNTRLC(4))CNTRLZ(3)^= EXSPL/EXDTPZCNTRLZ(4) = EXSPLCNTRLZ(5)=0.RETURNENDSUBROUTINE DMCCONTROL (CNTRLZ,CNTRLD)DIMENSION CNTRLZ(5),CNTRLD(5)INTEGER*4,CNTRLDCNTRLD(1)=INT(2*CNTRLZ(1))IF(CNTRLD(1).GT.255)THENCNTRLD(1)=255PRINT*,'MAX. GAIN!'ENDIFIF(CNTRLD(1).LT.O.OR.CNTRLD(1).EQ.1)THENAppendix B. Programs Listing^ 188CNTRLD(1) =0PRINT*,'MIN. GAIN=',CNTRLD(1)ENDIFCC CHECK CORRECTNESS OF NEXT LINE (256?)CNTRLD(2)=INT(127*CNTRLZ(2))IF(CNTRLD(2).GT.127)^CNTRLD(2)=127IF(CNTRLD(2).LT.0) CNTRLD(2)=0.CCNTRLD(3)=INT(256*CNTRLZ(3))IF(CNTRLD(3).GT.255)THENCNTRLD(3)=255PRINT*,'MAX. ZERO!'ENDIFIF(CNTRLD(3).LT.O. )THENCNTRLD(3)= 0PRINT*,'MIN. ZERO!'ENDIFCCNTRLD(4)=INT(256*CNTRLZ(4))IF(CNTRLD(4).GT.255)THENCNTRLD(4)=255PRINT*,'MAX. POLE!'ENDIFIF(CNTRLD(4).LT.O. )THENCNTRLD(4)=0PRINT*,'MIN. POLE!'ENDIFCCNTRLD(5)=0CRETURNENDB.2.7 Print OutSUBROUTINE PRINTOUTDIMENSION CNDQNT(5),ATRNET(5),CNGATR(5),DECTBL(5,5,5),PRFORM(5)CHARACTER*5,CNVAR(5)CHARACTER*6,CNQNT(5)Appendix B. Programs Listing^ 189CHARACTER*5,ACVAR(5)CHARACTER*5,ACQNT(5)INTEGER CNDQNTENTRY INITLINGUOPEN(UNIT=74,FILE='LINGUIST.DAT')READ (74,15) CNVAR,CNQNT,ACVAR,ACQNT15 FORMAT (5A5,5A6,5A5,5A5)CLOSE(74)RETURNENTRY INITPRNT(ATRNET)PHMAXD=ATRNET(1)*57.29PRINT 100100 FORMAT (20X,'Initial attributes:')PRINT 101,PHMAXD,ATRNET(2),ATRNET(3),ATRNET(4)101 FORMAT (5X,'PHMAX=',F4.1,5X,'FRMAX=',F4.0,4X,'HFRGN=',F4.20,5X,'LFRGN=',F4.1)RETURNENTRY PRNT(CNDQNT,PRFORM,DECTBL,ATRNET,OIPHMAX,IFRMAX,IHFRGN,ILFRGN,K)PHMAXD=ATRNET(1)*57.29PRINT 102,K102 FORMAT(20X,'TEST SIGNAL',2X,I3)PRINT 103,CNVAR(IPHMAX),CNQNT(CNDQNT(IPHMAX)),PRFORM(IPHMAX),ACVAR(1),DECTBL(IPHMAX,CNDQNT(IPHMAX),1),PHMAXD103 FORMAT(1X,A5,' = ',A6,' (',F5.2,') ==> ',A5,'AC= ',F4.1,2XO ,'PHMAX=',F7.2)PRINT 104,CNVAR(IFRMAX),CNQNT(CNDQNT(IFRMAX)),PRFORM(IFRMAX)O ,ACVAR(2),DECTBL(IFRMAX,CNDQNT(IFRMAX),2),ATRNET(2)104 FORMAT(1X,A5,' = ',A6,' (',F5.2,') ==> ',A5,'AC= ',F4.1,2X,'FRMAX=',F7.2)PRINT 105,CNVAR(IHFRGN),CNQNT(CNDQNT(IHFRGN)),PRFORM(IHFRGN),ACVAR(3),DECTBL(IHFRGN,CNDQNT(IHFRGN),3),ATRNET(3)105 FORMAT(1X,A5,' = ',A6,' (',F5.2,') ==> ',A5,'AC= ',F4.1,2X,'HFRGN=',F7.2)PRINT 106,CNVAR(1),CNQNT(CNDQNT(1)),PRFORM(1),ACVAR(4),DECTBL(1,CNDQNT(1),4),ATRNET(4)106 FORMAT(1X,A5,' = ',A6,' (',F5.2,') ==> ',A5,'AC= ',F4.1,2XAppendix B. Programs Listing^ 190,'LFRGN=',F7.2)RETURNENTRY FINALPRNT(CNDQNT)PRINT 107107 FORMAT(20X,'Final performance: ')PRINT 108,CNVAR(1),CNQNT(CNDQNT(1)) ,CNVAR(2),CNQNT(CNDQNT(2))@^,CNVAR(3),CNQNT(CNDQNT(3)) ,CNVAR(4),CNQNT(CNDQNT(4))0 ,CNVAR(5),CNQNT(CNDQNT(5))108 FORMAT(1X,A5,'=',A6,3X,A5,'=',A6,3X ,A5,'=',A6,3X,A5,'=',A60,3X,A5,'=',A6)RETURNEND*eofAppendix B. Programs Listing^ 191B.3 Fuzzy Tuner Program listingB.3.1 Main Program DECISIONPROGRAM DECISIONC^Program DECISION computes, off-line, the Fuzzy Tunner Decision-Table.C^3 Data base are used:C^a) Ruleset Table (RULST), generated in sub-program SUBRU LST.b) Membership Functions table of the Condition Variables (CNDMF), generatedin sub-program SUBCNDMF.C^c) Membership Functions of the Action Variables (ACTMF), generatedin sub-program SUBACTMF.Sub-program SUBRLTION computes the Fuzzy Relations Table (RLTION)using SUP (Sub-program SUP) of MIN (Sub-program MIN) operation.This Relation table is now matched with the Membership Function ofCondition Variable by applying the compositionl rule of inference("SUP" of "MIN"), in sub-Program SUBDCSION, to generate the Fuzzy valueof the action. This value is defuzzified in sub-program SUBDEFUZD, usingthe Center Of Gravity Method.The Decision table is stores in DCSION to be used by the Servo ExpertTo produce the Tunning Action in real-time.COMMON/COM1/ CNDVAR(5),CNDQNT(5),ACTVAR(5),ACTQNT(5),ACTGRD(5)COMMON/COM2/ imax,jmax,kmax,lmax,mmax,nmaxDIMENSION CNDMF(5,5,5),ACTMF(5,5,5),RULST(5,5,5)#,BARLEV(5,5,5,5,5),RLTION(5,5,5,5),DCSION(5,5,5)CHARACTER*5,CNDVARCHARACTER*6,CNDQNTCHARACTER*5,ACTVARAppendix B. Programs Listing^ 192CHARACTER*5,ACTQNTINTEGER ACTGRD,RULSTCALL DATCALL SUBCNDMF (CNDMF)CALL SUBACTMF (ACTMF)CALL SUBRULST (RULST)CALL SUBRLTION (CNDMF,ACTMF,RULST,RLTION)CALL SUBDCSION (RLTION,CNDMF,DCSION)CCCCSTOPENDAppendix B. Programs Listing^ 193B.3.2 Sub-Program DATASUBROUTINE DATACOMMON/COM1/ CNDVAR(5),CNDQNT(5),ACTVAR(5),ACTQNT(5),ACTGRD(5)COMMON/COM2/ imax,jmax,kmax,lmax,mmax,nmaxCHARACTER*5,CNDVARCHARACTER*6,CNDQNTCHARACTER*5,ACTVARCHARACTER*5,ACTQNTINTEGER ACTGRDc^Membership Function cardinality for the Condition Variables:kmax=5c^Membership Function cardinality for the Action Variables:nmax=5Cc^CONDITION AND ACTION VARIABLES AND QUANTITIES:c^Fuzzy CoNDdition VARiables (CNDVAR), index i, Cardinality imax.imax=5C!^IMAX=1c^OFFSET in the error response:CNDVAR(1)='OFFST'c^OSCILlation in error response:CNDVAR(2)='DMPRT'c^SPEED of response:CNDVAR(3)='RISIN'cc^OVer SHoot of the error response:CNDVAR(4)='0VSHT'c^Damped natural frewuencyCNDVAR(5)='DMPFR'Appendix B. Programs Listing^ 194c^^Fuzzy CoNDition QuaNTitie (CONQNT) index j, Cardinality jmax.jmax=5c^ GRADc^Well UNder SPCisfiaction^(-3)CNDQNT(1)='UNSATF'c^UNDer SPCification^(-2)CNDQNT(2)='POOR 'c^IN_SPCification^(-1)CNDONT(3)='MODRAT'c^OKEY^ ( 0)CNDONT(4)='IN_SPC'c^Well OVer SPCification^(1)CNDONT(5)= 1 0VRSPC'c^Fuzzy Action Variables index 1, Cardinality lmax.c!^LMAX=1lmax=5Cc^Change the PHase LeaD in the C.0 freq.ACTVAR(1)='PHMAX'c^Change the CRose-OVer Frequency.ACTVAR(2)='FRMAX'c^Change the HIgh Frequency Gain.ACTVAR(3)='HFRGN'c^Change the Low Frequency Gain.ACTVAR(4)='LFRGN'c^Change the Dead BaNd Zoon.ACTVAR(5)='DBNDZ'Appendix B. r Programs Listing^ 195c^^Fuzzy ACTION Quantities (Grades from -2 to +2), index m, Cardinality mmax.mmax=5c^ GRADc^Negative HI^(-2)ACTQNT(1)='NEGHI'ACTGRD(1) = -2c^Negative LOACTQNT(2)='NEGLO'ACTGRD(2) = -1c^No ChanGe^( 0 )ACTQNT(3)='NOCHG'ACTGRD(3) = 0c^Positive LOACTQNT(4)='POSLO'ACTGRD(4) = 1c^Popsitive HI^(+2 )ACTQNT(5)='POSHI'ACTGRD(5) = 2OPEN(UNIT=74,FILE='LINGUIST.DAT')WRITE (74,15) CNDVAR,CNDQNT,ACTVAR,ACTQNT15 FORMAT (5A5,5A6,5A5,5A5)CLOSE(74)RETURNENDAppendix B. Programs Listing^ 196B.3.3 Sub-Program CNDMFSUBROUTINE SUBCNDMF (CNDMF)COMMON/COM1/ CNDVAR(5),CNDQNT(5),ACTVAR(5),ACTQNT(5),ACTGRD(5)COMMON/COM2/ imax,jmax,kmax,lmax,mmax,nmaxDIMENSION CNDMF(5,5,5)CHARACTER*5,CNDVARCHARACTER*6,CNDQNTCHARACTER*5,ACTVARCHARACTER*5,ACTQNTINTEGER ACTGRDopen(unit=60,file='cndmf.tbl')c^Asume Crisp Values for Condition i, Quantity j (i.e [0 0 0 1 0] ):DO 2 i = 1,imaxDO 2 J = 1,jmaxc^DO 2 k = 1,kmaxc^IF (j.eq.k) GO TO 1c^CNDMF(i,j,k) = 0.c^GO TO 2c 1^CNDMF(i,j,k) = 1.DO 2 k = j,kmaxCNDMF(i,j,k)=1.-(k-j)*0.2CNDMF(i,k,j)=CNDMF(i,j,k)2 CONTINUEDO 3 i = 1,imaxPRINT 10,CNDVAR(i)WRITE(60,10) CNDVAR(i)10 FORMAT (1h0,//,'^Membership Function Table for ConditionOVariable:',A5)PRINT 11WRITE(60,11)11 FORMAT (1H,23X,' 1^2^3^4^5')PRINT 12Appendix B. _Programs Listing^ 197WRITE(60 , 12)12 FORMAT (1H , 15X , 50 ( ' - ' ) )DO 3 .1 - = 1, jmaxPRINT 13 , CNDQNT(j ) , (CNDMF (i , j ,k) ,k=1,kmax)WRITE(60 , 13) CNDQNT( j) , (CNDMF(i , j ,k) ,k=1,kmax)13 FORMAT ,(1h,8x,A6, ' I ' ,5F10 .1)3 CONTINUEclose (60)RETURNENDAppendix B. Programs Listing^ 198B.3.4 Sub-Program ACTMFSUBROUTINE SUBACTMF (ACTMF)COMMON/COM1/ CNDVAR(5),CNDQNT(5),ACTVAR(5),ACTQNT(5),ACTGRD(5)COMMON/COM2/ imax,jmax,kmax,lmax,mmax,nmaxDIMENSION ACTMF(5,5,5)CHARACTER*5,CNDVARCHARACTER*6,CNDQNTCHARACTER*5,ACTVARCHARACTER*5,ACTOTINTEGER ACTGRDopen(unit=61,file='actmf.tbl')c^Asume Crisp Values for Condition 1, Quantity m (i.e [0 0 0 1 0] ):DO 2 1 = 1,lmaxDO 2 m = 1,mmaxc^DO 2 n = 1,nmaxc^IF (m.eq.n) GO TO 1c^ACTMF(1,m,n) = O.c^GO TO 2c 1^ACTMF(l,m,n) = 1.c 2 CONTINUEDO 2 n = m,mmaxACTMF(1,m,n)=1.-(n-m)*0.2ACTMF(1,n,m)=ACTMF(1,m,n)2 CONTINUEDO 3 1 = 1,lmaxPRINT 10,ACTVAR(1)WRITE(61,10)10 FORMAT (1h0,//,14X,' Membership Function Table for the ActioneVariable:',A5,/,)PRINT 11, (ACTGRD(n),n=1,nmax)Appendix B. Programs Listing^ 199WRITE(61,11)11 FORMAT (1H,15X,5I10,/,10X,58('-'))WRITE(61,12)12 FORMAT (1H,15X,50('-'))DO 3 m = 1,mmaxPRINT 13 ,ACTQNT(m),(ACTMF(1,m,n),n=1,nmax)WRITE (61,13) ACTQNT(m),(ACTMF(1,m,n),n=1,nmax)13 FORMAT (1h,8X,A5,' I',5F10.1)3 CONTINUECLOSE(61)c^RETURNENDAppendix B. Programs Listing^ 200B.3.5 Sub-Program RULESETSUBROUTINE SUBRULST (RULST)COMMON/COM1/ CNDVAR(5),CNDQNT(5),ACTVAR(5),ACTQNT(5),ACTGRD(5)COMMON/COM2/ imax,jmax,kmax,lmax,mmax,nmaxDIMENSION RULST(5,5,5),RULST1(5,5,5),RULS(5,5,5)CHARACTER*5,CNDVARCHARACTER*6,CNDQNTCHARACTER*5,ACTVARCHARACTER*5,ACTQNTCHARACTER*5,RULSINTEGER RULST,RULST1,ACTGRDc^Rules for default: IF CONDITION(i) = OKY, THEN ACTION(1) = NCH .open(unit=62,file='rulset.tb1 1 )DO 1 i = 1,imaxDO 1 j = 1,jmaxDO 1 1 = 1,lmaxRULST(i,j,l) = 3RULS (i,j,1)=ACTQNT(3)^1^CONTINUE^C^RULES 140R: IF OSCIL = CNDVAR THEN PHMAX = ACTQNT^C^if OSCIL = WUNSPC then PHMAX = POSHIRULS (2,1,1) = ACTQNT(5)RULST(2,1,1) = 5^C^if OSCIL = UNDSPC then PHMAX = NOCNGRULS (2,2,1) = ACTQNT(3)RULST(2,2,1) = 3^C^if OSCIL = IN_SPC then PHMAX = NOCNGRULS (2,3,1) = ACTQNT(3)RULST(2,3,1) = 3^C^if OSCIL = OK^then PHMAX = NOCNGRULS (2,4,1) = ACTQNT(3)Appendix B. Programs Listing^ 201RULST(2,4,1) = 3C^if OSCIL = WOVSPC then PHMAX = NOCNGRULS (2,5,1) = ACTQNT(3)RULST(2,5,1) = 3C^RULES FOR: IF SPEED = CNDVAR THEN PHCOV = ACTQNTC^if SPEED = WUNSPC then PHCOV = NEGHIRULS (3,1,1) = ACTQNT(1)RULST(3,1,1) = 1C^if SPEED = UNDSPC then PHCOV = NEGLORULS (3,2,1) = ACTQNT(2)RULST(3,2,1) = 2C^if SPEED = IN_SPC then PHCOV = NEGLORULS (3,3,1) = ACTQNT(2)RULST(3,3,1) = 2C^if SPEED = OK^then PHCOV = NOCNGRULS (3,4,1) = ACTQNT(3)RULST(3,4,1) = 3C^if SPEED = WOVSPC then PHCOV = POSLORULS (3,5,1) = ACTQNT(4)RULST(3,5,1) = 4CC^RULES FOR: IF OVSHT = CNDVAR THEN PHMAX = ACTQNTC^if OVSHT = WUNSPC then PHMAX = POSHIRULS (4,1,1) = ACTQNT(5)RULST(4,1,1) = 5C^if OVSHT = UNDSPC then PHMAX = POSLORULS (4,2,1) = ACTQNT(4)RULST(4,2,1) = 4C^if OVSHT = IN_SPC then PHMAX = POSLORULS (4,3,1) = ACTQNT(3)RULST(4,3,1) = 4C^if OVSHT = OK^then PHMAX = NOCNGRULS (4,4,1) = ACTQNT(3)RULST(4,4,1) = 3C^if OVSHT = WOVSPC then PHMAX = NEGLORULS (4,5,1) = ACTQNT(2)RULST(4,5,1) = 2Appendix B. Programs Listing^ 202C^RULES FOR: IF OSCIL = CNDVAR THEN COVFR = ACTQNTC^if OSCIL = WUNSPC then PHCOV = NEGHIRULS (2,1,2) = ACTQNT(1)RULST(2,1,2) = 1C^if OSCIL = UNDSPC then PHCOV = NEGLORULS (2,2,2) = ACTQNT(2)RULST(2,2,2) = 2C^if OSCIL = IN_SPC then PHCOV = NEGLORULS (2,3,2) = ACTQNT(2)RULST(2,3,2) = 2C^if OSCIL = OK^then PHCOV = NOCNGRULS (2,4,2) = ACTQNT(3)RULST(2,4,2) = 3C^if OSCIL = WOVSPC then PHCOV = NOCNGRULS (2,5,2) = ACTQNT(4)RULST (2,5,2) = 4C^RULES FOR: IF OVSHT = CNDVAR THEN COVFR = ACTQNTC^if OVSHT = WUNSPC then PHCOV = NEGHIRULS (4,1,2) = ACTQNT(1)RULST(4,1,2) = 1C^if OVSHT = UNDSPC then PHCOV = NEGLORULS (4,2,2) = ACTQNT(2)RULST(4,2,2) = 2C^if OVSHT = IN_SPC then PHCOV = NEGLORULS (4,3,2) = ACTQNT(2)RULST(4,3,2) = 2C^if OVSHT = OK^then PHCOV = NOCNGRULS (4,4,2) = ACTQNT(3)RULST(4,4,2) = 3C^if OVSHT = WOVSPC then PHCOV = NOCNGRULS (4,5,2) = ACTQNT(4)RULST(4,5,2) = 4C^RULES FOR: IF DMPFR = CNDVAR THEN COVFR = ACTQNTAppendix B. Programs Listing^ 203C^if DMPFR = WUNSPC then PHCOV = NEGHIRULS (4,1,2) = ACTQNT(1)RULST(4,1,2) = 1C^if DMPFR = UNDSPC then PHCOV = NEGLORULS (4,2,2) = ACTQNT(2)RULST(4,2,2) = 2C^if DMPFR = IN_SPC then PHCOV = NEGLORULS (4,3,2) = ACTQNT(2)RULST(4,3,2) = 2C^if DMPFR = OK^then PHCOV = NOCNGRULS (4,4,2) = ACTQNT(3)RULST(4,4,2) = 3C^if DMPFR = WOVSPC then PHCOV = NOCNGRULS (4,5,2) = ACTQNT(4)RULST(4,5,2) = 4C^if DMPFR = WUNSPC then FRMAX = NEGHIRULS (5,1,2) = ACTQNT(1)RULST(5,1,2) = 1C^if DMPFR = UNDSPC then FRMAX = NEGLORULS (5,2,2) = ACTQNT(2)RULST(5,2,2) = 2C^if DMPFR = IN_SPC then FRMAX = NEGLORULS (5,3,2) = ACTQNT(2)RULST(5,3,2) = 2C^if DMPFR = OK^then FRMAX = NOCNGRULS (5,4,2) = ACTQNT(3)RULST(5,4,2) = 3C^if DMPFR = WOVSPC then FRMAX = POSHIRULS (5,5,2) = ACTQNT(4)RULST(5,5,2) = 4c^RULES FOR: IF OFFST = CNDVAR THEN HFRGN = ACTQNTC^if OFFST = WUNSPC then HFRGN = POSHIRULS (1,1,3) = ACTQNT(5)RULST(1,1,3) = 5C^if OFFST = UNDSPC then HFRGN = POSLORULS (1,2,3) = ACTQNT(4)RULST(1,2,3) = 4Appendix B. Programs Listing^ 204C^if OFFST = IN_SPC then HFRGN = POSLORULS (1,3,3) = ACTQNT(4)RULST(1,3,3) = 4C^if OFFST = OK^then HFRGN = NOCNGRULS (1,4,3) = ACTQNT(3)RULST(1,4,3) = 3C^if OFFST = WOVSPC then HFRGN = NEGLORULS (1,5,3) = ACTQNT(2)RULSTp,5,3) = 2C^RULES FOR: IF OSCIL = CNDVAR THEN HFGRGN = ACTQNTC^if OSCIL = WUNSPC then HFRGN = NEGHIC RUL (2,1,3) = ACTQNT(1)C^RULST(2,1,3) = 1C^if OSCIL = UNDSPC then HFRGN = NOCNGC^RULS (2,2,3) = ACTQNT(3)C^RULST(2,2,3) = 3C^if OSCIL = IN_SPC then HFRGN = NOGNGC RULS (2,3,3) = ACTQNT(3)C^RULST(2,3,3) = 3C^if OSCIL = OK^then HFRGN = NOCNGC RULS (2,4,3) = ACTQNT(3)C^RULST(2,4,3) = 3C^if OSCIL = WOVSPC then HFRGN = NOGNGC^RUL$ (2,5,3) = ACTQNT(3)C RULST(2,5,3) = 3C^RULES FOR: IF RISE = CNDVAR THEN HFRGN = ACTQNTC^if RISE = WUNSPC then HFRGN = POSHIRULS (3,1,3) = ACTQNT(5)RULST(3,1,3) = 5C^if RISE = UNDSPC then HFRGN = POSLORULS (3,2,3) = ACTQNT(4)RULST(3,2,3) = 4C^if RISE = IN_SPC then HFRGN = POSLORULS (3,3,3) = ACTQNT(3)RULST(3,3,3) = 4Appendix B. • Programs Listing^ 205C^if RISE = OK^then HFRGN = NOCNGRULS (3,4,3) = ACTQNT(3)RULST(3,4,3) = 3C^if RISE = WOVSPC then HFRGN = NEGLORULS (3,5,3) = ACTQNT(2)RULST(3,5,3) = 2C^RULES FOR: IF OVSHT = CNDVAR THEN HFRGN = ACTQNTC^if OVSHT = WUNSPC then HFRGN = POSHIRULS (4,1,3) = ACTQNT(5)RULST(4,1,3) = 5C^if OVSHT = UNDSPC then HFRGN = POSLORULS (4,2,3) = ACTQNT(4)RULST(4,2,3) = 4C^if OVSHT = IN_SPC then HFRGN = POSLORULS (4,3,3) = ACTQNT(3)RULST(4,3,3) = 4C^if OVSHT = OK^then HFRGN = NOCNGRULS (4,4,3) = ACTQNT(3)RULST(4,4,3) = 3C^if OVSHT = WOVSPC then HFRGN = NEGLORULS (4,5,3) = ACTQNT(2)RULST(4,5,3) = 2CC^RULES FOR: IF DMPFR = CNDVAR THEN HFGRGN = ACTQNTC^if DMPFR = WUNSPC then HFRGN = POSHIRULS (5,1,3) = ACTQNT(5)RULST(5,1,3) = 5C^if DMPFR = UNDSPC then HFRGN = POSLORULS (5,2,3) = ACTQNT(4)RULST(5,2,3) = 4C^if DMPFR = IN_SPC then HFRGN = POSLORULS (5,3,3) = ACTQNT(4)RULST(5,3,3) = 4C^if DMPFR = OK^then HFRGN = NOCNGRULS (5,4,3) = ACTQNT(3)Appendix B. Programs Listing^ 206RULST(5,4,3) = 3C^if DMPFR = WOVSPC then HFRGN = NEGHIRULS (5,5,3) = ACTQNT(1)RULST(5,5,3) = 1c^RULES FOR: IF OFFST = CNDVAR THEN LFRGN = ACTQNTC^if OFFST = WUNSPC then LFRGN = POSHIRULS (1,1,4) = ACTQNT(5)RULST(1,1,4) = 5C^if OFFST = UNDSPC then LFRGN = POSLORULS (1,2,4) = ACTQNT(4)RULST(1,2,4) = 4C^if OFFST = IN_SPC then LFRGN = POSLORULS (1,3,4) = ACTQNT(4)RULST(1,3,4) = 4C^if OFFST = OK^then LFRGN = NOCNGRULS (1,4,4) = ACTQNT(3)RULST(1,4,4) = 3C^if OFFST = WOVSPC then LFRGN = NEGLORULS (1,5,4) = ACTQNT(2)RULST(1,5,4) = 2DO 2 i = 1,imaxPRINT 10,CNDVAR(i)WRITE(62,10) CNDVAR(i)10^FORMAT(1h0,//,30X,'Rules for Condition Variable:',A5,/)PRINT 11,(ACTVAR(1),1=1,1max)WRITE (62,11) (ACTVAR(1),1=1,1max)11^FORMAT(1H,22X,5A10,/,20x,55('-'))DO 2 J = 1,jmaxPRINT 12,CNDQNT(j),(RULS(i,j,1),1=1,1max)c^^PRINT 13,CNDQNT(j),(RULST(i,j,1),1=1,1max)WRITE(62,12) CNDQNT(j),(RULST(i,j,1),1=1,1max)12^FORMAT(1h,15x,A6, 1 1',5A10)13^FORMAT(1h,15x,A6,'1',5I10)2^CONTINUECLOSE(62)RETURNAppendix B. Programs Listing^ 207ENDAppendix B. Programs Listing^ 208B.3.6 Sub-Program RELATIONSUBROUTINE RELATION (CNDMF,ACTMF,RULST,RLTION)COMMON/COM1/ CNDVAR(5),CNDQNT(5),ACTVAR(5),ACTQNT(5),ACTGRD(5)COMMON/COM2/ imax,jmax,kmax,lmax,mmax,nmaxDIMENSION CNDMF(5,5,5),ACTMF(5,5,5),BARLEV(5,5,5,5,5)0,RULST(5,5,5),RLTION(5,5,5,5)CHARACTER*5,CNDVARCHARACTER*6,CNDQNTCHARACTER*5,ACTVARCHARACTER*5,ACTQNTINTEGER ACTGRD,RULSTOPEN(UNIT=63,FILE='RELATION.TBL')DO 1 i = 1,imaxDO 1 1 = 1,lmaxIF(i.ne.1.or.l.ne.1) go to 110PRINT 10, CNDVAR(i),ACTVAR(1)WRITE(63,10) CNDVAR(i),ACTVAR(1)10 FORMAT(1H1,/////,10X,'Development of the Fuzzy Realation Table!for:',A6,' ==>',A5)110 continueDO 2 j = 1,jmaxDO 3 k = 1,kmaxDO 3 n = 1,nmaxBARLEV(i,l,j,k,n) =# MIN(CNDMF(i,j,k),ACTMF(1,RULST(i,j,1),h))3 CONTINUEIF(i.ne.l.or.l.ne.1) go to 112Appendix B. Programs Listing^ 209PRINT 11 ,CNDVAR(i),CNDQNT(j),ACTVAR(1),ACTQNT(RULST(i,j,1))WRITE(63,11) CNDVAR(i),CNDQNT(j),ACTVAR(1),ACTQNT(RULST(i,j,1))11 FORMAT(1h,//,25X,'IF ',A5,' =',A6,' Then',A5,' =',A5)PRINT 12, (ACTGRD(n),n=1,nmax)WRITE (63,12) (ACTGRD(n),n=1,nmax)12 FORMAT(1h,/,22X,5110,25X,55('_'))112 continueDO 2 k=1,kmaxIF(i.ne.l.or.l.ne.1) go to 113PRINT 13,k,(BARLEV(i,l,j,k,n),n=1,nmax)WRITE(63,13) k,(BARLEV(i,l,j,k,n),n=1,nmax)13 FORMAT (1h,10X,I10, 1 1',5F10.1)113 continue2 CONTINUEDO 5 k = 1,nmaxDO 5 n = 1,kmaxRLTION(i,l,k,n)=BARLEV(i,1,1,k,n)DO 5 j = 1,jmax-1RLTION(i,l,k,n) = MAX(RLTION(i,l,k,n),BARLEV(i,l,j+1,k,n))5 CONTINUEIF(i.ne.1.or.l.ne.1) go to 115PRINT 14,CNDVAR(i),ACTVAR(1)WRITE(63,14) CNDVAR(i),ACTVAR(1)14 FORMAT(1h,//,17x,' Composite Relation Table for ',A5,' ==> ',A5)PRINT 15, (ACTGRD(n),n=1,nmax)WRITE(63,15) (ACTGRD(n),n=1,nmax)15 FORMAT (1H1,22X,5I10,/,15X,58('-'))115 continueDO 7 k = 1,kmaxIF(i.ne.1.or.l.ne.1) go to 116PRINT 16,k,(RLTION(i,l,k,n),n=1,nmax)WRITE(63,16) k,(RLTION(i,l,k,n),n=1,nmax)Appendix B. programs Listing^ 21016 FORMAT(1h,10X,I10,'I',5F10.1)116 continue7 CONTINUE1 CONTINUECLOSE(63)RETURNENDAppendix B. Programs Listing^ 211B.3.7 Sub-Program DECISIONSUBROUTINE SUBDCSION (RLTION,CNDMF,DCSION)INTEGER ACTGRDCOMMON/COM1/ CNDVAR(5),CNDQNT(5),ACTVAR(5),ACTQNT(5),ACTGRD(5)COMMON/COM2/ imax,jmax,kmax,lmax,mmax,nmaxDIMENSION CNDMF(5,5,5),RLTION(5,5,5,5),SHANY(5,5,5,5,5)!,YAEL(5,5,5,5),DCSION(5,5,5)CHARACTER*5,CNDVARCHARACTER*6,CNDQNTCHARACTER*5,ACTVARCHARACTER*5,ACTQNTOPEN(UNIT=64,FILE='DECISION.TBL')DO 1 i = 1,imaxDO 1 1 = 1,1maxDO 1 j = 1,jmaxDO 2 n = 1,nmaxDO 2 k = 1,kmaxSHANY(i,l,j,k,n) = MIN(CNDMF(i,j,k),RLTION(i,l,k,n))2 continuec!^do 100 k=1,kmaxc! 100 print 110,i,l,j,k, (shany(i,l,j,k,n),n=1,nmax)c! 110 format(1h,2x,4i5,5f5.0)DO 3 n = 1,nmaxYAEL(i,1,J,n)=SHANY(i,1,J,1,n)DO 3 k = 1,kmax-1YAEL(i,l,j,n) = MAX(YAEL(i,l,j,n),SHANY(i,l,j,k+1,n))3 CONTINUEAppendix B. Programs Listing^ 212C^PRINT 10, (YAEL(i,l,j,n),n=lonmax)C^WRITE(64,10) (YAEL(i,l,j,n),n=1,nmax)C 10 FORMAT(1h,10X,5F10.1)1 CONTINUECALL SUBDFUZD (YAEL,DCSION)DO 5 i = 1,imaxPRINT 11,CNDVAR(i)C^WRITE(64,11) CNDVAR(i)11 FORMAT(1H,///,25X,'Fuzzy Decision Table for Condition:'@,2x,A5,/,20x,55('*'))PRINT12, (ACTVAR(1),1=1,1max)C^WRITE(64,12) (ACTVAR(1),1=1,1max)12 FORMAT(1H,/,40X,'ACTION VARIABLE',/,20x,5a10,/,10x,60('-'))DO 5 j = 1,jmaxPRINT 13,CNDUT(J),(DCSION(i,l,j),1=1,1max)WRITE(64,14) (DCSION(i,j,1),1=1,1max)13 FORMAT(1H,12X,A6,'I',5F10.1)14 FORMAT(5F10.2)5 CONTINUECLOSE(64)RETURNENDAppendix B. Programs Listing^ 213B.3.8 Sub-Program DEFUZZYSUBROUTINE SUBDFUZD(YAEL,DCSION)CINTEGER ACTGRDCOMMON/COM1/ CNDVAR(5),CNDQNT(5),ACTVAR(5),ACTQNT(5),ACTGRD(5)COMMON/COM2/ imax,jmax,kmax,lmax,mmax,nmaxDIMENSION YAEL(5,5,5,5),DCSION(5,5,5)CHARACTER*5,CNDVARCHARACTER*6,CNDQNTCHARACTER*5,ACTVARCHARACTER*5,ACTQNTCDO 1 i = 1,imaxDO 1 1 = 1,lmaxDO 1 j = 1,jmaxCDCSION(i,l,j) =DO 1 n = 2,nmaxDCSION(i,l,j) =1 CONTINUEDCSION(i,l,j) =CRETURNEND*eofYAEL(i,l,j,1)*ACTGRD(1)DCSION(i,l,j)+YAEL(i,l,j,n)*ACTGRD(n)DCSION(i,l,j)/nmaxAppendix B. Programs Listing^ 214B.4 Subprogram LEARNSUBROUTINE LEARN(K,PRFRS,THOLRN,CNGATR,RULSET)COMMON/COM1/ CNVAR,CNQNT,ACVAR,ACQNTDIMENSION RULSET(5,5,4),PRFRS(5),PRFRSO(5),CNGATR(4)#,THOLRN(5),DPRFRM(5),RULS(5,5,4)CHARACTER*5,CNVAR(5)CHARACTER*6,CNQNT(5)CHARACTER*5,ACVAR(4)CHARACTER*5,ACQNT(5)CHARACTER*5,RULSINTEGER RULSETOPEN(UNIT=70,FILE='RULS.LRN')OPEN(UNIT=71,FILE='RULSET.LRN')IF (K.EQ.1)THENDO 1 1=1,5PRFRSO(I)=PRFRS(I)DO 1 J=1,5DO 1 L1=1,4RULSET(I,J,L1)=31^RULS(I,J,L1)=ACQNT(3)RETURNENDIFL=K -1DO 2 1=1,5DPRFRM(I)=(PRFRS(I)-PRFRSO(I))/ABS(PRFRS(I))IF(DPRFRM(I)*SIGN(1.,CNGATR(L)).LE.-THOLRN(I))THENRULSET(I,1,L)= 5RULSET(I,2,L)= 4RULSET(I,3,L)= 4RULSET(I,4,L)= 3RULSET(I,5,L)= 2ELSEIF(DPRFRM(I)*SIGN(1.,CNGATR(L)).GE.+THOLRN(I))THENRULSET(I,1,L)= 1RULSET(I,2,L)= 2RULSET(I,3,L)= 2Appendix B. Programs Listing^ 215RULSET(I,4,L)= 3RULSET(I,5,L)= 4ENDIFDO 6 J=1,56^RULS(I,J,L)=ACQNT(RULSET(I,J,L))2 CONTINUEDO 3 i = 1,5WRITE(70,10) CNVAR(i)10^FORMAT(1h0,//,30X,'Rules for Condition Variable:',A5,/)WRITE (70,11) (ACVAR(1),1=1,4)11^FORMAT(1H,22X,4A10,/,20x,55('-'))DO 3 J = 1,5WRITE(70,12) CNQNT(j),(RULS(i,j,1),1=1,4)12^FORMAT(1h,15x,A6,'I',4A10)WRITE(71,13)(RULSET(i,j,1),1=1,4)13 FORMAT(4I10)3 CONTINUECLOSE(70)CLOSE(71)RETURNEND