Particle Swarm Sliding Mode-Fuzzy PID Control Based on Maglev System

The magnetic levitation system is a typical open-loop unstable system. To weaken the chattering phenomenon of sliding mode control (SMC), a hybrid control strategy of particle swarm sliding mode-fuzzy PID control was designed. This strategy uses particle swarm optimization (PSO) to optimize the SMC using the method of exponential approach law, so as to obtain the best sliding mode surface parameters and exponential approach rate coefficients, thus shortening the time required to approach the stable region when the nonlinear system is far from the stable point; a state supervision controller was designed by analyzing the stable conditions of sliding mode. When the system approaches the stable region, it smoothly transitions to fuzzy PID control, thereby weakening the chattering phenomenon of SMC. To verify the dynamic performance of the designed algorithm, a magnetic levitation ball system was selected as the controlled object. Through simulation and experiment, it was verified that the controller had strong robustness and strong anti-interference performance. It effectively weakened the chattering and had good adaptability to external disturbance and state variable crossing.


I. INTRODUCTION
The magnetic levitation system has the advantages of no contact and no friction. It has broad application prospects in transportation, aerospace, life medicine and other fields.
However, the open-loop instability and nonlinear characteristics of the system increase the difficulty of system control, and the system control algorithm requires higher requirements. Therefore, the research on the control algorithm of the magnetic levitation system has very important theoretical value and practical significance.
In practical applications, as the requirements for fast dynamic response, steady-state accuracy, and antiinterference ability of the system increase, quite a few scholars have proposed various advanced control methods [1]- [5]. The structure of fuzzy control rules is simple, which reduces the complexity of algorithm design and has strong robustness. In addition, the fuzzy PID control formed by the combination of fuzzy control and PID control has the characteristics of convenient use and strong adaptability [6], so it The associate editor coordinating the review of this manuscript and approving it for publication was Kashif Sharif . has been widely used in various control systems [7], [8]. Literature [9] applied fuzzy PID to power system frequency control, fuzzy control was used to fuzzify the input and output parameters and adjusted the PID control output online. Compared with ordinary PID control, the designed algorithm had stronger anti-disturbance ability, but there were overshoot phenomenon and large steady-state errors. Literature [10] combined fuzzy control with IoT for real-time control of maglev trains, which has more stable performance compared to PID, but the designed fuzzy rules have a small adaptation surface. Literature [11] proposed a neuro-fuzzy SMC, which reduces the effect of parameter uptake. However, the slow online learning speed of neural networks increases the computational complexity. Literature [12] proposed an adaptive fuzzy PID control for nonlinear system. The addition of a fuzzy compensation controller made up for the gap with an ideal state. In addition, the PSO was used to optimize the learning rate of adaptive PID control algorithm, the designed algorithm was applied to the system and has good dynamic performance. But the anti-interference ability of the control algorithm still needs to be strengthened. SMC has strong robustness and has been one of the most VOLUME 9, 2021 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ efficiently utilized control schemes for uncertain systems [13], but due to the factors such as time or space lag and the influence of system inertia, the SMC system is prone to chatter. As the nonlinearity of the system raises, it will seriously affect the control performance of the controller [14]. Literature [15] proposed a sliding mode adaptive controller, which improves the robustness of the system compared with SMC, but there is an obvious chattering phenomenon. To maintain the superiority of SMC while reducing chattering as much as possible, many scholars have done a lot of research [16]- [19]. Literature [20] proposed a fuzzy sliding mode control (FSMC) method. To reduce chattering, the combination of reaching law and fuzzy switching gain was applied to the control algorithm, which improved the dynamic performance of the system, but there was a case of excessive overshoot. Literature [21] divided the traditional SMC into switching control and equivalent control. When the system was far from the equilibrium point, the stable region was approached by SMC; after the system reached the stable region, fuzzy control was used to adjust the switching control online to reduce its weight in SMC, and genetic algorithm was used to optimize the membership function in fuzzy control, the chattering was effectively weakened and the system control accuracy was improved. But the designed control algorithm was cumbersome and computationally expensive. Literature [22] designed a FSMC based on evolutionary programming for a maglev ball system, the optimal input and output gains of FSMC were determined through evolutionary programming, which greatly reduced the times of trial and error to determine parameters compared with traditional FSMC. Good position tracking performance could be maintained even when the quality of the ball changed. But the chattering problem of SMC had not been well solved. For SMC and fuzzy control, there are obvious advantages and disadvantages. Combining the two methods in an appropriate way and optimizing the SMC parameters would result in a controller with good performance.
To achieve the purpose of reducing the chattering of the SMC as much as possible while maintaining the fast response speed of the SMC and the strong robustness of the fuzzy PID, a new method of hybrid control based on PSO sliding mode and fuzzy PID was proposed. The particle swarm algorithm was used to optimize the sliding mode parameters using the exponential reaching law method. When the nonlinear system is far from the stable point, the SMC is used to quickly approach the stable region. A state supervision controller was designed by analyzing the stability conditions of the sliding mode. Its function is to smoothly transit to the fuzzy PID control when the system approaches the stable region, thereby weakening the chattering phenomenon of the SMC. To verify the dynamic performance of the designed algorithm, the control object of a magnetic levitation ball system was selected, and through simulation and experiment, it was verified that the controller had strong robustness and weakened chattering effectively, and had good adaptability to external interference and state variables. The main structure of this paper is as follows: Section II introduces the maglev system and analyzes the designed control algorithm process; The simulation results of the designed control algorithm are presented in Section III; Section IV is the experimental results and the comparison between the tracking performance of the designed control algorithm and the SMC; Finally, the main conclusion of this paper is shown in Section V. Fig. 1 is a diagram of a simple magnetic levitation system. The maglev system is mainly composed of electromagnet, track, position sensor, power amplifier circuit, and control parts. In Fig. 1, mg is the gravity of the electromagnet, F(i, z) is the suspension force of the electromagnet, and z is the air gap length. Passing a certain current through the coil turns of the electromagnet will generate electromagnetic force. By adjusting the current in the windings to balance the electromagnetic force and gravity, the electromagnet can stably suspend in the set position.

