Design and Real-Time Implementation of Takagi–Sugeno Fuzzy Controller for Magnetic Levitation Ball System

An integral state feedback control method based on T-S fuzzy model is proposed for nonlinear and unstable magnetic levitation ball system in this paper. Firstly, the fuzzy model of the magnetic levitation ball is derived from the nonlinear dynamic model by using the sector nonlinearity, and the local controller is designed by using the integral state feedback control. The global controller is constructed by a parallel distributed compensation (PDC) method, and the feedback gain is obtained using a linear matrix inequality (LMI). Finally, the integrated state feedback controller is applied to the position control of the magnetic levitation ball system, and a dSPACE real-time control platform is established for experimental research. The simulation and experiment are performed to prove that the designed controller can levitate the ball stably, and has better control performance.


I. INTRODUCTION
Magnetic levitation technology applies magnetic force to overcome gravity to suspend a magnetic object. Compared with other technologies, this technology has the advantages of no friction, no lubrication, low noise, long life and cleanliness due to the zero mechanical contact between the suspension and the support. In the research of magnetic levitation technology, the single-degree-of-freedom magnetic levitation ball system is a simplification of other complex magnetic levitation systems. It is a simple and effective research object to study magnetic levitation technology with its simple structure and easy to implementation. It is also the basis for studying multi-degree-of-freedom magnetic levitation control system.
With the development of control theory, there are more and more control methods for magnetic levitation systems. In order to obtain better control effects, the control algorithms are becoming more and more complicated. In [1], [2], the parameters of the PID controller are optimized by the grey wolf optimizer and teaching learning based optimization.
The associate editor coordinating the review of this manuscript and approving it for publication was Ning Sun . In order to solve the problem of poor robustness caused by the feedback linearization strategy in [3], an overall sliding mode control using the H∞ method is proposed. In [4], the mixed sensitivity design method is adopted for H∞ controller synthesis, and a robust feedback controller is designed to meet robustness against model uncertainties. In [5], it proposes a decentralized PID control for the magnetic levitation system, and utilizes the extremum seeking (ES) method to tune PID parameters on-line to improve the steady-state performance of the system with few oscillations. In [6], model reference adaptive control (MRAC) is used for closed loop fractional-order PID (FOPID) control of a magnetic levitation (ML) system. In [7], a novel 2-DOF fractionalorder controller with inherent anti-windup capability is proposed and is applied in a magnetic levitation system (MLS). In [8], four novel controllers called fractional static sliding mode controller, fractional integral static sliding mode controller, fractional dynamic sliding mode controller and fractional integral dynamic sliding mode controller are proposed and and is applied in a magnetic levitation system. In [9], an optimization procedure based on the CS(cuckoo search) algorithm is presented to optimize all the parameters of the VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see http://creativecommons.org/licenses/by/4.0/ fuzzy logic control which involve not only the membership functions positions but also the rule base and it is applied to a nonlinear magnetic levitation system. In [10], a sliding mode controller (SMC) is designed to regulate the current, which in turn controls the position through an electromagnet. Literature [11], to improve the suspension control performance of maglev trains,an adaptive neural-fuzzy sliding mode controller ANFSMC is presented using a sliding surface, an adaptive-fuzzy estimator and a neural-fuzzy switching law to handle disturbances, and nonlinear and unmatched uncertainties in the system. The principles of the SMC and the approximation capability of the fuzzy systems are utilized to compensate for the adaptive approximation error, and the neural-fuzzy switching law is employed to reduce the chattering. In [12], a novel nonlinear position-stabilizing controller for magnetic levitation is proposed by combining the active damping injection technique and disturbance observers (DOBs). In [13], in view of the wide application of the internet of things (IoT) in intelligent transportation, a new method for realizing suspension control for mediumlow-speed maglev trains using the IoT and an adaptive fuzzy controller is proposed.
In 1985, Japanese scholars Takagi and Sugeno proposed a fuzzy system identification method, referred to as the T-S fuzzy model. The T-S fuzzy model is described by fuzzy IF-THEN rules which represent local linear input-output relations of a nonlinear system. The main feature of a T-S fuzzy model is to express the local dynamics of each fuzzy implication rule by a linear system model. The overall fuzzy model of the system is achieved by fuzzy ''blending'' of the linear system models. The mathematical modeling of the T-S fuzzy model is more accurate than traditional fuzzy model [14]. In [15], based on the obtained T-S fuzzy model, a fuzzy state feedback controller is used to ensure the required mixed performance of original electromagnetic suspension system to be achieved. In [16], A fuzzy H∞ robust state feedback controller for magnetic levitation systems is designed based on parallel distribution compensation (PDC) design method and the proposed T-S model. In [17], a switched fuzzy controller is proposes and a magnetic levitation system is modeled by two self-organizing neural-fuzzy techniques to achieve linear and affine Takagi-Sugeno (T-S) fuzzy systems(more freedom than linear T-S model). Combining the algorithm with input and output data for structural identification and parameter identification, the process is cumbersome and computationally intensive, and is suitable for systems with unclear physical models.
The main contributions of the paper are as follows. Firstly, the T-S fuzzy model is established for the magnetic levitation ball system by the method of sector nonlinearity. Based on the T-S fuzzy model, a parallel distributed compensation (PDC) method is applied to design the integral state feedback controller, and the stability of the control algorithm was proved using Lyapunov's theorem. Secondly, a realtime control experiment platform are designed based on dSPACE, which can conveniently complete the verification of the control algorithm. The proposed integral state feedback controller has better control performance for the magnetic levitation ball system. The remainder of this paper is organized as follows. In Section II, the dynamic model of the magnetic levitation ball system is presented. Section III presents an Integral controller based on the T-S fuzzy model for the magnetic levitation ball system. Section IV provides provides simulation and experimental results. Section V gives the conclusions.

