# Semi-Active Magnetic Levitation System for Education
## Appendix A MagLev Mathematical Model  
Figure 4 shows the electromagnetic system model. The force applied by the electromagnet on the levitating magnet can be closely approximated as  
\[f=k\frac{i(t)}{d(t)^{4}}, \tag{1}\]  
where \(k\) is a constant that depends on the geometry of the system [34]. The parameters of the electromagnetic levitation system are determined as in Table 1. It follows from [PERSON]'s second law that  
\[m\ddot{d}(t)=mg-k\frac{i(t)}{d(t)^{4}}, \tag{2}\]  
where \(d(t)\) is the vertical position of the levitating magnet measured from the bottom of the coil, \(i(t)\) is the current through the electromagnet, \(m\) is the mass of the levitating magnet, and \(g\) is the acceleration due to gravity. Moreover, from [PERSON]'s voltage law, we have  
\[v=Ri(t)+L\frac{di(t)}{dt}. \tag{3}\]  
We assume that the current wave will not be dramatically affected by the induced polarization, so we can use the slowly varying amplitude approximation [38], where it is assumed that the envelope of a forward travelling wave pulse varies slowly in timecompared to a period or wavelength. Thus, we can consider that \(\frac{di(t)}{dt}\simeq 0\), and the relation between the control input (voltage \(v=u(t)\)) and the current \(i(t)\) is as follows:  
\[i(t)=\frac{1}{R}u(t). \tag{10}\]  
The MagLev system Equation (11) is then  
\[\ddot{d}(t)=g-\frac{k}{mR}\frac{u(t)}{d(t)^{4}}. \tag{11}\]  
Letting \(x^{T}(t)=[x_{1}(t),x_{2}(t)]=[d(t),\dot{d}(t)]\) be the state of the system, the standard state description can be written as (we omit the time variable \(t\)):  
\[\left[\begin{array}{c}\dot{x}_{1}\\ \dot{x}_{2}\end{array}\right]=\left[\begin{array}{c}x_{2}\\ g-\frac{k}{mR}\frac{k}{x_{1}^{4}}\end{array}\right]. \tag{12}\]  
The equilibrium points of the system are at:  
\[\left[\begin{array}{c}\dot{x}_{1e}\\ \dot{x}_{2e}\end{array}\right]=\left[\begin{array}{c}\sqrt[4]{\frac{k}{gmR} }\;u_{e}\\ 0\end{array}\right], \tag{13}\]  
where \(u_{e}=\frac{gmR}{k}\,x_{1e}^{4}\) is the required voltage to suspend the levitating magnet at \(x_{e}^{T}=[x_{1e},x_{2e}]=[x_{ref},0]\). Consider \(\Delta x=x-x_{e}\) and \(\Delta u=u-u_{e}\). Then, Jacobian linearization of the system about the equilibrium point is  
\[\Delta\dot{x}=\left[\begin{array}{cc}0&1\\ \frac{4g}{x_{1e}}&0\end{array}\right]\Delta x+\left[\begin{array}{cc}0\\ -\frac{k}{mRx_{1e}^{4}}\end{array}\right]\Delta u \tag{14}\]  
Consider \(A=\frac{4g}{x_{1e}}\) and \(B=-\frac{k}{mRx_{1e}^{4}}\). The transfer function of the linearized system is  
\[P(s)=\frac{U(s)}{\Delta(s)}=\frac{B}{s^{2}-A}. \tag{15}\]  
A PID controller (5) can be designed for this system using the pole assignment method [39], paying special attention to optimizing the disturbance response and providing good damping to the closed-loop response. From (5), \(U(s)=K_{p}+sK_{d}+\frac{K_{i}}{s}\), and \(R(S)\) is the Laplace transform of the reference. Then, the transfer function of the closed-loop system is  
\[\frac{\Delta(s)}{R(s)}=\frac{B(s^{2}K_{d}+sK_{p}+K_{i})}{s(s^{2}-A)+s^{2}K_{d} +sK_{p}+K_{i}}. \tag{16}\]  
Using the experimental parameter value in Table 2, we obtain \(A=2.973\times 10^{3}\) and \(B=-78.34\). By pole placement, for instance, the nominal values for control parameters can be found. Then, the PID controller can be tuned by repeated experiments accounting for the control error.