A. MAGNETIC LEVITATION SYSTEM
For a simple maglev system, define the system input and output as the electromagnet voltage and displacement respectively, and select the electromagnet displacement and speed as the state variables. The system state equations can be expressed as: In the expression of electromagnet displacement derivative, A11 and A12 respectively represent the variation coefficient of electromagnet displacement and velocity; B1 is the coefficient of input voltage. In the expression of electromagnet velocity derivative, A21 and A22 respectively represent the variation coefficient of electromagnet displacement and velocity; B2 is the coefficient of input voltage.

B. OVERVIEW OF THE PROPOSED CONTROL ALGORITHM
The control algorithm designed for the magnetic levitation system is shown in Fig. 2: The entire control strategy is composed of a combination of SMC based on exponential reaching law and fuzzy PID control. In the SMC part, the sliding mode surface parameter c and exponential reaching law parameters ε, n are optimized through particle swarm algorithm. So as to shorten the time to reach the sliding surface and to achieve a smooth transition between SMC and fuzzy PID control, a supervisory controller is designed based on the Lyapunov stability principle by analyzing the state of sliding mode. When the system state is approaching the stable region, the SMC is gradually switched to fuzzy PID control. The fuzzy PID control part takes the error e and the error change rate de as input, and uses the fuzzy inference method to adjust the PID parameters according to the fuzzy rule library.

