Hardware Oriented

Modeling and Control of Magnetic Levitation Systems using PD Controller

Aim

The goal of this experiment is to gain hands-on experience in controlling a magnetic levitationmagnetic levitationA highly non-linear, open-loop unstable system where an object is suspended in the air using magnetic fields, necessitating an active feedback controller (e.g., PD control) for stabilization. system using a PD controller.
  1. To understand the nonlinear dynamic behavior of a magnetic levitation plant (MLP).
  2. To derive and apply a linearized model of the magnetic levitation system around an equilibrium operating point.
  3. To implement and compare analog and digital PD control techniques for stabilizing the levitated object.
  4. To evaluate reference tracking performance of the digital controller using a square wave input.

Apparatus & Software

Sl. No.Apparatus / SoftwareTechnical SpecificationQuantities
1Magnetic Levitation Plant (MLP)Feedback Instruments Magnetic Levitation System 33-210, with IR sensor and electromagnet1
2Interface Card (A/D & D/A Board)PCI1711 Lab I/O Board with ADC and DAC channels1
3Desktop PCRunning MATLAB/Simulink for digital control implementation1
4MATLAB / SimulinkR2023 or compatible, with Control System Toolbox1
5Analog Control CircuitContinuous-time analog circuitry with position and gain knobs1

Theory

Magnetic levitation (maglev), also referred to as magnetic suspension, is a technique in which an object is suspended in space without any physical contact, using only magnetic forces. The magnetic force generated by an electromagnet counteracts the gravitational force acting on the levitated object. In addition to providing sufficient lift to balance gravity, the system must ensure stability so that the object does not drift, oscillate uncontrollably, or collapse into the electromagnet.
Magnetic Levitation Plant (MLP)
The Magnetic Levitation Plant (MLP) consists of an electromagnet, a ferromagnetic object, position sensing elements, and an interface card that facilitates communication between the plant and a desktop PC. The interface card contains Analog-to-Digital (A/D) and Digital-to-Analog (D/A) converters, enabling real-time signal exchange for sensing and control purposes.
Figure 1: Schematic diagram of the Magnetic Levitation Plant (MLP)

Figure 1: Schematic diagram of the Magnetic Levitation Plant (MLP)

The nonlinear dynamic behavior of the magnetic levitation system is governed by the equation of motion:
mz¨=mgρz2m\ddot{z} = mg - \frac{\rho}{z^2}
where m is the mass of the levitated object, z is the vertical displacement from the electromagnet, g is the acceleration due to gravity, and ρ is a constant defined as:
ρ=1μ0N2A\rho = \frac{1}{\mu_0 N^2 A}
Here, μ₀ is the permeability of free space, N is the number of turns in the electromagnet coil, and A is the cross-sectional area of the electromagnet. This equation highlights the inherent nonlinearity of the magnetic force, which varies inversely with the square of the air gap.
Linearized Model
To design linear control strategies, the nonlinear system is linearized around an equilibrium operating point (z₀, i₁₀), where the magnetic force balances gravity. Small deviations in position (Δz) and coil current (Δi₁) are considered, leading to the linearized transfer function:
Δz(s)Δie(s)=kies2kz\frac{\Delta z(s)}{\Delta i_e(s)} = \frac{-k_{ie}}{s^2 - k_z}
where the system parameters are defined as:
kie=2mgie0,kz=2mgz0k_{ie} = \frac{2mg}{i_{e0}}, \quad k_z = \frac{2mg}{z_0}
This transfer function reveals that the open-loop system is inherently unstable due to the positive feedback nature of the magnetic force with respect to position. Therefore, an appropriate feedback controller is essential to stabilize the levitated object and maintain the desired position.

Pre-Lab / Circuit Diagram

Figure 2(a): Digital control circuit model

Figure 2: Digital control circuit/model used for magnetic levitation

Procedure

Analog Control:
  1. Set up the magnetic levitation plant with the analog control circuitry.
  2. Use the position knob to set the desired equilibrium position of the levitated ball.
  3. Adjust the gain knob to tune the controller gain for stable levitation.
  4. Observe and record the levitation behavior of the ball under analog control.
Digital Control:
  1. Connect the magnetic levitation plant to the desktop PC via the PCI1711 Lab I/O Board (ADC/DAC interface).
  2. Open the Simulink model implementing the discrete-time PD controller.
  3. Configure the feedback ADC and DAC channels in the Simulink model.
  4. Set the desired reference position (e.g., square wave input) in the Simulink model.
  5. Run the Simulink model and observe the ball position response on the signal scope.
  6. Record the output response and compare with the reference signal.

Simulation / Execution

