Maglev PID Controller
// ABSTRACT
For ME 344: Control Systems, my team of three modeled a magnetic levitation system in MATLAB and designed a PID controller implemented in LabVIEW. The controller tracks step, sine, square, and random inputs at frequencies up to 60 Hz and amplitudes of 0.25 cm — the most dynamic performance achieved in the class. The project combined analytical system modeling with iterative experimental tuning.
SKILLS
TOOLS
System Description
The Maglev system levitates a ferromagnetic ball beneath an electromagnet. The electromagnet current is modulated to keep the ball at a target height — a classic unstable control problem, since the magnetic force increases as the ball moves closer to the magnet, creating a positive feedback loop that the controller must overcome.
The system responds to user-defined setpoints and perturbations via a LabVIEW front panel.
System Modeling (MATLAB)
Before designing the controller, we modeled the electromechanical dynamics in MATLAB to establish the plant transfer function. Key steps:
- Linearization: The magnetic force is nonlinear (proportional to 1/distance²). We linearized around the nominal operating point to obtain a linear time-invariant model
- Parameter identification: System constants (electromagnet inductance, ball mass, nominal air gap) were estimated from the hardware specifications and measured experimentally
- Stability analysis: Used SISOtool to evaluate open-loop poles and determine the range of gains that provide stable closed-loop behavior
The linearized plant has a right-half-plane pole — confirming the system is inherently unstable and requires active control at all times.
PID Controller Design (LabVIEW)
The controller was implemented in LabVIEW with a user-accessible front panel for real-time gain adjustment and input signal selection.
Design process:
- Started with proportional control only to establish a baseline
- Added derivative action to damp oscillations (critical for the unstable plant)
- Added integral action to eliminate steady-state error for step inputs
- Iteratively tuned all three gains experimentally against live hardware
The final controller achieves:
- Step inputs: Settling time < 200 ms, no steady-state error
- Sine inputs: Tracks accurately up to 60 Hz
- Square inputs: Sharp response with minimal overshoot
- Random inputs: Stable tracking across the tested amplitude range
Front Panel Design
The LabVIEW front panel was designed for easy operation during testing and demonstration:
- Input signal selection (step, sine, square, random)
- Live amplitude and frequency controls
- Real-time position and error plots
- PID gain sliders with live feedback
Results
The controller achieved the widest dynamic range in the class — tracking inputs at frequencies up to 60 Hz and amplitudes up to 0.25 cm. This performance reflected both a well-tuned controller and a front panel that made tuning fast and visible.
The project reinforced a core lesson in control engineering: the model guides your starting point, but experimental tuning on real hardware is where controllers are actually built.