C. SLIDING MODE CONTROLLER
For the second-order system of magnetic levitation, firstly determine its sliding surface, so that the motion on the sliding surface has excellent motion quality. To improve the real-time control and the simplicity of the design, the switching function of the SMC is defined as: Tracking error e = [e,ė] T ; let C = [c, 1], where the coefficient c is selected to gratify Hurwitz polynomial. One can get: Let the command signal be r, one can get: SMC satisfies the requirement of reaching the switching surface from any point within a limited time, and there is no specific plan for the approaching movement route. To improve the dynamic quality of the approaching route, the method of exponential approach law was adopted.
In (6),ṡ = −ns is the exponential approach term, and the solution is s = s(0)e −nt . n is the coefficient of the exponential approach term; ε is the coefficient of the constant velocity approach term.
The symbolic function sgn(s) is defined as: Knowing from (4) and from the formula of sliding mode exponential reaching law, one can get: s is expressed as: Combining (1) and (9), the output u h of the SMC part can be obtained as: To weaken the chattering phenomenon of the controller on the sliding mode surface, a state supervisory controller u j was designed. Its purpose is to smooth the transition when the sliding mode function s tends to a certain value in the neighborhood of zero. The boundary layer with thickness ϕ is selected near the sliding mode surface, namely when s > ϕ, the control strategy u = u h + u j ; when s ϕ, fuzzy PID acts on the system. In this way, when the moving point of the system reaches the vicinity of the sliding surface, the switching is changed to a smooth transition, which avoids chattering. The supervisory controller u j is designed as: (s) is designed as: Define the Lyapunov function as: To satisfy the existence and reachability of sliding mode, the generalized sliding mode reachability condition must be satisfied:V After adding the supervisory controller to the control system, there are: Since the control input is a constant value in the suspension system, the differential equation of sliding motion is obtained: We observe thatV ≤ 0, that is, under the supervision control, the SMC system is still stable. And the total output u of SMC is obtained at this time:

E. PARTICLE SWARM OPTIMIZATION SLIDING MODE CONTROLLER
PSO searches the optimal solution in complex space through cooperation and competition between individuals. The basic steps are: select the parameters to be optimized, initialize the particle swarm and parameter settings, establish the fitness function, and update the particle swarm. Compared with the genetic algorithm, particle swarm algorithm has higher randomness and faster convergence speed. Suppose the particle swarm is searched in an n-dimensional space, the position of the particle in the space can be expressed as . . , v in ) represents the particle velocity. The PSO algorithm formulas are: In (18) and (19), x id (k), v id (k) refers to the position and the velocity of particle i on the dth dimension respectively in the kth iteration; P pb (k), P gb (k)− the optimal position of individual and global particles; c 1 , c 2 − learning factor; w, k−inertia factor and number of iterations; N 1, N 2−random numbers between 0 and 1.
To further improve the calculation speed of PSO, w was optimized at the same time. When the w is large, it has a strong global optimization ability, which is conducive to finding the global optimal solution; when the w is small, it has a strong local optimization ability, which is conducive to the convergence of the algorithm. For comprehensive consideration: In (20), w start and w end are the initial inertia weight and the inertia weight when iterating to the maximum number of times respectively; k is the current iteration algebra; maxgen is the maximum number of iterations, hence the w is a function of the k.
For the exponential approaching law, the parameters ε and n can be appropriately selected to ensure the rapidity of the arrival segment and suppress high-frequency vibration. However, to reduce the impact of high-frequency vibration on the system, a minor value of ε must be selected. It will make the system enter the sliding mode longer and reduce the robustness of SMC. Increasing n can speed up the approach speed, but when it is a long way from the sliding mode surface, it will heighten the required control intensity, causing high frequency vibration; while reducing n makes the time to approach the sliding mode longer. The reasonable choice of coefficients in SMC would have an important impact on system performance.
To overcome the high-frequency tremor caused by the conventional exponential reaching law, ε, c, and n in (10) were optimized by the PSO algorithm. The algorithm used a velocity-position search model. The particle flies at a certain speed in the space, and the speed was dynamically adjusted according to individual experience and group experience.
The steps of PSO designed SMC parameters were as follows: 1) Initialize particle position and velocity.
2) Evaluate the fitness of each particle, set the objective function as: Take the fitness function as: The fitness function uses Integral time absolute error (ITAE) as an indicator. The smaller the fitness function, the better the individual. Therefore, take the parameter value corresponding to the minimum fitness function.
3) Compare the fitness value of the particle with its passing Pbest, if it is better, use it as the current best position 4) Compare the fitness value of the particle with the global experience of Gbest, if it is better, set it to the best global position 5) Change the speed and position of particles according to (18) and (19). 6) If the end condition is not reached, return to 2) and continue the loop.

