5 .. \..-4».‘—c . v. . ?. 5w: 1 7.. ._ J. .3. . .2 .msmmwfirr r. x 2a.... 4 “wwfisw A . ‘ n“ .3: .4. .5 .- .r 4% . _ ' . . n... ‘3. L5,». ~. :1 3. . 4 .93.: J 51 f . 5.. 1.3:. 1. age». {at k :2...» 4 use-nlv i2 . 2,. .5. at. : 5...". 5.. a. .V :...:a§.w..fi. V: :‘A‘Attit... fa“? f .. rm?" r k. :3, s. a .34.... .Lx s. ‘34.. «I n. Mr 8...... {it A .. A 3.2 1.. Jury... :._ . n. a 5 1.413 . . :Wu , . .5... 4 ., .. .a ; . . . 5:4 . .. 6% V 4 1 my. maiufmr§§c , .,...,...r_¢..,r§.,.m§t “$4.. , ,. g . . f gggww _ . M83 as Imliliil‘filllllljllllgglwl 1293 O1 LIBRARY Michigan State University This is to certify that the thesis entitled FUZZY LOGIC FDR EMBEDDED SYSTEMS: DESIGN OF A REFRIGERATOR CONTRDLILER presented by Weijiang Robert Yu has been accepted towards fulfillment of the requirements for ‘m degree in _EJ_e§_tr_1'mJ Eng Major professor f/gz/ii 0-7639 MS U is an Affirmative Action/Equal Opportunity Institution PLACE IN RETURN BOX to remove this checkout from your record. TO AVOID FINE return on or before date due. MAY BE RECALLED with earlier due date if requested. DATE DUE DATE DUE DATE DUE ma chlefi-atd FUZZY LOGIC FOR EMBEDDED SYSTEMS: DESIGN OF A REFRIGERATOR CONTROLLER By Weijiang Robert Yu A THESIS Submitted to Michigan State University in partial fulfillment of the requirements for the degree of MASTER OF SCIENCE Department of Electrical and Computer Engineering 1999 ABSTRACT FUZZY LOGIC FOR EMBEDDED SYSTEMS: DESIGN OF A REFRIGERATOR CONTROLLER By Weijiang Robert Yu Fuzzy logic design has been popular in the engineering domain for decades. Its application ranges from control to decision support technology. Fuzzy logic design overpowers the more conventional design strategies because of the ease with which it can represent linguistic terms and ill-defined problems. Moreover, it is very simple to implement using low cost micro-controller in solving complex and non-linear problems. In this thesis, the motivation and relevance for applying fuzzy logic to embedded systems is examined. The history of fuzzy logic and the concepts Of the mathematical foundation that fuzzy logic is built on - fuzzy set theory - is studied. Research has concentrated on the most popular fuzzy logic design methods for embedded systems. Details in constructing fuzzification interface, defuzzification interface, and rule evaluation block are presented. The hardware/software implementation issues are studied. This thesis also provides a demonstration of applying fuzzy logic design to a home appliance followed by results analysis and recommendations. DEDICATION This work is dedicated to my parents. ACKNOWLEDGMENTS This thesis would not have been possible without the help and support Of ECE faculty and staff. Special thanks go to Mr. Carlo Adinata and EE482 Home Appliances Design Team, who provided valuable data for my project, and many thanks tO Mr. Peter Leslie Semig, who helped me check the grammar and format of this thesis. My thank also goes to Whirlpool Corporation, who supplied the refrigerator that used in this investigation. In addition, my thanks go tO Dr. Diane T. Rover and Dr. Bruce Kim for their critical review of my thesis and their valuable suggestions to help me improve the quality of my thesis. Most importantly, special recognition and thank goes to Dr. P. D. Fisher, whose encouragement, guidance and support were essential for me to finish this thesis. TABLE OF CONTENTS LIST OF TABLES .............................................................................. vii LIST OF FIGURES ............................................................................ viii CHAPTER 1 INTRODUCTION ................................................................................ 1 1.1 Objectives ........................................................................................ 2 1.2 Outline ............................................................................................ 2 CHAPTER 2 FUZZY LOGIC .................................................................................... 4 2.1 A Brief History Of Fuzzy Logic ............................................................... 4 2.2 Fuzzy Sets ......................................................................................... 5 2.3 Linguistic Hedges ................................................................................ 7 2.4 Frame Of Cognition .............................................................................. 9 CHAPTER 3 CONSTUCTION OF A FUZZY CONTROLLER .................................... 11 3.1 From Expert Control to Fuzzy Controlll 3.2 Structure of a Fuzzy Controller ............................................................... 14 3.2.1 Fuzzification ........................................................................... 15 3.2.2 Rule based knowledge base (Rule Evaluation).......... . . .......19 3.2.3 Defuzzification ............................................................................ 22 3.3 Issues Of Stability and Verification ........................................................... 27 CHAPTER 4 DEMONSTRATION AND ANALYSIS ................................................. 28 4.1 Introduction ...................................................................................... 28 4.2 A BriefReview Ofthe Structure OfRefrigerator...........................................29 4.3 Problems with Refrigerator .................................................................... 32 4.4 Solutions tO the Problems ..................................................................... 34 4.5 Hardware and Software Development Tool .............................................. 36 4.5.1 Hardware platform ...................................................................... 36 4.5.2 Software development ................................................................. 38 4.6 FuzzyTech Software ........................................................................... 39 CHPATER 5 ANALYSIS AND RESULTS ............................................................... 41 5.1 Introduction .................................................................................... 41 5.2 Interactive Analysis .......................................................................... 41 5.3 Defrost Fuzzy Controller Result and Analysis ............................................ 43 5.4 Conclusions ...................................................................................... 46 CHAPTER 6 RECOMMENDATIONS FOR FUTURE WORK ..................................... 48 APPENDIX A DESIGN OF FUZZY DEFROSTING SYSTEM ..................................... 49 A.1 Introduction ................................................................................... 49 A2 General Information ........................................................................ .49 A.3 Project Description ........................................................................... 49 A.4 System Structure ............................................................................. 50 A5 Linguistic Variables ......................................................................... 50 A.5.l Output variable “Defrost_PeriOd” .................................................. 53 A.5.2 Input variable “DoorOpen_Time” .................................................. 54 A.5.3 Input variable “Humidity” ........................................................... 54 A6 Interface ....................................................................................... 55 A.7 Rule Blocks ................................................................................... 56 A.7.l Rule block “RBI” ..................................................................... 57 APPENDIX B .................................................................................... 58 B.1 Introduction ................................................................................... 58 B.2 Fuzzy Technology Language for Fuzzy Defrosting System ........................... 58 APPENDIX C .................................................................................... 65 Cl Introduction ................................................................................... 65 C2 Code ........................................................................................... 65 vi LIST OF TABLES 3.1 Comparison Of Defuzzification Algorithms [3] ................................... 26 A-l Project Statistics ........................................................................... 49 A-2 Linguistic Variables ..................................................................... 52 A-3 Properties Of Linguistic Input Variables ............................................ 52 A-4 Properties Of Linguistic Output Variables ......................................... 53 A-5 Definition Points of Membership Functions for "Defrost_PeriOd" ...... 53 A-6 Definition Points Of Membership Functions for ‘DoorOpen_Time”....54 A-7 Definition Points of Membership Functions for “Humidity”...............55 A-8 Input Interfaces .............................................................................. 55 A-9 Output Interfaces ........................................................................... 55 A-lO Rules Of Rule Block “RBI” ............................................................ 57 vii LIST OF FIGURES 3.1 Structure Of a Fuzzy Controller ........................................................ 14 3.2 Illustration Of Fuzzy Logic Terminology ......................................... 16 3.3 Different Shapes Of Membership Functions ...................................... 17 3.4 Values Stored for Optimal Fuzzification ........................................... 18 3.5 Illustration of Best Compromise ..................................................... 23 3.6 COA Defiizzification ...................................................................... 24 3.7 Illustration Of Most Plausible .......................................................... 25 4.1 Basic Structure of Refrigerator [9] ...................................................... 30 4.2 Heat Transfer Illustration Of Refrigerator [9] ....................................... 31 4.3 Block Diagram of Fuzzy Controller for a Refrigerator.........................35 5.1 Transfer Plot Of Fuzzy Defrosting Controller ...................................... 45 5.2 Time Response of Fuzzy Defrosting Controller ................................. 45 5.3 3D Plot Of Fuzzy Defrosting Controller ............................................ 46 A-l Structure Of the Fuzzy Logic Defrosting System ............................... 50 A-2 Membership Function of ‘Temperature’ ........................................... 51 A-3 Membership Function of ‘Defrost_PeriOd’ ........................................ 53 A4 Membership Function Of ‘DoorOpen _Time’ .................................... 54 A-5 Membership Function Of ‘Humidity’ .............................................. 55 viii Chapter 1 INTRODUCTION Fuzzy logic has been enjoying remarkable popularity since 1965, when Dr. L. A. Zadeh first proposed this concept [1]. Fuzzy logic theory Offers a conceptual framework for the representation of linguistic terms such as “very”, “maybe”, or “pretty fast”. Fuzzy logic design provides a solution to either Optimal control problems where the choice Of Optimality criteria is a matter Of experience, or ill-defined control problems where criteria is not quite clear to the Boolean logic based modern computers. Industry experts predicted that fuzzy logic would play an important role in embedded systems and become a multibillion—dollar business [2]. Typical application areas of embedded systems include home appliance, consumer electronics, industry controller, vehicular technology, robotics, power systems and image processing and pattern recognition. This thesis aims tO understand the motivation for fuzzy logic, grasp the comprehensive concepts of fuzzy logic theory, summarize the fuzzy logic design methodology for embedded systems, demonstrate certain fuzzy control algorithms for an embedded system used in a home appliance, and present the results of the design. 1.1 Objectives The main goal Of this thesis is tO summarize and Show the fuzzy logic design methodology for embedded systems, the most commonly used “fuzzy” algorithms for designing fuzzy controllers and to demonstrate its application in home appliance. Toward this end, some specific Objectives were involved and these are briefly described below. The relevance of fuzzy logic design for embedded systems was to be studied. A refrigerator was to be examined and a refi’igerator controller for defrosting system by using fuzzy logic was to be designed. The user interface and energy saving issues Of the refrigerator were to be examined and compared with the conventional design. 1.2 Outline This thesis is organized into five chapters, beginning with this introductory chapter. The chapter is followed by an overview of the history of fuzzy logic, the concepts Of fuzzy set, and the important issues on fuzzy logic related concepts such as Frame Of Cognition and linguistic hedges. The next chapter describes the relationship between expert system and fuzzy system, examines the structure of a fuzzy controller and the most popular algorithms used by embedded system design engineers. In the next chapter, chapter 4, two problems that used to be solved by conventional solution in home appliance industry are examined, and two design proposals using fuzzy logic technology to improve the performance of the refrigerator are suggested. Software implementation Of the fuzzy defrosting system is demonstrated. The last chapter deals with the analysis Of the results of the fuzzy defrosting system. Recommendations on further Optimization of the fuzzy defrosting system and software/hardware implementation Of the temperature setting feature. Chapter 2 FUZZY LOGIC 2.1 A Brief History of Fuzzy Logic [3] The modern logic can trace its origins back to ancient Greek philosophy. Due to the efforts Of those famous philosophers, particularly Aristotle, a theory of logic -- the SO- called “ The Law Of Thought” was born [4]. One of the most famous, the “law of Excluded Middle” states that any proposition can be either True or False only. However, Heraclitus who stated that it is possible for things to be both “True” and “Not True” challenged this law. It was then Plato who indicated that there is a third state (neither True nor False). Then it was Lukasiewicz who first systematically proposed the concept that could be the alternative to the Aristotle’s two-value logic [5]. In the early 20th century, Lukasiewicz introduced a three-value logic. He assigned a numeric value tO the third state that can be translated as “possible”. Later on he found out four-value logic, five-value logic and then he proposed that it is possible to have infinite- value logic. It is then until recently that the notion Of an infmite-value logic was developed. In 1965, Dr. L. A. Zadeh from University Of California, at Berkeley published his work about “Fuzzy Sets” which mathematically described the fuzzy set theory [1]. This theory uses the membership function to map the elements Of set to the values between 0 and 1 instead Of using characteristic function that maps all the elements of the set tO the value 0 and 1. He also proposed Operations on how to calculate firzzy logic. 2.2 Fuzzy Sets Before we get to the concept Of the fuzzy set, let us remind ourselves Of Boolean Logic, which is a cornerstone of all mathematical tool used. Based on this two-value logic, no matter how complicated an Object is, we will assign it to one Of two complementary categories, such as good and bad, Odd and even. Sometimes it does make sense. For example, we can always classify integer numbers as Odd or even. Nevertheless, we are faced with Objects that are ill defined and do not have clearly defined boundaries in engineering tasks. Consider the categories such as low pressure, high temperature, small errors etc., which convey a useful meaning that is only Obvious under a certain context. However, the line between the inclusion and exclusion of an Object for such categories are not clear. Therefore the conventional two-value logic is not well fit for this kind Of problems. Here is an example Of how two-value logic can give rise to undesired phenomena: One piece of wood log does not constitute a pile nor two nor three... On the other hand we will agree that 1 million pieces Of log constitute a pile. What is the clear—cut line in between? Can we say that 42,000 pieces Of log don’t constitute a pile but 42,001 would constitute a pile? As we can see, two-value logic can not perfectly explain this dilemma. The key point Of fuzzy sets is that it extends the concept Of a set by admitting different grades Of belonging, or so called membership. By fuzzy set concept, this wood log problem can be easily solved by allowing for all intermediate situations between complete membership and complete non-membership. The higher the value of the membership Of an Object M defined by fuzzy set A, the stronger the link of the object to the category described by A. SO in the above problem we can define 42,000 pieces Of log satisfies the category “pile” at a degree equal to 89%, while 100 pieces of log is characterized by a grade Of membership as 2%. Definition as stated by W. Pedrycz [6]: A fuzzy set A defined on a universe of discourse X is characterized by membership function A: X —> [0,1] Where the grade of membership A(x) describes the degree to which x satisfies the class defined by A. A(x) = 1 denotes all the elements are completely belong to A while A(x) =0 denotes all the elements that definitely do not belong to A. All the properties and laws of crisp set hold except for the exclusion law. However, the exclusive law is an exception: These two relationships Simply indicate the under-lap or over-lap between a fuzzy set and its complement. The logic Operations defined on a fiizzy set can be described point-wise as: 0 AN D(x,y) : min(x,y) o OR(x,y) : max(x,y) o NEG(x) : 1- it Where x and y are two grades Of membership. 2.3 Linguistic Hedges Linguistic hedges [7] are special linguistic terms that modify other linguistic term. The terms such as very, high, medium or extreme are examples Of linguistic hedges. Linguistic hedges are not applicable to the classic Boolean logic. Terms such as very adult, very horizontal, or very rectangle are meaningless. Any linguistic hedge, H, can be interpreted as a unary function [7], h, on [0,1]. If h (a) < a, for all a e[0,l], the operation that represents the linguistic term is called strong; if h (a) > a, for all a e[0,l], then the Operation is called weak The special case that h (a) = a is called identity. A strong Operation reduces the truth-value Of the associate proposition. A weak Operation on the contrary, increases the truth-value Of the proposition. An Operation H has to satisfy the following self-explanatory conditions summarized in [7]: o h(0) = 0 and h(1)= 1; o h is continuous function; 0 if his strong, then h'1 is weak and vice versa; A popular class of functions that satisfy these conditions is Ha(a) = a“, Where aeR+, R+ is a set Of positive real numbers and a 6 [0,1]. When on < l, h is weak; when or > 1, h is strong. SO choosing different values of 0t will let us define and distinguish the meaning Of a linguistic term in different context. This is very usefidl when constructing a membership function for an ill-defined system where nature language that can only be understood in certain context is used. Consider the following example: P1: Humidity is high, P2: Humidity is very high, P3: Humidity is medium high, we let the linguistic hedges very and medium be represented by the strong Operation h(a) = a2 and the h(a) = am. SO if according to our fuzzy set “High”, 50% moisture is considered to be “High” at the grade of 0.8. Then VERY HIGH (50%) = (0.8) 2 = 0.64 and MEDIUM HIGH (50%) = (0.8) V’ = 0.89, and TRUTH (P2) = 0.64, and TRUTH (P3) = 0.89. We find here that the stronger the assertion is the less true it is, which agrees with our intuition. 2.4 Frame of Cognition [8,9] When human beings are trying to solve some complicated problems, they first try to classify their knowledge in terms Of some general concept and then to find out the essential relationship between these concepts. This kind Of Top-Down approach can help us to figure out more detailed solutions from those general knowledge and relationships that connect them. This effort will not help us to find the exact numbers or values we need to achieve our goal, but rather help us to classify some Objects into more general categories like sets (fuzzy sets). It is known that human being can only memorize and use very limited numbers Of concepts at a time in solving complicated problem, however, the structure Of these concepts is important for efficient memorizing, recalling and utilizing. When linguistic labels are defined by fuzzy sets, they assign a certain property to all the values on the universe discourse. This property is known tO be the grade of belonging. When the whole universe discourse is defined by labels, some Of the regions will then be defined as compatible to the highest extent with the labels. The linguistic label assigned to a certain variable forms a frame of cognition of the variable. Fuzzy sets {F1, F2,. . ..} form a frame Of cognition A if: 0 A covers the universe, i.e. all elements of the universe belong to at least one label with nonzero degree Of membership. 0 For each individual element, the sum Of the degree Of belong must be one for all labels that are applicable to this element. In general, the concept Of a frame Of cognition is a very helpful concept in the application Of fuzzy sets by contributing to an efficient formation Of membership functions that are essential to fuzzy logic design. This concept Of the fuzzy set is well known for its importance in narrowing the gap between the pure numerical techniques and the pure symbolic methods. The numerical techniques mainly used today by computer stress particularly in precision and lack Of the necessary generality. On the other hand, human beings can successfully finish some tasks without even knowing all the exact values Of the parameters that involves in their actions. Fuzzy sets come in between like a bridge. Each Object in the fuzzy set is described by symbols or so—called labels - e.g., small, medium, or large. Meanwhile, these labels are connected with the numerical characteristics Of the system through certain semantics. And these numerical characteristics are expressed in the form of membership functions that have numerical grades assigned to them. AS we can see later in this thesis, the trade Off between the representation generality and the precision can be efficiently satisfied by modifying the parameters Of the symbols and the number of the symbol itself. The modification is largely done to the membership function and rule evaluation without any big changes in the design structure. 10 Chapter 3 CONSTRUCTION OF A FUZZY CONTROLLER 3.1 From Expert Control to Fuzzy Control Tasks like driving an automobile on a snow-covered roadway, adjusting the water temperature when we are taking a shower, or packing a fragile non-standard-shaped object — while common in our life — continuously create tough challenges to the embedded controlled robot. Let’s first take a look at how we accomplish our tasks in our everyday life. When a particular task has to be solved, we first will — with our goal in 11 mind -— examine the current situation we are in and try to get as much information as we can. Based on the information we have, we try to recall the entire set Similar situations we have been in and their solutions from our experience (our memory serves as a huge knowledge base in our brain). Then with the help Of the feedback from the result Of our control actions and our goals we quickly achieve the best or close enough result to our goal within a few actions. Consider the example Of controlling the temperature in a building. People in each individual room tend to have different temperature preferences. Hence, human being Operators have to be replaced in these processes Of control by computers or embedded micro-controllers. These controllers must mimic the decision- making skills of the room occupants. A comprehensive module has to be built to undertake all the control activities. However, just as human beings can not describe an object if they have no prior knowledge of it, the controller cannot be constructed to replace human beings when it does not incorporate a complete control knowledge base. The traditional modules used in engineering all have the following premises [6]: o The system has to be known; if there are some uncertainties with the system, the control result gotten by the human-replaced controller can not be Optimal. - The known system has to be clearly and completed defined by mathematical models. 0 The goal of the control has to be specified in some direct system related variables in the term of clearly defined formulas. These variables are also called performance indices. Unfortunately, when the complexity of the system increases, incorporating these assumptions completely into the control model is not realistic. This is due to the fact that 12 some Of the systems are nonlinear or some factors Of the systems are non-stationary, such as time variant systems. A more common problem today is not only the difficulty at finding such a complete model, but also the dilemma that a more precise model usually leads to more complicated multi-valued fimctions with more undetermined parameters to be estimated. Even after we overcome all these troubles and finally find such models, we can only keep them as nice theoretical solutions in the textbook. Given the current technology, it is almost impossible to use embedded systems with limited on-board resources to implement the complicated equations that need extensive calculation time while still satisfying the requirement of real-time control. Moreover, in a real world task, it is likely that we can’t specify the performance index that is supposed to be minimized in a numerical manner; i.e., the degree to which difi‘erent people feel comfortable about the room temperature is different. Sometimes, a complete mathematical model can not even be used to achieve the desired performance index. This usually happens when more than one goal needs to be accomplished within the control actions and where these goals are contradictory. A good example for this is the air conditioner. Some people want the room to be kept cool while they also want the air conditioner to be energy efficient. This will explain the situation in the human Operator controlled system (or so called expert system) where Operators can complete the task very well but can not explain too much on why and how they achieved the optimality in the way they handled the control activities. The answer in general is the effective use of the symbolic computation, which is good at interacting with ill-defined problems or linguistic hedges, as well as numerical values. The expert system owes its success to engineering heuristics. I3 Heuristics plays an important role in achieving the compromise Of partial criteria Of contradictory requirements. It is well accepted that the fuzzy controller is one Of many kinds Of expert systems, which has a computerized inference mechanism tO represent vague human decision. A FeedBack .__.. Fuzzification ..___. Inference Engine = Defuzzification Figure 3.1: Structure of a Fuzzy Controller 3.2 Structure of A Fuzzy Controller It is worth emphasizing that the purpose Of fuzzy control is to analyze and process fuzzy information using a non-fuzzy reasoning scheme. Its fuzziness comes from the nature of the ill-defined problem (e. g., problems that are not clearly defined, such as what the control action of the air conditioner should be if the room temperature is high), the vague representation of the goal (e.g., what constitute energy efficiency), and the way the knowledge base is built on. All this natures determine the structure of a fuzzy controller. A typical fuzzy controller has three parts, as shown in Figure 3.1: 14 o Fuzzification o Rule-based knowledge base (Rule Evaluation or so called Inference Engine) 1» Defuzzification 3.2.1 Fuzzification Fuzzification process — so called input interface - involves domain transformation. Some technical terms, as Shown in Figure 3.2, in this process are: Labels: names that are used to describe the membership function i.e. short fast. Universe discourse: the range Of all the possible value that is applicable to the system. Crisp inputs: distinct real time input values. Fuzzy inputs: the degree, on a 0 to 1 scale, to which the crisp input agrees the membership function. Membership function: each membership function is a fuzzy set. Each membership function is a function that maps eligible crisp input value to a fuzzy input that satisfy the concept of the term Of the labels that describe the membership function. Scope of each label: The range of crisp inputs that the membership function will map. With all Of these concepts, the membership function is the key for the fuzzification process. As we will see later in this chapter, the way rule-based knowledge base is assembled determines that at least one label must be assigned to each membership function. These labels are always linguistic variables or linguistic representations of technical figures Often used by human beings. For example, the technical figure “Temperature” can have a linguistic interpretation {hot, medium warm, normal, medium cold, freezing}. From psychology research on human beings, it has been shown that 15 humans use their Short-term memory to process the technical figures and the short-term memory can handle only up to seven terms at a time. As it is general accepted as a rule, real world engineering always use symmetric labels that have their number as three, five, or seven. labels very cold cold medium warm Membership Function input / 0.45 —————— crisp input : I I l 0 ln—SCODG —>l 2'08? universe discourse ll Figure 3.2: Illustration Of Fuzzy Logic Terminology In all these concepts, the membership function is the most important in the fuzzification process. Membership function is established to assign numerical values to the linguistic variable. It is this membership function that makes the fuzzy controller a powerful but, also, a flexible tool to cope with the linguistic variable in the process of control while still precise enough for computer implementation. The membership function is unlike the characteristic function used in Boolean logic, where labels fully 16 agrees the characteristic function on one side of the clear cut boundary and doesn’t agree at all on the other side. Instead, the crisp inputs within the scope of the membership function changes gradually from fully inapplicable to fully applicable. Many different shapes of membership function have been proposed by firzzy logic research. Only four are used at practice (see Figure 3.3): Z-type, A-type (lambda), l'I-type (PI), and S-type. These types are all normalized and therefore. their maximum is always 1 and minimum is always 0. Other kind of membership functions are discarded by engineers at practice either because they are too complicated to implement for embedded system or because they can be replaced by Z-type or S-type functions. Sometimes people use cubic spline shape fimction to get better performance. This spline membership function is still based on the previous four types but connect the maximum and minimum using spline lines instead of straight lines. The improved performance, however, is achieved by increasing the complexity of the implementation of the membership IL /\ function. PI-Type Lambda-Type Z-Type S-Type Figure 3.3: Different Shapes of Membership Functions 17 During the process of fuzzification, the membership function will take a real time input value and assign a unique grade value for each given label. After the fuzzification, there will be a fuzzy input for each label corresponding to the current crisp input. It is important to know that the smn of the fuzzy inputs for all labels is 1. Usually the computation for the membership is the most time consuming part. However, by using the standard membership function, an optimal fuzzification algorithm exists [10]. In this algorithm, membership fimction is represented by two base points and two slopes. As indicated in Figure 3.4 that is shown below, since A and B are always equal to 0 and 1, respectively, the generated code will only store this two points. In addition, the code stores the slopes of the two straight lines that across A and B. Slope_A h--—-—--------------- 0 Areal Area 2 Area 3 1 Figure 3.4: Values Stored for Optimal Fuzzification Therefore, the membership in the figure for three different areas are: Area 1: zero. Area 2: min { (crisp input — A)* slope_A, 1} Area 3: max {1 — (crisp input — B)*slope_B, 0} Since only comparison, subtraction and one-step multiplication is used, the speed of this Optimal algorithm is five times faster than the four points representation of the PI- type membership on a normal micro-controller with no multiplier/divider. 3.2.2 Rule-based knowledge base (Rule Evaluation) After we get the fuzzy input we need, we will proceed to the second part Of the “fuzzy” processing — Rule Evaluation. The knowledge base is made up of if-then statements with linguistics variables. For example, a typical rule will look like “IF the Temperature is Hot and the Humidity is Wet THEN the cooling time is Long”. The concept Of rule evaluation is to determine what the control action should be based on the linguistics rules made by experts given the fuzzy input value. The rules are written in nature language, however, it is confined to a set of predefined linguistics terms and observes a strict syntax. The syntax is in the form of: IF antecedent_l And antecedent_2 And THEN consequent_l And concequent_2 Where each antecedent is in the form of: Crisp Input Variable is Label For example, Temperature is Hot. Here Temperature is the name of the crisp input and Label is Hot, which is one of a few labels that describe the input membership function of Temperature. The consequent takes a similar form: Crisp Output Variable is Label 19 For example, Cooling Time is Long. Here Cooling Time is the name of the crisp output and Long is one Of many Labels that describe the output membership function Of , Cooling Time. The term “And” is fuzzy Operator that will be applied to get the minimum value from all the antecedents. Actually, fuzzy rules presented originally allow other fuzzy Operators such as fuzzy OR and NOT as we mentioned in previous chapter. However, when rules are implemented, normalized rule representation is used. For rules like “IF A OR B THEN C” will be rewritten as “IF A THEN C” and “IF B THEN C”. For rule like “IF NOT A THEN B” we still take this rule as it is in the form of “IF C THEN B”. But we know if the truth value of A is 0.7, then the truth value of C which is NOT A is 0.3. Some of rules doesn’t depend on any input variables, such as “Cooling Time is Long”. This type of rule is called assertion. This kind of rules is not very common in the control tasks, but sometimes it happens. It has the same properties when we calculate the truth- value of rules. Knowledge base is a rule block, which includes all the assertions and normalized rules. One advantage of fuzzy logic knowledge base is that it is all made up of linguistics terms like natural language. So the expert doesn’t have to know anything about computers to write the rules. And when the programmer tries to implement the knowledge base, he doesn’t have to have any prior knowledge of the expert system to implement the rule base in the way the expert wants as long as rules are written in the required format. During the rule evaluation, fuzzy inputs of each label, which are gotten from fuzzification will be plugged into corresponding rules that have the same crisp input 20 variable and labels. Then the truth-value of each individual rule will be calculated using the Min-Max technique. The truth-value of each rule will be used to determine the truth- value of the “THEN” part consequent. The truth-value of each consequent is called fuzzy output. In the Min-Max technique, the minimum truth-value Of all the antecedents of each rule will be written down as the truth-value of the current rule. Then afier all the rules have their truth-values, we find the truth-values of all consequent in every rule and for each consequent the fuzzy output is the maximum value of the truth-values of this consequent in all rules. For instance, if we got the fuzzy inputs of each labels {Hot, Medium, Cold} describing the crisp input variable Temperature are {0.8, 0.2, 0} and the fuzzy inputs of labels {Wet, Medium, Dry} that describe crisp input variable Humidity are {0.6, 0.4, 0.}. And the rule block has four rules (for the sake of simplicity, we also denote Truth (#) as the truth value of rule ii): 1. IF Temperature is Hot (0.8) and Humidity is Wet (0.6) THEN Cooling Time is Long. Truth (1) = min (0.8,0.6) = 0.6 2. IF Temperature is Medium (0.2) and Humidity is Dry (0.0) THEN Cooling Time is Short. Truth (2) = min (0.2,0.0) = 0.0 3. IF Temperature is Cold (0.0) and Humidity is Medium (0.4) THEN Cooling Time is Short. Truth (3) = min (0.0,0.4) = 0.0 4. IF Temperature is Medium (0.2) and Humidity is Medium (0.4) THEN Cooling Time is Long. Truth (4) = min (0.2,0.4) = 0.2 21 SO the fuzzy output for label “Long” that describes crisp output “Cooling Time” is max (0.2,0.6) = 0.6, and the fuzzy output for label “Short” that describes crisp output “ Cooling Time” is max (0.0,0.0) = 0.0. So given the membership functions assigning to each crisp variables and the current rules, the rules inference generates the fuzzy outputs {0.6,0.4,0.0} for labels {Long, Medium, Short} describing crisp output “Cooling Time”. It is pretty clear that a control action will be taken for a time length somewhere between “Long” and “Medium” as we defined. But we only have a general idea of what the time length should be. In order to get the exact value that computer or micro-controller can understand we need to defuzzify the fuzzy outputs and find the crisp value Of the output variable. In real world task, rules can have different weight. SO some rules may have higher priority than others, some rules may never fire. 3.2.3 Defuzzification The conversion from linguistics fuzzy output to a real non-fuzzy value is called defuzzification. The output membership function uses exact the same types of membership functions as input membership function does. In practice, Singleton membership functions are also used for output membership function for simplicity. There are different defuzzification methods given the meaning of the linguistics terms. In general, there are two big categories as being called by C. V. Altrock: Best Compromise and Most Plausible Result [10]. 0 Best Compromise: 22 In the previous example, fuzzy output is {O.6,0.4,0.0}. Let’s assume that the typical values Of each labels for output Cooling Time are: Long 30 minutes Medium 15 minutes Short 0 min Then for the best compromise result, as indicated in Figure 3.5, we calculate the expectation of Cooling Time: 30 x 0.6 + 15 x 0.4 = 24 minutes Defuzzification methods that are used for best compromise include: 0 15 24 30 Figure 3.5: Illustration Of Best Compromise Center Of Area (COA) / Center Of Gravity (COG): This method first truncates the values of each label, which are above the fuzzy output of that label and then try to find the balance point of the membership functions or so called center of area / center of gravity. This balance point indicates the best compromise (see Figure 3.6). COA/COG works fine with those whose membership functions have identical shape. If two membership functions have different shapes (the areas of membership function are 23 different), then the one that has bigger area will have a greater impact on the output than the one that has smaller area when both have the same degree of validity. But, as we know, having larger area simply means there are more values fit in the category described by the label than the one with smaller area. A short medium long 0.6 0.4 Figure 3.6: COA Defuzzification Another disadvantage Of COA/COG method is its large amount of computation involved during the process. This is mainly because the effort spent on calculating integration of the truncated membership functions. For this reason. some fuzzy logic processors use what so called fast COA. We can have a pretty good estimation of the result by taking a few sample points over the membership function and superimpose these samples. Since the overlapped areas of membership functions are neglected during the calculation, this approach can only be seen as an approximation of COA. Center of Maximum (COM: 24 This is an even simpler version of COA. The example given at the beginning of this section uses this method. This approach only takes the typical value of each membership function rather than calculates the area under each membership function. Notice that if the output membership function is singleton, then COA/COG is the same as COM. COM is a very popular solution in real world engineering due to its high computation efficiency. 0 Most plausible result Sometimes best compromise doesn’t apply to some problems. For instance, a robot is controlled by an embedded micro-controller. The output labels are {steer left 30°, stay straight, steer right 30°}, and the fuzzy output are {0.5, 0, 0.5} indicating there is an obstacle right in front of the robot. Under this circumstance, the robot should turn to either left or right, both will be fine. However, if we are using the best compromise method, we will get the steering angle 0, as shown in Figure 3.7. This is Obviously wrong. 0.5 0.5 -15 15 Figure 3.7: Illustration of Most Plausible The approach solving this Situation is called Mean of Maximum. Instead of finding the balance point, MOM finds the most valid term and takes the typical value of that term as the result. 25 A very important property of defuzzification is continuity. If small change of input doesn’t cause a sudden change on any variables at the output end, then we will say the defuzzification method used is continuous. In a closed-loop control process, the last thing we want to happen is the output jump abruptly responding to small changes of inputs. This will cause the output oscillation and therefore system instability. The COA/COG and COM are continuous methods because the result gotten from these methods are the compromise of all the possibilities, therefore abrupt jump can never happen. The MOM, however, can sometimes come up solutions that are completely Opposite. SO in the real world, an integrator will be connected to the fuzzy controller to keep the output continuous. The “best compromise” methods are used mostly in quantitative problems such as control, whereas the most plausible methods are used mainly in decision support. A comparison between all the methods mentioned above is listed in Table 3.1 below. COA, COG FAST COA COM MOM Categories Best Best Best Most Plausible Compromise Compromise Compromise Result Membership NO good for MF No good for Good Good Function shape with different MF with shape different shape Computation Very low OK High Very High efficiency Continuity Yes Yes Yes NO Applications Quantitative Quantitative Quantitative Decision making Table 3.1: Comparison of Defuzzification Algorithms [10] 26 3.1 Issues of Stability and Verification The issue of stability has been argued since the fuzzy logic concepts are proposed [1 1]. Whether or not fuzzy logic is a viable way to enhance the performance achieved by conventional approach has been challenged by lots of critics. The focus is on whether there is a mathematics proof of the stability. It is known that the stability theory of the conventional control completely suffices the fuzzy systems [10]. Fuzzy systems that have the properties of deterministic, time invariant and nonlinear are classified in control theory as nonlinear multi-band controller. Therefore, all the stability analysis that applicable to the conventional nonlinear multi-variant controllers are applicable to the fuzzy controller. But since most fuzzy systems have very complex nonlinear characters, it is almost impossible to find a stability proof. Normally, a conventional approach that has the same complexity is also impossible to get a stability proof. 27 Chapter 4 DEMONSTRATION AND ANALYSIS 4.1 Introduction In this chapter, an application of using fuzzy logic to improve the performance and the energy consumption of a home refrigerator will be demonstrated. Problems will be stated and a solution using fuzzy logic algorithm will be suggested and designed. The use of fuzzyTech [12] software will be demonstrated and analysis and recommendations will be given. Home appliances have been a very important part of people’s life today. People are dealing with them in their everyday life. Companies have tried their best to bring the most easily to use but least energy-consumed appliance to the market to attract the customers. Thanks to today’s technology, they can offer a lot more dreams features to the 28 customers than they could five years ago [13]. However, home appliances are not industry machines. Their costs have to be as attractive as their performance and they have to have a high-level friendly user interface to satisfy the “non-technical” users. Fuzzy logic is an innovation technology that allows implementing complex and intelligence functions into embedded system. It has the advantages of implement non-linear and adaptive control using limited system resource such as an 8-bit micro-controller. In this demonstration, we will first examine a typical home appliance --- refrigerator from the point of view of energy saving and user interface. 4.2 A Brief Review of the Structure of Refrigerator [14] A refrigeration system, as shown in Figure 4.1, consists of a compressor, condenser, dryer, capillary tube, evaporator and refrigerant. The compressor pumps evaporated Freon gas from the evaporator coil and then compress it. When the Freon returns to a liquid state, it gains heat. The heat is then released outside the cabinet. Afier passing the condenser, the refi'igerant enters the capillary tube. This is a small metering device that only allows an exact amount of liquid refi‘igerant to flow through before entering the large tubing of the evaporator. AS the refrigerant leaves the small capillary tube, the sudden increase in tube Size of the evaporator causes a drop in pressure that allows the fluid to evaporate and cool down. Now it gains heat and ready to be cycled again. See Figure 4.2 for the heat transfer illustration of refrigerator. As the cycle continues, everything inside the food compartment would eventually freeze. TO control the temperature, a thermostat is used to monitor temperature at the evaporator and control the power to the compressor. AS the temperature inside the 29 refrigerator rises, the thermostat turns on the compressor. The thermostat can be adjusted to control the desired refrigerator temperature by a knob as the one we see in most of the refrigerator. EVAPORATOR FAN ‘5"‘\'A:Ih_‘|.l Jane’s-163 5- Figure 4.1: Basic Structure of a Refrigerator [14] During this process, the refrigerator not only picks up heat from food, but also gets moisture from warm air caused by door opening. The moisture then forms the frost on the evaporator. As frost accumulates to a certain point, it reduces the evaporator's 30 effectiveness. In order to keep the system operating properly, the refrigerator needs periodic defrosting. HEAT TRANSFER IN A REFRIGEMTOR Figure 4.2: Heat Transfer Illustration of Refrigerator [[4] There are three types of defrosting systems in use today--manual, cycle and automatic (no frost). In the manual system, freezer defrosts by turning off the power and let the ice melt. In the cycle system, an electric heater is activated when the compressor is off to melt ice if there is any (freezer section still has to be done manually if there is a heavy buildup of ice). An automatic defrost system consists of a low watt heater, a thermostat to turn on and off the heater, and a timer to control the defrost cycle. As frost 31 accumulates, the timer starts the defrost cycle. Then, the compressor will be turned Off and the heater will be turned on. After the frost cycle is finished, the thermostat turns Off the heater and the timer allows the water to drain to a defrosting pan before starting the compressor. 4.3 Problems with Refrigerator In today’s home appliance industry, one most important issue is energy saving [15,16]. The refrigerator is the most common home appliance and is one of the biggest users of electricity in most homes. Depending on its age and size, the refrigerator can account for as much as one third of a non-electrically heated home’s electricity usage. They account for nearly 20 percent of residential electricity [15]. The energy saving goal is not to cut the power consumption to zero, but to eliminate all the possibilities of energy wasting. A tremendous extra power will be needed when the frost starts to accumulate in the freezer. The frost accumulation reduces the evaporator’s effectiveness, and the refrigerator gets warm. As mentioned above, we have three types of defrost system. The first two types of system are no way user-friendly and therefore are out of consideration. The automatic system is the most popular one in the market because of its user-friendly interface and the no-frost result. But after taking a closer look at its defrost control mechanism we found most of the unnecessary energy waste are coming from the defrost system. In spring 1998, a characterization test of a home refiigerator was conducted by one of the Design Teams of the computer system design course in the Department of 32 Electrical and Computer Engineering, Michigan State University. The result [17] has shown that there will be a huge temperature jump whenever the defrosting cycle kicks in. when the defrosting cycle starts, the compressor was turned off and the heater was turned on. The refrigerator with automatic defrost system defrost twice a day with each cycle lasts around one hour. Defrost cycle starts kicking in everyday at a fixed schedule. This is mainly due to the fact that the designer Of the defrosting system can not predict the time of the accumulation of frost. SO no matter if there is frost, the compressor will be turned off and the heater will be on when defrost cycle starts to guarantee a no-frost. During the defi'ost cycle, the temperature in the freeze will go up to 15°C from -1 8°C for about one hour. This unwanted temperature rise is no good to the food. And since when the defrost cycle is off, the compressor has to use extra power to cool the temperature down to its normal, energy waste will occur. In another word, if the customer just went grocery shopping not long before the defrosting cycle starts, then the refrigerator will get warmed up for an hour when it most needs at the moment is cooing down. Moreover, in the case that the door of the refrigerator has been keeping closed for a long time such as when the customer is away on vacation, refrigerator will still defrost twice a day even there is little frost. Another common energy waste comes from the customers themselves. For most refrigerators, there is a knob for temperature control. However, a lot of customers don’t know what the right temperature range the refrigerator should stay in to keep the food fresh and to have less energy wastes. Sometimes, when there is a big load increase, i.e. after grocery shopping, people tend to turn down the temperature setting to get a large cooling effect. Because of this and lacking of the knowledge on what is the right 33 temperature, people tend to turn the temperature lower than necessary, and most of the time they forget to turn it back up when the right temperature is reached and the food is over cooled. Before the temperature setting is corrected, the extra energy used for the unnecessary cooling is wasted. 4.4 Solutions to the Problems The solution for the defrosting system to avoid unnecessary energy consumption is adaptive defrost control [16], which removes the frost only when it is necessary. We have noticed that two main factors that can cause the curnulating of frost are humidity and temperature. Temperature changes in the freezer is largely caused by the frequency of door openings and the length that the door is Opened (It is shown by surveys that the normal door open time is 30 to 90 seconds). SO we can say the defrost cycle is a fimction Of the humidity and the door Open time. And it is not linear. In a traditional non-linear implementation, either a complete but complicated mathematical model has to be generated or a look up table has to be provided. As the precision requirement increases, both methods become unrealistic for a real time control using low cost micro-controllers. So a two inputs fuzzy controller will be designed to overcome these difficulties. The fully documented fuzzy defrosting controller design is provided in Appendix A. As for solving the temperature setting problem, we first look at the mechanism Of the compressor. Since the control Of compressor is hysteresis control, which set the upper and lower limits for the temperature. The compressor is on only when the upper limit is exceeded and is turned Off when the lower limit is hit. Big hysteresis setting delayed the 34 compressor’s switching activities while narrow hysteresis setting increases the frequency of the switching activities. When the compressor switches too frequent, a lot of energy will be used. However, when there is a time we need to start the cooling right away or we have some food that have to stay in a strict temperature range to stay fresh, we have to change the hysteresis setting lower. As mentioned in the previous chapter, fuzzy logic has its advantage of reconciling conflicting requirements. The design idea of this fuzzy controller to improve the temperature setting performance is presented below. Its hardware and software implementation need further work and will be recommended in Chapter 6. F eedBack Temperature + —1 SetTemperaturel ' E) I ll— Compresso? Fuzzy controller Humidity ,, ’- Defrost Period Door Open Time Figure 4.3: Block Diagram Of Fuzzy Controller for a Refrigerator The Temperature Setting fuzzy controller is to have three inputs: difference between the set temperature and the temperature in the refrigerator (or so-called feedback error), changes of the set temperature, and the set temperature that is differentiated by time. The output of the fuzzy controller goes to control the hysteresis and the compressor. When the feedback error is big, fuzzy controller will send signal to the compressor so that the desired temperature will be reached faster, and at the same time set the hysteresis big, so disturbances will not cause unnecessary on-Off switches during this time. The time 35 differentiated set temperature is used by the fuzzy controller to remember for the user to turn the temperature back up when the desired temperature is reached. This input will be zero after a given time if the user doesn’t modify the set temperature any more. The number Of changes of the set temperature is used to understand if the user want to set the temperature specifically in a certain range. If the user wants to set the temperature precise, he tends to adjust the setting more than once. When this happens, the hysteresis will be set relatively small so the activities of the compressor will be more sensitive to the temperature changes. The completed design block diagram of the refrigerator fuzzy controller is given in Figure 4.3. 4.5 Software and Hardware Development Tool 4.5.1 Hardware platform The target platform for developing fuzzy logic ranges from normal low cost 8 bit micro-controllers with limited on board RAM and ROM to 64-bit RISC processors. The development of fuzzy logic processor has experienced three phases: 0 Analog Fuzzy Processor The analog fuzzy processor is made up by fuzzy logic gate. A voltage signal ranging from +5V to -5V serves as the membership degree from 0 to 1. This type of processor has never made its way out of the lab, mostly due to its inflexibility in implementation. Any changes of the rules or membership functions require the re-design of the hardware. 0 Digital Fuzzy Processor 36 A digital fuzzy processor is a conventional digital processor a fuzzy instruction set. This type of process can only support fuzzy computation. Two processors were used. One host micro-controller that handles all the peripherals and I/O, and pre-computation, while the fuzzy processor working on the fuzzication, rule evaluation and defuzzification. Both processors are connected either by a series communication port or a dual ported RAM. The host micro-controller will get the crisp input and send to the fuzzy processor. After the fuzzy processor finish computing, it will send the result back. Because Of the overhead of communication, the speed advantage of fuzzy processor is compromised. And Since this digital fuzzy processor usually uses up to three chips (if includes and dual ported RAM), the cost is very expensive. In addition, programming for the communications needs extra efforts and extra interrupts in order to synchronize both processors. 0 Integrated fuzzy logic processor In this phase, manufacturers made it possible to integrate both processors within one Chip. This effort reduces the communication overhead remarkably. There are two approaches: An earlier approach treated the fuzzy logic processor just as another cell or memory. This approach requires an additional silicon area and a full functionality of ALU (Arithmetic Logic Unit). The latest approach is to enhance the instruction set of the conventional micro-controller. It keeps the micro-controller’s own ALU and adds some additional functions to it. This approach reduces a great deal of areas that the earlier approach requires and the code of the micro-controller is much more compact since all the existing instructions and registers can be used by the fuzzy processing too. This fuzzy 37 processor can be also used as a general—purpose micro-controller. Some manufacturers even add hardware supports to the fuzzification, rule evaluation and defuzzification to Speed up the computation even more. Since no re-design is needed for the micro- controller, this integrated fuzzy processor has great potentiality. Manufacturer such as Motorola has already put its new series micro-controller (i.e. MC68HC12) with fuzzy logic module to the market [18, 19, 20]. 4.5.2 Software development Good design software should Offer good combinations of design, simulation, optimization, testing, verification and implementation. There are mainly three types of software development methods. The first one is just using any program language and codes the whole fuzzy system. The second one is to use a pre-compiler to translate the text version of the Fuzzy Logic Description Language or FTL (Fuzzy Technology Language) into a programming language, i.e. ANSI C. The first one usually need re- program a large portion when changes of the fuzzy system are made while the second one is hard to debug due to the text representation. The third and the most popular one is called virtual design interface. The whole design is a matter of drag-and-point graphic implementation. The FTL or any programming code can be generated for specific hardware platform by the code generator using this kind of virtual design software too. The graphic design software tool I will be introduced is fuzzyTech. The author will demonstrate the fuzzy defrost system using this software. 38 4.6 FuzzyTech Software [12][21] o Linguistic Variables Editor The editor is used to define the linguistic variables and their membership functions. Membership functions are always defined point-wise using definition points that can be easily dragged and positioned by the mouse. There are two alternatives exist to connect the definition points: L-shape and S-shape. For S-shape, the user can specify the asymmetry factor in the range from 0 to 1. For standard membership functions, only the positions of the maximum points are required. The software will automatically generate all the definition points. 0 Interface Options For input interfaces, three algorithms are supported. The first one, Fuzzy Input. Fuzzy input indicates that all the values are inputted into firzzy control system as a vector of the grade of membership belongings. The second one is compute membership function. This is the most popular fuzzification method used in almost all the applications. As mentioned earlier, the method only stores the definition points and slops and computes the fuzzification at run time. For a few micro-controller, the “look up membership function” is also supported. The computation of the fuzzification is completed in the compile time and stores in a table in the code. This method causes big code size, but is faster overall if the computation for the fuzzification is too complex to do during run time. 39 For output interface, different defuzzification methods exist too. “Fuzzy Output” outputs a vector of the membership degree of the results of inference. Then there are COM, COA, and MOM. For more details, refer to chapter 3. Among those, COM is the most Often used algorithm. There is also one method called BSUM, which represents Bounded Sum. This method uses the bounded sum rather than the maximum operator to aggregate the individual areas. SO no overlap area will be computed more than once. 0 Rule Editor Two alternatives of generating rules exist. One is called the spreadsheet rule editor. IF-THEN rule statements can be generated automatically. Users can configure the rule block the way they want it to be created. 1. Alpha cut: delete all rules with the weight less than the alpha value inputted by user. 2. Set DOS: sets the weights of rules to a fixed value 3. Create full rule block: creates rules for each combination of terms. For each possible combination of input variables, a rule for each output variable is generated. 4. Created partial rule block: creates rules for each combination of terms. However, it is different from the “created full rule block” in that the user has to specify the output. The rule that is not specified with output will be considered incomplete and will be erased when the editor is closed. The other rule editor is called matrix rule editor. This editor is preferred when designing a complex system. The variable terms will be put into a matrix with the degree of membership belongings indicated by the shade of gray. Non-firing rules will be identical to the zero-weighted rules. 40 Chapter 5 ANALYSIS AND RECOMMENDATIONS 5.1 Introduction In this chapter, the use of interactive debug of fuzzyTech to analyze the defrosting fuzzy control design will be introduced. The result will be demonstrated and analyzed. Further hardware implementation and software tuning will be recommended. 5.2 Interactive Analysis In fuzzyTech, after the initial design of a fuzzy controller is done, we can debug and test the design using fuzzyTech’s interactive debug tool. Interactive debug mode can be turned on by going to the menu Debug-> Interactive. In the debug mode, any input can be selected and its value can be changed within its universe discourse. This debugger can 41 be used as a real time data feeder. Designers can then Observe the output value and evaluate the result. There are also three analyzers that can be turned on when the system is in debug mode. 0 Transfer Plot The transfer plot (Figure 5.1) will let users analyze input /Output characteristics. When the analyzer is Open, two inputs and one output can be selected and resolution can be set over there too. Two input variables are plotted in the horizontal and vertical axes while the value of the selected output variable is indicated as plot color. The color bar on the lower part of the window shows the color-value relation. 0 3D Plot 3D Plot (Figure 5.3) shows the input/output characteristics Of the fuzzy system. It allows a plane that is drawn in the control space. Two inputs will be drawn in the horizontal and vertical axis while the value of the output will be indicated as the plot color in the control space. 0 Time Plot Time Plot (Figure 5.2) lets the user to see the time response characteristics of the fiizzy system. User can add as many inputs or outputs as they want and feed the simulated system real time data using the interactive debugger, a time response series will be plotted in the Time Plot. 42 5.3 Defrost Fuzzy Controller Result and Analysis The Defrost fuzzy controller will take two inputs from humidity sensor and door open detecting sensor. When door Opening is detected, a timer will start timing the length of the door Opening. If the length of time is not long enough to start a defrost cycle, then the time will be accumulated until the defrost cycle kicks in. Then the timer will be reset to zero. Since the fuzzy defrost system only defrosts when necessary, the length of the defiosting cycle is reduced. This helps to solve the problem the automatic defrost system has. The automatic defrost system has a fixed length of defrosting cyclel hour) no matter how much frost is. Testing is done using fuzzyTech’s interactive analyzers. First from the 3D transfer Space (Figure 5.3), we can see the fuzzy controller has a wider control zone with emphasis on some regions. This is largely due to the non-linearity of the door open activity and different humidity situations. With more information being considered, a wiser decision could be made by using fuzzy controller. In the plot the deep color and Shallow color represent extreme situations and these two regions do not account for the main part of the control space. There are more areas representing the situation between the two extreme points, which is reasonable, and therefore the consequent output action will be necessary and waste no extra energy. Moreover, the output will correspond differently to different input values. For each one of the infinite inputs on the universe discourse, the output will have one and only one unique value for it. This is the biggest achievement over using conventional controller or look-up table. It is almost impossible for the conventional design to take all situations into consideration while still using the 43 low cost micro-controllers. The code size of the defrosting fuzzy controller is only less than 6K. In the time plot, real time data were fed through the interactive debugger. The time plot is shown in Figure 5.2. The data fed are randomly picked within the universe discourse of one input with the other unchanged. Output is Observed and plotted with both inputs in the same plot. We noticed that the output -- length of defrost cycle acts to the Opposite of the trend Of humidity and accumulated door open time. AS humidity increases the period between two consecutive defrost cycles is shortened, when the humidity decrease then the defrosting cycle is prolonged. When there are frequent door opening activities, defrosting cycle is shorter than normal. And the defrosting cycle is prolonged if there are fewer doors Opening activity. All these agree our intuitive. The concept and structure Of the designed controller has shown its superior to the original automatic defrost system. This adaptive defrost fuzzy controller has its flexibility in dealing with the entire situation the refrigerator might have and not adding tOO much overhead. And due to the prompt response of the controller to different situations, no pre- fixed schedule and extra defrosting length are needed. Therefore, energy is saved. However, the result is far from optimal. This is partially due to the facts that for each different individual refrigerator, the temperature characteristic is different. Further membership and rule tuning are required for each individual type of refrigerator. A thorough characterization of the refrigerator’s temperature behavior will be needed. According to the results of characterization, the universe discourse, label scope and the shape of the membership might have to be modified base on the new information. Q ~_.n__.3 c I Figure 5.1: Transfer Plot Of Fuzzy Defrosting Controller Period Blot Items: [I elm {l Period DoorO pen__T ime Humidity Figure 5.2: Time Response of Fuzzy Defi'osting Controller 45 [leliclthF'e new ii 1 , ; murmur. ‘ “11““ i it ’t 'I “it.!|.‘.,|.1.l‘... \ I “‘6 \\ it“ \ Seek“ ‘O \\ \ \“ \“ ”s ‘9‘ ‘ \t“ \‘ ‘C 0““ \ \b \“ \\ . \\\\\\§ - \\ 0‘ ‘0‘“ . I ‘ \“\\‘ SN“ \\ \\ 1 \\§\\\\ \ l\ . l l 1.75 l 2.63 .194: 7 7.88 8.75 9.83 10.50 11.38 1225 13.13 14 0 0.88 5.4 Conclusions over several chapters. The work in this thesis serves to help understand the practical use of fuzzy logic in embedded system design. These topics included defining the structure of the fuzzy controller, choosing of the fuzzification, rule evaluation and defuzzification The fuzzy logic concepts and design methodologies were presented in this thesis Figure 5.3: 3D Plot of Fuzzy Defrosting Controller algorithms, and designing hardware/software and analysis. From the analysis, the advantage of fuzzy logic design is evident. As it is shown in Figure 5.3, fuzzy controller deals with more situations with less system resources. The 46 whole code for programming the fuzzy controller is less than 6K, which is small enough to be Stored in the 32K on-board memory Of some embedded system controller, i.e., handyboard. Since for each combination Of the inputs there is an unique output that can be easily found through the membership function, real time processing — the bottleneck in conventional controller for computing a complicated model — will never going to be a problem. The quickness and easiness to get an output for a fuzzy controller is almost like a lookup table. But a lookup table can never hold a large amount of data without requiring more memory, and be able to store infinite combinations of input states. Moreover, fuzzy controller is better Off solving ill-defmed, non-linear problems and helps to solve problems with conflicting goals. In this fuzzy defrosting controller case, the two conflicting goals energy efficiency and no frost results are well resolved by adopting the adaptive defrost mechanism. Combining the simple but optimal mathematical model — i.e., membership function — and heuristic estimations - i.e., the average door Open time is 30 to 90 seconds, no prefixed defrost schedule is needed. Thereafter, the length of each defrost cycle will be greatly shortened. The energy save from the improved fuzzy defrost system is expected to be 50% while the no frost result can still be guaranteed. At last, since fuzzy logic controllers rely on the values within the universe discourse and label scope to represent the numerical characteristic of the problem, membership function and rule tuning are required for the same system working in different environments. However, this very reason makes the fuzzy logic design methodology very attractive and provides designers with a flexible but powerful design tool which is easier to be implemented and optimized. 47 Chapter 6 RECOMMENDATIONS FOR FUTURE WORK The demonstration of using fuzzyTech software to design the defrost system were provided in the previous chapter and a recommended fidzzy controller for setting temperature for energy saving and user- friendly interface was proposed. The next step would be to implement the defrost controller onto the refrigerator, modify and tune the membership function and rule base of the fuzzy controller based on the characterization of the refrigerator. In addition to this, a software implementation for the fuzzy controller that automatically set the temperature is recommended. This would provide the opportunity to further explore the concepts and methodologies of fuzzy design and the necessary experience to develop the fuzzy controller. 48 Appendix A DESIGN OF FUZZY DEFROSTING SYSTEM A.1 Introduction This is the fully documented design of adaptive defrosting system using fuzzy logic. In this part, the general information of the design, the fuzzy defrosting system structure and the definition of the linguistic variables for the fuzzy defrosting controller are described. Details on input/output interface, definition Of rule block, and the methods that are used for fuzzy logic computations are presented. A.2 General Information Author: Weijjiang Robert Yu Created: 1 1/1 7/98 Print Date: 5/22/99 Edition Edition Name: fuzzyTECH 5.01 MCU-HC11/12 Explorer Neuro Modul: NeuroFuzzy add-on Module not installed A.3 Project Description First Edition. Variables V les V ' les e Blocks es F unctions TableA-l: Project Statistics 49 A.4 System Structure The system structure, as shown in Figure A-l, identifies the fuzzy logic inference flow from the input variables to the output variables. The fuzzification in the input interfaces translates analog inputs into fuzzy values. The fuzzy inference takes place in rule blocks that contain the linguistic control rules. The outputs of these rule blocks are linguistic variables. The defuzzification in the output interfaces translates them into analog variables. Defrost System Pt er DoorOpen_Ti MIN Baggifin-T' Defrost_Perio——IDelrosl_Perio m m— E.Ti.-i’_ Humidity Figure A-l: Structure of the Fuzzy Logic Defrosting System Figure A-l shows the whole structure of this fuzzy system including input interfaces, rule blocks and output interfaces. The connecting lines symbolize the data flow. A.5 Linguistic Variables 50 This appendix contains the definition of all linguistic variables and of all membership functions. Linguistic variables are used to translate real values into linguistic values. The possible values Of a linguistic variable are not numbers but so called 'linguistic terms'. For example: To translate the real variable 'Temperature' into a linguistic variable three terms, 'COld', ‘Pleasant' and 'Warm' are defined. Depending on the current temperature level each of these terms describes the 'temperature’ more or less well. Each term is defined by a membership function (MBF). Each membership function defines for any value of the input variable the associated degree of membership of the linguistic term. The membership functions of all terms of one linguistic variable are normally displayed in one graph. The following figure (Figure A-2) plots the membership functions of the three terms for the example 'Temperature'. A 'Temperature' of 66 °F is a member of the MBFs for the terms: Cold to the degree of 0.8 Pleasant to the degree of 0.2 Warm to the degree of 0.0 000 65.0 700 750 00.0 ' Farrenhel Figure A-2: Membership Function of 'Temperature' 51 Linguistic variables have to be defined for all input, output and intermediate variables. The membership functions are defined using a few definition points only. The following table (Table A-2) lists all linguistic variables of the system, their types and their term names. ariable Name erm Names Time Short, Short, Normal, Long, Extreme Long , Normal, Wet N Table A-2: Linguistic Variables The properties of all input variables are listed in Table A—3. [Eput Variable 'Min 'Max ase Var. Unit lFuzzification [DoorOpen_Time 0 900 Second Compute MBF [Humidity 0 1 Percent Compute MBF Table A-3: Properties of Linguistic Input Variables The properties Of all output variables are listed in the following table (Table A-4). The default value of a variable is used if no rule is firing for this variable. Different methods can be used for the defuzzification, resulting either into the Most Plausible Result or the Best Compromise. The Best Compromise is produced by the methods: 0 COM (Center of Maximum) 0 COA (Center of Area) 0 COA BSUM, a version especially for efficient VLSI implementations 52 The Most Plausible Result is produced by the methods: - MOM (Mean of Maximum) MOM BSUM, a version especially for efficient VLSI implementations [Output Variable lMin [Default ax lBase Var. Unit efuzzification Eefrost_Period 0 - 14 Days OM Table A-4: Properties of Linguistic Output Variables A.5.1 Output variable "Defrost_Period" 0.0 . _ . . .. . , W . ._ ._ .. K 00 . . 4.0 (7.0 . , 1110 14.0 Figure A-3: Membership Function of "Defrost_Period" The output membership fimction is defined as Shown in Figure A-3. erm Name . Points (x, ) 0, 0) (1, 1) 14,0) 0,0) (1,0) ( .1) 10,0) (14,0) 0.0) ( ,0) (1 1) 14,0) Table A-S: Definition Points of Membership Function for "Defrost_Period" 53 A.5.2 Input variable "DoorOpen_Time" Eritrernefihort Short Normal Long Extreme_Long 1‘0? /\ ~ ’/’\‘-. '- 08 ~ ‘ 0.8 04 0.2‘ ,1 0.0 , 3 ~ , 0.0 250.0 450.0 6500 9001: Figure A-4: Membership Function of "DoorOpen_Time" [Term Name Shape/Par. [Definition Points (x, y) I‘Extreme_Shorlinear (0, l) (200, 0) (900, 0) hort linear (0, 0) (200, 1) (400, 0) (900, 0) ormal linear (0, 0) (200, O) (400, l) (600, O) (900, 0) ong linear (0, 0) (400, O) (600, l) (900, 0) Extreme_Lon linear (0, 0) (600, 0) (900, l) Table A-6: Definition Points of Membership Functions for "DoorOpen_Time" Overall time of open door between two consective defrost cycle is defined in Table A-6 and the membership function is shown in Figure A-4. A.5.3 Input variable "Humidity" 54 Figure A-5: Membership Function of "Humidity" [Term Name Shape/Par. [Definition Points (x, y) lDry linear (0, 1) (0.15, l) (0.5, 0) (1, 0) [Normal linear (0, 0) (0.15, 0) (0.5, 1) (0.845, 0) (1, 0) lWet linear (0, 0) (0.5, 0) (0.845, 1) (1, 1) Table A-7: Definition Points of Membership Functions for "Humidity" The membership function of “Humidity” is shown in Figure A-5 and defined as indicated in Table A-7. A.6 Interfaces [Input Variable lIo-Mapping uzzification [DoorOpen_Time Compute MBF [Humidity Compute MBF Table A-8: Input Interfaces [Output Variable o-Mapping 7Defuzzification Eefrost_Period COM Table A-9: Output Interfaces 55 The methods that will be used for firzzy logic computations for fuzzification and defuzzification are shown in Table A-8 and Table A-9. A.7 Rule Blocks The rule blocks contain the control strategy Of a fuzzy logic system. Each rule block confines all rules for the same context. A context is defined by the same input and output variables Of the rules. The rules' 'if part describes the situation, for which the rules are designed. The 'then’ part describes the response of the fuzzy system in this situation. The degree of support (DOS) is used to weigh each rule according to its importance. The processing of the rules starts with calculating the 'it‘ part. The operator type of the rule block determines which method is used. The Operator types MIN-MAX, MIN- AVG and GAMMA are available. The characteristic of each operator type is influenced by an additional parameter. For example: MIN-MAX, parameter value 0 = Minimum Operator (MIN) MIN -MAX, parameter value 1 = Maximum Operator (MAX) GAMMA, parameter value 0 = Product Operator (PROD) The minimum Operator is a generalization of the Boolean 'and'; the maximum operator is a generalization of the Boolean 'or'. The fuzzy composition eventually combines the different rules to one conclusion. If the BSUM method is used all firing rules are evaluated, if the MAX method is used only the dominant rules are evaluated. 56 A.7.1 Rule block "RBI" Parameter Aggregation: MINMAX Parameter: 0.00 Result Aggregation: MAX Number of Inputs: 2 Number of Outputs: 1 Number of Rules: 15 Table A-10 defines all the rules for fuzzy defrosting controller. IF Time Short .00 .56 .20 .81 .59 .48 .90 .82 .75 .17 . 1 .52 et .30 Table A-10: Rules of Rule Block "RBI" 57 Appendix B FUZZY TECHNOLOGY LANGUAGE FOR FUZZY DEF ROSTING SYSTEM B.1 Introduction Appendix B is the design of the fuzzy defrosting system written in text format. As we mentioned earlier, this is also a kind of software code that can be used to implement the fuzzy controller. The difference between this fuzzy technology language and the other popular programming languages is that the fuzzy technology language has to be precompiled using either compilers for C or for assembly language to generate real C codes or assembly codes before use. B.2 Fuzzy Technology Language for Fuzzy Defrosting System PROJECT { NAME = DEFROST_SYSTEM.FTL; TITLE =DEFROST_SYSTEM; AUTHOR = Weijjiang Robert Yu; DATEFORMAT = M.D.YY; LASTCHANGE = 11.18.98; CREATED = 11.17.98; SHELL = EXPL12; COMMENT { First Edition} /* COMMENT */ SHELLOPTIONS { ONLINE_REFRESHTIME = 55; ONLINE_TIMEOUTCOUNT = 1100; ONLINE_PORT = SERIAL; ONLINE_CODE = OFF; COMMENTS = ON; TRACE_BUFFER = (ON, PAR(100)); 58 FTL_BUFFER = (OFF, PAR(1)); PASSWORD = OFF; PUBLIC_IO = ON; FAST_CMBF = OFF; FAST_COA = OFF; F ILE_CODE = OFF; BTYPE = 8_BIT; } /* SHELLOPTIONS */ MODEL { VARIABLE_SECTION { LVAR { NAME = Defrost_Period; BASEVAR = Days; LVRANGE = MIN(0.000000), MAX( 14.000000), MINDEF(0), MAXDEF(255), DEF AULT_OUTPUT(0.500000); RESOLUTION = XGRID(0.100000), YGRID( 1 .000000), SHOWGRID (ON), SNAPTOGRID(ON); COMMENT { The time between two consecutive defrost cycles} /"‘ COMMENT */ COLOR = RED (0), GREEN (0), BLUE (255); TERM { TERMNAME = Short; POINTS = (0.000000, 0.000000), (1.000000, 1.000000), (5.000000, 0.000000), (14.000000, 0.000000); SHAPE = LINEAR; COLOR = RED (0), GREEN (0), BLUE (255); TERM { TERMNAME = Normal; POINTS = (0.000000, 0.000000), (1.000000, 0.000000), (5.000000, 1.000000), (10.000000, 0.000000), (14.000000, 0.000000); SHAPE = LINEAR; COLOR = RED (128), GREEN (0), BLUE (0); TERM { TERMNAME = Long; POINTS = (0.000000, 0.000000), (5.000000, 0.000000), (10.000000, 1.000000), (14.000000, 0.000000); 59 SHAPE = LINEAR; COLOR = RED (0), GREEN (128), BLUE (128); }/*LVAR*/ LVAR { COMMENT { NAME = DoorOpen_Time; BASEVAR = Second; LVRANGE = MIN(0.000000), MAX(900.000000), MINDEF(0), MAXDEF(255), DEF AULT_OUTPUT(0.500000); RESOLUTION = XGRID(5.000000), YGRID(1.000000), SHOWGRID (ON), SNAPTOGRID(ON); Overall time of open door between two consective defrost cycle.) /* COMMENT */ COLOR = RED (0), GREEN (128), BLUE (0); TERM { TERM { TERM { TERM { TERMN AME = Extreme_Short; POINTS = (0.000000, 1.000000), (200.000000, 0.000000), (900.000000, 0.000000); SHAPE = LINEAR; COLOR = RED (255), GREEN (0), BLUE (0); TERMNAME = Short; POINTS = (0.000000, 0.000000), (200000000, 1.000000), (400.000000, 0.000000), (900.000000, 0.000000); SHAPE = LINEAR; COLOR = RED (0), GREEN (128), BLUE (0); TERMNAME = Normal; POINTS = (0.000000, 0.000000), (200.000000, 0.000000), (400.000000, 1.000000), (600.000000, 0.000000), (900.000000, 0.000000); SHAPE = LINEAR; COLOR = RED (0), GREEN (128), BLUE (128); TERMNAME = Long; POINTS = (0.000000, 0.000000), (400000000, 0.000000), 60 TERM { } } /* LVAR */ LVAR{ TERM { TERM { TERM { (600.000000, 1.000000), (900000000, 0.000000); SHAPE = LINEAR; COLOR = RED (128), GREEN (0), BLUE (0); TERMNAME = Extreme_Long; POINTS = (0.000000, 0.000000), (600.000000, 0.000000), (900.000000, 1.000000); SHAPE = LINEAR; COLOR = RED (0), GREEN (128), BLUE (128); NAME = Humidity; BASEVAR = Percent; LVRANGE = MIN (0.000000), MAX( 1 .000000), MINDEF(0), MAXDEF(255), DEFAULT_OUTPUT(0.500000); RESOLUTION = XGRID(0.005000), YGRID(1.000000), SHOWGRID (ON), SNAPTOGRID(ON); COLOR = RED (255), GREEN (0), BLUE (0); TERMNAME = Dry; POINTS = (0.000000, 1.000000), (0.150000, 1.000000), (0.500000, 0.000000), (1.000000, 0.000000); SHAPE = LINEAR; COLOR = RED (255), GREEN (0), BLUE (0); TERMNAME = Normal; POINTS = (0.000000, 0.000000), (0.150000, 0.000000), (0.500000, 1.000000), (0.845000, 0.000000), (1.000000, 0.000000); SHAPE = LINEAR; COLOR = RED (0), GREEN (128), BLUE (0); TERMNAME = Wet; POINTS = (0.000000, 0.000000), (0.500000, 0.000000), 61 (0.845000, 1.000000), (1.000000, 1.000000); SHAPE = LINEAR; COLOR = RED (0), GREEN (0), BLUE (255); I } /* LVAR */ } /* VARIABLE_SECTION */ OBJECT _SECTION { INTERFACE { INPUT = (Humidity, CMBF); POS = -213, -1; } INTERFACE { INPUT = (DoorOpen_Time, CMBF); POS = -219, -146; INTERFACE { OUTPUT = (Defiost_Period, COM); POS = 109, -74; RULEBLOCK { NAME = RBI; INPUT = DoorOpen_Time, Humidity; OUTPUT = Defrost_Period; AGGREGATION = (MIN_MAX, PAR (0000000)); RESULT_AGGR = MAX; POS = -66, -102; RULES { IF DoorOpen_Time = Extreme_Short AND Humidity = Dry THEN Defi'ost_Period = Long WITH 0.000; IF DoorOpen_Time = Extreme_Short AND Humidity = Normal THEN Defrost_Period = Long WITH 0.563; IF DoorOpen_Time = Extreme_Short AND Humidity = Wet THEN Defrost_PeriOd = Normal WITH 0.195; IF DoorOpen_Time = Short AND Humidity = Dry THEN Defrost_Period = Long WITH 0.813; IF DoorOpen_Time = Short AND Humidity = Normal THEN Defrost_Period = Normal WITH 0.586; IF DoorOpen_Time = Short 62 AND Humidity = Wet THEN Defrost_PeriOd = Normal WITH 0.477; IF DoorOpen_Time = Normal AND Humidity = Dry THEN Defrost_PeriOd = Normal WITH 0.352; IF DoorOpen_Time = Normal AND Humidity = Normal THEN Defrost_Period = Normal WITH 0.898; IF DoorOpen_Time = Normal AND Humidity = Wet THEN Defrost_PeriOd = Normal WITH 0.820; IF DoorOpen_Time = Long AND Humidity = Dry THEN Defrost_PeriOd = Normal WITH 0.750; IF DoorOpen_Time = Long AND Humidity = Normal THEN Defrost_Period = Normal WITH 0.172; IF DoorOpen_Time = Long AND Humidity = Wet THEN Defrost_Period = Short WITH 0.859; IF DoorOpen_Time = Extreme_Long AND Humidity = Dry THEN Defrost_PeriOd = Normal WITH 0.711; IF DoorOpen_Time = Extreme_Long AND Humidity = Normal THEN Defrost_PeriOd = Short WITH 0.516; IF DoorOpen_Time = Extreme_Long AND Humidity = Wet THEN Defrost_PeriOd = Short WITH 0.305; } /* RULES */ REMARK { TEXT = Defrost System; POS = -86, -195; FONTSPEC = -32, 700, 0, 0, 0, 18, 0; F ONTNAME =Times New Roman; COLOR = RED (0), GREEN (0), BLUE (128); } } /* OBJECT _SECTION */ } /* MODEL */ } /* PROJECT */ TERMINAL { BAUDRATE = 19200; DATABITS = 8; PARITY = 0; 63 STOPBITS = 1; PROTOCOL = NO; CONNECTION = PORTI; INPUTBUFFER = 256; OUTPUTBUFFER = 256; } /* TERMINAL */ ONLINE { TIMESTAMP = 1998111821523500; } /* ONLINE */ Appendix C ASSEIVIBLY CODE FOR FUZZY DEFROSTING CONTROLLER C.1 Introduction This appendix is documented with the assembly code generated for the fuzzy defrosting controller for using Motorola’s MC68HC11/MC68HC12 micro-controller. The code is ready to be downloaded to the micro- controller if the current design is not to be changed. Any changes Of parameters to the design will need re-generation of the code. C.2 Code ' ----- FuzzyTECH 5.01 MCU-HC11/12 Explorer --- Pre-assembler ---------- code generation date: Sat May 22 15:14:38 1999 ------- project: DEFROSI MCU: 12 ~19 VI. ‘0" XDEF _defrosl XDEF _initdefi'osl ; input/output interface Of controller ------------ XDEF _DoorOpen_Time_defrOSl ;00H .. FFH XDEF _Humidity_defrosl ;00H .. FFH XDEF _Defrost_Period_defrosl ;00H .. FFH ; external functions of fuzzy library ............. XREF flms XREF com ; external variables of fuzzy library ............. XREF fuzptr XREF _invalidflags XREF itcnt XREF tpptr XREF crisp XREF otcnt switch .bss 65 ; RAM i/O-vars fuzvals: ;8 + 3 + 0 fvs: _t_DoorOpen_Time_defrosl: ds.b 5 _t_Humidity_defrosl: ds.b 3 _t_Defrost_Period_defrosl: ds.b crispio: '3 _DoorOpen_Time_defrOSI: ds.b l _Humidity_defros1: ds.b 1 _Defrost_Period_defrosl: ds.b 1 switch .text ; standard term definition (x1, x2, x3, x4) ---------- tpts: dc.b $00, $00, $00, $39 dc.b $00, $39, $39, $71 dc.b $39, $71, $71, $AA dc.b $71, $AA, $AA, $FF dc.b $AA, $FF, $FF, $FF dc.b $00, $00, $26, $80 dc.b $26, $80, $80, $D7 dc.b $80, $D7, $FF, $FF ; xcom table (defuzzification) xcom: dc.b $12, $53, $86 ; rule table(s) _rt0: dc.w fvs+$0, fvs+$5, $FFFE dc.w fvs+$A, $FFFE dc.w fvs+$0, fvs+$6, $FFFE dc.w fvs+$A, $FFFE dc.w fvs+$0, fvs+$7, $FFFE dc.w fvs+$9, $FFFE dc.w fvs+$1, fvs+$5, $FFFE dc.w fvs+$A, $FFFE dc.w fvs+$l, fvs+$6, $FFFE dc.w fvs+$9, $FFFE dc.w fvs+$1, fvs+$7, $FFFE dc.w fvs+$9, $FFFE dc.w fvs+$2, fvs+$5, $FFFE dc.w fvs+$9, $FFFE dc.w fvs+$2, fvs+$6, $FFFE dc.w fvs+$9, $FFFE dc.w fvs+$2, fvs+$7, $FFFE dc.w fvs+$9, $FFFE dc.w fvs+$3, fvs+$5, $FFFE dc.w fvs+$9, $FF FE 66 dc.w fvs+$3, fvs+$6, $F FF E dc.w fvs+$9, $FFFE dc.w fvs+$3, fvs+$7, $FFFE dc.w fvs+$8, $FFFE dc.w fvs+$4, fvs+$5, $FFFE dc.w fvs+$9, $FFFE dc.w fvs+$4, fvs+$6, $FF FE dc.w fvs+$8, $FFFE dc.w fvs+$4, fvs+$7, $FFFE dc.w fvs+$8, $FFFF rtO: dc.b $00, $8F, $31, $CF, $95, $79, $59, $E5, $Dl, $BF, $2B dc.b $DB, $35, $83, $4D _defrosl: ; fuzzification ldy #fuzvals ldd #tpts std tpptr ldab #$5 stab itcnt ldab _DoorOpen_Time_defrosl stab crisp jsr flms ldab #$3 stab itcnt ldab _Humidity_defrosl stab crisp jsr flms ; inference init ; rule block 0 ldx #_rt0 ldy #rt0 ldaa #255 sec sei ;patch revw ;min aggregation, product composition cli ;patch ; defuzzification clr _invalidflags ldy #fuzvals + $8 ldx #xcom + $0 ldab #$3 67 stab otcnt jsr com bcc out0valid ldab #$09 out0valid: stab _Defrost_Period_defrosl ldab _invalidflags rts ;end Of fuzzy controller ; initdefrosl _initdefrosl : ldy #$3 ldaa #0 begin: staa fuzvals + $7,y dey bne begin rts ;data size knowledge base (bytes): ;RAM: 14 0000EH ;ROM: 140 0008CH ;TOTAL: 154 0009AH 9 end 68 BIBLIOGRAPHY Bibliography [1] Zadeh, L. A., “Fuzzy Sets,” Information and Control, Vol. 8, 1965 [2] “Fuzzy Logic 2.0”, Motorola [3] James F. Brule, “FUZZY SYSTEMS - A TUTORIAL”, [Online] Available http://www.austinlinks.com/Fuzzy/tutorial.htrnl [4] S. Komer, "Laws Of thought," Encyclopedia Of Philosophy, Vol. 4, MacMillan, NY: 1967, pp. 414-417. [5] C. Lejewski, "Jan Lukasiewicz," Encyclopedia Of Philosophy, Vol. 5, MacMillan, NY: 1967, pp. 104-107. [6] Witold Pedrycz, “Fuzzy Control and Fuzzy Systems”, second, extended edition, 1993 [7] George J. Klir/BO Yuan, “Fuzzy Sets and Fuzzy Logic -- Theory and Applications” [8] Pedrycz, W., 1990. “Fuzzy sets framework for development Of perception perspective,” Fuzzy Sets & Sys. [9] Pedrycz, W., 1992. “Selected issues Of frame of knowledge representation realized by means of linguistic labels,” Int. J. Intelligent Syst. [10] Constantin Von Altrock, “Fuzzy Logic and NeuroFuzzy Applications Explained”, [l l] E.H.Mamdani, “Twenty Years Of Fuzzy Control: Experiences Gained and Lessons Learned”, IEEE Technology Update Series, Fuzzy Logic Technology and Applications. [12] “fuzzyTech 4.0 MCU Edition Manual,” INFORM/Inform Software Corp., [13] Hideyuki Takagi, “Application of Neural Networks and Fuzzy Logic to Consumer Products”, IEEE Technology Update Series, Fuzzy Logic Technology and Applications. [14] [Online] Available http://www.pbs.org/weta/planet/main/SOftware/refrigerator/chill- tech.htrnl - [15] Alan Meier, “Energy Test Procedures for the twenty-first Century”, [Online] Available http://eetd.lbl.gov/EA/Buildings/ALAN/Publications/AMCE/AMCE.text.html [16] James Braharn,“Energy Efficiency Sends Appliance Designers into A Spin”, Machine Design, August 7, 1997, [Online] Available http://www.penton.com/md/edit/features/80797/appliances080797.htrnl [17] [Online] Available, Tariq M. Al-Hindi, Amy A. Piotrowski, Carlo Adinata, Joel Ross, Paul Kabir, Aaron Olds, Spring, 1999 http://www.egr.msu.edu/~ee482/Ieams/98fall/design1/web/fmalreport.htm [18] [Online] Available http://www.mcu.motsps.com/hc12/home.html [19] [Online] Available http://www.mcu.motsps.com/lit/hc12.html [20] “CPU12 Reference Manual”, Motorola, [Online] Available http://www.mcu.motsps.com/lit/manuals/cpu12/cpu12rg.pdf [21] “fuzzyTech 4.0 Online Edition Manual,” INFORM/Inform Software Corp., 70 ntcurcau star: UNIV. LIBRARIES iliilliiiiliiillliilliiiiliiliiiiiililiililiillliiilllliiilll 31293018345904