Ali:FPGA Implementation of a Fuzzy Control Surface

This paper presents a design methodology of a dual-input single-output fuzzy logic controller where synthesizing the classical three stages, fuzzification, inference engine, and defuzzification, are replaced by the outcome control surface obtained from these stages which is treated as a tow dimensional table called fuzzy control table FCT. With this proposed approach, (8x8), (16x16), (32x32), and (64x64) FCTs were investigated each having 64, 256, 1024, and 2048 values respectively. To make this system adaptable to different operating states a supervisor fuzzy controller is designed to continuously adjust, on line, the output factor of the basic fuzzy controller based on the error and change in error signals. The proposed architecture is implemented in XC3S200 FPGA, Spartan-3 starter kit to control the position of a D


Introduction:
Fuzzy Logic introduced by Lotfi Zedah in 1965 has been making rapid progress in recent years particularly in the area of control [1].The main advantage of fuzzy logic as compared to the conventional control approach reside in the fact that no mathematical modeling is required for the design of the controller [2].The controller rules are based especially on the knowledge of the system behavior and on the experience of the control engineer.Fuzzy control table (FCT) simplifies the standard fuzzy control algorithm by employing a look-up table which is generated off-line from an initial set of common sense fuzzy rules.The table acts as the control surface and represents "compiled" control knowledge.The look-up table for a two-term controller is a discrete function mapping the error and change in error inputs to corresponding controller outputs producing a 3D (three dimensional) control surface [3].The control performance of the fuzzy logic controller (FLC) can be enhanced by the following ways: rule tuning, membership functions tuning, and scaling factors adjusting, among which scaling factors adjusting is the most common way to improve performance [4].The tuning procedure can be time-consuming, expensive and difficult task [5].This problem can be dynamically solved by using self-tuning scheme for the fuzzy controller.The selection of the scaling factors, especially the output scaling factor is very important for a FLC because of its strong influence upon the overall performance of the controller [4].Labview program, with it's toolkits, is used in this paper to design a FLC, test it, and generating a control surface while treating it as a two dimensional table.In addition to that, a graphical user interface (GUI) is designed to monitor the system parameters and response.The control unit with both fixed output gain obtained by trial and error and self tuning output gain is designed using VHDL (very high speed integrated circuit hardware description language) in order to implement it in the FPGA (field programming gate array).
Many researches and works have been done and published about fuzzy controllers.In 1997, J. Matas, L. G. de Vicufia and M. Castilla, presented a monolithic fuzzy controller based on the approximation by planes of the control surface created by the interaction of rules with fuzzy sets.The approximated control surface allows to obtain the control action directly.This controller is specially adequate to control systems where the fast response in control loop is necessary [6].In 1999, R. K. Mudi and N. R. Pal, proposed a simple but robust model independent self-tuning scheme for FLCs.The output scaling factor is adjusted on-line by fuzzy rules according to the current trend of the controlled process.The rule base for tuning the output scaling factor is defined on error and change in error of the controlled variable using the most natural and unbiased membership functions [7].In 2005, H. Zhuang and S. Wongsoontorn, presented a method for the design and tuning of FLCs through modifying their control surfaces.The method can be summarized as follows.First, fuzzy control surfaces are modeled with Bezier functions.Shapes of the control surface are then adjusted through varying Bezier parameters.A genetic algorithm is used to search for the optimal set of parameters based on the control performance criteria [8].In 2008, S. N. Abd Alrazaaq, developed an adaptation mechanism for fuzzy controllers in order to perfect the response performance against different dynamic operating conditions.The control system has been constructed from two main parts: a basic fuzzy controller designed to produces the output control signal , and three supervisor fuzzy controllers designed to continuously adjust , online, the input and output scaling factors of the basic fuzzy controller [9].

Basic fuzzy controller design:
The design of a fuzzy logic controller needs the selections of such control elements and parameters as scaling factors for input/output signals, a set of rule base, fuzzification and defuzzification methods and operations for the fuzzy reasoning, which include an implication, compositional and aggregation operations of antecedents and consequents [10].The Labview software is used to design the controller using PID and fuzzy logic toolkit which enables integrating a fuzzy controller into virtual instrument environment.This controller has been designed with two inputs position error (e(k)) and change of position error (  e(k)) and a single output (u(k)) representing the control signal to the motor as shown in figure (1) where The relationships between the scaling factors and the input and output variables of the fuzzy controller are: The seven triangular input and output member ship functions are adopted for the controller are shown in the figure (2).For the system under study the universe of discourse for both e(k) and  e(k) may be normalized to be within the range [-1,1], and the linguistic labels are {NB, NM, NS, ZO, PS, PM, PB}.

Figure (2): Membership function for E, ΔE, and u
The controller action is based on Mamdani fuzzy type, center of gravity defuzzification method with min-max inference engine.The rules which state the relationship between the input domain fuzzy sets and output domain fuzzy sets can be derived from a step response curve of a closed-loop system [11] and are represented in a tabular form as shown in table (1).The input factor Ge and Gce shown in figure (1) are used to map the real measured variables from potentiometer into values in the universe of discourse (UOD) span before fuzzy reasoning.The controller crisp output should be translated to the basic domain accepted by the D.C. motor which is accomplished by the output factor Gu.
Table (1): Rule base for basic fuzzy controller

