$35
Department of Electrical and Computer Engineering
ECE411S – Real-time Computer Control
LAB 2
CONTROL OF A MAGNETICALLY LEVITATED BALL
1 Purpose
The purpose of this experiment is to familiarize you with modelling nonlinear systems using
Simulink, performing linearization, designing and evaluating various controllers, and verifying
your design on the nonlinear system.
2 Introduction
We are most familiar with control design tools developed for linear systems. Many industrial
systems contain nonlinearities—for example, saturation. It is therefore important to understand
limitations to design procedures based on linear systems. A magnetic levitation system to suspend a ball is often used as an illustrative model for control design of a nonlinear system. You
can read more about a fully operational maglev train connecting Shanghai Pudong International
Airport to Pudong using the link http://en.wikipedia.org/wiki/Shanghai Maglev Train.
The simplified differential equation for the system is
y¨ = g − k
u
2
y
2
,
where u, the control input, is the current through the electromagnet, y is the vertical displacement
of the ball from the magnet, g is the gravitational acceleration constant, and k is a constant
determined by the physical dimensions and material of the system. For the purposes of this
experiment, g = 9.8 and k = 1. The design specification is to achieve stability by keeping the
ball suspended at some fixed distance from the electromagnet.
3 Preparation
The majority of control system designs are based on linear models. We shall first build a
Simulink model of the nonlinear system, then linearize the model you have built to design a
controller.
Complete the following preparation exercises and hand in your answers, on a separate
sheet, to your T.A. at the beginning of the lab. Every student must hand in his/her own
work. There is space provided below to record your preparation work for the experiment.
1
3.1 Building the Nonlinear Model
1. Take the state vector x = (y, y˙), corresponding to the position and velocity of the ball.
Write down the nonlinear differential equation for x in the form
x˙ = f(x, u)
y = h(x, u),
where f(x, u) = (f1(x, u), f2(x, u)) is a 2-dimensional vector with component functions
f1(x, u) and f2(x, u).
2. Set up your Simulink model, defining a suitable nonlinear function in your model. Include,
in your model, the In1 block, under the Sources library. This represents your input.
Similarily, include the Out1 block to represent the output, y. (These will be important
for the linmod command you will use in Section 3.2.) Save, print and label your model.
3.2 Linearizing the System
1. Let the desired equilibrium position be ¯y = 0.5. The equilibrium position is maintained by
a steady-state input current ¯u. Thus at equilibrium, y = ¯y and u = ¯u, and there should
be no change in the ball’s position. Determine and record ¯u, taking it to be positive. For
your own record, write down f(x, u), h(x, u), and ¯u in the space below.
2. Linearize the system around the equilibrium state ¯x = (¯y, 0) analytically. Consider the
system of differential equations in the following form:
x˙ = f(x, u)
y = h(x, u).
Given this nonlinear system and an equilibrium condition, its linearization around (¯x, u¯) is
given by
δx˙ =
∂f
∂x
x, ¯ u¯
δx +
∂f
∂u
x, ¯ u¯
δu
δy =
∂h
∂x
x, ¯ u¯
δx +
∂h
∂u
x, ¯ u¯
δu,
where δx = x − x¯, δu = u − u¯ and δy = y − h(¯x, u¯) denote the deviations of x, u and
y from equilibrium. The notation
∂f
∂x
x, ¯ u¯
denotes the constant matrix having the i–j-th
element ∂fi
∂xj
(¯x, u¯). Let A =
∂f
∂x
x, ¯ u¯
and so on. Determine the matrices A, B, C and D
2