II. MODELING AND ANALYSIS OF MAGNETIC LEVITATION SYSTEM A. MAGNETIC LEVITATION BALL DEVICE
This paper uses the Googoltech GML1001 magnetic levitation ball experimental device. The structure of the control system is shown in Figure 1, and the control system structure is mainly composed of power amplifier circuit, electromagnet, small ball, light source and photoelectric sensor. The experimental device controls the movement or suspension of the ball in the vertical direction by adjusting the current in the coil of the electromagnet.

B. MATHEMATICAL MODEL OF THE MAGNETIC LEVITATION SYSTEM
Since the magnetic levitation ball system is a complex nonlinear system, especially when analyzing the magnetic circuit of electromagnet, there are many uncertain factors, and some interference factors are ignored in the modeling process.
Dynamic analysis of the system: According to Newton's second law, the controlled steel ball is only subjected to gravity G and electromagnetic force in the vertical direction without other external disturbances, so the simplest nonlinear model in terms of ball position and electromagnetic coil current i is given by where m is the mass of the steel ball, g is the acceleration of gravity, x is the distance from the center of the ball to the lower surface of the electromagnet, and i is the current in the coil of the electromagnet.
(1) The electromagnetic force that the controlled steel ball receives in the magnetic field is: where µ 0 is the magnetic permeability in the air, N is the number of turns of the electromagnet coil, A is the crosssectional area of the solenoid, and is the electromagnetic force constant.
(2) System equilibrium point equation: where x 0 is a certain equilibrium position in space, i 0 is the current in the coil at the equilibrium position of the steel ball.
(3) The power amplifier circuit adopts a voltage-current type amplifier, and the input voltage is approximately linear with the input current in the normal working range, and the expression is k a is the power amplifier gain.
In summary, the system state space model can be given as: In the actual control system, the input voltage u of the power amplifier circuit is used as the control amount, and the system output u out is the output voltage of the sensor post-processing circuit. Select the state variable x 1 = u out , x 2 =ẋ 1 = u out , y = x 1 , the system's state space expression is: k s and k a are the sensor output voltage gain and the power amplifier gain, respectively.

III. INTEGRAL T-S FUZZY CONTROL
It is well known that by using conventional state feedback control, there be a steady state error in closed loop system. In order to improve the performances of the conventional state feedback control, a new state has been introduceḋ x e = (x 0 − x 1 (t))dt (9) Combining (8) with the general system, the augmented dynamics becomes Taking coordinate translation on an equilibrium point is necessary for the stability analysis.
Here the sensor output voltage at the equilibrium point Define the augmented state vectorx(t) = x x e T . The following augmentation system can be obtained from equations (10) and (11).
From the nonlinear dynamic equation of the magnetic levitation system of expression (12), the T-S fuzzy model of the system is derived by the method of ''sector nonlinearity''. For equation (12), define two nonlinear terms, Next, calculate the maximum and minimum values of z 1 (t) and z 2 (t) underx ∈ (−∂, ∂). They are obtained as follows: max z 1 (t) = m 1 , min z 1 (t) = m 2 max z 2 (t) = n 1 , min z 2 (t) = n 2 From the maximum and minimum values, z 1 (t) and z 2 (t) can be represented by z 1 (t) = M 1 (z 1 (t)) · m 1 + M 2 (z 1 (t)) · m 2 z 2 (t) = N 1 (z 2 (t)) · n 1 + N 2 (z 2 (t)) · n 2 (15) where M 1 (z 1 (t)) + M 2 (z 1 (t)) = 1 N 1 (z 2 (t)) + N 2 (z 2 (t)) = 1 Therefore the membership functions can be calculated as: Figure 2 shows the membership functions. The augmented T-S fuzzy system can be used to describe the magnetic levitation ball system: The augmented T-S fuzzy system can be expressed aṡ Here, For the T-S fuzzy system (18), using the PDC, the integrated T-S fuzzy controller is designed by: . . , r, r = 4 The overall fuzzy controller is presented by Substituting (21) into (18), and defining G ij =Ã i −B i K j , i < j, we obtain: Theorem 1: The equilibrium of a fuzzy system (16) is globally asymptotically stable if there exists a common positive definite matrix P such that Proof: Proof of Theorem 1 is derived using a quadratic function V (x(t)) =x T (t)Px(t).where P is the positive definite symmetric matrix.Then, If there exists a P > 0 and condition (23) holds such thaṫ V (x(t)) =ẋ(t) T Px(t)+x(t) T Pẋ(t) < 0 proves the stability of system (22), and system (22) is also said to be quadratically stable. Theorem 1 thus presents a sufficient condition for the quadratic stability of system.
Using these LMI conditions, we define a stable fuzzy controller design problem. Define X = P −1 , M i = F i X , then (23) can be expressed as the following linear matrix inequality:

