MICROCONTROLLER BASEDIMPLEMENTATION OF A FUZZYKNOWLEDGE BASED CONTROLLERDEBASMITA PATTNAIK (109EE0298)BONANI SAHU (109EE0302)DEVADUTTA SAMANTARAY (109EE0061)DEPARTMENT OF ELECTRICAL ENGINEERINGNATIONAL INSTITUTE OF TECHNOLOGY, ROURKELA1
MICROCONTROLLER BASEDIMPLEMENTATION OF A FUZZYKNOWLEDGE BASED CONTROLLERA Thesis submitted in partial fulfillment of the requirements for the degree ofBachelor of Technology in “Electrical Engineering”ByDEBASMITA PATTNAIK (109EE0298)BONANI SAHU (109EE0302)DEVADUTTA SAMANTARAY (109EE0061)Under guidance ofProf. SUBHOJIT GHOSHDepartment of Electrical EngineeringNational Institute of TechnologyRourkela-769008 (ODISHA)May-20132
DEPARTMENT OF ELECTRICAL ENGINEERINGNATIONAL INSTITUTE OF TECHNOLOGY, ROURKELA- 769 008ODISHA, INDIACERTIFICATEThis is to certify that the draft report/thesis titled “MICROCONTROLLER BASEDIMPLEMENTATION OF A FUZZY KNOWLEDGE BASED CONTROLLER”, submitted tothe National Institute of Technology, Rourkela by Bonani Sahu, Roll No: 109EE0302,Debasmita Pattnaik, Roll No: 109EE0298 & Devadutta Samantaray, Roll No: 109EE0061 forthe award of Bachelor of Technology in Electrical Engineering, is a bonafide record of researchwork carried out by them under my supervision and guidance.The candidates have fulfilled all the prescribed requirements.To my knowledge, the draft report/thesis which is based on candidates’ own work, has notsubmitted elsewhere for a degree/diploma.In my opinion, the draft report/thesis is of standard required for the award of a Bachelor ofTechnology in Electrical Engineering.Prof. Subhojit GhoshSupervisorDepartment of Electrical EngineeringNational Institute of TechnologyRourkela – 769 008 (ODISHA)3
ACKNOWLEDGEMENTWe have been highly indebted in the preparation of this report to our supervisor, Prof.Subhojit Ghosh, whose patience and kindness, as well as his academic experience, has beeninvaluable to us.The informal support and encouragement of many friends has been indispensable. We wouldnot have contemplated this road if not for our parents, who instilled within us a love ofcreative pursuits, science and language, all of which finds a place in this report.4
ABSTRACTIn recent times, fuzzy logic has been used and applied in wide areas, starting fromconsumer electronics like washing machines to robotics to many industrial control systems liketemperature controllers for process plants.Our work describes an implementation of fuzzy logic control algorithm usinginexpensive hardware to control the temperature of a system, without any special softwaretools. A cooling system generally involves complex and time-variant plant, with delays andnon- linearity, and often with poorly defined dynamics. Fuzzy logic control algorithm solvesproblems that are difficult to address with traditional control techniques, and at the same timeprovides us with a response better than conventional PID controllers. In the present work, thishas been proved with the help of MATLAB simulations.Thereafter the program for the fuzzy control algorithm is written in C languageand implemented through ARDUINO UNO tool kit. Further system functional is tested andthe performance is evaluated taking several set-points and disturbances into account. Theperformance of the hardware is compared with that of MATLAB simulations of the samecase and the results are verified.5
CONTENTSAbstract5Contents6List of Figures8List of Tables8Abbreviations and Acronyms9CHAPTER 1INTRODUCTION1.1 Motivation111.2 Literature Review111.3 Thesis Objectives131.4 Organization of Thesis13CHAPTER 2OVERVIEW OF FUZZY LOGIC2.1 Introduction162.2 Implementation of Fuzzy Logic162.3 Fuzzy Inference System19CHAPTER-3DESIGN AND ANALYSIS OF FUZZY LOGIC CONTROLLER3.1 Introduction223.2 Development of Rule Base223.3 Simulation in MATLAB243.4 Results243.5 Conclusion25CHAPTER-4HARDWARE IMPLEMENTATION OF FUZZY LOGIC CONTROLLER4.1 Introduction274.2 Components Used274.3 Overall Experimental Setup304.4 Model Layout316
CHAPTER-5EXPERIMENTAL RESULTS AND COMPARITIVE STUDY5.1 Comparative Study335.2 Conclusion34CHAPTER-6CONCLUSION AND FUTURE WORK6.1 Conclusion366.2 Future Work36References37Appendixa) Program Code developed in C 39b) Program Code developed in ARDUINO UNO kit417
LIST OF FIGURESFig. NoName of the FigurePage. No.2.1Different Types of Fuzzy Set152.2Different Types of Membership Function172.3Structure of Fuzzy Inference System193.1Block Diagram for the Design of Controller233.2Comparison of Performances of PID and FLC for their Step Response244.1Microcontroller ATMEGA 328294.2ARDUINO UNO Tool Kit294.3Membership Function used in FIS304.4MATLAB Simulink Block of Fuzzy Logic Controller314.5Schematic Diagram of PWM Block314.6Experimental Setup of the Hardware Model of the Controller31LIST OF TABLESTab. NoName of the TablePage. No.3.1Rule Base Table of PI Controller5.1Comparison of the Arduino Kit and Simulink Output for different errorsignals23348
ABBREVIATIONS AND ACRONYMSAC-Alternating CurrentDC-Direct CurrentPWM-Pulse Width ModulationEMI-Electro Magnetic InterferenceMATLAB-MATrix LABoratoryPID-Proportional, Integral and DerivativeFLC-Fuzzy Logic ControllerMF-Membership FunctionCPU-Central Processing UnitUSB-Universal Serial BusFTDI-Future Technology Devices InternationalIC-Integrated CircuitLED-Light Emitting DiodeSMPS-Switched Mode Power SupplySPI-Serial Peripheral Interface9
CHAPTER1INTRODUCTION10
1.1MOTIVATION:Nowadays, in globalization era there are always the foundation of the new technologiesfeatures every year. Automatic control system has become the most popular feature which israpidly gaining its popularity due to its importance to certain applications. Process controlsystems are often nonlinear and difficult to control accurately and efficiently. These dynamicmodels are more difficult to derive than those used in aerospace or robotic control, and theytend to change in an unpredictable way. The conventional PID controllers, in variouscombinations have been widely used for industrial processes due to their simplicity andeffectiveness for linear systems, especially for first and second order systems. It has beenwell known that Proportional Integral Derivative (PID) controllers can be effectively used forlinear systems, but usually cannot be used for higher order and nonlinear systems. Fuzzylogic has emerged as one of the active areas of research activity particularly in controlapplications. It is a very powerful method of reasoning when mathematical models are notavailable and input data are imprecise. Fuzzy logic performs better when compared toconventional control mechanisms like PID. The main objective behind fuzzy logic is torepresent and reason with some particular form of knowledge expressed in linguistic form.This work addresses an application that involves the system control system. It presents afuzzy controller that uses an adaptive neuro-fuzzy inference system. Fuzzy Inference system(FIS) is a popular computing framework and is based on the concept of fuzzy set theories,fuzzy if and then rules, and fuzzy reasoning.1.2LITERATURE REVIEW:Implementation of fuzzy logic technology for the development of sophisticatedcontrol systems has become one of the most rapidly growing successful technologies. This ismainly because fuzzy logic resembles human decision making with an ability to generateprecise solutions from approximate information. It fills up an important gap in engineeringdesign methods left vacant by purely mathematical approaches (e.g. linear control design),and purely logic-based approaches (e.g. expert systems) in system design. While otherapproaches require precise equations to model real-world behaviours, fuzzy design canaccommodate the uncertainties of real-world human language and logic by providing both anintuitive method for describing systems in human terms and automating the conversion ofthose system specifications into effective model [1]. Fuzzy Logic relates input to output inlinguistic terms that can be easily understood. It allows for the rapid prototyping because the11
system designer doesn’t need to know everything about the system before starting. It ischeaper because they are easier to design. It involves simplified knowledge acquisition andrepresentation. It is used to achieve less overshoot and oscillation. It achieves steady state in ashorter time interval.Fuzzy logic was coined in the year 1965 by Lotfi Zadeh. From then on, the history offuzzy logic follows the pattern of many recent key technologies: invented in the U.S.,engineered to perfection in Europe, and currently, mass-marketed in Japan.The use of fuzzy logic provides very fast response and reliable operation. As thesoftware is more or less common for all control application, we can use this fuzzy control forother applications including non-linear systems. The ultimate advancement possible will beincorporation of neural networks in combination with the fuzzy algorithm. Neural networkscan be used to absolutely authorize the design process of fuzzy systems [1]-[3]. The FLCperformance is superior to the PID controller, presenting faster transient response and lessovershoot and oscillation. It is also more robust against disturbances than the PID controller.But it has some steady state errors due to the coarse tuning and small size of fuzzy set whichcan be achieved by resizing the fuzzy sets and finer tuning for the membership functions [4][8]. Unlike some fuzzy controllers with hundreds and thousands of rules running on computersystems, a unique FLC that uses a small number of rules and simple implementation can beused to solve a system control problem with unknown dynamics or variable time delayscommonly found in industry. The control result can be improved by resizing the fuzzy setsand finer tuning for the membership functions [9]. A closed loop control systemincorporating fuzzy logic has been developed for a class of industrial temperature controlproblems. A unique fuzzy logic controller (FLC) structure with an efficient realization and asmall rule base that can be easily implemented in existing industrial controllers was proposed.It was demonstrated the potential of FLC in both software simulation and hardware test in anindustrial setting. This includes compensating for thermo mass changes in the system thatdeals with unknown and variable delays, operating at various temperature set-points withoutretuning, etc. It is achieved by applying, in FLC, a classical control strategy and an adaptationmechanism to compensate for the dynamic fluctuations in the system.Fuzzy logic not only replaces conventional control techniques, but also provides asolution where conventional methods are not satisfactory. When a present control solutionactually exists, replacement of fuzzy logic may not be indispensable. But it is not often true.12
An alternative solution by using Fuzzy logic control may be better. It all depends on how farthe system under control is known to us in its parameters, variables and various relationshipsof control. If determined values of such variables are not existing, then fuzzy logic basedclassification of the variables provides a solution which may be better than a method ofcontrol using\assumed relationship.1.3THESIS OBJECTIVES:The following objectives are hopefully to be realized at the end of the project.1) To study the fuzzy logic and its characteristics.2) To study the comparison in the performances of FLC and conventional controlalgorithms like PID.3) To develop a controller which could take in an analog signal, compare it with acertain reference value and then give the control output required for the signal toreach the reference.4) To authenticate experimental results obtained from the laboratory set-up and toanalyse the results with the simulated results in the MATLAB-Simulink Environment.1.4ORGANISATION OF THESIS:The thesis is organised into six chapters including the chapter of introduction. Eachchapter is different from the other and is described along with the necessary theory requiredto comprehend it.Chapter 2 deals with an overview of Fuzzy Logic. It describes the inception of fuzzylogic, followed by a description of the types of membership functions used in fuzzy sets. Thelayout of a Fuzzy Inference system is also described and its various procedures are explained.Chapter 3 describes the analysis and design of Fuzzy Logic Controller. The choice ofa certain rule base used is justified and a FLC is designed using this particular rule base. Theperformance of FLC is compared with that of conventional control algorithms, taking PID asan example. The comparison is done in a MATLAB-Simulink environment and the result isverified.13
Chapter 4 shows the practical implementation of the proposed model. The hardwareused for the implementation is briefly described, followed by a study of all the blocksrequired in the actual model. An ARDUINO hardware model and a MATLAB-Simulinkmodel of the controller block are simultaneously designed. Then, the overall experimentalsetup is charted out for open loop configuration of the controller.Chapter 5 presents the experimental results of the hardware block so designed. Theoutput waveform generated from the hardware is compared with that of the Simulink modelto verify the results.Chapter 6 concludes the work performed so far. The possible limitations inproceeding research towards this work are discussed. The future work that can be done inimproving the current scenario is mentioned. The future potential along the lines of this workis also discussed.14
CHAPTER2OVERVIEW OF FUZZYLOGIC15
2.1INTRODUCTIONLotfi Zadeh, the father of fuzzy logic, claimed that many sets in the world that surroundsus are defined by a non-distinct boundary. Zadeh decided to extend two-valued logic, definedby the binary pair {0, 1}, to the whole continuous interval [0, 1], thereby introducing agradual transition from falsehood to truth. Fuzzy control is a control method based on fuzzylogic. Just as fuzzy logic can be described merely as "computing with words rather thannumbers"; fuzzy control can be described simply as "control with sentences rather thanequations". A fuzzy controller can include empirical rules that are mainly useful in operatorcontrolled plants.Even though the broad sense of fuzzy logic covers a wide range of theories andtechniques, its core technique is based on four basic concepts:(1) Fuzzy sets: sets with smooth boundaries;(2) Linguistic variables: variables whose values can be described bothqualitatively and quantitatively by fuzzy sets;(3) Possibility distribution: constraints on the value of a linguistic variableimposed by assigning it a fuzzy set; and(4) Fuzzy if then rules: a knowledge representation scheme for describing afunctional mapping or a logical formula that generalizes an implication in two-valued logic.FIGURE 2.1: (a) CLASSICAL SET (b) FUZZY SET2.2MEMBERSHIP FUNCTIONS2.1.1 DEFINITIONA fuzzy set is defined by a function that maps objects in a domain of concern to theirmembership value in the set. Such a function is termed as membership function and is usually16
denoted by the Greek symbol μ for ease of recognition and consistency. A membershipfunction can be designed in three ways:(1) Interview those who are familiar with the underlying concept and later adjust itbased on a tuning strategy.(2) Build it automatically from data;(3) Learn it on the basis of feedback from the system performance.2.1.2 TYPES OF MEMBERSHIP FUNCTIONSa) Triangular Membership FunctionThis MF is mainly classified by three parameters namely {a,b,c}So it can be represented byTriangle (x;a,b,c) 0x a,(x-a) /(b-a), a x b(c-x) / (c-b), b x cc x0,By using min and max, we have alternative expression as followsTriangle(x,a,b,c) max(min((x-a)/(b-a), (c-x)/(c-b)),0)Where the parameters a,b,c determine the x coordinates of the three corners of the underlyingtriangular MF.b) Trapezoidal Membership FunctionThis MF is mainly classified by four parameters namely {a,b,c,d}So it can be represented byTrapezoid (x;a,b,c,d) 0,x a(x-a) / (b-a) , a x b1,b x c(c-x) / (c-b), c x d0,d xBy using min and max, we have alternative expression as followsTrapezoid(x,a,b,c,d) max(min((x-a) / (b-a),1, (d-x) / (d-c)),0)Where the parameters a,b,c,d determine the x coordinates of the three corners of theunderlying trapezoidal MF.17
c) Gaussian Membership FunctionThis MF is mainly classified by four parameters namely {c,σ}Gaussian(x; c,σ) Where c and σ are the centre and width of the MF respectively.d) Generalised Bell Membership FunctionThis MF is mainly classified by four parameters namely {a,b,c}bell(x; a ,b ,c) ( )Where b is always positive .We can vary c and a to vary centre and width of the MF and b tocontrol slopes at crossover points.(a)(b)(c)(d)FIGURE 2.2: DIFFERENT TYPES OF MEMBERSHIP FUNCTIONS: (a) TRIANGULAR (b)TRAPEZOIDAL (c) GAUSSIAN (d) GENERALIZED BELL18
2.3FUZZY INFERENCE SYSTEM Fuzzification: Converting crisp facts into fuzzy sets described by linguisticexpressions. Membership functions can be flat on the top, piece-wise linear and triangleshaped, rectangular, or ramps with horizontal shoulders. These three choices can be explainedby the ease with which a parametric functional description of a membership function can beobtained, stored with minimum use of memory and employed efficiently, in terms of realtime requirements by the inference engine. Inference: The fuzzy IF-THEN rule expresses a fuzzy implication relation betweenthe fuzzy sets of the premise and the fuzzy sets of the conclusion. The basic function of therule base is to represent in a structured way the control policy of an experienced processoperator in the form of a set of production rules such as:If (process state) then (control output)The “if” part of such a rule is called rule antecedent and is a description of a processstate in terms of a logical combination of atomic fuzzy propositions .The “then” part of therule is called the rule consequent and is again the description of the control output in terms ofa logical combination of fuzzy propositions. These propositions represent the linguisticvalues which the control outputs take when the current process state matches the process statedescription in the rule antecedent. In our terminology, a fuzzy control rules provide aconvenient way for expressing control policy and domain knowledge. The proper choice ofprocess state variables and control variables is essential to the characterisation of theoperation of a fuzzy system. Typically the linguistic variables in a FLC are states, state error,state error derivative and state error integral. Aggregation: This process aggregates the individual rule outputs to obtain the overallsystem output. It will be also a fuzzy subset over the output universe (a union operationyields a global fuzzy set of the output). De-fuzzification: to obtain crisp output (various de-fuzzification methods can be used,as, e.g., center of gravity, bisector of area, and mean of maximum, to obtain a crisp numericaloutput value).19
FIGURE 2.3: STRUCTURE OF FISFuzzy logic is a powerful way to put engineering expertise into products in a shortamount of time. It's highly beneficial in automotive engineering, where many system designsinvolve the experience of design engineers as well as test drivers. Due to their simpleformulas and computational efficiency, both triangular and trapezoidal MFs have beenextensively used especially in real time implementation. However since the MFs arecomposed of straight line segments, they are not very smooth at the corner points specified bythe parameters. Since trapezoidal MF has two corner points while triangular MF has just one,we use triangular MF most frequently among all MFs. The implementation of fuzzy logic forcontrol applications requires a microprocessor or Microcontroller based system. Themicrocontroller offers low cost and compact digital systems due
fuzzy controller that uses an adaptive neuro-fuzzy inference system. Fuzzy Inference system (FIS) is a popular computing framework and is based on the concept of fuzzy set theories, fuzzy if and then rules, and fuzzy reasoning. 1.2 LITERATURE REVIEW: Implementation of fuzzy logic technology for the development of sophisticated
Microcontroller Based Home Automation System Page ix 2.7 MICROCONTROLLER FEATURES' 19 2.8 Microcontroller clock 20 2.9 THE MICROCONTROLLER SYSTEM 20 3.1 SMART HOME CONTROL SYSTEM 23 4.1 AC AND HEATER CONTROL 27 4.2 Temperature meter, day light sensor & water level sensor 28 4.3 REMOTE CONTROL CIRCUIT 29 5.1 Software Development 31 5.2 FINAL .
Pic-Microcontroller Based Fully-Automatic International organization of Scientific Research 14 P a g e Figure 1: System Block Diagram 2.1 PIC16F877A Microcontroller A microcontroller is a microcomputer on a single
Abstract—This paper describes new microcontroller platform based on 32-bit ARM Cortex M microcontroller. This platform was developed at our faculty to replaceolder board with Freescale HCS08 microcontroller for use in lessons of microcontroller programming. Main comp
The AVR Microcontroller & Embedded Systems (Mazidi & Naimi) 2 The AVR Microcontroller & Embedded Systems (Mazidi & Naimi) rTo understand the software and hardware of a microcontroller-based sys-tem, one must first master some very basic concepts underlying computer archi- tecture. In this ch
microcontroller, this project focus only on the PIC16F877A Microcontroller where it's pins as shown in Fig. 6. Fig. 6 Pin diagram of PIC16F877A microcontroller . 3 Automatic street light control Circuit Design . The inputs in the streets lighting system are LDR and photoelectric sensors, after dusk the light sensor .
Ultra-Low Power Microcontroller OVERVIEW The AX8052F100 is a single chip ultra lowpower microcontroller primarily for use in radio applications. The AX8052F100 contains a high speed microcontroller compatible to the industry standard 8052 instruction set. It contains 64 kBytes of FLASH and 8.25 kBytes of internal SRAM. The AX8052F100 features 3 16 bit general purpose timers with capability .
A microcontroller is an integrated chip that is often part of an embedded system. The microcontroller includes a CPU, RAM, ROM, I/O ports, and timers like a standard computer, but . microcontroller programming .Doing t
PIC Microcontroller: PIC microcontrollers is a kind of programmable microcontroller which produced by microchip, it can be programmed by many programming language.[3] Fig ( 11 ): PIC Microcontroller Chip H-Bridge (