The digital control approach involved implementing a PD controller using a Simulink model. The control algorithm was executed in discrete time, and the required control signal was applied to the magnetic levitation plant through a digital-to-analog interface.
The Simulink model includes PCI1711 Lab I/O Board feedback ADC and DAC channels, a PID controllerpid controllerA generic control loop feedback mechanism (Proportional-Integral-Derivative) widely used in industrial control systems to continuously calculate an error value and apply a precise dynamic correction. block, voltage-to-position converters, sinus and square wave signal sources, and a signal scope for real-time output monitoring.

Observations

This experiment was carried out using both analog and digital control techniques to study the behavior of the magnetic levitation system. The observed outputs corresponding to each are shown below.
Analog Control Response:
In the analog control mode, the magnetic levitation plant was controlled using continuous-time analog circuitry. Two knobs — one to set the equilibrium position and the other to set the gain — were used. The system was able to levitate the ball around the desired equilibrium point.
Digital Control Response:
The digital control approach involved implementing a controller using a digital model and associated circuitry. The control algorithm was executed in discrete time, and the required control signal was applied to the magnetic levitation plant through a digital-to-analog interface.
Figure 3(a): Analog control output — levitated ball at equilibrium

Figure 3(a): Analog control output — levitated ball at equilibrium

Figure 3(b): Digital control output — levitated ball with digital controller

Figure 3(b): Digital control output — levitated ball with digital controller

Figure 4: Ball position response corresponding to square wave input

Figure 4: Ball position response (blue) corresponding to square wave input (yellow - top) and Control Input provided to the system (bottom)

Calculations

Nonlinear Equation of Motion:
mz¨=mgρz2m\ddot{z} = mg - \frac{\rho}{z^2}
Electromagnetic Constant:
ρ=1μ0N2A\rho = \frac{1}{\mu_0 N^2 A}
Linearized Transfer Function (around equilibrium point z₀, i₁₀):
Δz(s)Δie(s)=kies2kz\frac{\Delta z(s)}{\Delta i_e(s)} = \frac{-k_{ie}}{s^2 - k_z}
System Parameters:
kie=2mgie0,kz=2mgz0k_{ie} = \frac{2mg}{i_{e0}}, \quad k_z = \frac{2mg}{z_0}

Results & Analysis

The experimental results demonstrate that both analog and digital control techniques are capable of stabilizing the magnetic levitation system. However, noticeable differences were observed in terms of response smoothness, flexibility, and robustness.
A digital control model was also tested using a square wave reference input. The corresponding motion of the levitated ball closely followed the square wave pattern, indicating effective tracking performance of the digital controller.
From the results, it is observed that the digital control approach provides better tuning flexibility but relatively poorer stability compared to analog control. The analog control approach provides limited tuning parameters (position and gain) but demonstrates stable levitation. The ability of the digital model to accurately follow a square wave input demonstrates its effectiveness in handling reference changes and maintaining system stability.
AspectAnalog ControlDigital Control
Tuning FlexibilityLimited (position + gain knobs only)High (full PD parameter tuning)
StabilityBetterModerate
Reference TrackingNot evaluatedEffective (square wave tracking demonstrated)
ImplementationContinuous-time analog circuitryDiscrete-time Simulink model via DAC/ADC
Overall, digital control proves to be more suitable for different tuning techniques, while analog control provides better stability for the magnetic levitation system.

Conclusion

Magnetic levitation is a contactless suspension technique in which an object is levitated by balancing gravitational force with electromagnetic force. Since the magnetic force is highly nonlinear and sensitive to position, the system is inherently unstable and requires continuous feedback control to maintain the levitated object at a desired position. Proper controller design is therefore essential to achieve stable and accurate levitation.
In this experiment, the magnetic levitation system was controlled using both analog and digital control techniques. The analog control approach provided continuous-time control and demonstrated basic stabilization of the levitated ball; however, it has limited tuning parameters (position and gain). The digital control approach, implemented using a discrete-time Simulink model, offered better flexibility in tuning and improved tracking performance. The digital controller was also able to accurately follow a square wave reference input, showing effective reference tracking and improved robustness.
Magnetic levitation systems have important applications in areas such as high-speed maglev trains, frictionless bearings, vibration isolation systems, and precision positioning devices. For simpler systems with limited requirements, analog control can be sufficient due to its simplicity. However, for advanced applications requiring high accuracy, adaptability, and ease of implementation, digital control is generally preferred. Thus, digital control techniques are more suitable for modern magnetic levitation applications.

Post-Lab / Viva Voce

