Design of A Controller For The Plant: The Ball and Beam
Design of A Controller For The Plant: The Ball and Beam
GROUP 34 Professor :
FONTEYN Martin GARONE Emmanuele
KHALIL Kassem Teaching assistant :
NGUYEN VAN BINH Julien BUSSIOS Maxime
2023-12-01
Contents
1 Introduction 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Plant 2
2.1 Plant description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1.1 Static characteristic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Instrumentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.3 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.4 Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
6 Conclusion 20
6.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Introduction
1
1.1 Introduction
This report summarizes what has been done during the laboratory sessions. In theses laboratory
sessions, the analysis and the design of a controller, considering the requirements and specifica-
tions for a real plant, are carried out. The right solution is not known beforehand, and optimal
organizations is required to find the most appropriate solution.
Software tools such as MATLAB and Simulink will be used to validate the correct operation of the
system in real-time.
Considering several parameters that will be mentioned later in this report, the approaches will be
explained in detail, taking into account these parameters.
1
Plant
2
2.1 Plant description
The project deals with problem known as the "Ball and Beam" system.
(put here image of the real plant)
Figure x Picture of the "Ball and Beam" system
A ball is placed along a gutter, and its position varies depending on the orientation of the gutter
due to the influence of its own weight.
At one end, the beam is connected to a roller support, while at the opposite end, it’s linked to a
slider capable of vertical movement along a linear guide using a ball screw drive. This screw is
powered by a DC motor driven by electrical current. The objective is to maintain the ball at any
chosen position along the beam.
input current vs value reached in steady state big deadzone => have to take it into account in the
code show linearization of the deadzone
2.2 Instrumentation
sensor, input,
2.3 Specifications
The basic requirements state the the controller has to be able to stabilize the ball at any available
position. The more advance requirements state that the controller should be able to
2
CHAPTER 2. PLANT 3
• Switch between two different points with a maximum of 0.5cm overshoot in maximum 10s
Note that it doesn’t specify the kind of reference to follow (step, ramp, etc), nor the difference in
distance between the start and end point.
2.4 Control
cascade control had been chosen from the beginning The idea is to add loops to control interme-
diate variables, that we might have access to. A disturbance is associated to each intermediate
variable, thus it is a good idea to try to counteract it before the effect of the disturbance becomes
visible on the output. In line of principle, using more information is always better. On top of the
better disturbance rejection, we have to remember that our models are not perfect, and are usu-
ally linear approximations. This can also be seen as more disturbances that we have to reject. The
inner loops are simple SISO systems : it reduces a multivariable control problem into a series of
SISO control. The inner loops should be way faster, so they can be neglected in order to simply the
design of the control laws. This will be in appendix : Inner loop :
C 1 (z)G 1 (z) 1
V (z) = Vd (z) + d
1 +C 1 (z)G 1 (z) 1 +C 1 (z)G 1 (z)
¯ ¯
If the internal controller is very fast, meaning ||C 1 (e j ω )G 1 (e j ω )|| >> 1 We have : - ¯ 1+C (e j ω1)G (e j ω ) ¯ ≈
¯ ¯
1 1
¯ C 1 (e j ω )G 1 (e j ω ) ¯
¯ ¯
0 - ¯ 1+C (e j ω )G (e j ω )
¯ ≈ 1 Meaning V (z) ≈ Vd (z) and the inner loop is neglectable.
1 1
disturbance : linearizing a model can be seen as a disturbance the bandwidth of the outer loop
can be lower (good thing because only two AA filters with a cutoff frequency of 100 Hz, the third
one is at 40 Hz).
White box modelling
3
3.1 Introduction
Approach of white box modeling : derive (electro)-mechanical equations to determine the system.
the exact coefficients can hardly be known as simplifications are made, but it gives the order of the
system (number of zeros and poles).
it’s not that hard (there is one in another report) note that it doesn’t matter that much, as the
dynamic is way faster than the outside loop in the cascade control (cf later).
3.3 Angle
3.3.1 Equation
by gauss approximation :
t an(α) ≈ α
l
α= (3.2)
d
l̇
α̇ =
d
4
CHAPTER 3. WHITE BOX MODELLING 5
Then
V = R ∗ω (3.3)
V = l˙
l˙ = R ∗ ω (3.4)
α̇ ∗ d = R ∗ ω
By laplace transform
3.4 Position
This part discusses the black box modelling that was being done in parallel with the white box
characterizations. Black box has the advantage to be quick and reliable, but needs to be couple
with White box to explain physically the order of the system. It also allows the verify the white box
equations, especially the order of the system.
The idea of this modelling technique is to introduce a step at the input of the system being char-
acterized (to excite all frequencies). Based on the step response and the provided script (which
doesn’t work for integrators), the transfer function of the system can be found.
The first system that needs to be characterized is the DC motor. Its input is the armature current of
the motor, and the output is the angular velocity of the motor. It is easy to send a step as the input,
as there is a direct access to the current being sent. This step should start close to the regulation
settings, meaning at equilibrium. The goal is to have a stable system, so the input starts at the edge
of the deadzone, while the beam is at 0°.
In order to find the transfer function, it is best that the system reaches stead state, meaning con-
stant angular velocity. This proved to be a problem, as for normal current, the slider reaches the
limit switch way before the critical angular velocity is reached. To make it a bit easier, only the
steps making the beam move up were considered, as gravity would help slow things down. This
wasn’t enough, so two additional options were considered : to reduce the current to the minimum,
meaning there would be lots of friction, or to start with a beam slightly below 0°. It was chosen to
reduce the current to barely over the deadzone current (i.e. the maximum current before the beam
moves). Ultimately, this design choise didn’t matter much, as the inner loops are way faster than
6
CHAPTER 4. BLACK BOX MODELLING 7
It is obvious that there are significant differences between the theoretical and the simulated
output. It was chosen to approximate it by a first order, as the derivative at the origin wasn’t equal
to zero. Furthermore, the white box modelling shows that a DC motor can be approximated by a
CHAPTER 4. BLACK BOX MODELLING 8
first order transfer function. Also, this first loop is way faster than the outer loop, so it doesn’t really
matter.
For the second system, whose input is the output of this system, the step will be required at the
angular velocity which means that this system needs to be controlled. A simple proportional con-
troller was chosen, as it is enough to fully impose the position of the single pole. It can be seen on
the root locus that the system is stable for any positive gain, and that the response will be faster the
greater the gain (a response is faster the more negative is the real part of the pole). In cascade con-
trol, the inner loops should be as fast as possible, so the gain should indeed be as high as possible.
It was however limited by the saturation, and it was determined in Simulink that a gain around 4
would be a good tradeoff.
4.3 Angle
The input of the second system is the angular velocity of the motor, and its output is the angle of
the beam. The starting position are the same as before (beam at 0°, angular velocity = 0 r ad /s, the
difference being that the step is now the reference for the proportional controller.
It was found to be a simple integrator, just like the white box predicted it.
1.6547
G 2 (s) = (4.2)
s
This time, the theoretical and actual output were much closer. Note that the input is not a
CHAPTER 4. BLACK BOX MODELLING 9
perfect step, but it doesn’t matter as this only affects the angle for a brief period.
For the same reason as for the DC motor, this system needs to be controlled before finding the third
transfer function. Again, the root locus shows that the system is stable for any strictly positive gain.
In Simulink, a gain of 6 was found to be a good tradeoff between speed and saturation.
CHAPTER 4. BLACK BOX MODELLING 10
4.4 Position
The input of the last system is the angle of the beam, and its output is the position, which is the
signal that is eventually controlled. In this case, it would be optimal to start the experiment with
the ball in the middle of the beam, but it wasn’t possible as it required a controlled system. It was
decided that the ball would start furthest from the position sensor, so that for a positive step, the
ball would have to travel the whole beam before colliding and bouncing back.
The transfer function was found to be a double integrator (like the white box moddeling pre-
dicted), but with a significant delay. This delay is probably due to friction stopping the ball from
moving before a certain angle, added to the fact that the beam angle step takes some time to rise.
9 −0.4s
G 3 (s) = ·e (4.3)
s2
CHAPTER 4. BLACK BOX MODELLING 11
Now that all the transfer functions have been found, and the inner loops were controlled, it was
time to controller the outer loop. The first idea was to use a PD controller. The proportional action
forces the position error to tend to zero, while the derivative action forces the speed to tend to zero
(stabilizing effect). This derivative action is particularly good when there are delays, which is the
case in this plant. This worked in simulation, but not in practice. The next idea was to add a filter
pole, to make a phase lead controller.
The Bode plot of G 3 (s) shows that while the low frequency gain is high (for a good reference track-
ing), and the high frequency gain is low (for a good attenuation of noise), the phase is greater
than 180° at any frequency, which means that it is unstable. This system needs a greater phase, to
achieve a sufficiently high phase margin. This is why a phase lead controller was chosen, whose
equation is :
1 + sT
C (s) = k c (5.1)
1 + sT α
A good starting point are the specifications. The settling time is t s = 10s, and the overshoot is
1cm
Mp = 5cm = 20%. The value 5cm was arbitrarily chosen. Knowing the relationship between the
12
CHAPTER 5. OUTSIDE LOOP CONTROLLER 13
overshoot and the damping factor, one can compute ϵ and the phase margin :
p−πϵ
M p = e 1−ϵ2
p π 2
µ ¶
⇔ϵ= 1 + 1 = 0.59 (5.2)
ln M p
P M ≈ 100◦ · ϵ = 60◦
It was decided that the point with the highest phase will be the frequency for which the gain equals
1
0 dB. In other words, |C ( j ωc )G( j ωc )| = 1 where ωc = p
T α
for a phase lead controller. It is possible
do derive α, which represents the spacing between the zero and the pole, from the maximal phase
given by the controller :
φmax = 60◦
1−α
tan φmax = p (5.3)
2 α
⇔ α = 0.072
It was decided out of good practice to have a gain margin of 6 dB for the open loop :
9 · k c 1 + sT
OL(s) = ·
s 2 1 + sT α
G M = 6d B ⇔ |OL( j ω180◦ )| = 6d B, Ar g (OL( j ω180◦ )) = −180◦ (5.4)
∂Ar g (OL( j ω))
= 0 for ωc , |OL( j ωc )| = 0d B
∂ω
CHAPTER 5. OUTSIDE LOOP CONTROLLER 14
1
ωc = p
T α
s
kc 1
|OL( j ωc )| = 1 ⇔ p · 9T 2 α = 1 ⇔ T = p
α 9k c α
(5.5)
Arg(OL( j ω180◦ )) = −180 ⇔ −0.4 · ω180◦ + Arg(1 + j ω180◦ T ) − Arg(1 + j ω180◦ T α) = −180
£ ¤
In order to solve those equations to find T and k c , an optimization script was developed. It
minimizes Ar g (OL( j ω180◦ )) + 180◦ and G M + 6d B (as fminsearch only solves for a solution equal
to zero). It found these values for the phase lead/PD with filtering pole :
k c = 0.0531 K d = 0.0531
(5.6)
T = 2.7936 k p = 0.4752
α = 0.0718 T f = 0.2006
The resulting open loop bodeplot shows a gain margin of 6.02d B , and a phase margin of 29.4◦ .
The phase margin is lower than expected due to delay, which prevents one of saying that the phase
margin is the maximum phase of the controller. This phase margin was accepted, as trying to make
it bigger would mean more measuring noise (α would need to be even smaller). It is possible to
OL(s)
C L(s) = (5.7)
1 + OL(s)
CHAPTER 5. OUTSIDE LOOP CONTROLLER 15
5.2.2 Simulation
The simulation of this controller gave promising results, but it wouldn’t never quite reach the spec-
ifications. Note that a ZOH was omitted from the system for simplicity, as the delay of G 3 (s) of 0.4s
was an order of magnitude higher than any sampling delay. A saturation block was added, to sim-
ulate a hard limit of the current sent to the motor.
5.2.3 Discretization
In order to discretize the controller, Tustin’s approximation was used. With this technique, one
can say that if the continuous time controller C (s) is stable, its discretized version C (z) will also be
stable.
5.2.4 In practice
As the reference tracking with the theoretical values wasn’t quite meeting the specifications, fur-
ther hand tuning was done. It was observed that a higher K p meant a slightly faster response (the
CHAPTER 5. OUTSIDE LOOP CONTROLLER 16
settling time was mainly limited by the imposed saturation of the sensors), meant more overshoot
but helped to reduce the initial static error. In theory, there shouldn’t be any static error as the
outer loop system is a double integrator. However the static characteristic is not unique depend-
ing on the position of the ball.
Increasing K d on the other hand made the system stable earlier, but slowed it a bit.
As previously mentioned, forced saturation of the motor was introduced, where the current was
limited in the I ∈ [−4, 7]A.
While it exceeds by far the specifications, it is interesting to note that the results showed a signif-
icant static error when the reference was above 35 cm. It is probably a result of the linearization
(the ball was always going straight to the sensor, and not going away from it), and also the sensor
noise at high distance.
One hypothesis was that the step was too high, so it was tried in two smaller consecutive steps and
still didn’t work.
It is easy to notice that there is a lot of noise in the output, even when the reference is constant.
Several techniques were tried, such as readjusting the deadzones and adding a minimal error be-
low which there is no input, but those fixes eventually lead to worse performance.
CHAPTER 5. OUTSIDE LOOP CONTROLLER 17
Figure 5.8: Output of the plant for two consecutive steps, trying to reach 45cm
5.4 Bonus
A sinusoidal input was first simulated in Simulink, then tested on the system. While the prac-
tical values for the controller give a ωc = 2.92r ad /s, suggesting that a sinusoidal reference will
be correctly followed up to that frequency, it was found experimentally that it was the case up to
f = 0.1H z, or ω = 0.63r ad /s.
CHAPTER 5. OUTSIDE LOOP CONTROLLER 19
6.1 Conclusion
20