Design and FPGA Implementation of Takagi- Sugeno Fuzzy Controller Based on LUTs

81 Design and FPGA Implementation of TakagiSugeno Fuzzy Controller Based on LUTs Rasha Ilham Majeed rasha_elham@yahoo.com Abstract In this paper, an approach for designing Fuzzy Controller based on Takagi-Sugeno inference engine with high computational speeds in architecture is proposed. The work focuses on advantages and disadvantages of Takagi-Sugeno control as compared with Mamdani's', in addition to focus on how computational complexity of the inference engine can be reduced and the speed of computation can be increased. Fuzzy Controller is implemented on FPGA using Look-Up Table (LUT). Whereas, each LUT is represented by Block RAMs in FPGA besides using number of arithmetic units in the design. To interface the design with users, a GUI program is designed using Visual Basic. Using JTAG port, the GUI's data can be stored in Block RAMs. Later, a designed Air Conditioning application is implemented and the practical results (in FPGA), theoretical results (computed by hand) and Matlab results are compared.


1-Introduction
Fuzzy Logic, which was developed in early 1960s, provided a tool to deal with uncertainty and human reasoning [1]. The main characteristic of a fuzzy logic is the capability to express the knowledge in a linguistic way. Fuzzy Logic empowers the digital designer with the ability to use non-linear controllers for their applications. Fuzzy Logic is used to control systems, whose mathematical model is unknown or time varying, or that requires human experience [1] [2]. Fuzzy systems are also used for controlling high speed systems, and for processing of large volumes of data where enormous amount of computational speeds are required. High computational speeds may be achieved when these systems are realized on a digital hardware [2]. Computational speed of a digital hardware can be increased either by having parallelism or reducing computational complexity or both. Since a digital system works on a reference clock, the computational speed will also depend on the speed grade of the digital system [3]. Fuzzy Controller contains two main types: Mamdani and Takagi-Sugeno Fuzzy Controller [4]. Despite Mamdani Fuzzy Controllers are more famous and used than Takagi-Sugeno Type, but its digital hardware design is long and complex [2]. Whereas, Mamdani design consists of several parts of computing fuzzy outputs. These prosperities of Mamdani control are not working well in several types of applications [4]. On the other hand, Takagi-Sugeno design has many advantages as working well with linear techniques (as PID), having guaranteed continuity of the output surface, and the systems are computationally efficient [2] [4]. To find the properties of Takagi-Sugeno design in implementation and application, an approach to design an architecture of Takagi-Sugeno Fuzzy controller is introduced and implemented on an FPGA kit. Then, a Sugeno GUI program to interface the design with the application of user is designed. The application is represented by an Air Conditioning System. The implementation of that application in Takagi-Sugeno is accomplished and its practical and theoretical outputs, are compared with the values obtained by Matlab. This paper is organized as follows: besides this introducing section, section 2 presents the design of a Takagi-Sugeno Fuzzy inference engine for an FPGA implementation. In section 3, the architecture of such controller is described. The design of Sugeno GUI is given in section 4. Section 5 contains the utilization of RAM blocks of FPGA in storing files. A Fuzzy Controller example on air conditioning system is designed in section 6. The implementation steps and results are illustrated in section 7. Finally, this paper is concluded in section 8.

2-Design of Takagi-Sugeno Fuzzy Inference Engine for an FPGA Implementation
Fuzzification is the process of converting the input crisp values into a set of membership values in the interval {0, 1} in the corresponding fuzzy sets. There are numerous different t y p e s o f m e m b e r s h i p f u n c t i o n s [ 5 ] . A f i n i t e c o l l e c ti o n o f t r i a n g u l a r f u z z y s u b s e t s a r e considered, which are unimodal, convex, and normal. The triangular and trapezoidal membership functions (triangular membership function being a special case of the trapezoidal function) are the most famous functions [2]. Sugeno or Takagi-Sugeno Inference Engine is introduced in 1985; it is similar to the Mamdani method in many respects. The first two parts of the fuzzy inference process, fuzzifying the inputs and applying the fuzzy operator, are exactly the same [2]. The main difference between Mamdani and Sugeno is that the Sugeno output membership functions are either linear or constant. A typical rule in a Sugeno fuzzy model has the form

If Input 1 = x and Input 2 = y Then Output is z = ax + by + c
where a, b, and c are the constants of linear equation. For a zero-order Sugeno model, the output level z is a constant (a=b =0). The output level z i of each rule is weighted by the firing strength w i of the rule. For example, for an AND rule with Input 1 = x and Input 2= y, the firing strength is where F 1,2 (.) are the membership functions for Inputs 1 and 2 as shown in Figure (1). The final output of the system is the weighted average of all rule outputs, computed as the easiest way to visualize first-order Sugeno systems is to think of each rule as defining the location of a moving singleton as given by That is, the singleton output spikes can move around in a linear fashion in the output space, depending on what the input is.

