## 3 Fuzzy Logic Controller Design  
Due to the non-linear dynamics presented by the MLS [44], FLC is applied for maintaining a ferromagnetic sphere at a specific vertical position \(r\), providing two advantages: A simple and robust non-linear control system and, an easy to implement controller since it is based on the linguistic description of the global system behavior [8]. The FLC consists of three main modules: The fuzzification process module which takes the inputs to the controller and produces a degree of membership for each fuzzy set in the membership function, the inference engine which takes these fuzzy set memberships and determines which rules should be evaluated, and the defuzzification process which takes the output values from the inference mechanism and translates them into an output dispatch signal [8; 35; 38; 39]. Mamdani-based inference and defuzzification of the center of gravity are used in this paper.  
A simple proportional-derivative (P-D) FLC type is chosen. The first input of the FLC is the position error, which represents the error between the desired sphere height and the actual sphere height. The second input of the FLC is the derivative of error, which indicates whether a positive/negative variation of the position is progressing or not. The controller will use this information to decide whether a high/low control action is needed to accomplish a predefined group of performance parameters or not. The output of the FLC is the control signal, which represents the control signal injected to the electromagnet of the MLS. The controller will use this information to decide a higher/lower control signal according to the value of its input.  
The MF used for input and output data are shown in Figure 3 and the rules to be evaluated are given in Table 1, leading to a simple 25 rules FLC to reduce the controller computational complexity  
Figure 1: Control system structure for magnetic levitation system (MLS) using fuzzy logic control (FLC).  
Figure 2: MLS model representation in Simulink.  
and facilitate a subsequent implementation. At the beginning, following a current preset practice of the FLC parameters, five triangular MF, uniformly distributed, are assigned to the FLC inputs and output, whereas the initial RB is defined according to the heuristic knowledge of the MLS performance and corresponds to a standard P-D based FLC.  
For MF, \"NB\" represents the \"Negative Big\" fuzzy set, \"NS\" represents the \"Negative Small\" fuzzy set, \"ZE\" represents the \"Zero\" fuzzy set, \"PS\" represents the \"Positive Small\" fuzzy set and \"PB\" represents the \"Positive Big\" fuzzy set.  
The CS algorithm used to optimize the MF for the input and output and the RB of the FLC are discussed next.  
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline \multirow{2}{*}{**Control Signal**} & \multicolumn{6}{c}{**Position Error**} \\ \cline{2-7}  & & **NB** & **NS** & **ZE** & **PS** & **PB** \\ \hline \multirow{5}{*}{Derivative of error} & NB & PB & PB & PS & PS & ZE \\  & NS & PB & PS & PS & ZE & NS \\ \cline{1-1}  & ZE & PS & PS & ZE & NS & NS \\ \cline{1-1}  & PS & PS & ZE & NS & NS & NB \\ \cline{1-1}  & PB & ZE & NS & NS & NB & NB \\ \hline \hline \end{tabular}
\end{table}
Table 1: Fuzzy logic initial rules for magnetic levitation system (MLS) control.  
Figure 3: Membership functions (MF) used for inputs and output data: (**a**) Position error (input), (**b**) derivative of error (input), (**c**) control signal (output).