Main Content

Magnetic Levitation Model

vrmaglev is an example showing the interaction between dynamic models in Simulink® and virtual worlds. The Simulink® model represents the HUMUSOFT® CE152 Magnetic Levitation educational / presentation scale model. (

The plant model is controlled by a PID controller with feed forward to cope with the nonlinearity of the magnetic levitation system.

The position of the ball responds to the changing value of the setpoint. You can observe this change not only in the Scope window, but also in a viewer window displaying the virtual world. Note that the position of the ball represents the real dynamics of the system. If you switch the VRML viewer to the Camera 3 viewpoint, you can observe and control the ball easier.

There are two possible methods of setting the ball position setpoint - using a Signal Generator and visually by clicking at a desired position in the virtual reality scene.

In the virtual scene, a VRML sensor is defined. If you click in the space between the magnetic coil and the bottom plate, VRML sensor is updated and its value is read into Simulink model using the VR Source block.