F. FUZZY PID CONTROLLER
To weaken the sliding mode chattering phenomenon and enhance the system's ability to cope with external interference, the SMC is combined with the fuzzy PID control.
Through the characteristics of the size, direction, and change trend of the system deviation, the fuzzy PID controller can make fuzzy inferences based on the fuzzy rule library. In this way, PID parameter self-tuning can be realized, thereby enhancing the dynamic response-ability of the system and achieving a more satisfactory control effect.
The fuzzy control takes the error e (the distance of the electromagnet from the balance position) and the error change rate de as input. In the light of the fuzzy rule library, output parameters are adjusted by the fuzzy inference method, so that the controlled object has excellent static and dynamic performance. The adjustment parameters are changed as follows: The fuzzy PID control output u p is: In (24), e is the error. The membership function of the input variable and the output variable are selected as a triangle. The membership function is uniformly distributed. The method of defuzzification is the center of gravity method. The control rules are the conventional 49 fuzzy control rules. The comprehensively designed controller is:

III. SIMULATION
To verify the dynamic characteristics and tracking performance of the designed algorithm in the maglev system, a maglev ball system model is taken as the controlled object, and the system input is defined as the electromagnet voltage and the output is the ball displacement.
In the case of ignoring other interference forces received by the ball, select displacement and velocity of the ball as the state variables, and substitute the actual physical parameters of the maglev system to obtain the system state equation.
The model parameters of the system are shown in Table 1: Based on the system's dynamic equations, electrical and mechanical correlation equations, boundary equations, and electrical equations, the system shown in Fig. 9 is modeled and analyzed [23], [24]. For this magnetic levitation system, the transfer function expression is: And E = i0/2g, F = i0/x0. Substituting the data in Table 1 can get: After substituting the actual parameters, the system transfer function is obtained as: According to the model, the simulink module in matlab was employed for simulation.
In the particle swarm algorithm, the number of particles is 100, the number of iterations is 50, and the dimension is 3. The selected coefficients n, ε, and c are searched by the PSO as 64.27, 5.2, 46, respectively, and Fig. 3 shows the change curve of fitness function.
One can observe that the particles reached the optimal state in the 36th generation. Obtain proper PID initial parameters   through trial and error methods. K p0 , K i0 , K d0 are taken as: 8, 10, 0.5, respectively. In (20), w star = 0.9, w end = 0.4.
The linguistic variables, basic domain, fuzzy subset, fuzzy domain and proportional parameters of input variables and output variables are shown in Table 2. Fuzzy PID control rules are shown in Table 3.
The input variables of the fuzzy controller select the displacement deviation e and the deviation change rate de of the steel ball, and the output variables are the correction amounts of PID parameters k p , k i , k d . Fig. 4 is a diagram of the k p fuzzy surface composition in fuzzy PID. Through Fig. 4, Fig. 5, and Fig. 6, we observed that the fuzzy PID outputs k p , k i , k d changed with e and de. Fig. 5 is a diagram of the k i fuzzy surface composition in fuzzy PID. Fig. 6 is a diagram of the k d fuzzy surface composition in fuzzy PID. VOLUME 9, 2021     Under the mixed control of particle swarm sliding mode and fuzzy PID, the response curve of the gap is shown in Fig. 7 while tracking rectangular wave between 8mm and 12mm.
From Fig. 7, we observe that the system rise time is 0.06s, about 0.08s to reach the equilibrium point and stabilize without overshoot, and there is no chattering phenomenon of the SMC at the equilibrium point.
Based on the data in Tab. 1, the balance current and power amplifier gain of the system are changed appropriately to obtain Eq. (29), and the designed control algorithm is simulated in the case of model mismatch to verify the robustness of the algorithm. The model transfer function becomes: When the model is mismatched, the response curve when tracking the same rectangular wave between 8mm and 12mm is shown in Fig. 8.
When the model is mismatched, the system rise time is 0.068s and there is no overshoot. The controller can still maintain good tracking performance. Through the disturbance response to the designed algorithm and the rectangular wave tracking simulation test in the case of model mismatch, the results show the superiority of this algorithm.
By comparison Fig. 7 and Fig. 8, we observe that the designed algorithm has weakened the chattering problem and improved dynamic performance..

