# Comparison of Nonlinear and Linear Controllers for Magnetic Levitation System
## 3 Control Design
### Nonlinear Control of Magnetic Levitation Using Feedback Linearization  
The nonlinear control based on feedback linearization and result from [22] is developed in this section. A nonlinear control law compensating the nonlinear terms is combined with the corresponding state space transform to convert the nonlinear closed-loop control to the pole-placement control for a transformed linearized model. The resulting control law aims at shaping the closed-loop system dynamics according to the poles prescribed for the linear system. All the developments are performed for an original continuous nonlinear state space ML model (5). To eliminate the steady-state control error when positioning the levitating ball, additional state is considered corresponding to the controller integration term. To simplify computations and implementation of a resulting nonlinear control law, the nonlinear terms including exponential functions are approximated by rationalefunctions (such approximations are frequently used in magnetic levitation models). The considered nonlinear model is then  
\[ \begin{split}\frac{dx_{1}}{dt}&=x_{2}\\ \frac{dx_{2}}{dt}&=-\frac{F_{em1}}{2m}+g\approx- \frac{1}{2m}x_{3}^{2}f(x_{1})+g\\ \frac{dx_{3}}{dt}&=\frac{1}{f_{ap}(x_{1})}(k_{1}u+ c_{1}-x_{3})\\ \frac{dx_{4}}{dt}&=x_{1}-w\end{split}  \tag{23}\]  
where approximating functions for exponential terms are  
\[f(x_{1})=\frac{1}{ax_{1}^{2}+bx_{1}+c},\quad f_{ap}(x_{1})=\frac{1}{(dx_{1}+e) ^{2}}.\]  
Parameters \(a=11234.45\); \(b=39.608\); \(c=0.33387\); \(d=830\); \(e=5.66\) were found by fitting the original nonlinear functions from (5) using least squares method. Approximations \(f(x_{1})\) and \(f_{ap}(x_{1})\) are depicted in Figures 2 and 3 respectively. Figure 3: Quadratic rational function approximation of exponential term for \(\frac{dx_{3}}{dt}\). Figure 2: Quadratic rational function approximation of exponential term for \(\frac{dx_{3}}{dt}\), comparison with simpler rational function from [22]—in green. It can be shown that nonlinear system (5) or (23) meets standard assumptions on the existence and uniqueness of its solution. The feedback linearization is based on appropriate nonlinear transformation of the system equations so that the linear system is received. To achieve this end, we consider the state variable transformation  
\[ \begin{split} z_{1}&=x_{1}-w\\ z_{2}&=x_{2}\\ z_{3}&=-\frac{1}{2m}x_{3}^{2}f(x_{1})+g\\ z_{4}&=x_{4}+\frac{K_{1}}{K_{4}}w\end{split}  \tag{24}\]  
and target linear system  
\[ \begin{split}\frac{dz_{1}}{dt}&=z_{2}\\ \frac{dz_{2}}{dt}&=z_{3}\\ \frac{dz_{3}}{dt}&=-(K_{1}z_{1}+K_{2}z_{2}+K_{3}z_{ 3}+K_{4}z_{4})\\ \frac{dz_{4}}{dt}&=z_{1}\end{split}  \tag{25}\]  
as in [22]. The aim is to find the corresponding control law \(u\) such that the linear system (25) is for state variables (24) equivalent to nonlinear system (23) with the appropriately determined control \(u\). Note that \(z_{3}\) in (24) corresponds to the right hand side of \(\frac{dz_{3}}{dt}\) in (23). Thus, \(u\) conforming to the \(\frac{dz_{3}}{dt}\) in (23) should be determined so that \(\frac{dz_{3}}{dt}\) in (25) is fulfilled. To meet this end, firstly (23) is used to receive  
\[u=\frac{1}{k_{1}}\bigg{(}\frac{dx_{3}}{dt}f_{ap}(x_{1})-c_{1}+x_{3}\bigg{)}= \frac{f_{ap}(x_{1})}{k_{1}}\frac{dx_{3}}{dt}+\frac{x_{3}-c_{1}}{k_{1}}. \tag{26}\]  
From (24), the derivative of \(z_{3}\) is  
\[\frac{dz_{3}}{dt}=-\frac{1}{m}x_{3}\frac{dx_{3}}{dt}f(x_{1})-\frac{1}{2m}x_{3} ^{2}\frac{df(x_{1})}{dt}x_{2}. \tag{27}\]  
The control law (26) should make the right hand side of (27) equal to linear term \(-(K_{1}z_{1}+K_{2}z_{2}+K_{3}z_{3}+K_{4}z_{4})\) from (25).