Fall 2022
Mag Lev Project

Mission
The objective of this lab was to design and test a PID control system for a magnetic levitation device, where a metal ball hovers over a magnetic field. Using LabVIEW, an interactive PID controller was developed through a closed-loop block diagram to regulate the device, ensuring minimal error and robust handling of disturbances to the input.
The system was tuned to its gamma value to control the neutral position of the ball and its movement for four specified input function controls. Through experimentation, the proportional gain (Kc), derivative time (Td), and integral time (Ti) values were determined for each input, allowing the metal ball to maintain levitation while accommodating various disturbances.
The recorded values indicated a Kc of 2.5 for the height input and 2 for the other three inputs, Ti of 0.01 for the height input, Ti of 0.001 for the sin input, and 0.4 for the other two inputs, and Td of 0.001 for all four inputs.
Control Systems Background
Magnetic levitation systems are integral to various applications in today’s society, including high-speed trains, wind tunnels, and machinery. These systems, often nonlinear and unstable in nature, necessitate the use of PID controllers for effective control.
PID (Proportional-Integral-Derivative) controller systems are employed when both steady-state and transient performance improvement is required. Utilizing feedback mechanisms, PID controllers calculate and compare errors with actual measured values of the system. Tuning of PID controllers is typically accomplished using the Ziegler-Nichols method, which provides three gain parameters: the controller's proportional gain (Kp), integrator time constant (Ti), and derivative time constant (Td). These parameters are derived from closed feedback loop parameters such as gamma, nominal operating point, and nominal current.
In the case of a magnetic levitation system, an electromagnet coil generates a magnetic field that attracts a magnetizable object, enabling levitation. By controlling the current in the electromagnet coil, the magnetic force is regulated, with current decreasing as the object approaches the magnet. This system, designed by Feedback Instruments Ltd, Crowborough UK, employs a feedback loop to adjust the force exerted on the metallic ball, thereby controlling its levitating height. An infrared (IR) position sensor tracks the ball's position, allowing for precise control. The ball's position is manipulated by adjusting the current through the electromagnet, which, in turn, is controlled by applying a voltage across its terminals. Consequently, the ball's position is indirectly regulated by the applied voltage.
Error is determined by comparing the feedback height to a desired reference height, with the resulting error inputted into a controller for correction.

Mathematical Derivations
The Maglev system can be dynamically modeled using Newton’s Laws, treating the metallic ball as being in equilibrium when subjected to an electromagnetic field. Differential equations are employed to describe the Maglev system, with the displacement of the ball determined by the equation derived from the free body diagram.
The constant 'k' representing the magnetic force is calculated based on equilibrium conditions around the nominal operating point. These conditions are established by setting the derivatives of the nonlinear model equation to zero. The resulting expression for 'k' is given by: k = mgx^2/I^2, where 'x' denotes the position of the ball relative to the electromagnet, and 'I' represents the current flowing through the electromagnet.


​
A PID controller offers the flexibility to incorporate any combination of proportional (P), integral (I), and derivative (D) controller types, making it a versatile choice for control systems. Consequently, it was decided that a PID controller would be utilized for the Maglev system, with the option to adjust the parameters to resemble PI or PD controllers if deemed more effective during the tuning process.
Before determining the values of the proportional gain (Kc), integral time (Ti), and derivative time (Td), the nominal current (Io), nominal operating point (Xo), and gamma (γ) were established. Xo represents the position away from the magnet where the voltage reads 0, determined by holding the ball at this position and recording the height. Io, the current at the same position, was calculated using Ohm’s law. The gamma value was derived by setting Kc, Ti, and Td to 0, and recording voltage and displacement values at the top and bottom of the system.
MATLAB was employed to model the system with the determined parameters to understand its response to different values and guide the selection process. Using MATLAB's PID tuning functions, the controller parameters were determined.
While the system's performance was promising, the gain was deemed excessively high for the Maglev system, prompting the use of the Ziegler-Nichols method during experimentation. The proportional gain value was adjusted until the system exhibited optimal stability and independence in levitating. Subsequently, Ti was increased to enhance levitation duration, followed by adjustments to Td to achieve full levitation while minimizing oscillations.
To validate the determined parameters, tests were conducted involving gentle disturbances to observe the system's stability. Variations in amplitude and frequency of sine and square functions were also explored, highlighting the impact of different gamma values on stability and operational range.
Design Procedure