3-Takagi-Sugeno Fuzzy Controller Architecture
The designed fuzzy inference engine consists of two inputs and one output. Takagi-Sugeno fuzzy controller consists of two main stages: fuzzification and inference engine. Fuzzification stage is designed using LUT1 and LUT2 components as shown in Figure ( depends on the value of the input. Figure (2) shows the block diagram of hardware implementation. Both inputs are processed in parallel. I.e., the outputs of LUT1 and LUT2 are available at the same clock pulse. The outputs of LUT1 and LUT2 are collected to a 20bit data consisting of two possible membership values (8-bit each) and the two fuzzy sets (3bit each). Inference Engine has two components. The Minimum block consists of four sub_blocks which are used to find the minimum degree which is the weight. For example, the first one is designed to find the minimum between MFS1 and MFS4 and so on. The second one is termed as 'LUT3' block. It represents four identical Block RAMs. They store the outputs of Sugeno linear equations which are computed using GUI program and, stored using JTAG port. L1, L2, L3, and L4 of fuzzification after merging serve as address to those four Block RAMs (merging is done in VHDL code of the architecture.

4-Design of Sugeno GUI
To interface Sugeno fuzzy controller design with the application of user, GUI program is designed using Visual Basic. This program is designed by three sequential forms as shown in

6-A Fuzzy Controller Example
Fuzzy Controller Air Conditioning System is considered in this paper as an example. There are two control input variables to adjust the temperature of an air conditioning (AC) room [12]: the temperature error T E , which is defined as the difference between the current temperature and the target set temperature as given by

T E = T set-point -T preent -----(2)
and dT E / dt, the rate of the temperature error change with time as given by Form c
The membership function for T E consists of five fuzzy logic ranges that can be defined using the linguistic terms as Cold, Cool, Warm, Mild, and Hot. The graphical representation of the membership function of T E is depicted in Figure (6). The values of the x-axis of the membership function have been scaled as an 8-bit hexa value representing the actual reading from the temperature sensor. Similarly, the y-axis for the grade of the membership function starts from 00h (false) to FFh (completely true).
The second input variable to the temperature fuzzy controller is the rate of change of temperature with respect to time. The calculation results in the rate of temperature change per time interval as defined by

Time between Temp
The purpose of implementing the rate of temperature change in fuzzy control is to determine the velocity at which the process should react. Since time between temperature readings is triggered by every clock cycle in this application, the rate of temperature change can be simplified to become the difference between the current and previous temperature reading. As usual, the rate of temperature change takes three linguistic terms Slow, Moderate, and Fast as its membership function. The graphical representation of this membership function is shown in Figure (7).
The output membership functions of the fuzzy temperature control are singletons; five different linguistic terms of the singleton output Very Low, Low, Medium, High, and Very High are used to describe the heated control variations. Figure (8) shows the graphical representation of the singletons of these five variables.

7-Implementation Steps and Results
The implementation steps are: 1-Entering Membership points for each input using Visual Basic as shown in Figure (4 (6) and (7) respectively, and then storing the inputs values and its degrees in hexa files as shown in Figure (4).

8-Conclusions
In this paper, certain properties of Takagi-Sugeno Fuzzy Controller design have been concluded. From Table (7), we notice that the consumed area (number of slices) of implementing the design in Spartan 3E kit is 13% of total number of slices. That means the consumed area is very small with fast computations as result of reducing the computation and complexity of the design and using LUTs in Fuzzification stage instead of arithmetic units. As comparing the results of Takagi-Sugeno design with Mamdani design' results, it can be concluded that the consumed area of Takagi-Sugeno design is less than Mamdani's as result of using additional units in Mamdani's system to find Fuzzy outputs as in Ref. [13]. Using LUTs in Takagi-Sugeno design in parallel have also reduce the complexity and computation of the design in addition to the fast execution of the system. Unfortunately, the use of LUTs may lead to some reduction in accuracy of implementation [14].
From this paper, It may also be concluded that each type of Fuzzy controller has special uses. Whereas, Takagi-Sugeno is working well with linear techniques (e.g., PID control), with optimization and adaptive techniques, and mathematical analysis, Mamdani on the other hand is well suitable for non linear control system.
To test the designed controller, Sugeno Fuzzy Controller is tested as a Proportional Fuzzy Logic Controller (PFLC) for a closed loop system. To compare the Sugeno operation with its Mamdani , the same controlled system (plant) has been taken from Ref. [3]. To implement that system, a closed loop system using LabView has been implemented and interfacing Sugeno FLC (on FPGA) with LabView System has been done via DAQ 6251 as shown in Figure (12). The implemented system has been divided into two parts: the first part is for supplying Step Function = 5 volt and finding the error and change of error of the system. The second represents the plant of the system. After implementing, comparing the characteristics of the system response in Figure (24) of Ref. [3] with the obtained system response in this paper shown in Figure (13) is done. From comparing, the characteristics of the system response in Ref. [3] with its characteristics in this paper, we notice that Mamdani Fuzzy Control is better than Sugeno Fuzzy Control in controlling on control system. Whereas, the value of overshoot in system response is higher than its value in Mamdani control. Table (8) shows the characteristics (Max. Overshoot, rise time, Settling time , Overshoot time) of that system based on Mamdani Fuzzy Controller and Sugeno Fuzzy Controller.