IV. EXPERIMENT
To verify the dynamic performance of the particle swarm sliding mode and fuzzy PID control algorithm, the maglev ball system mentioned above was utilized as the controlled object.
The electromagnetic force is generated by passing current in the electromagnet winding. By controlling the current in  the electromagnet winding, the electromagnetic force generated is balanced with the gravity of the steel ball, so that the steel ball can be stably suspended in the air in an equilibrium state. The magnetic levitation ball system uses MATLAB's Real-Time Windows Target (RTW) and VC++ to compile and generate the system executable VC language, while using PCI1711 data acquisition card to exchange the generated data in real time. The designed control algorithm is used to control the ball online to achieve the purpose of stable levitation of the ball.
The electromagnetic device is composed of steel ball, power amplifier, laser sensor, and electromagnet. In addition, the hardware required for the experimental research includes the upper computer, PCI1711 data acquisition card; the software required for the system includes MATLAB, PCI1711 acquisition card driver, VC++ database, and compiler. The system model is shown in Fig. 9.
Based on the Real-Time Windows Target under MATLAB, the system was tested experimentally. To verify the anti-interference ability and the tracking performance of the control algorithm, firstly set the air gap to 1cm, to test the anti-disturbance ability of the control algorithm, a voltage signal with a value of 0.6 and a duration of 0.3s is added at 20s, and change the air gap to 1.2cm at 25s. Under the same conditions, the SMC and the particle swarm sliding mode-fuzzy PID (PSFP) control are used for position tracking experiments. The ball position output curve is shown in Fig. 10. We observe that the SMC is adjusted to the equilibrium position about 0.3s after being disturbed, and the response time is 0.12s when the equilibrium position changes, after being disturbed, the overshoot is 8.5%, and there is obvious chattering at the equilibrium position.
The designed control algorithm is adjusted to the equilibrium position about 0.2s after being disturbed and can respond quickly when the equilibrium position changes. After being disturbed, the overshoot is 6.7%. Compared with SMC, it weakens chattering and has a stronger anti-interference ability.
To further verify the effectiveness and robustness of the design control algorithm, paste flat pads on the surface of the steel ball. A single flat pad has a diameter of 10mm and a mass of 0.006kg, and the performance of the control algorithm was tested when the number of pastes was 0(case1), 1(case2), and 2(case3) respectively. The experimental results are shown in Fig. 11.
By pasting the flat pads on the steel ball, it can be found that the steel ball can still maintain good levitation performance when the model parameters are appropriately changed, and the designed control algorithm has strong robustness.

V. CONCLUSION
To weaken the chattering of SMC, this paper proposed a new method of particle swarm sliding mode-fuzzy PID hybrid control to improve the robustness of the maglev system and weaken the sliding mode chattering.
Firstly, the particle swarm algorithm was utilized to optimize the sliding mode parameters using the exponential reaching law method, and the speed of approaching the stable region when the nonlinear system is far from the stable point is accelerated. The state supervision controller was designed by analyzing the stability conditions of the sliding mode. When the system is approaching the stable region, it smoothly transitions to fuzzy PID control to achieve high-precision and no static error and weaken the chattering phenomenon of SMC. To verify the dynamic performance of the designed algorithm, a maglev ball system was selected as the controlled object. Through simulation and experiment, it was verified that the designed control method had strong anti-interference and tracking performance. VOLUME 9, 2021 Compared with the traditional SMC, this control method weakens the chattering phenomenon, the quality of the sliding mode of the control system is guaranteed and improved, and there is no overshoot. It not only maintains the anti-interference ability of fuzzy PID control, but also maintains good tracking performance when the model is mismatched. And has practical application value.
However, the online optimization of particle swarm optimization in the algorithm takes a long time, and the particle swarm algorithm should be optimized in the future. In addition, after replacing the controlled object, the fuzzy control rules should be adjusted appropriately, which will undoubtedly increase the workload. The fuzzy rules should be optimized in the future.