Note: The following questions are intended to evaluate conceptual understanding arising from this experiment on Modeling and Control of Magnetic Levitation Systems using a PD Controller.
  1. Q: Why is a magnetic levitation system considered inherently unstable, and why is open-loop control insufficient to levitate the ball?

    A: The magnetic force on the ferromagnetic ball varies inversely with the square of the air gap (F ∝ 1/z²). This creates a positive feedback effect with respect to position: if the ball moves closer to the electromagnet, the attraction force increases, pulling it even closer; if it moves away, the force decreases and gravity pulls it further down. This runaway behavior means the equilibrium is unstable. In the linearized transfer function Δz(s)/Δi₁(s) = −kᵢ₁/(s² − kz), the positive term kz in the denominator places a pole in the right half of the s-plane, confirming open-loop instability. A constant current (open-loop) cannot correct for position disturbances, so continuous feedback control is essential.
  2. Q: What is the purpose of linearizing the magnetic levitation system, and what are the limitations of the linearized model?

    A: Linearization simplifies the nonlinear equation of motion mz̈ = mg − ρ/z² into a linear transfer function valid for small deviations around the equilibrium point (z₀, i₁₀). This allows the application of well-established linear control design techniques such as PD, PID, root locus, and frequency response methods. The linearized transfer function Δz(s)/Δi₁(s) = −kᵢ₁/(s² − kz) is valid only within a small neighborhood of the operating point. For large deviations — for example, when the ball is disturbed significantly from equilibrium — the nonlinear terms become dominant and the linear model loses accuracy, potentially causing the controller to fail.
  3. Q: What are the roles of the proportional (P) and derivative (D) terms in the PD controller used for the magnetic levitation system?

    A: The proportional term generates a control signal proportional to the position error (difference between desired and actual ball position). It provides restoring force to push the ball back toward the setpoint. However, proportional controlproportional controlA control strategy that produces an output proportional to the current error value (P-action). It helps decrease rise time but cannot eliminate steady-state error completely. alone cannot stabilize the levitation system because the plant has a right-half-plane pole (inherently unstable). The derivative term responds to the rate of change of the error (velocity of the ball). It effectively predicts where the ball is heading and provides damping by opposing rapid movements, thereby preventing oscillations. The combination of P and D terms introduces sufficient phase lead to relocate the closed-loop poles into the left half-plane, achieving stable levitation.
  4. Q: The Magnetic Levitation Plant (MLP) uses an IR sensor and an A/D–D/A interface board. What is the role of each component in the control loop?

    A: The IR sensor (infrared sensorinfrared sensorAn electronic device that emits or detects infrared radiation to sense its surroundings. It is widely used in object detection and proximity sensing by measuring reflected IR light.) measures the position of the levitated ball by detecting the amount of IR light blocked by the ball at different heights, converting it to a voltage signal proportional to the air gap z. This voltage is fed to the A/D converter on the interface board, which digitizes the analog position signal so that the desktop PC can read it. The PC runs the control algorithm (PD controller), computes the required current command, and sends it to the D/A converter, which converts the digital control signal back to an analog voltage. This analog signal drives the current amplifier, which adjusts the electromagnet coil current i₁ to control the magnetic force on the ball.
  5. Q: In this experiment, analog control was observed to provide better stability while digital control offered better tuning flexibility. Explain the reasons for this trade-off.

    A: Analog control operates in continuous time with no sampling delay, quantization error, or computational latency. The continuous nature of the feedback loop allows the controller to respond instantaneously to position changes, which is critical for stabilizing the fast dynamics of the magnetic levitation system. Digital control introduces a sampling period, quantization of the sensor signal, and a computational delay between measurement and actuation. If the sampling rate is not sufficiently high relative to the system bandwidth, these effects introduce phase lag and can destabilize the system. However, digital control allows precise, easily adjustable gain parameters, implementation of complex algorithms, and integration with PC-based environments like Simulink, offering greater flexibility for experimentation and retuning.
  6. Q: What do the system parameters kᵢ₁ and kz represent physically, and how do they depend on the operating point?

    A: kᵢ₁ = 2mg/i₁₀ is the current gain — it represents how sensitively the ball's acceleration responds to a small change in coil current around the equilibrium current i₁₀. A larger equilibrium current (ball held at a lower position with stronger force) results in a smaller kᵢ₁, meaning the same current change produces less acceleration. kz = 2mg/z₀ is the position stiffness — it quantifies the destabilizing effect of position perturbations. A smaller air gap z₀ (ball closer to the electromagnet) results in a larger kz, making the system more unstable and harder to control. Both parameters must be recomputed if the operating point changes, and the controller gains may need to be retuned accordingly.
  7. Q: How did the digital controller perform when a square wave reference input was applied, and what does this demonstrate about the controller's tracking capability?

    A: When a square wave reference input was applied, the levitated ball's position closely followed the switching pattern of the square wave, alternating between two distinct levitation heights. This demonstrates that the digital PD controller has good reference tracking performance — it can respond to step changes in the setpoint and drive the ball to the new desired position within a short transient period. The control input (coil current command) showed corresponding switching behavior with transient spikes at each reference change, consistent with the derivative action of the controller responding to the sudden error changes. This result validates the effectiveness of digital control for setpoint changes in the magnetic levitation system.

References & Resources (Not Applicable)

This section is not required for this experiment.