IV. SIMULATION AND EXPERIMENT
In order to verify the effectiveness of the designed controller, the simulation was first performed on MATLAB/Simulink, and then the experimental research was carried out using the dSPACE platform. The physical model parameters of the magnetic levitation ball system are shown in Table 1.

A. SIMULATION RESEARCH
According to the parameters of the magnetic levitation ball system, it can be calculated: Step response of different controllers. m 1 = 1523.6705, m 2 = 705.4920, n 1 = 3638.6365, n 2 = 1310.2592 Therefore, by using YALMIP, we can solve the LMI of (24) and obtain the controller gain matrix of the PDC as follows:   Table 2. Select the overshoot, rise time, peak time, and stability time as performance indicators of the system.

B. EXPERIMENTAL RESEARCH ON DSPACE
dSPACE (Digital Signal Processing and Control Engineering) real-time simulation system is a set of control system development and test work platform based on MATLAB/ Simulink. Its real-time system includes hardware system  with high-speed computing capability and easy-to-use realtime code generation, downloading, testing and debugging software ControlDesk. dSPACE hardware is mainly divided into single board system, component system and other accessories. The single board system integrates the processor CPU and peripheral I/O circuits into one board to form a complete real-time simulation system. The DS1103 controller board is the most powerful and I/O-rich development system in the current single-board system. It can meet the needs of users for rapid control prototyping. ControlDesk is a virtual instrument-based comprehensive experimental environment developed by dSPACE. It provides many virtual interfaces, allowing users to access or modify the parameters of real-time models at any time during operation. ControlDesk window is shown in Figure 4.The real-time control platform is shown in Figure 5.
dSPACE provides a set of computer-aided control system design CDP (Control Development Package) for control system development. CDP mainly includes MATLAB, Simulink, RTW, RTI and dSPACE series software tools. MATLAB can  analyze, design, optimize system model; Simulink can build a block diagram of the system and perform offline simulation; configure the system I/O through the RTI library to connect the magnetic float experimental device to the control loop; RTW will generate real-time control block diagram to gener-     levitation ball control algorithm based on dSPACE is shown in Figure 6.
The real-time control block diagram of the magnetic levitation ball system based on dSPACE is shown in Figure 7. When the given voltage is −3V, the ball can be stabilized at 0.02m from the lower surface of the magnet. The position output curve of the system is shown in Figure 8, and the performance index is shown in Table 3.
In order to verify the robustness of the controllers, at 12th second, another small ball is added, and the position of the ball changes as shown in Figure 9. Tracking of sinusoidal signals of controller based on T-S integral state feedback as shown in Figure 10. The suspension of the balls in the experiment is shown in Figure 11.
The real-time response of the magnetic levitation system with PID, state feedback controller, integral state feedback controller has been compared and summarized in Table 3, which reflects the superiority of the integral state feedback controller based T-S fuzzy model over PID controllers and state feedback controller in generating better transient response. The integral state feedback controller not only enables the ball to be quickly and stably suspended, but also has the advantage of no overshoot. In particular, when another ball is added, the controller can still achieve stable suspension of the ball after a short adjustment, and has good robustness.

V. CONCLUSION
Based on the analysis of the structure and working principle of the magnetic levitation ball system, the T-S fuzzy model of the system is established for the nonlinear characteristics of system. The integral state feedback controllers based on T-S fuzzy model is designed by PDC and LMI, and the stability of the closed-loop system is judged by Lyapunov stability theorem. Finally, the real-time control platform of the magnetic levitation ball system built by dSPACE software and hardware environment is used for experimental verification. Compared with the PID controller and state feedback controller for given system, the simulation and experimental results show that the controller proposed can stabilize the steel ball and has better control performance.