Control surface:
With two inputs one output the input-output mapping is a surface.Figure (3) depicts a control surface that represents the relationship between error E(k) and change in error Δe(k) on the input side, and controller output u on the output side results from a fuzzy controller designed in section 2.
The control surface is treated as a FCT.In a table based controller, the relation between all input combinations and their corresponding outputs are arranged in a table.With two inputs one output, the table is a two-dimensional lookup table (2D-FCT) [12].The resolution of each input has its effect on the shape of the control surface.Figure (5) shows the control surface obtained using different resolutions.

Self tuning Fuzzy logic Controller:
FLC is called adaptive if any one of its tunable parameters (scaling factors, membership functions, and rules) changes when the controller is being used, otherwise it is not adaptive or it is a conventional FLC.An adaptive FLC that fine tunes an already working controller by modifying either its membership functions or scaling factors or both of them is called a selftuning FLC [7].On the other hand, when a FLC is tuned by automatically changing its rules it is then called a self-organizing FLC [7] [13].Since the proposed FLC is tuned by modifying the output gain of an existing FLC depending on the present value of error and change in error we describe it as a self-tuning FLC.The block diagram of the proposed self tuning FLC is shown in figure (6).
All membership functions for controller inputs (E and  E) and controller output (U) are defined on the common normalized domain [-1,1] as shown in figure (2) whereas the membership functions for the gain factor (  ) is defined on the normalized domain [0,1] as illustrated in figure (7).The rule base in table 2 is used for the computation of  [7].The relationships between the output gain and the output variables of the self tuning FLC becomes as in equation ( 6).

Fuzzy Control System Structure:
The whole system structure is shown in figure (8) which is composed from the following units and parts.

A. D.C servo motor:
The D.C servo motor with unknown parameters used in this paper is connected to a 40:1 gearbox, the gearbox is connected to a flywheel, with a degree scale on it, and to a sensing potentiometer.The feed back signal from the sensing potentiometer tells where the flywheel is positioned [14].
Figure ( 8): Fuzzy control system structure B. ADC0804: Is a CMOS 8-bit successive approximation A/D converter which uses a differential potentiometer ladder.This type of converter is easy to interface to a microprocessor, or operates as "stand alone'' (minimum interfacing logic is needed) [15].The device is operated in the free-running mode by connecting INTR to the WR input with CS=0 as shown in figure (9).To ensure start-up under all possible conditions, an external WR pulse is required during the first power-up cycle.C. DAC0800: The DAC0800 series are monolithic 8-bit high speed current output digital-to-analog converters (DAC) featuring typical settling times of 100 ns [16].

Tests and Results:
The designed control system is used practically for real time position control via D.C. servo motor.In order to compare the response with different scaling values for the inputs of the fuzzy controller unit shown in figure (12), the performance parameters such as rise time, settling time, overshoot, and steady state error are tested.The input quantization factors Ge and Gce values are set to (0.25) obtained using equations ( 7) and (8).On the other hand the output scaling factor Gu is set to (40) obtained by trial and error procedure.

   e e
To evaluate the controller performance, several position tracks are applied and the controller is tested and the results are presented in figures (14), and (15).Tables (4) and ( 5) reveal numerically the measurements.

Conclusions:
The main contribution of this work is the FPGA implementation of a fuzzy control surface as 2D FCT, with different sizes, and using it for position control via a D.C. servo motor to study how different number of bits affects the performance.Implementing different table resolutions shows that a small number of bits is enough to design a satisfactory controller.A cheap digital to analog and analog to digital converters ( 8bit ) are used to construct the controller to keep it simple, cheap, and practical.On the other hand, converters with higher resolutions ( 12bit ) are used to monitor the response of the controller ( being available in the data acquisition card used ) by the GUI which is designed and implemented to laboratory testing and experimenting with the designed controller yet it is not considered a part of the designed controller.The table based controller implementation dramatically improves execution speed, as the run-time inference is reduced to a table look-up which is a lot faster.Due to the fact that tuning scaling factor is difficult to set with an iterative manual process, a supervisor fuzzy controller is applied to automatically adjust the output scaling factor of the basic fuzzy controller, where the effective tuning time decreases using this approach.On the other hand, continuous tuning in real time adapts the system to variable needs and requirements.The design of FCT allows their future utilization to implement any fuzzy controller for other real time applications.The results indicate that it is really feasible to implement real time fuzzy controllers in low cost FPGAs, like the Spartan 3 family from Xilinx.However, the controller example adopted in this paper suffers from a main disadvantage when a new change in angle is very small ( below 3 degrees in both directions) the controller output fails to activate the motor because a very small applied voltage is not sufficient to overcome the moment of inertia of the motor from a standstill.This disadvantage may suggest a further research work to overcome this handicap.

Figure ( 1 )
Figure (1): Block diagram of a fuzzy control system

Figure ( 5 )
Figure (5): Different size 8x8, 16x16, 32x32, and 64x64 FCT Unit GUI: Labview program is used to implement GUI which supplies the controller with the value of a set point and receives the feedback signal from the potentiometer through NI PCI-6251 National semiconductor data acquisition card.It helps displaying the system real time response, measuring performance parameters such as rise time, settling time, overshoot, and steady state error.Figure(10) and(11), illustrate the front panel and block diagram of GUI respectively.