Control of the Ball on the Wheel
System
R.W. van Gils
DCT 2007.010
Traineeship report
Coach(es):
Dipl.-Ing. K. Rieger, MSc.
Supervisor:
Prof. Dr. H. Nijmeijer
Technische Universiteit Eindhoven
Department Mechanical Engineering
Dynamics and Control Technology Group
Eindhoven, February, 2007
Preface
This report with the title Control of the Ball on the Wheel System, is made at the institute of
Automatic Control and Control Systems Technology of the Johannes Kepler University Linz. It is done
during my three months stay in Linz as part of the Erasmus Exchange Program.
The three months I studied in Linz, I have learned very much, and I had a great time as well. I want
to thank the staff of the institute for being really helpful and also for being very friendly. In particular
I want to thank o.Univ.-Prof. Dipl.-Ing. Dr. Kurt Schlacher for the great opportunity of studying in
Linz and of course I want to thank Dipl. Ing. Karl Rieger, MSc. in particular, for instructing me very
adequately.
Finally I want to thank Prof. Dr. Henk Nijmeijer, for suggesting the University of Linz and this institute
as internship site.
Eindhoven, February 2007
Abstract
Digital process control is quite common in industrial applications. This report describes the setup of a
system that consists of a laptop and two digital acquisition cards, to carry out digital process control on
systems like the Ball on the Wheel system.
The software on the laptop is based on the operating system Linux. Linux is a high precision operating
system. RTAI is installed to allow the execution of code in realtime and for visualization. The visualization
takes place in XRtaiLab; in this program it is also possible to adjust parameters in realtime. In addition
COMEDI is installed, to mount the digital acquisition cards to a driver.
To test the usability of this system, several control strategies to control the Ball on the Wheel system
have been developed. The develloped controllers stabilize the ball on the top of the wheel in a equilibrium
point and some let it follow a trajectory. With this system several control strategies can be tested in a
very fast and cheap way.
Contents
1 Introduction
2 The
2.1
2.2
2.3
2.4
Ball on the Wheel System
Modeling the BOW System . . .
Linearization of the BOW Model
Feedback Linearization . . . . . .
System Parameters . . . . . . . .
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
3
5
6
7
3 Controller Design
3.1 Linear Controller and Observer . .
3.1.1 Linear State Feedback Law.
3.1.2 Linear Observers . . . . . .
3.1.3 Simulation . . . . . . . . .
3.2 Feedback Linearization . . . . . . .
3.2.1 Trajectory Generator . . . .
3.2.2 Controller . . . . . . . . .
3.2.3 Trajectory Observer . . . .
3.2.4 BOW plant . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
9
9
9
10
10
10
11
12
13
23
4 Results
4.1 Linear Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Nonlinear Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
25
25
5 Conclusions and Recommendations
29
A Implementation of a Controller
31
B Control Environment
B.1 Hardware . . . . . . . . . . . . . . . . . . . .
B.1.1 National Instruments, DAQ 6063E . .
B.1.2 National Instruments, DAQ Dio-24 . .
B.2 Software . . . . . . . . . . . . . . . . . . . . .
B.2.1 Linux . . . . . . . . . . . . . . . . . .
B.2.2 RTAI . . . . . . . . . . . . . . . . . .
B.2.3 COMEDI and COMEDILIB . . . . . .
B.3 Laptop Performances . . . . . . . . . . . . . .
B.4 Sensor Readings . . . . . . . . . . . . . . . .
B.4.1 Laser to measure ϕ2 . . . . . . . . . .
B.4.2 Period Measurement (PM) for ωw . .
B.5 Connection to dSpace . . . . . . . . . . . . .
B.5.1 Read and Write Channels . . . . . . .
B.5.2 Test Compatibility of Simulink Blocks
B.5.3 Test Controllers . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
33
33
33
33
34
34
34
34
34
36
36
37
38
38
38
39
C Connections
C.1 Connection to the dSpace PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
C.2 Connection to the plant its laser and motor . . . . . . . . . . . . . . . . . . . . . . . . . .
C.3 Connection to the PM device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
41
41
41
41
IV
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
CONTENTS
CONTENTS
V
D DAQ Specifications
D.1 National Instruments DAQ DIO-24 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
D.2 National Instruments DAQ 6063E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
43
43
44
E Theory
E.1 Linearization around an Equilibrium
E.2 Linearization by Static Feedback . .
E.3 Linear Controller . . . . . . . . . . .
E.3.1 Linear State Feedback Law. .
E.3.2 Linear Observers . . . . . . .
45
45
45
46
46
47
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
F Ball Parameter Identification
51
G All Results
57
List of Symbols
81
Bibliography
81
1 Introduction
Digital process control is quite common in industrial applications. This report describes the setup of a
system that consists of a laptop and two digital acquisition cards, to carry out digital process control on
small systems.
The system that needs to be controlled by means of this laptop, is the so called Ball on the Wheel (BOW)
system. It can be seen in figure 2.1. It consists of a wheel and a ball. The wheel can be actuated by a
DC motor. The ball which has to be stabilized on top of the wheel can either be one out of four available
balls. Three of these balls are gymnastic balls and a fourth ball is made out of PVC. In chapter 2, the
plant, the modeling of the plant as well as the identification of the system parameters are discussed.
The main goal of the project this report handles about, is testing a new setup to control the above
mentioned system. The new setup consists of a laptop with two digital acquisition and output (DAQ)
cards. The laptop runs on Linux and the controllers can be constructed in Matlab/Simulink (Windows
version) and compiled in Linux. Previously the BOW system (and other systems like it) has been
controlled by means of a computer equipped with a dSpace card. The control with the laptop is less
expensive however.
As stated, the wheel can be actuated by a DC motor. It can generate a torque to let the wheel rotate,
when given an input voltage of −10 ≤ uA ≤ 10 . The ball has to be situated on top of the wheel and
its position is measured by a laser. The system is additionally equipped with an incremental encoder,
through which the angle of the wheel can be measured. The angular velocity can be determined by means
of a method called Period Measurement (PM), more about this in appendix B, in this appendix one can
also read more about the setup and the control environment. Detailed information about the motor, the
laser and the encoder can be found in [5] and [6].
Furthermore some developed controllers and their theory, will be discussed in chapter 3. In chapter 4
some results of the designed controllers are shown.
1
2 The Ball on the Wheel System
In figure 2.1, the BOW system can be seen. The ball needs to be stabilized at the top of the wheel,
by means of a laptop running on Linux. Furthermore the wheel can be actuated by a DC motor. The
position of the ball as well as the angular velocity of the wheel can be measured. More about the laptop
and its software and the connections between it and the system, can be read in appendix B. The way in
which the system is modeled is explained here, but to model the system, it is needed to make a schematic
representation of the system first. In figure 2.2, a schematic representation is shown. During the modeling
of the equations of motion, the assumption is made, that slip does not occur between the wheel and the
ball.
Figure 2.1: The Ball on the Wheel system
2.1
Modeling the BOW System
The equations of motion are derived by means of the Lagrange formula for mechanical systems
d ∂L
∂L
)−(
)=Q
(
dt ∂ q˙i
∂qi
(2.1)
with L = T − V , where T is the kinetic energy and V the potential energy of the system.
The kinetic energy is give by
Tm
Tw
Tb
ωb
vb
2
, ωm = iωw
= 12 Im ωm
1
2
= 2 Iw ωw
= 12 Ib ωb2 + 12 mb vb2
= r1b (rw ωw − (rw + rb ) ω2 )
= (rw + rb ) ω2
3
(2.2)
2. The Ball on the Wheel System
2.1. Modeling the BOW System
4
Figure 2.2: Schematic representation of the BOW system
and the potential energy is
Vw
Vm
Vb
rb ϕb
=
=
=
=
0
0
mb g (rw + rb ) cos (ϕ2 )
rw ϕw − (rw + rb ) ϕ2
(2.3)
For generalized coordinates qi = [ϕw , ϕ2 ] are used and if (2.2) and (2.3) are utilized in (2.1) and with the
generalized forces
Q=
ikm (uA −km ωm )
RA
0
− rv ωw
then the following equations of motion will arise
ϕ¨w = ω̇w
=
+
ϕ¨2 = ω̇2
=
+
2
RA Ib mb grw sin(ϕ2 )−(Ib +mb rb2 )(i2 km
+rV RA )ωw
2 )
RA ((Iw +Im i2 )(rb2 mb +Ib )+Ib mb rw
ikm (Ib +mb rb2 )uA
2 )
RA ((Iw +Im i2 )(rb2 mb +Ib )+Ib mb rw
2
2
RA mb g(Ib rw
+rb2 Iw +rb2 Iw i2 ) sin(ϕ2 )−Ib rw (i2 km
+rV RA )ωw
2 )
RA (rw +rb )((Iw +Im i2 )(rb2 mb +Ib )+Ib mb rw
ikm Ib rw uA
2 )
RA (rw +rb )((Iw +Im i2 )(rb2 mb +Ib )+Ib mb rw
(2.4)
(2.5)
In the vector Q, the torque of the motor is added, the dynamical system of the motor is neglected however,
since it is way faster than the dynamical system of the BOW plant. The viscous friction of the wheel is
also added in this vector. For simplicity other friction is neglected here. For a more detailed derivation
the reader is referred to [8]. To make these equations less complicated, the following new parameters are
introduced.
2. The Ball on the Wheel System
2.2. Linearization of the BOW Model
F
Z
2
= RA ((Iw + Im i2 )(rb2 mb + Ib ) + Ib mb rw
)
= (rw + rb )
α
β
= RA Ib mb grw
= (Ib + mb rb2 )
γ
δ
2
= (i2 km
+ rV RA )
2
= RA mb g(Ib rw
+ rb2 Iw + rb2 Iw i2 )
χ
ξ
= ikm
= Ib rw
5
If these parameters are substituded in (2.4) and (2.5), then they are given by
ϕ¨w = ω̇w
=
ϕ¨2 = ω̇2
=
α sin(ϕ2 ) − β · γ · ωw + χ · β · uA
F
δ sin(ϕ2 ) − ξ · γ · ωw + χ · ξ · uA
F ·Z
(2.6)
(2.7)
For the state vector x = [ωw , ϕ2 , ω2 ] is chosen, i.e. the angular velocity of the wheel, the position of
the ball and its time derivative. The angle of the wheel ϕw is not taken in the state vector, since the
differential equations do not depend on this variable. The system equations can be written as
ẋ = f (x) + g(x) · u
with
f (x)
g(x)
2.2
=
=
α sin(ϕ2 )−β·γ·ωw
F
ω2
δ sin(ϕ2 )−ξ·γ·ωw
F ·Z
χ·β
F
0
χ·ξ
F ·Z
(2.8)
(2.9)
Linearization of the BOW Model
To stabalize the ball on top of the wheel, the nonlinear BOW system, will be controlled by means of two
different control strategies. For the first one the system is linearized around the equilibrium points of the
system. For the other one, a linearizing feedback law is derived. The feedback linearized system serves as
the base for the flatness based control. Because of the fact that the system is exact feedback linearizable.
For both cases the mathematical theory is elaborately discussed in [6] and [7]. Moreover the most
important subjects, which are essential for this chapter, are illustrated in appendix E.1 and E.2.
Linearization of the BOW system
By means of the software package MAPLE, the equilibrium points of this system can be calculated. The
system is in equilibrium when f (x) + g(x) · u = 0 is fulfilled. The values for this equilibrium points are
denoted as xs and depend on the static input, uAs
χ
γ uAs
xs = 0
0
2. The Ball on the Wheel System
2.3. Feedback Linearization
6
This means that for every equilibrium point, the ball is on top of the wheel and stays there. As one can
easily see, there are infinitely many equilibrium points. For which the ball is on the top of the wheel,
while ωw has different values, depending on the value of uAs . By linearizing around an equilibrium point
the following linear matrices A and b are found
∂f
|x ,u
A=
∂x s As
b=
∂f
|x ,u
∂u s As
=
=
−β·γ
F
α
F
−ξ·γ
F ·Z
χ·β
F
δ
F ·Z
0
0
χ·ξ
F ·Z
0
0
1
0
(2.10)
(2.11)
These matrices do not depend on the equilibrium point nor the static input uA .
2.3
Feedback Linearization
For the second control strategy, feedback linearization is performed. Whether the system is exact feedback
linearizable and thus a flat output can be found will be discussed in this section. Furthermore, the theory
for this control strategy can be found in appendix E.2.
Exact feedback Linearization
Utilizing the AIsys package within the software package MAPLE [12], a linearizing feedback law is
calculated. Because (Lg h) · · · Lg Lfn−2 h = 0 has to hold for the system to be exact feedback linearizable.
First a suitable output y has to be found.
Next equations have to hold, if the system is exact feedback linearizable for a specific output: (Lg h) = 0,
(Lg Lf h) = 0 and the output should not depend directly on the input. The first equation is fulfilled when
the derivative with respect to time of the output does not depend on the input. This is fulfilled when the
next equation holds:
∂h
∂h
=−
∂x1
∂x3
∂g
∂x3
∂g
∂x1
=
ξ
Zβ
(2.12)
with x = [ωw , ϕ2 , ω2 ]T = [x1 , x2 , x3 ]T . This equation is also fulfilled when the output is equal to ϕ2 , but
with this output the second equation will not hold.
ξ
Equation (2.12) holds for y = Zβ
x1 − x3 . For this output, the second equation also is fulfilled. With
respect to this output the system can be exact feedback linearized. Thus this output is the desired flat
output. The state transformation follows as
ξ
h(x)
Zβ ωw − ω2
(2.13)
z = T(x) = (Lf h) (x) = ξα−βδ
βZF sin (ϕ2 )
2
ξα−βδ
Lf h (x)
cos
(ϕ
)
ω
2
2
βZF
The linearizing state feedback law for this transformations reads
βZ 2 F 2
ξα − βδ
δ sin (ϕ2 ) γωw
2
u= v−
sin (ϕ2 ) ω2
−
+
βF Z
cos (ϕ2 ) (ξα − βδ) χξ
χξ
χ
From (2.13) the inverse state transformation can be calculated symbolically
βZF
ϕ2 = arcsin
z2
ξα − βδ
βZF
βZF
z3
cos arcsin
z2
ω2 =
(αξ − βδ)
ξα − βδ
(2.14)
(2.15)
(2.16)
2. The Ball on the Wheel System
ωw =
2.4
Zβ
ξ
2.4. System Parameters
βZF
βZF
z3 + z1
cos arcsin
z2
(αξ − βδ)
ξα − βδ
7
(2.17)
System Parameters
For the modeling, several parameters of the system need to be identified. This is already done in [5] and
[6]. So the parameters for the wheel, the motor and the laser are already known. The parameters of the
ball need to be identified again. Since in the latter work a different ball has been used and in the other
work the same ball has been used but under different circumstances.
The system parameters are given in table 2.1.
Wheel parameters
Iw
rw
dw
Laser parameters
dx
dy
Motor parameters
Im
RA
km
Transmission parameter
i
Friction parameter
rV
0.156
0.269
0.088
14
2.3 · 10−3
Moment of inertia
Radius
distance between discs
[m]
[m]
Horizontal distance
Vertical distance
kgm2
[Ω] Nm
A
Moment of inertia
Anchor resistance
Constant of turning moment
[-]
Transmission coefficient
Nms viscous friction
0.238
0.3565
64.0 · 10−7
2.3
40.326 · 10−3
kgm2
[m]
[m]
rad
Table 2.1: BOW parameter values
Ball Parameter Identification
In [5], [6] and [8] the identification of the ball parameters can be seen. Four different balls have been
used, a blue, a green, a yellow and a red one. The values of the ball parameters of the four different
balls are listed below in table 2.2. The advantage of the red ball is its symmetry, since it is made out
of PVC while the other balls have to a certain extent an asymmetric structure, since they are made out
of rubber. Because of this, the moment of inertia can not be identified accurate enough for these balls
and therefore an average is taken, more about the identification of the ball parameters can be found in
appendix F.
blue ball
green ball
yellow ball
red ball
mb [kg]
0.2824
0.2859
0.4210
0.200
rb [m]
8.07 · 10−2
8.2 · 10−2
8.9 · 10−2
8.0 · 10−2
rb,red [m]
6.76 · 10−2
6.92 · 10−2
7.74 · 10−2
6.68 · 10−2
Table 2.2: Ball parameters
Jb [kgm2 ]
1.6 · 10−3
1.8 · 10−3
3.4 · 10−3
8.17 · 10−4
3 Controller Design
Both linear and nonlinear controllers will be discussed here. The linear ones will be discussed shortly
however, since they are only used to test the setup and because the theory is rather easy.
3.1
Linear Controller and Observer
Before designing a nonlinear controller, a linear controller is designed and implemented, to test the new
setup. Linear controllers are meant to stabilize the system around an equilibrium point. Since not all
states can be measured, linear observers will have to be designed as well. Controllers and observers have
been considered with both y = [ϕ2 ] and y = [ϕ2 , ωw ]. The theory to calculate the linear gains for these
controllers and observers can be found in appendix E.3, here only the values for these gains are given.
The model calculated in the foregoing chapter,
ẋ = f (x) + g(x) · u
with
f (x)
g(x)
=
=
α sin(ϕ2 )−β·γ·ωw
F
ω2
δ sin(ϕ2 )−ξ·γ·ωw
F ·Z
χ·β
F
0
χ·ξ
F ·Z
(3.1)
(3.2)
is linearized, through which the linear matrices from (3.3) and (3.4) are given.
∂f
A=
|x ,u
∂x s As
=
∂f
|x ,u
b=
∂u s As
=
−β·γ
F
α
F
−ξ·γ
F ·Z
χ·β
F
δ
F ·Z
0
0
χ·ξ
F ·Z
0
0
1
0
(3.3)
(3.4)
The system is discretised with a sample time of 1 [ms] and the controllers and observers are designed.
3.1.1
Linear State Feedback Law.
For the implementation on the laptop in order to control the real plant the following values are taken for
K.
Kd,startup
=
Kd
=
−1.147 71.84 18.18
−10.47 275.3 71.35
Two different gains have been chosen, one to make a slow controller, which can be used to sweep the ball to
the top of the wheel. The eigenvalues of this slow controller are λ1 = 0.999, λ2 = 0.996 and λ3 = 0.996.
The second controller is designed to have an as good as possible linear controller, so a fast controller
which can be used when the ball is already on top of the wheel, with eigenvalues, λ1 = 0.996 + 0.000621i,
λ2 = 0.996 − 0.000621i and λ3 = −0.984.
9
3. Controller Design
3.1.2
3.1.2. Linear Observers
10
Linear Observers
Two linear observers are taken into consideration. The first one, called the identity observer, estimates
all states. The other one, the reduced observer, only estimates the states, which are not measured.
The values for the identity observer which are taken, to implement in the controller to control the real
plant are given by
K̂ϕ,id
K̂GT M,id
=
=
−2.754 0.6199 1.150
7.837 · 10−4
0.6191
0.6408
T
0.9893
2.815 · 10−6
−2.501 · 10−4
There are two different vectors, since both the cases with y = [ϕ2 ] and y = ϕ2 ωw are considered.
This observer is used to implement in the slow controller, to sweep the ball to the top of the wheel and
therefore it does not need to have a fast behavior.
The values for the reduced observer which are taken, to implement in the fast controller to control the
real plant are given by
3.1.3
K̂ϕ,red
=
K̂GT M,red
=
Simulation
−264.4 15.37
T
−9.959 0.006284
The controllers and observers are implemented in Matlab/Simulink. With this program it is possible to
test the controller. First the linear controller and observer are checked by letting it control the linear
system. After that the controller is used to control the nonlinear BOW model. To simulate the nonlinear
system a S-function is written in C-code.
BOW plant
Now the controllers are used to control the BOW plant. At first only the position of the ball is measured.
For this output the estimated values for ωw and ω2 are very noisy, because of the noise on the measured
state. Because of this the calculated input has even more noise. This results in a stable controller, though
the motor has to shift gears very often and makes an awkward sound.
Therefore the measured value for ωw is taken with it in the controller. This controller works significantly
better. The results from both controllers are discussed in chapter 4.
Finally a controller is made in which one can change equilibrium
points,
by changing uAs in realtime.
The controller together with the reduced observer with y = ϕ2 ωw shows the smallest oscillations
when the ball is stabilized on top of the wheel. Furthermore in this controller a switch is build in which
can be put in three different states. In the first one the motor gets no input voltage, one can switch to
this state, to change balls for instance. The second one is a really slow controller, this controller can be
used to sweep the ball to the top of the wheel, from the starting position, this controller is made with an
identity observer, just to show this observer works well. Finally, the third controller is a faster controller.
This one should be used when the ball is already on top of the wheel.
3.2
Feedback Linearization
In this section the feedback linearizing controller is discussed. This controller compensates for the nonlinear terms in the equations of motion such that a linear model remains. This linear model is controlled
by an error controller. The original states are transformed to z coordinates like is discussed in chapter
1.3. And these coordinates are compared with a desired value for the coordinates at a certain time. The
error between these values is controlled to zero by the error controller.
3. Controller Design
3.2.1. Trajectory Generator
11
The desired value for the z coordinates are generated by a trajectory generator. And the x coordinates
which can not be measured are estimated by a trajectory observer. The theory to these parts of the
controller are discussed in this section of chapter 3. In figure 3.1 a systematic overview of the controller
can be seen.
Figure 3.1: Schematic representation of a feedback linearizing controller
3.2.1
Trajectory Generator
To be able to calculate the error between the real values of the states and the desired ones, a trajectory
generator is designed. The trajectory is always a nth order polynomial. The most important part of the
trajectory is that both at the step time as well as at the end time the polynomial has to satisfy some
criteria. First of all, at the starting time the value of the polynomial has to be equal to the value of
the state at that time. Second, at the end it should be equal to the desired value. Finally some of its
derivatives in both points, have to be zero. The number of derivatives which have to be zero is r + 1, r
being the relative degree.
Trajectory for changing ωw
To make a trajectory to change ωw a trajectory for z1 needs to be calculated and there are ten boundary
conditions for a trajectory to change z1 . If the trajectory has to be followed from t = 0 [s] till t = T [s],
the boundary conditions read
z1,d (t = 0) = z1,initial , z1,d (t = T ) = z1,end
(3)
(4)
ż1,d (t = 0) = z̈1,d (t = 0) = z1,d (t = 0) = z1,d (t = 0) = 0
(3)
(4)
ż1,d (t = T ) = z̈1,d (t = T ) = z1,d (t = T ) = z1,d (t = T ) = 0
With these ten boundary conditions a unique polynomial
of ninth
order can be calculated. It can be
0 −5 5 for the three different trajectories and
seen in figure
3.2
in
x
coordinates.
With
ω
=
w,initial
ωw,end = −5 5 0 . The initial and end values for z1 can be calculated using (3.5).
ξ
h(x)
Zβ ωw − ω2
(3.5)
z = T(x) = (Lf h) (x) = ξα−βδ
βZF sin (ϕ2 )
ξα−βδ
L2f h (x)
cos
(ϕ
)
ω
2
2
βZF
Between the different trajectories a delay is added, such that the ball stays some seconds in the equilibrium
point. The calculated polynomial reads
420
540 2 315 3 70 4
∆z1 5
t − 2 t + 3 t − 4t
z1,d (t) = z1,initial + 5 t −126 +
T
T
T
T
T
with ∆z1 = z1,initial − z1,end .
3. Controller Design
3.2.2. Controller
12
The trajectories for z2 and z3 , can easily be calculated by taking time derivatives of this polynomial.
This is automatically done by the S-function of the trajectory generator.
20
omegaw, [rad/s], phi2 [deg], omega2 [deg/s]
omegaw
phi
15
2
omega
2
10
5
0
−5
−10
−15
−20
0
2
4
6
8
time [sec]
10
12
14
Figure 3.2: Trajectory to change ωw in x coordinates
Trajectory for changing ϕ2
Another trajectory which is taken, is a trajectory where the ball moves over the wheel, in such a way
that ϕ2 oscillates between 9 and -9 degrees. Hereto a trajectory for z2 needs to be calculated, this means
eight boundary conditions need to be taken into consideration. If the trajectory has to be followed from
t = 0 [s] till t = T [s], the boundary conditions read
z2,d (t = 0) = z2,initial , z2,d (t = T ) = z2,end
(3)
ż2,d (t = 0) = z̈2,d (t = 0) = z2,d (t = 0) = 0
(3)
ż2,d (t = T ) = z̈2,d (t = T ) = 0 = z2,d (t = T )
With this eight boundary conditions a unique polynomial of seventh order can be calculated. Because the
trajectory generator needs to have the polynomial for z1,d , the trajectory for z2 needs to be integrated
once
as well. In figure 3.3 the polynomial of eighth order
can be seen
in x coordinates. With ϕ2,initial =
0 9 −9 for the three trajectories and ϕ2,end = 9 −9 0 . The initial and end values for z2
can be calculated using (3.5).The calculated polynomial for z1,d reads
14
5
10
∆z2
z1,d (t) = z2,initialt + 4 t5 −7 + t − 2 t2 + 3 t3
T
T
T
T
with ∆z2 = z2,initial − z2,end .
3.2.2
Controller
Since the nonlinear terms are compensated for in the linearizing feedback, the error controller has to
control a linear system. Thus it can be designed by means of the LQR command, for example. In
simulation the values for the different matrices are adapted, till the desired behavior occurs. The values
which are implemented for Ker are as given in (3.6).
Ker =
316.2 144.7 17.3
(3.6)
3. Controller Design
3.2.3. Trajectory Observer
13
5
omegaw
4
phi
2
omega
3
2
2
z1, z2, z3
1
0
−1
−2
−3
−4
−5
0
2
4
6
8
time [sec]
10
12
14
Figure 3.3: Trajectory to change ϕ2 in x coordinates
3.2.3
Trajectory Observer
Both the feedback linearizing controller and the error controller, require all states to be measured. But
like is mentioned before, not all system states can be measured. Therefore also an observer has to be
designed. When the ball is controlled to an equilibrium point by means of a linear controller and observer,
the system is linearized around that equilibrium point and therefore the controller only works when the
states have small perturbations around the equilibrium point. In this case the system is linearized along a
trajectory and therefore the observer only works if the states have small perturbations around the desired
trajectory. This special observer, is called the trajectory observer here, [7].
As stated before, only the states ϕ2 and ωw can be measured. The trajectory observer for the BOW
system has first been designed in [7]. Since a different coordinate transformations as well as a different
notation is used, some of these observers are redesigned here. Full state as well as reduced observers will
be designed, with both y = [ωw , ϕ2 ] and y = [ϕ2 ].
Trajectory planning with state observation
The observation of the states is done by means of the measured states and the input voltage, under the
assumption that these states and the input are close to the desired values. The observer then can be
based on the system equations, which are linearized along the trajectory. This leads to a linear time
varying system. Lateron the time variance is compensated for and the error dynamics are stabilized. The
structure of the closed loop of the observer and the trajectory controller can be seen in figure 3.4. Here
y ∈ Rl are the measured states and x̂ ∈ Rn are the estimated ones.
Nonlinear observer
The BOW system can be written in the following way
ẋ
y
= f (x, u) ,
= h(x),
x(0) = x0 , u ∈ Rm
y ∈ Rl
(3.7)
The nonlinear observer with time variance compensation will need to have the form presented in (3.8)
and will be designed with the help from [3] and [7]
x̂˙ = f (x̂, u) + K̂ (t) (h (x̂) − y) ,
x̂ (0) = x̂0
(3.8)
3. Controller Design
3.2.3. Trajectory Observer
14
Figure 3.4: Closed loop structure of observer and trajectory controller
Here K̂ (t) is the actual design parameter and should have such values that the error, e = x̂ − x, tends
to zero. The differential equation for this error is given by
ė = f (x̂, u) − f (x, u) + K̂ (t) (h (x̂) − h (x))
e (0) = x̂0 − x0
(3.9)
The observer which is discussed here, will be designed under the assumption that the differences between
the desired values zd and the real values of z will be small then the in (3.10) given perturbations will
also be small.
∆x = x − xd
(3.10)
∆u = u − ud
Because the perturbations are assumed to be small, the system states are located nearby the trajectory
at every time. Under this assumption it is permitted to linearize the system from (3.7) around the
trajectory. After doing this a linear time variant system remains
˙
∆x
∆y
=
=
A (t) ∆x + B (t) ∆u,
C (t) ∆x
∆x (0) = x0 − xd (0)
(3.11)
with:
∂f (x, u)
∂h (x)
∂f (x, u)
|xd (t),ud (t) , B (t) =
|xd (t),ud (t) , C (t) =
|xd (t)
∂x
∂u
∂x
The linearization around the desired trajectory requires the knowledge of both the trajectory values,
xd (t), as well as the input for that trajectory, ud (t). These values can be calculated from the desired
trajectory zd (t). The start value for the approximation is chosen as x̂0 = xd (0) and because of the error
controller the perturbation ∆x̂ = x̂ − xd between the estimated value and the desired value is assumed
to be small. And therefore the error dynamics given in (3.9) are linearized around the desired trajectory.
h
i
˙ = A (t) ∆x̂ + B (t) ∆u + K̂ (t) (C (t) ∆x̂ − C (t) ∆x) − [A (t) ∆x + B (t) ∆u]
∆e
{z
}
{z
} |
|
A (t) =
observer
system
with the matrices from (3.11). In error coordinates follows
˙ = A (t) + K̂ (t) C (t) ∆e = Ae (t) ∆e
∆e
(3.12)
˙
∆ξ
∆y
(3.13)
with a time variant system matrix Ae (t). Assuming that the system is observable, it is possible to give
K̂ (t) such parameters, that the time variance in AeO (t), the error system matrix in observer normal
from, is compensated for and the resulting time invariant system is asymptotically stable. To be able
to find such a gain, the matrices from (3.11) should be exponentially limited, [3], this means that the
components of the matrices stay within boundaries, which can be given by any exponential function.
This limitation can be established by choosing the right trajectory. To find the right parameters for K̂ (t)
easier, the system of (3.11) should be transformed into the time variant observer normal form.
=
=
AO (t) ∆ξ + BO (t) ∆u
CO (t) ∆ξ
3. Controller Design
3.2.3. Trajectory Observer
The matrices of (3.13) have the following form [7]:
Ā11 (t) Ā12 (t)
···
Ā1l (t)
..
.
.
Ā21 (t) Ā22 (t)
.
.
AO (t) =
..
.
.
..
..
Āl−1,l (t)
.
Āl1 (t)
···
Āl,l−11 (t)
Āll (t)
with
0
1
0
Āii (t) =
.
..
0
0
and
0
0
0
Āij (t) =
.
..
0
0
Furthermore
T1
CO = ...
Tl
0 0
0 0
1 0
.. ..
. .
0 0
0 0
0 0
0 0
0 0
.. ..
. .
0 0
0 0
with Ti =
0
···
···
..
.
···
···
..
.
..
..
.
···
···
.
···
···
···
···
..
.
···
···
..
.
..
..
.
···
···
···
.
···
···
1y(i)
ay(i−1)+1,y(i) (t)
ay(i−1)+2,y(i) (t)
..
.
..
.
ay(i)−1,y(i) (t)
ay(i),y(i) (t)
ay(i−1)+1,y(j) (t)
ay(i−1)+2,y(j) (t)
..
.
..
.
ay(i)−1,y(j) (t)
ay(i),y(j) (t)
···
0
15
(3.14)
and y(i) =
i
X
yj
(3.15)
j=1
The values for yj are the observer indices. The error dynamics in the observer normal form read
˙ = AO (t) + K̂O (t) CO (t) ∆ε
∆ε
(3.16)
The parameters for K̂O (t) are easy to find, as will be shown further on. After the transformation
backwards to the original coordinates, the design of the observer is done.
This observer normal form exists if the system is observable, so what remains is the explanation how to
see whether the system is observable and the way in which the coordinate transformation matrix can be
calculated.
Observability of time variant systems
When linearized along a trajectory, normally what remains is a time variant system. To check whether
the linear time variant system is observable, one has to check a time variant observabillity matrix.
Given is a linear time variant system
ẋ
y
with x ∈ Rn , u ∈ Rm and y ∈ Rl .
= A(t)x + B(t)u
= C(t)x
(3.17)
3. Controller Design
3.2.3. Trajectory Observer
16
This system is then and only then observable when the time variant observability matrix, Q, is of rank
n all the time [3]
cT1 (t)
..
.
y1 −1 T
MA
c1 (t)
.
..
Q(t) =
T
cl (t)
..
.
MyAl −1 cTl (t)
(3.18)
In here the vectors cTi (t) are from the matrix C(t) from (3.17). MA is the differential operator
T
k T
MA cTi = cTi A + ċTi , Mk+1
A c = MA MA ci ,
k ≥ 0, M0A = cTi
Transformation to time variant observer form
To transform an observable time variant system like the system in (3.17), the time variant state transformation matrix is chosen as
ξ = Θ (t) x
To define this matrix, first a second differential operator, which operates on a vector b, is defined:
k
N0A b = b, NA b = Ab − ḃ, Nk+1
A b = NA NA b ,
k≥0
Now the matrix can be calculated according to (3.19), see [3].
Θ−1 (t) =
with
N0A θ1 , . . . , NyA1 −1 θ1
yl −1
θl
| · · · | N0A θl , . . . , NA
(3.19)
[θ1 (t), . . . , θl (t)] = Q−1 (t)CTO (t)
And after differentiating the new statevector the system from (3.13) remains with
AO (t) =
Θ̇(t) + Θ(t)A(t) Θ−1 (t)
BO (t) = Θ(t)B(t)
CO (t) = C(t)Θ−1 (t)
(3.20)
The Reduced Trajectory Observer
The, in the above section, discussed observer (3.8), estimates all states, and so it is called a full state
observer. Like in the linear case, there is also a reduced form, which only estimates the unknown states.
The design of this observer is also based on the flat output and the linearization of the system around
the trajectory. The assumption is made, like for the full state observer, that the error controller keeps
the values nearby the desired ones. In contrast with the full state observer, the reduced one is in this
case going to be a linear observer.
To design the reduced observer, the BOW system, which is linearized around a trajectory and with a
time variant differential equation, but with a time invariant output is considered
ẋ
y
= A(t)x + B(t)u
= Cx
(3.21)
3. Controller Design
3.2.3. Trajectory Observer
17
For (3.21) the following holds
rank (C) = dim (y) = l
Furthermore, the statevector is transformed into x = yT wT , with y the measured states and w the
unmeasured ones. The statevector is transformed into this form by means of the transformation matrix
C
T=
V
with rank (T) = n. Now the system can be written in the next form
ẏ
A11 (t) A12 (t)
y
B1 (t)
=
+
u
ẇ
A21 (t) A22 (t)
B2 (t)
w y
I 0
y
=
w
(3.22)
with the dimensions:
y : l × 1, w : (n − l) × 1, B1 (t) : l × m, B2 (t) : (n − l) × m
A11 (t) : l × l, A22 (t) : (n − l) × (n − l), A12 (t), AT21 (t) : l × (n − l)
Only the part of the states, called w needs to be estimated and therefore a next quantity is introduced
v = w + K(t)y
(3.23)
with a time variant matrix, K(t) : (n − l) × l, which is determined lateron. The differential equation of
this new quantity reads
v̇ = ẇ + K̇(t)y + K(t)ẏ
or when (3.22) and (3.23) are joined together
v̇
=
+
(A22 (t) + K(t)A12 (t)) v + (K(t)B1 (t) + B2 (t)) u
K̇(t) + A21 (t) + K(t)A11 (t) − A22 (t)K(t) − K(t)A12 (t)K(t) y
To estimate w the new quantity, v, is estimated and the reduced observer has the form
v̇
=
ŵ
+
=
(A22 (t) + K(t)A12 (t)) v + (K(t)B1 (t) + B2 (t)) u
K̇(t) + A21 (t) + K(t)A11 (t) − A22 (t)K(t) − K(t)A12 (t)K(t) y
v − K(t)y
(3.24)
The time variant gain K(t) still needs to be determined. Therefore the approximation error is introduced,
e = ŵ − w. The error dynamics for that error are
ė = (A22 (t) + K(t)A12 (t)) e = Ă(t)e
(3.25)
The design parameter K(t) is chosen in such a way that the time variance of the matrix Ă(t) is compensated for and that the dynamics become asymptotically stable.
When these equations are based on system, which is linearized around the trajectory, then the observer
that needs to be implemented reads
v̇ = Ā22 (t) + K(t)Ā12 (t) v + K(t)B̄1 (t) + B̄2 (t) ∆u
K̇(t) + Ā21 (t) + K(t)Ā11 (t) − Ā22 (t)K(t) − K(t)Ā12 (t)K(t) ∆y
+
(3.26)
y
y
x̂ =
=
ŵ
wd + v − K(t)∆y
3. Controller Design
3.2.3. Trajectory Observer
18
with
∆y = y − yd = y − h(xd ), ∆u = u − ud , xTd =
ydT
wdT
and the matrices
∂f (x, u)
∂f (x, u)
Ā11 (t) Ā12 (t)
B̄1 (t)
=
|xd (t),ud (t) ,
|xd (t),ud (t)
=
Ā21 (t) Ā22 (t)
B̄2 (t)
∂x
∂u
Observer Design for the BOW System
Since both observers are based on the linearization of the system around the trajectory, first the linearized
system matrices are calculated. The system is given by
˙
∆x
= A(t)∆x + b∆uA
∆y
= C∆x
(3.27)
with matrices
and expressions
A(t) =
∆x
∆uA
∆y
−β·γ
F
0
−ξ·γ
F ·Z
α
F
cos (ϕ2,d (t))
0
δ
cos
(ϕ2,d (t))
F ·Z
= x − xd = ωw − ωw,d
= uA − uA,d
= y − Cxd
0
1 ,
0
ϕ2 − ϕ2,d
b=
χ·β
F
0
χ·ξ
F ·Z
ω2 − ω2,d
(3.28)
T
(3.29)
It is clear that for these time variant matrices only ϕ2,d (t) is needed. The values for this function can be
easily calculated from the desired trajectory of z1,d (t).
βZF
ϕ2,d (t) = arcsin ẏd (t)
ξα − βδ
With this function one can determine, the components of the matrices, A and b fulfill the in [3] given
criterion for the in the next part derived criterion. All components are absolutely limited, which means
the values stay within certain boundaries.
An observer with y =
ϕ2
ωw
T
When both the position of the ball as well as the angular velocity of the wheel are measured, then the
only value which needs to be estimated is ω2 . The output of the system is
T c1
0 1 0
∆y =
∆x =
∆x
(3.30)
cT2
1 0 0
To look whether the system described by (3.27) and (3.30) is observable, the observability matrix from
(3.18) has to be calculated. The observer indices are, y1 = 2, y2 = 1
cT1
0 1 0
Q = cT1 A + ċT1 = 0 0 1
(3.31)
cT2
1 0 0
Clearly this matrix is of full rank and so the system is observable. For the transformation in observer
normal form a matrix, Θ(t), can be calculated now. The output matrix in observer normal form reads
0 1 0
CO =
0 0 1
3. Controller Design
3.2.3. Trajectory Observer
19
which is used to calculate the vectors θ1 and θ2
Q−1 (t)CTO =
θ1
θ2
and the transformation matrix reads
0
Θ= 0
1
A full state observer with y =
ϕ2
ωw
0
1
0
0
= 0
1
1
0
0
1
0
0
(3.32)
T
The design of the observer from (3.8), is done by first transforming the system described by (3.27) and
(3.30), into the observer normal form. This is done by using (3.20)
δ cos(ϕ2,d )
ξγ
−
0
FZ
FZ
0
0
(3.33)
AO = 1
α cos(ϕ2,d )
βγ
0
−
F
F
The system matrix from the error dynamics, (3.12), can be calculated now with the matrix
k11 (t) k12 (t)
K̂O (t) = k21 (t) k22 (t)
k31 (t) k32 (t)
δ cos(ϕ2,d )
0
+ k11 (t) − FξγZ + k12 (t)
F
Z
k21 (t)
k22 (t)
ĂO (t) = AO (t) + K̂O (t)CO = 1
α cos(ϕ2,d )
βγ
0
+ k31 (t) − F + k32 (t)
F
(3.34)
The chosen parameters for K̂O (t) should be so, that the matrix ĂO (t) is not time varying anymore and
it should be Hurwitz. When keeping this in mind the parameters for K̂O (t) only can be
δ cos(ϕ )
ξγ
− F Z2,d − α10
F
Z
−α11
0
K̂O (t) =
α cos(ϕ2,d )
βγ
−
−
α
12
F
F
The parameters α10 , α11 and α12 have to be chosen in such a way, that the matrix from (3.34) is Hurwitz.
The characteristic polynomial reads as
det sI − ĂO = s2 + α11 s + α10 (s + α12 )
Finally the matrix K̂O (t) has to be transformed back to the original coordinates, before it is implemented.
This is easily done by K̂(t) = Θ−1 K̂O (t). This implemented in the system gives the nonlinear trajectory
observer
f (x̂)+guA
˙
ω̂w
ϕ̂˙ 2 =
ω̂˙ 2
+
z
}|
{
αsin(ϕ̂2 )−β·γ·ω̂w +χ·β·uA
F
ω̂2
δsin(ϕ̂2 )−ξ·γ·ω̂w +χ·ξ·uA
F ·Z
α cos(ϕ2,d )
βγ
−
F
F − α12
−α11
0
δ cos(ϕ2,d )
ξγ
− α10
− FZ
FZ
ϕ̂2 − ϕ2
ω̂w − ωw
3. Controller Design
3.2.3. Trajectory Observer
20
The eigenvalues of the observer will have to smaller than the eigenvalues of the controller. They should
not be that small that too big input voltages are calculated. Via trial and error next values are chosen
for the coefficients
α10 = 400,
α11 = 50,
α12 = 30
λ2 = −30,
λ3 = −10
which result in the eigenvalues
λ1 = −40,
A reduced observer with y =
ϕ2
ωw
T
The statevector of the linear system can be written in the next form
T
∆y
=
∆x = ∆ωw ∆ϕ2 ∆ω2
∆ω2
and like is done in (3.22) the system matrix can be divided into the four matrices
A11 =
A21 =
Together with K = [ k1
calculated by
h
− βγ
F
0
α cos(ϕ2,d )
F
− FξγZ
δ cos(ϕ2,d )
FZ
0
i
,
A12 =
0
1
, A22 = 0
k2 ], the system matrix of the error dynamics can be determined. It is
Ă = A22 + KA12 = k2
Because the matrix only consist of k2 , k1 can be chosen freely and is set to zero. The eigenvalue of the
system matrix is equal to k2 , so it should be chosen negative. From (3.26) the observer which has to be
implemented, can be calculated as
v̇
=
ω̂2
=
χξ
∆uA +
k2 v +
FZ
ω2,d + v − k2 ∆ϕ2
2
ξγ
δ cos (ϕ2,d )
− k2 ∆ϕ2 −
∆ωw
FZ
FZ
For the implementation in the controller for the real plant, the value k2 = −6 is chosen. This value again
is chosen via trial and error.
An observer with y = [ϕ2 ]
When only the position of the ball is measured, then both velocities ωw and ω2 need to be estimated.
The output equation of the systems reads in that case
y = cT x =
0 1
0
(3.35)
x
with (3.18) and (3.35) the observability matrix reads:
0
cT
= 0
cT A + ċT
Q(t) =
d
cT A + ċT
cT A + ċT A + dt
− FξγZ
1
0
δ cos(ϕ2,d )
FZ
0
1
0
This matrix is of full rank for every value of ϕ2,d . So the system is observable. To transform the system
to the observer normal form, first the output matrix in observer normal form has to be determined.
CO =
0
0 1
3. Controller Design
3.2.3. Trajectory Observer
21
Since there is only one output, the observer index for this output equals 3, otherwise the system would
not be observable. With (3.19) the transformation matrix can be calculated.
0 βγ
− FξγZ
F
βγ
Θ= 0
(3.36)
1
F
0
1
0
A full state observer with y = [ϕ2 ]
First the system matrix for the observer normal form is calculated out of (3.20) and (3.36)
cos (ϕ2,d )
0 0 γ(βδ−ξα)
F 2Z
δ
AO = 1 0
F Z cos (ϕ2,d )
βγ
0 1
−F
with this the time variance compensation gain can be determined
γ(βδ−ξα)
− F 2 Z cos (ϕ2,d ) − α0
KO =
− FδZ cos (ϕ2,d ) − α1
βγ
F − α2
With the choice of the parameters α0 , α1 and α2 the eigenvalues of the error dynamics can be placed.
By means of the other terms the time variance in the system matrix of the error dynamics in observer
normal form is compensated for. The characteristic polynomial of the error dynamics reads
det sI − ĂO = s3 + α2 s2 + α1 s + α0
Finally the time variance compensation gain needs to be calculated in original coordinates, with K(t) =
Θ−1 KO (t). And the full state trajectory observer reads
f (x̂)+g(x̂)uA
with:
z
˙
ω̂w
ϕ̂˙ 2 =
ω̂˙ 2
K(t) =
}|
αsin(ϕ̂2 )−β·γ·ω̂w +χ·β·uA
F
ω̂2
δsin(ϕ̂2 )−ξ·γ·ω̂w +χ·ξ·uA
F ·Z
mb grb2 γ cos(ϕ2,d )+F Zα0
ξγ
{
+ K(t) (ϕ̂2 − ϕ2 )
β(δ cos(ϕ)−F Zα1 )
Fξ
βγ
F − α2 δ cos(ϕ2,d )
βγ
− α1 − βγ
FZ
F
F −
+
−
α2
β 2 γZ(βγ−F α2 )
F 2ξ
For this observer, the following parameter values are chosen via trial and error:
α0 = 3566,
α1 = 2750,
α2 = 509
A reduced observer with y = [ϕ2 ]
To design the reduced observer, the simple state transformation
0 1 0
x̄ = Px, P = 1 0 0
0 0 1
T = y
is needed, to switch the order of the states to x̄ = ϕ2 ω1 ω2
w
T
.
3. Controller Design
3.2.3. Trajectory Observer
22
The submatrices from (3.22) read
A11 = 0, A21 =
Together with K̂(t) =
k1
"
α cos(ϕ2,d )
F
δ cos(ϕ2,d )
FZ
#
, A12 =
0 1
, A22 =
− χβ
F
− FχξZ
0
0
k2 , the system matrix of the error dynamics can be calculated
Ă(t) = A22 + K̂(t)A12 =
− χβ
F
− FχξZ
k1
k2
(3.37)
The matrix, Ă(t), is already time invariant and thus the determination of K̂, which is also time invariant,
only depends on the position the eigenvalues. The characteristic polynomial of the matrix from (3.37)
reads
γ (k1 ξ − k2 βZ)
(βγ − F k2 )
s+
det sI − Ă = s2 +
F
FZ
(3.38)
p(s) = (s − λ1 ) (s − λ2 )
(3.39)
while the desired polynomial looks like
From (3.38) and (3.39) the gain, K̂, can be calculated as.
k1
k2
=
Z
F ξγ
β 2 γ 2 + βγF λ1 + βγF λ2 + F 2 λ1 λ2
βγ+F λ1 +F λ2
F
The structure of the reduced trajectory observer looks like
v̇1
v̇2
ω̂w
ω̂2
=
+
"
=
− χβ
F
− FχξZ
χβ
F
χξ
FZ
k1
k2
v1
v2
α cos(ϕ2,d )
+ βγ
F
F k1 − k1 k2
δ cos(ϕ2,d )
+ FξγZ k1 − k22
FZ
ωw,d + v1
ω2,d + v2
−
k1
k2
#
∆uA
∆ϕ2
∆ϕ2
For implementation in realtime the eigenvalues are chosen, again via trial and error, like:
λ1 = −8,
λ2 = −2
When an observer with y = [ϕ2 ] is used, it can take longer before the angular velocity of the wheel is set
to zero. This is treated in [7].
Furthermore in [7] it is discussed whether an observer with y = [ωw ] can be used. It has been designed
and the conclusion is that it does not work at all. So it is not discussed in this work.
Discretization of the system
The observer system has to be discretised for implementation. The Euler method to solve differential
equations is applied. The Adams-Bashforth algorithm is implemented as well, which is done, since the
Euler method might not be numerically stable for the BOW system with a sampling time of 1 ms. It has
turned out that both methods are suitable for implementation.
3. Controller Design
3.2.4
3.2.4. BOW plant
23
BOW plant
After the controllers
observers are tested on the plant, it shows that using the full state
and the different
observer with y = ϕ2 ωw , results in the smallest errors between the desired trajectory and the real
values of the three states. As mentioned before, it happens sometimes that, for the case that only the
position of the ball is measured, it takes quite long before the angular velocity of the wheel is set to zero.
In addition the PM device generates unwanted peaks in the ωw signal. When the signal for this state is
taken to calculate uA , like is the case with the reduced observer, these peaks will appear in uA as well.
The full state observer calculates all states through which these peaks are smoothed out. If one wants
to use the reduced observer efficiently, a routine has to be written which takes care of filtering out the
mentioned peaks. This has already been done in [7] as well.
Furthermore the feedback linearization controllers are equipped with a switch to choose between different
trajectories. The switch should always have the value 1 or 2, when the process is started, since for 1 the
controller does not output anything, for 2 the trajectory to bring the ball to the top is run, for 3 the
change in equilibrium points is followed, for 4 the trajectory for the oscillating of ϕ2 is run and finally
for 5 points 3 and 4 are alternated.
4 Results
The linear controllers are used to stablilize the system around specific equilibrium points. With the
nonlinear controller some trajectories are taken for different balls, they can be seen in appendix G. In
this chapter some main results will be discussed.
4.1
Linear Controllers
The linear controller with the smallest oscillations in the equilibrium points is the controller with y =
ϕ2 ωw with the reduced observer. These oscillations in the equilibrium point can be blamed on the
fact that the gearbox as well as the bearings do not work perfectly. Furthermore the model is based on
a 2D schematic representation, while the real system consists of three dimensions. The fact, that only
viscous friction is considered in this model and other friction is neglected will also contribute to these
oscillations.
4.2
Nonlinear Controller
The best tested nonlinear
controller
is the feedback linearizing controller with the full state trajectory
observer with y = ϕ2 ωw . In this chapter we also have a look at the results of the nonlinear
controller with full state trajectory observer with y = [ϕ2 ].
Nonlinear controller with the full state trajectory observer with y = [ϕ2 ]
In chapter 3 it is mentioned that for this observer it can take some time before the angular velocity of
the wheel is set to zero. In figure 4.1 this can be seen clearly, where the three states are shown while a
trajectory for ϕ2 is taken.
Nonlinear controller with the full state trajectory observer with y =
ϕ2
ωw
The results of this controller, can be seen in figure 4.2, while taken a trajectory for ϕ2 . This controller
follows the trajectory for ϕ2 very closely and has therefore a good behavior. All states are estimated
since the full state trajectory observer is implemented. After the trajectory is taken the ball does not
overshoot significantly, except for the first time, but this depends on the actual ball starting orientation.
In comparison with the above mentioned controller with y = [ϕ2 ], the angular velocity of the wheel is
way closer to the desired value. The values for ϕ2 however, are approximately the same, when oscillating
ϕ2 , while in the equilibrium point the controller for two measured states is significantly better again.
Nonlinear controller with the reduced trajectory observer with y =
ϕ2
ωw
When using the reduced trajectory observer together with the signals ϕ2 and ωw there are some peaks
in the signal of ωw , therefore this observer is not chosen for implementation in the final controller. Like
can be seen in figure 4.3 however, it shows less big oscillations when it is controlled to the equilibrium
point. This will be even better, when the red ball is used to stabilize on the wheel. The oscillations have
a maximum of 0.002 radians in both ways, which is about half a millimeter. For comparison it is 0.005
radians in both ways for the full state observer, which is about 1.3 mm.
The main conclusion after seeing these results has to be, that the controllers which use both measurements
work significantly better than the ones, only using the measurement of the position of the ball. Therefore
both measurements should be used when designing a controller if that is possible. Results of different
maneuvers and different controllers can be seen in appendix G.
25
Oscillations in the equilibrium point can be blamed on, as stated before, gears, bearings and a too
inaccurate model, both with respect to friction and with respect to the schematic model.
5
measurement
desired trajectory
omega
w
0
−5
−10
0
5
10
15
time [sec]
20
25
30
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
time [sec]
20
25
30
0.4
measurement
desired trajectory
0.3
0.2
omega
2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
time [sec]
20
25
30
Figure 4.1: Results of feedback linearizing controller with full state observer for y = [ϕ2 ], while taking a
trajectory for ϕ2 .
4. Results
4.2. Nonlinear Controller
2
27
measurement
desired trajectory
0
omega
w
−2
−4
−6
−8
−10
−12
0
5
10
15
time [sec]
20
25
30
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
time [sec]
20
25
30
0.5
measurement
desired trajectory
0.4
0.3
omega
2
0.2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
time [sec]
20
25
30
Figure 4.2: Results of feedback linearizing controller with full state observer for y =
taking a trajectory for ϕ2 .
ϕ2
ωw , while
4. Results
4.2. Nonlinear Controller
28
1
measurement
0
omega
w
−1
−2
−3
−4
−5
−6
0
2
4
6
8
10
time [sec]
0.35
measurement
0.3
0.25
0.2
phi
2
0.15
0.1
0.05
0
−0.05
−0.1
−0.15
0
2
4
6
8
10
time [sec]
0.4
measurement
0.2
0
omega
2
−0.2
−0.4
−0.6
−0.8
−1
−1.2
0
2
4
6
8
10
time [sec]
Figure 4.3: Results of feedback linearizing controller with reduced observer for y =
taking the ball from the begin position to the top of the wheel.
ϕ2
ωw , while
5 Conclusions and Recommendations
In this report a setup to control systems like the Ball on the Wheel (BOW) system, is discussed. To
test the control system, linear controllers and observers are implemented. In appendix G the results of
this controller can be seen. Another controller to test the setup is the nonlinear, feedback linearizing,
controller, with a trajectory observer. The results of this controller can be seen in appendix G as well.
Finally the results of the trajectories taken with these controllers can be seen in this appendix too.
The results clearly show, that the controllers developed, worked sufficiently on this Linux based control
system. In contrast to other controller setups, this system has some advantages.
First of all it is very easy to work with. If a control strategy needs to be tested, first it is just modeled
in Matlab/Simulink. When the controller is tested in Simulink it can be transferred to the laptop. On
the Linux system the source code is compiled and after that the controller can be tested. In this way it
is not only very easy to test a certain controller, but it is not time consuming at all, as well.
The number of devices needed to test the controller in realtime is small. This means the setup is rather
easy to move and build up. Because of the small number of devices needed, the costs of the whole setup,
excluding the plant, are not high as well.
A third advantage is the implementation of loops with different sampling times. In Simulink different
loops can be given different sampling times and they only need to be separated by a rate transition block.
Because of this, the performances of the laptop can be optimally used.
The controllers with y = ϕ2 ωw , showed a better behavior than the controllers with y = [ϕ2 ]. It can
be concluded that the observers do not estimate the angular velocity of the wheel well
enough. Since the
error between the desired trajectory and the real one is small with y = ϕ2 ωw , it can be concluded
that both measurements are required.
During the trajectory and during the stabilization of the ball on top of the wheel, the ball makes some
small oscillations. These oscillations are bigger for higher angular velocities of the wheel. The oscillations
can be blamed on the fact that the gearbox as well as the bearings do not work perfectly. Furthermore
the model is based on a 2D schematic representation, while the real system consists of three dimensions.
The fact, that only viscous friction is considered in this model and other friction is neglected will also
contribute to these oscillations.
During the three months in which the work is done, there has not been enough time to work out all the
subjects that are wanted. Some points which are left for the future are:
• Build a 3D model and schematic representation
• Add complex friction to model
• Better identification of ball parameters
• Adapt rubber belt of the wheel
The first two points are recommendations for the model of the ball on wheel system. Some assumptions
made in this work, can contribute to errors between simulations and experiments. Therefore it is recommended to construct a 3D schematic representation and the friction model should be extracted in such a
way that it also handles more complex friction, than viscous friction.
The last two points regard to the BOW plant. Like can be read in the second chapter, the identification
of the ball is not satisfiable. A few different alternatives are thought of, but they are not executed.
Another way to identify the ball parameters may be by taking a trajectory for some time, while a controller
is running that deals with a roughly estimated inertia but still stabilizes the ball along the trajectory.
Then one can use the method discussed in appendix F, to identify the inertia of the ball.
29
5. Conclusions and Recommendations
30
The ball still will show an asymmetric behavior however, through which it is not possible to rotate the
wheel at high velocities, since the ball starts to bounce then. The symmetric red ball showed a great
behavior though, controllers are actually able to stabilize it on top of the wheel significantly better then
the other balls. But because of the smoothness of the ball’s surface, slip will occur when the wheel
accelerates too fast. That is why it is suggested that the red PVC ball discussed in this report is adapted
in such a way that the surface is less smooth, through which more friction between the wheel and the
ball will remain. So that the wheel is able to have a high acceleration without slip occurring between the
ball and the wheel.
Finally the rubber belt on the wheel makes the wheel not to be a perfect circle, so it could be helpful to
adapt the rubber belt around the discs.
A Implementation of a Controller
Now it is shown, how an already made controller, can be implemented on the laptop and how the controller
is run. Some of the, in this report discussed controllers, are copied to a folder on the laptop, if you go
to the folder /home/test/BOWtest/Controllers you can run them (’./filename -v -f &’) without having
to compile them. All filenames of these controllers will end with a color, this is the color of the ball it is
designed for. The controllers are:
lincontzm_blue
This is a linear controller with a reduced (linear) observer. Both ϕ2 and ωw are used to approximate ω2 .
The controller is equipped with a switch, with this one can switch between different states: 1 no input; 2
a slow controller; 3 a fast controller. When started the slow controller works. Because of this it can just
sweep the ball to the top of the wheel, from the begin position. (So it is not needed to hold it on top
of the wheel when it is started.) Furthermore the constant u_As can adapted in the parameter block in
XRtaiLab, to switch between equilibrium points. |uAs | ≤ 4.
linconphi_blue
Same controller as lincontzm_blue, but this one only uses the state ϕ2 to approximate the other two.
multi_traj_gtm_blue
This controller makes use of a linearizing feedback. Both ϕ2 and ωw are used to approximate ω2 . This is
done by a full state trajectory observer. When the controller is started the ball has to be in the starting
position (so do not put it on top of the wheel!). With a trajectory generator the ball is moved to the top
of the wheel. Now one can switch between different trajectories. In the parameters window in XRtaiLab,
the constant switch can be put to:
1
2
3
4
5
no input
trajectory from starting point
switching between equilibrium points
let the ball follow a trajectory (changing ϕ2 ).
switching between program 3 and 4
After the ball is swept on by program 2, it keeps the ball on the top. If the switch is put to 1 and then
to 2 again it follows the trajectory from the starting point again. If it is put from 3, 4 or 5 to 2, then it
stabilizes the ball on top again. Programs 3, 4 and 5 keep on following their trajectory with periods of
15 sec1 .
multi_traj_phi_blue
Same controller as multi_traj_gtm_blue, but this one only uses the state ϕ2 to approximate the other
two.
multi_traj_red_gtm_blue
Same controller as multi_traj_gtm_blue, but this one is equipped with the reduced trajectory observer
in stead of the full state observer.
1 When
the switch value is adapted it takes some seconds (maximal 15 sec) before the plant reacts.
31
A. Implementation of a Controller
32
multi_traj_gtm_green
Same controller as multi_traj_gtm_blue, but this one is compiled with the parameters of the green ball
in stead of those of the blue one.
multi_traj_gtm_yellow
Same controller as multi_traj_gtm_blue, but this one is compiled with the parameters of the yellow
ball in stead of those of the blue one.
multi_traj_gtm_red
Same controller as multi_traj_gtm_blue, but this one is compiled with the parameters of the red ball
in stead of those of the blue one. When this controller is started the ball should be at the top
position. This is because when a trajectory to bring the ball to the top of the wheel is run,
there will occur slip.
multi_traj_red_gtm_green
Same controller as multi_traj_gtm_blue, but this one is equipped with the reduced trajectory observer
in stead of the full state observer and it is compiled with the parameters of the green ball in stead of
those of the blue one.
Implementation of a just developed controller
Now it is shown how to compile a in Matlab/Simulink modeled controller.
• First a controller has to be modeled in Matlab/Simulink. To get the measured states the RTAI
devices blocks can be used. In the window simulation parameters under the tab realtime workshop,
it should be indicated that the build model will be put in a folder called test_rtai. Furthermore
the simulation time should be put to inf.
• When S-functions are used, the C-code of it should be pasted inside the folder called test_rtai
• Start the laptop and enter the kernel 2.6.15.7. The username is: test, and the password is test as
well.
• After entering the terminal and registering as super user (password: test), move to the folder
ni_daq6036 (by typing ’cd ni_daq6036’). Here run the init file twice, to mount the DAQ cards to
the drivers of COMEDI (make sure the cards are pushed into the PCMCIA slots and type ./init)
• Now go to the folder BOWtest (or another folder) (’cd ..’; ’cd BOWtest’).
These three points only need to be executed the first time. As long as the laptop is not shut down they
do not need to be executed.
• Copy the Matlab/Simulink test_rtai to the folder BOWtest on the laptop.
• Now compile the source code, by typing in the test_rtai folder ’make -f test.mk’
• Finally type ’./test -v -f &’ to run the file, make sure all device are powered before doing this.
• With typing ’xrtailab &’ XRtaiLab will be opened in a different window in here you can visualize
the data and adjust parameters.
B Control Environment
To control the Ball on the Wheel system, a laptop (HP OmniBook) set up with the operating system
Linux (Debian) is used. Several software packages are installed on the laptop, in order to be able to
interact with the plant in realtime.
The control functions can be programmed manually via text editors. This control system also allows
the code generation directly from a Scilab/Scicos simulation model or from a Matlab/Simulink (Windows/Linux based) model at the touch of a button. So, for example, the control algorithms can be
created and simulated in Matlab/Simulink (Windows version). Then the realtime code is generated by
the Realtime Workshop of Matlab, which can be executed on the Linux based control system without
any further modifications.
This control system is a realtime system for performing fast control law prototyping from scratch. Users
can develop and test control functions rapidly and reliably in real time. Latency times of control processes
without overruns down to 3.5 µs can be realized. Another significant advantage of this system is its
compactness. This control system offers a new way to implement software for automatic control in a
cheap and very efficient hardware environment.
In this appendix the software and hardware used and the performances of the laptop will be discribed,
as well as the utilized sensors and the way in which they are connected to the laptop.
B.1
Hardware
To interact with the system, the laptop is equipped with two digital acquisition and output (DAQ) cards
of National Instruments.
B.1.1
National Instruments, DAQ 6063E
With this card one is able to either connect to the system or to a computer with a dSpace card. If it
is connected to the system, the card is used to read the distance the laser measures and to write the
calculated input voltage to the motor. Both the ADC’s and DAC’s have a resolution of 16 bits. The
connections between the plant and the card can be seen in appendix C.2.
To test a controller, which will be treated in section 2.5, first it is implemented on the laptop. The laptop
is connected with the dSpace system by means of this card and controls the BOW model simulated on
the dSpace system. Two or three channels deliver the states to the laptop and the laptop can send the
input voltage and another analog signal to the dSpace system. How the card is connected precisely to
this system can be seen in appendix C.1.
A more detailed specifications of this card can be found in appendix D.2.
B.1.2
National Instruments, DAQ Dio-24
The second card is used to read the bits from the Period Measurement (PM) device, see first [7], which
is used to measure the angular velocity of the wheel. This card has 24 Digital Input Output ports (DIO)
and because the card DAQ 6063E has eight additional ones, 32 DIO’s are available. For the default use
of the PM device however only 21 ports are needed. To be able to obtain the angle of the wheel as well,
two additional ports will be needed. And finally, if the PM device is set as accurate as possible, then
25 instead of 21 ports are needed, so with the 32 ports available, there are always enough DIO’s. In
appendix C.3 the connections between the PM device and the card can be seen.
In appendix D.1 the detailed specifications of the card are shown.
33
B. Control Environment
B.2
B.2. Software
34
Software
The operating system on the laptop, is Debian Sarge 3.1. Linux is an open source application, which
means that it is free to use and the source code on which it runs is completely accessible. In addition
RTAI 3.3 serves as the base for the realtime control system, it permits strict time constraints for data
acquisition and writing processes in applications, i.e. equidistant sampling time for control processes. It
also includes the application XRtaiLab, which is used for the visualization of both measured values and
calculated quantities. Furthermore COMEDI provides the device drivers for the data acquisition and
output cards.
B.2.1
Linux
The greatest advantage of Linux is that it gives the user full control of the system. For realtime control,
this is a necessity, since during the control, the realtime task should get highest priority. Even when the
system has too many task to fulfill during the sample time, it should always be able to measure the states
and calculate the output first. The utilized kernel is the kernel 2.6.15.7.
B.2.2
RTAI
The Real Time Application Interface adds the realtime component to the system. After patching the
kernel and installing the software, control processes can be performed in realtime [10]. It gives then
priority to realtime tasks. It will be to much to discuss it here thoroughly, therefore the reader is referred
to [10] for a more detailed look on this subject. For both reading and writing signals to the DAQ cards,
the institute supplied an additional Matlab/Simulink library. So the user is able to build op the entire
controller in Matlab/Simulink.
Before or after, the start of the realtime application XRtaiLab can be run. In this program it is possible
to connect to the process/thread in order to visualize the data. If the laptop is equipped with a Wireless
Local Area Network (WLAN) card, the WLAN, as well as the Local Area Network (LAN), can be utilized
to access control processes on this laptop. This application, also gives the possibility to edit parameters
realtime, in this way it is for example possible to switch between different controllers or trajectories.
Finally the program has the opportunity to execute/terminate control processes.
B.2.3
COMEDI and COMEDILIB
The Control and Measurement Device Interface and the accompanying Library takes care of the communication with the D/A and A/D converters, they also furnish the commands to operate these devices.
This is the most important application of all. Since not all converters are supported by this software.
Therefore it is advisable to examine the supported hardware list1 very thoroughly on forehand. The on
the laptop utilized PCMCIA Digital Acquisition and output cards are compatible according to this list.
B.3
Laptop Performances
Because the control system runs on a laptop, a time discrete controller has to be implemented. Because
A/D converters provide only quantized signals some errors will occur. These errors have to be kept small
in order to have a good control loop. In [8] some ideal conditions have been formulated:
• Exact synchronization of the A/D and D/A converters with fixed sampling time
• No quantification errors, no signal overflows and no temporal delays in ADC, DAC, measure- and
output ordering
• No conversion errors and parameters for the differential equations should be stored as floating points
• Infinitely small calculation times
1 This
list can be found at http://www.comedi.org/hardware.html
B. Control Environment
B.3. Laptop Performances
35
The exact synchronization of the ADC and DAC, as well as the fixed sampling time is ensured by the
suitable chosen system. The temporal delays in the converters can be kept small, if the right DAQ
cards are used. Quantification errors can not be avoided, they can be kept small however, by keeping
the accuracy and the resolution as high as possible. As is said before, the DAQ card used here, has a
resolution of 16 bits.
Boundary effects for DAC’s have to be considered. For ADC’s the signals usually are restricted by
hardware, in contrast to this, the restriction of DAC’s has to be done by software and an overflow has to
be avoided. Figure B.1 shows the desired output signal. It can be seen that the signal overflows in both
the upper bound as well as the lower bound. The figures B.2 and B.3 show the output which is given
by a restricted converter and a converter without restriction, respectively. Here both ADC and DAC are
restricted however.
Figure B.1: Wanted signal
Figure B.2: Given output for a restricted converter
Figure B.3: Given output for a converter without restriction
The demand for signals without conversion errors and the storage of the parameters for the differential
equations as floating points can be answered by choosing suitable implementations and the use of floating
point formats. The laptop used for the control, has a calculation time which is low enough, so it will not
tangle up the control task.
B. Control Environment
B.4. Sensor Readings
36
Realtime Applications
During a realtime task three time quantities are important, these are shown in figure B.4. The duration
of these quantities is not fixed, it is possible to predict, with a certain inaccuracy, the length of it though.
Figure B.4: Time division of a realtime task
Sampling time
The sampling time is the time in between two samples. It can be put to any value, within a minimum
and a maximum. The minimum is given by the maximum of the latency time + execution time, which
will be clarified in the following. The maximum is given by the system which has to be controlled. Since
the controller has to do a control step, that often, that, in this case, the ball will not fall of the wheel.
For the controllers in this report a sampling time of 1 ms is taken, since it is fast enough for the BOW
system. This is not the minimum of the sampling time for this laptop however.
Latency time
The latency time is the time between a task is asked for and the actual execution of the task. The latency
time for the laptop used, is thanks to some adaptions of the Debian GNU/Linux kernel very small, and
is maximum 3.5 µs.
Execution time
The execution time is the time needed to execute the task which is asked for. It depends on the number
of floating points operations which have to be made and on the way the application is implemented. This
time should be kept as small as possible for controllers.
B.4
Sensor Readings
As discussed in chapter 2 there are three important states, the angular velocity of the wheel ωw , the
position of the ball ϕ2 and the time derivative of the latter, ω2 . Two of these states can be measured and
the last one, ω2 , is estimated in different ways.
B.4.1
Laser to measure ϕ2
For measuring ϕ2 a laser is mounted on the BOW plant. It can measure the distance from the laser to
the ball very accurate. This distance is represented by a certain voltage provided by this sensor. And
B. Control Environment
B.4.2. Period Measurement (PM) for ωw
37
the voltage is send to the laptop. In the computer the distance can be calculated out of the voltage by
the following formula
dLP 2 = U KU + dOf f set
The voltage is multiplied with a gain KU and after that an offset is added, this leaves the distance, dLP 2 .
The values for the gain and offset are:
KU
=
dOf f set
=
37.8377 · 10−3
hmi
V
−0.7755 · 10−3 [m]
Afterward, ϕ2 can be calculated by
"
#
p
1 P2,x (C1 + N2 ) − P2,y − (C2 − N2 ) (C3 − N2 )
ϕ2 = arcsin
2
N2 (rw + rb,red )
(B.1)
with
C1
= (rw + rb,red )2 − rb2
C2
= ((rw + rb,red ) − rb )
2
C3
P2,x
= ((rw + rb,red ) + rb )
= dx − dLP 2
2
P2,y
N2
= dy
2
2
= P2,x
+ P2,y
The derivation of (B.1) and the above given values come from [6]. The calculation of ϕ2 is shown in
figure B.5, where the right hand block contains (B.1).
Figure B.5: Block model to calculate ϕ2 .
B.4.2
Period Measurement (PM) for ωw
The angle of the wheel, ϕw , can be measured by an incremental encoder. This variable is not a component
of the state vector and so it is not needed. Its time derivative ωw is of interest however. The incremental
encoder has got 4096 increments and because there are two measure points, where the increments are
checked, four different states are possible at every increment. See figure B.6. Thus the encoder is able to
2π
measure the minimum angle shift of 4·4096
rad.
Figure B.6: Four states per increment
B. Control Environment
B.5. Connection to dSpace
38
To measure the angular velocity of the wheel the PM device is developed. This device tries to generate
as many pulses as possible during the time when the increments do not change. The pulses are generated
at a high, but fixed frequency. This frequency has to be determined on forehand and can be at maximum
20 MHz and is set by default to this value. The number of pulses which is counted, is given by (default)
18 bits. The number of bits is adjustable from 14 till 22 bits. The floating point can be easily calculated
from the binary numbers2 . The calculation from the counter value to ωw can be done by using (B.2)
ωw =
2π
20e6
4 · 4096 count
(B.2)
For a more detailed look on this device the reader is referred to [7]. Here one will find the complete
working principle of the device as well as an error analysis. The settings of the device have been changed
a little bit, since it is used in [8].
B.5
Connection to dSpace
When a controller is designed, it is simulated in Matlab/Simulink first, to check whether it is stable. The
controllers for the BOW plant, will not run in Simulink however, but on Linux. So before one can use
a controller it should be made sure, that it works correctly when implemented in Linux. This security
is provided by letting the controller, control the BOW model, simulated in the dSpace system. In this
server client arrangement the computer with the dSpace card3 sends the calculated states to the laptop
and it receives the input voltage for the model. How to connect the laptop by means of the DAQ card,
to the dSpace PC, can be seen in appendix C.1.
B.5.1
Read and Write Channels
The DAQ card is used to connect to the dSpace PC. In B.1 one can see that only three input ports of the
laptop are connected with different outputs of the dSpace PC, since for this problem only three states
are needed.
The connections from the perspective of the laptop, can be seen in table B.1. To read and write the data
to and from the laptop the RTAI devices are used, the data_read and data_write blocks.
Laptop
dSpace PC
Inputs
read data
Channel 0
Channel 1
Channel 2
Outputs
write data
Channel 0
Channel 1
Outputs
DAC 1
DAC 3
DAC 2
Inputs
ADC 1
ADC 3
Table B.1: Connection between laptop and dSpace PC
B.5.2
Test Compatibility of Simulink Blocks
Since it is not known if the Simulink blocks which are used, to model the controller, are also compatible
on the Linux system, it is necessary to test the blocks from the Simulink library. For every block a model
is made which just inputs the output value of the dSpace PC and outputs the calculated value from the
2 If the bit equals 1 the decimal value equals 2bitnr. , if it is zero the decimal number is zero as well. To get the counter
value just add all decimal bit values.
3 For shortness, from now on called the dSpace PC
B. Control Environment
B.5.3. Test Controllers
39
block. On the dSpace system, the very same block is implemented to the dSpace card and both systems
get the same input. Because it is known, that the blocks are compatible for the dSpace card, the output
of both systems should be the same. This is checked in the dSpace ControlDesk application.
Because of signal transfers an offset can occur, this is canceled out by adding an offset in the model for
the Laptop. In table B.2 the blocks which are tested are shown, if one wants to use another block it is
recommended to test it first. Furthermore the S-function block is tested and it is compatible, but one
CANNOT use capitals in the file name of the S-functions, because the Matlab workshop, transforms the
capitals to lowercase letters, which is not a problem in Windows for a file name, but is in Linux. When
the model is build, the S-function has to be copied in the created folder, i.e. in the controllers source
code directory.
Simulink block
RTAI devices
Detail
All RTAI devices are compatible,
with RTAI scope data can be written to file
Constant
Sum
Gain
Product
Dot product
Mux/Demux
Logical operator
Data type conversion
Multiport switch
LTI block
State Space
Math function
Function
S-function block
Rate transition
Unit delay
Subsystem
Both element wise and matrix wise are compatible
When one wants to calculate with a boolean it
should be converted to a double
Switch between signals by changing a constant
Both Discrete and continuous blocks are compatible
User defined function
The S-function file name cannot consist of capitals
With this block multiple sampling times can be used
Table B.2: Compatible Simulink blocks
B.5.3
Test Controllers
The dSpace system is used to check if the controller works properly under Linux. After the whole
controller has been designed and the model has been made, it needs to be tested. This is done by using
hardware-in-the-loop control. In figure B.7 the general model structure which is build and transferred to
the Linux system, can be seen. The general model structure which will be loaded to the dSpace card can
be seen in figure B.8. The simulated BOW system can now be controlled by the Linux based controller
or a controller running on the same dSpace card. A mulitport switch is used to switch between the in
Linux calculated input and the input calculated by the dSpace card.
Figure B.7: Controller (model for Laptop)
B. Control Environment
B.5.3. Test Controllers
40
Figure B.8: Model to load to dSpace card
First the system that runs on the dSpace system is started. It is controlled by the controller on the dSpace
card, this simulates the holding of the ball at the top position of the wheel. Then when the controller is
started on the laptop, the input needs to be almost immediately switched to the one calculated in Linux,
since the BOW system is unstable by nature. After the process is killed on the Linux laptop, the BOW
model can be controlled again by the dSpace card.
C Connections
In this appendix it is shown, how the DAQ cards should be connected to the BOW plant and to the
dSpace PC.
C.1
Connection to the dSpace PC
The laptop can be connected to the dSpace PC by means of the DAQ 6063E. This card has several input
ports and output ports and only few are used to connect to the dSpace input ports and output ports.
See table C.3.
Ports of
DAQ 6063E
AO0
AO1
AI0
AI1
AI2
GND
Name on
socket
J22
J21
J68
J33
J65
J55, J54, J64, J32
Pin nr.
11
9
34
36
19
37, 33, 10,12,18
Port of
dSpace PC
ADC1
ADC3
DAC3
DAC1
DAC2
GND
Table C.1: Connection between laptop and dSpace PC
C.2
Connection to the plant its laser and motor
When the laptop is connected to the plant, the DAQ 6063E is used to retrieve the laser signal and write
the input signal.
Ports of
DAQ 6063E
AO1
AI1
GND
Name on
socket
J21
J33
J32, J55
Pin nr.
Details
27
34
33, 26
Motor Signal
Laser Signal
GND
Table C.2: Connection between laptop and plant its laser and motor
C.3
Connection to the PM device
To be able to read all the digital signals from the PM device it is connected to the laptop by means of
the DAQ DIO-24 card.
41
C. Connections
C.3. Connection to the PM device
Ports of
DAQ DIO-24
PA4
PA5
PA6
PA7
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
PC0
PC1
PC2
PC3
PC4
PC5
PC6
PC7
GND
Name on
socket
39
37
35
33
31
29
27
25
23
21
19
17
15
13
11
9
7
5
3
1
2k with k = 1..20
Pin nr.
20
2
21
3
23
5
24
6
26
8
27
9
29
11
30
12
32
14
33
15
1, 35
42
Details
PM device
bit 1
bit 2
bit 3
bit 4
bit 5
bit 6
bit 7
bit 8
bit 9
bit 10
bit 11
bit 12
bit 13
bit 14
bit 15
bit 16
bit 17
zero speed
write phase
direction
GND
Table C.3: Connection between laptop and PM device
Furthermore, It is necessary to supply the encoder with power. And the the four DIO’s which are still
available can be connected with the encoder signals, this is not necessary however.
Ports of
DAQ DIO-24
PA0
PA1
PA2
PA3
GND
Name on
socket
47
45
43
41
42, 44, 46, 48
Pin nr.
1
9
2
4
3
5
15
Details
PM device
VCC (+5 V)
(VCC)
phi0 (A)
phi90 (B)
/phi0 (Ainv)
/phi90 (Binv)
GND
Table C.4: Connection of socket E2 of the PM device [7]
D DAQ Specifications
In this appendix the specifications of the DAQ cards are shown
D.1
National Instruments DAQ DIO-24
General
Bustype
Analog Input
Number of channels
Analog output
Number of channels
Digital-I/O
Number of channels
Timing
Logic transfer
Max. input range
Max. output range
Counter/Timer
Number of counters/timers
Dimensions
Length
Width
Heigth
I/O entry
PCMCIA
0
0
24 DIO
Controlled by hardware-timing (<10 MHZ)
TLL
0..5 V
0..5 V
0
8.56 cm
5.4 cm
0.5 cm
68 pins VHDCI-entrysocket
Table D.1: Specifications of DAQ DIO-24
For more specifications visit, http://www.ni.com.
43
D. DAQ Specifications
D.2
D.2. National Instruments DAQ 6063E
National Instruments DAQ 6063E
General
Bustype
Product family
Triggering
Analog Input
Number of channels
Sample rate
Ressolution
Simultanouos sampling
Max. input range
onboard memory
Analog Output
Number of channels
Update rate
Resolution
Max. output range
Digital-I/O
Number of channels
Logic transfer
Timing
Max. input range
Max. output range
Counter/Timer
Number of counters/timers
Resolution
Max. input frequency
Logic transfer
Max. input range
Stability of the timebase
Dimensions
Length
Width
Heigth
I/O entry
PCMCIA
E-Serie
Digital
16 SE/8 DI
200 kS/s
16 bit
No
-10..10 V
1024 samples
2
1 kS/s
16 bit
-10..10 V
8 DIO
TLL
Statistically
0..5 V
0..5 V
2
24 bit
20 MHz
TTL
0..5 V
100 ppm
8.56 cm
5.4 cm
0.5 cm
68-pins VHDCI-entrysocket
Table D.2: Specifications of DAQ 6063E
For more specifications visit, www.ni.com.
44
E Theory
In this appendix the theory to several control strategies and observers used in this work is treated.
E.1
Linearization around an Equilibrium
Let us consider the following system
ẋ
y
= f (x, u) , x (t0 ) = x0
= g (x, u)
(E.1)
for which the input value for the interval 0 ≤ t ≤ T is given by u (t) = ũ (t). Then the solution is given
by x̃ (t) with x0 = x̃0 to the system (E.1). It is assumed that for only small perturbations to both u and
x0 , there will be only small perturbations in the solution. Then
x
= x̃ (t) + ∆x (t)
u = ũ (t) + ∆u (t)
y = ỹ (t) + ∆y (t)
(E.2)
By substitution of equation (E.2) in (E.1) it follows
x̃˙ + ∆ẋ
y
=
=
f (x̃ + ∆x, ũ + ∆u) , x (t0 ) = x˜0 + ∆x0
g (x̃ + ∆x, ũ + ∆u)
(E.3)
Utilizing the Taylor series expansion, equation (E.3) will be transformed into
x̃˙ + ∆ẋ
=
ỹ + ∆y
=
∂
∂
f (x̃, ũ) ∆x +
f (x̃, ũ) ∆u, x (t0 ) = x˜0 + ∆x0
∂x
∂u
∂
∂
g (x̃, ũ) ∆x +
g (x̃, ũ) ∆u
g (x̃, ũ) +
∂x
∂u
f (x̃, ũ) +
By means of equation (E.1) this leads to
∆ẋ
=
∆y
=
∂
∂
f (x̃, ũ) ∆x +
f (x̃, ũ) ∆u, x (t0 ) = x˜0 + ∆x0
∂x
∂u
∂
∂
g (x̃, ũ) ∆x +
g (x̃, ũ) ∆u
∂x
∂u
for sufficient small perturbations. For the linearization around an equilibrium point the values for ũ = us
and x̃˙ = 0 are inserted into the equation as well as the equilibrium points
∆ẋ =
∆y
E.2
=
∂
∂
f (xs , us ) ∆x +
f (xs , us ) ∆u, x (t0 ) = ∆x0
∂x
∂u
∂
∂
g (xs , us ) ∆x +
g (xs , us ) ∆u
∂x
∂u
Linearization by Static Feedback
Let us consider an Affine Input (AI) system of first order
ẋ =
y =
f (x) + g (x) u
h(x)
45
(E.4)
E. Theory
E.3. Linear Controller
46
∂
h(x) g(x) 6= 0 holds. The calculations are all
In this equation the output should be such that ∂x
performed with the AIsys package within the software package MAPLE [12]. Now an input u = u(x, v)
can be calculated with
∂
∂
ẏ = ∂x
h(x)ẋ = ∂x
h(x) (f (x) + g(x)u) = v
v−f (x)
(E.5)
u =
∂
h(x))g(x)
( ∂x
If the input from equation (E.5) is taken and inserted in (E.4), then the following system is acquired
ẏ = v
∂
Hereby ∂x
h(x) g(x) is called the Lie-derivative of the function h(x) with respect to g(x) and it is written
as
∂
h(x) g(x) = (Lg h)(x)
∂x
When an AI system of nth order with a relative degree r = n, see [2]
transformation
h(x)
y
(Lf h) (x)
ẏ
z = T(x) =
=
..
..
.
. Lfn−1 h (x)
y(n−1)
is subjected to the coordinate
then the following linear system in z coordinates is acquired.
0
z˙1
z2
z˙2
0
z
3
..
..
.
..
. =
=
.
zn−1
0
˙
zn
z˙n
(Lnf h) (x) T−1 (z)
Lg Lfn−1 h T−1 (z)
with
u=
u
(E.6)
v − (Lnf h) T−1 (z)
Lg Lfn−1 h T−1 (z)
equation (E.6) leads to a linear system of the form
dn
y=v
dtn
This coordinate transformation is not always possible. With the AIsys package, [12], one can check
whether it is possible to exact feedback linearize the system. Consequently a flat output will be given
by the specific system output, if it has full relative degree. For a more detailed view to this theory one
should have a look at [2], [6], [7].
E.3
E.3.1
Linear Controller
Linear State Feedback Law.
The linear state feedback law u = −K · x transforms a linear system into the form
ẋ = Ax + bu = (A − bK) · x
with A and b from (2.10) and (2.11). The real parts of the poles of the new system matrix (A − b · K)
have to be negative, for the linearized system to be stable. If the system is fully controlable, it is always
E. Theory
E.3.2. Linear Observers
47
possible to find a K for which this holds. The system is fully controllable when the controllability matrix
MR is of full rank. The controllability matrix for this linearized BOW system is
MR =
b A·b
A2 · b
=
−β 2 ·γ·χ
F2
χ·ξ
F ·Z
−ξ·γ·χ·β
F 2 ·Z
χ·β
F
0
χ·ξ
F ·Z
β 3 ·γ 2 ·χ
+ α·χ·ξ
F3
F 2 ·Z
−ξ·γ·χ·β
2
F ·Z
ξ·γ 2 ·χ·β 2
+ Fδ·χ·ξ
2 ·Z 2
F 3 ·Z
This matrix is of full rank and thus the system is fully controllable. Since the matrices A and b do not
depend on the equilibrium point which is linearized around, the state feedback gain K will be the same
for each possible equilibrium point.
LQR algorithm
One way to calculate the gain K is by means of the Linear Quadratic Regulator (LQR) algorithm [4].
This makes a LQR controller. The algorithm can be used in Matlab via the LQR command. When a
system has multiple inputs and outputs the LQR algorithm can be very helpful, this in contrary to pole
placement.
For the implementation on the laptop in order to control the real plant the following values are taken for
K.
Kd,startup
=
Kd
=
−1.147 71.84 18.18
−10.47 275.3 71.35
Two different values have been chosen, one to make a slow controller, which can be used to sweep the
ball to the top of the wheel. And another controller to have an as good as possible linear controller, so
a fast controller which can be used when the ball is already on top of the wheel. These controllers have
been designed for the discretised linearized BOW system.
E.3.2
Linear Observers
To stabilize the system by means of a linear state feedback law, all states have to be available. For
most systems, the states are not all available from measurements. Therefore the other states have to
be estimated. This can be done with an observer, if the system is observable. A linear system is fully
observable when the observability matrix MO is of full rank. If only the position of the ball ϕ2 is measured
then the observability matrix reads
C
MO = C · A =
C · A2
0
0
1
0
−ξ·γ
F ·Z
δ
F ·Z
0
1
0
This matrix does have full rank and therefore the system is fully observable. When both the position
and the angular velocity of the wheel are measured the observability matrix reads
C
MO = C · A =
C · A2
1
0
0
1
−β·γ
F
α
F
β 2 ·γ 2
F2
−ξ·γ
F ·Z
−β·γ·α
F2
δ
F ·Z
0
0
0
0
0
1
α
F
0
which is also of full rank. Three different, well known, observers are considered [1].
E. Theory
E.3.2. Linear Observers
48
The trivial observer
The first one is the trivial observer. This observer is identical to the system which has to be observed. It
gets an identical input and therefore the calculated state variables should be exactly the same as the ones
of the observed system. When the original system is disturbed however, the two systems only converge
to each other if the original system is stable. Since the BOW system is not stable, this observer can not
be used.
The identity observer
The second observer is called the identity observer and it outputs all estimated states of the original
system. The observer is a n-dimensional system with state vector z (t). The inputs to the observer are
of two types. The first set consists of a copy of the inputs of the original system, these inputs are the
control inputs, so they are available. The second set consists of the measurements y (t) available from
the original system.
ż(t) = Aobs z(t) + Bobs
u(t)
y(t)
The system matrix of the identity observer, Aobs , is similar to the one of the system being observed,
except that the original system matrix is added with a matrix K̂C. This takes care of the problem of the
trivial observer. The poles of the new system matrix, (A − K̂ · C), can be chosen arbitrarily if the system
is observable. The eigenvalues of this matrix are the same of its transposed matrix, (AT − CT · K̂T ).
And the
poles of the latter can be placed by using the acker or the LQR command. Note that for
1 0 0
C=
, the gain, K̂, cannot be calculated with acker. If the poles are in the left open half
0 1 0
plane, than the states of the observer will converge to the states of the observed system.
The input matrix, B, of the observer differs from the original b matrix a little more. Since the observer
has more inputs than the original system, this B matrix reads
Bobs = B − K̂ · D K̂
The values for the identity observer which are taken, to implement in the controller to control the real
plant are given by
K̂ϕ,id
K̂GT M,id
=
=
−2.754 0.6199 1.150
7.837 · 10−4
0.6191
0.6408
T
0.9893
2.815 · 10−6
−2.501 · 10−4
There are two different vectors, since both the cases for y = [ϕ2 ] and y = ϕ2 ωw are considered.
This are the values for the with respect to time discretised system. This observer is used for the startup
mechanism and therefore it does not need to have a fast behavior
The reduced observer
The identity observer described above, possesses a certain degree of redundancy. It reconstructs all n state
variables of the original system even though a certain amount of these variables, the output variables,
are already known precisely. It seems plausible that by eliminating this redundancy an observer could be
derived with order equal to the amount of unknown states. This observer is called the reduced observer.
It also makes use of the measured states, like the identity observer, but in contrast to this one, it only
calculates the states which are not available. To calculate the matrices of the reduced observer, the
original system is split into two parts, the states which can not be measured and the ones which can be.
Before calculating the unmeasured states, first some matrices have to be introduced. The C matrix which
is already introduced, gives the measured states, the now introduced V matrix gives the ones which are
not measured. The N and M matrix will be calculated in such away that the next equations holds.
E. Theory
E.3.2. Linear Observers
C
V
M
N
=
I 0
0 I
49
To calculate the unmeasured states, the following matrices are calculated:
Aobs
=
Bobs
=
h
i
(Ã − K̂ · C̃)
with à = VAN and C̃ = CAN
h
(V − K̂ · C) · B − (V − K̂ · C) · A · (M − N · K̂) · D
i
(V − K̂ · C) · A · (M − N · K̂)
The gain, K̂, can be calculated in the same way as is done for the identity observer. If the matrix Aobs
has its poles in the open left half plane, then the states of the observer will converge to the ones of the
original system.
The values for the reduced observer which are taken, to implement in the controller to control the real
plant are given by
K̂ϕ,red
=
K̂GT M,red
=
−264.4 15.37
T
−9.959 0.006284
F Ball Parameter Identification
As stated in chapter 2, the ball parameters have to be identified again. In [5], [6] and [8] the identification
can be seen. But because different balls have been used, the parameters of the balls need to be identified
again. Four different balls have been used. All these balls are weighted and their radii are measured.
With the radius known, the reduced radius has to be calculated as well. This is the distance from the
center of the ball to the wheel, see figure F.1.
Figure F.1: Calculation of the reduced radius
rb,red =
r
1
rb2 − d2w
4
The values of the ball parameters of the three different balls are listed below in table F.1. Out of the four
balls used three of them are balls made out of rubber, a blue, a green and a yellow one. The last ball is
made out of PVC, this one is red. The advantage of the latter is its symmetry, while the other balls have
in a certain extent an asymmetric structure.
blue ball
green ball
yellow ball
red ball
mb [kg]
0.2824
0.2859
0.4210
0.200
rb [m]
8.07 · 10−2
8.2 · 10−2
8.9 · 10−2
8.0 · 10−2
rb,red [m]
6.76 · 10−2
6.92 · 10−2
7.74 · 10−2
6.68 · 10−2
Table F.1: Ball parameters
The unknown ball parameter is the moment of inertia, Jb . This is identified by letting the ball roll down
a slope. The position of the ball, x, is measured using the laser on the BOW plant. The plant is adapted
in such a way that the ball can roll over two bars in front of the laser. If the whole plant is rotated a
little bit now, the bars will form a slope. The angle of the slope can easily be measured, α = arctan(h/l)
where h is the height of the slope and l is the length of the plant. Figure F.2.
The inertia of the red ball can be calculated as well as identified. Since it is symmetric and both the
inner and outer radius are known, the inertia can be calculated following:
51
F. Ball Parameter Identification
52
Figure F.2: Adapted plant to identify the inertia of the balls
Jb =
5
5
rb,o
− rb,i
2
mb 3
= 8.17 · 10−4 kgm2
3
5
rb,o − rb,i
From (2.1) the needed equation of motion can be calculated. In this equation friction is neglected. The
energy equations holding for a ball rolling down the slope are
T (q, q̇) =
V (q)
Inhere q = x and rr =
=
1 Jb ˙2
1
x
mb x˙2 +
2
2 rr2
−mb gx sin(α)
(F.1)
(F.2)
q
rb2 − 14 d2bars . By using (2.1),(F.1) and (F.2), the acquired equation of motion is
(F.3)
m̄ẍ − mb g sin(α) = 0
with m̄ = mb + Jb /rr2 . Now Jb can be determined in different ways, two of them will be discussed
here. First Jb is calculated by transforming the differential equation to the Laplace domain. By using
the method out of [9], it is no problem to take friction into account, since unknown parameters can be
identified. The equation of motion is then given by
(F.4)
m̄ẍ + cẋ − mb g sin(α) = 0
First (F.4) will be transformed to the Laplace domain, for simplicity a = mb g sin(α) will be written from
now on. It follows
m̄s2 X̂(s) − sX(0) − Ẋ(0) = a
1
s
(F.5)
Then the derivative with respect to s is taken two times of (F.5) to eliminate the unknown initial conditions
2m̄X̂(s) + 4m̄s
Afterward it is multiplied with
dX̂(s)
1
d2 X̂(s)
d2 X̂(s)
dX̂(s)
+
2c
= 2a 3
+ m̄s2
+
cs
ds
ds2
ds
ds2
s
1
s3 ,
(F.6)
which leads to
2
d X̂(s) 1
1
2m̄X̂(s) s13 + 4m̄ dX̂(s)
ds s2 + m̄ ds2 s
1
2c dX̂(s)
ds s3
+
2
X̂(s) 1
c d ds
2
s2
+
=
2a s16
(F.7)
F. Ball Parameter Identification
53
Transforming (F.7) back to the time domain, the equation reads1
m̄ 2
|
Z
(3)
x(t) + 4
c 2
|
Z
Z
(2)
−tx(t) +
{z
P11 (t)
(3)
−tx(t) + 4
{z
Z
(1)
Z
(2)
!
2
t x(t)
}
!
2
t x(t)
+
Z
a
2
| {z }
=
}
P12 (t)
(F.8)
(5)
Q1 (t)
By another integration of (F.8) one gets the equation system
P11 (t)
P21 (t)
P12 (t)
P22 (t)
m̄
Q1 (t)
·
=
c
Q2 (t)
(F.9)
R
R
R
with P21 (t) = P11 (t), P22 (t) = P12 (t) and Q2 (t) = Q1 (t). Furthermore some more equations can be
added to make the system over determined. Then the parameters will have to be found by using a least
squares algorithm for instance.
The trajectory which can be taken with the laser of the BOW system is very short, and so the values
do not converge fast enough and the identification with this algorithm has failed. Furthermore, the
gymnastic balls are not exactly symmetric and because of the short trajectory, it is not possible to take
an average moment of inertia. therefore the values for Jb changes dramatically, when multiple trajectories
are taken. For the red ball however, it can be seen that the value is converging to about 8.17·10−4 [kgm2 ],
see figure F.3.
Because it is not possible to identify the parameters sufficiently in the above mentioned way, a less
accurate way is used. The points of three different trajectories are plotted. These trajectories are taken
in such a way that the asymmetric shape of the ball affects it as less as possible. This is done by putting
the ball in such a way, that the line through the valve, lays in the plane of motion, but perpendicular to
the roll direction.
To calculate the value for the inertia, the following system is simulated
ẋ
ẍ
=
0
0
1
c
− m̄
x+
0
1
mb
g sin(α)
m̄
(F.10)
Both c and Jb are adapted to get an as good as possible trajectory fit. In the next figures (figure F.4,
F.5 and F.6) the results can be seen. In the end, the values as given in table F.2 are found. Here the
inertia of the red ball is not fitted but calculated as mentioned before.
blue ball
green ball
yellow ball
red ball
Jb [kgm2 ]
1.6 · 10−3
1.8 · 10−3
3.4 · 10−3
8.17 · 10−4
c [Ns2 /m]
0.4
0.45
0.5
-
Table F.2: Ball parameters continued
1 The
notation
R (α)
φ(t) =
R t R β1 R β2
0
0
0
R βα−1
···
0
φ(βα )dβα · · · dβ2 dβ1 ,
R
φ(t) =
R (1)
φ(t) =
Rt
0
φ(β1 )dβ1 is arranged
F. Ball Parameter Identification
54
−4
x 10
12
10
8
6
Jb
4
2
0
−2
−4
−6
−8
0
100
200
300
400
500
600
700
800
900
1000
−4
10
x 10
8
6
4
Jb
2
0
−2
−4
−6
−8
0
100
200
300
400
500
600
700
800
Figure F.3: Converging of Jb .
0.1
trajectory 1
trajectory 2
trajectory 3
fit
0.08
position [m]
0.06
0.04
0.02
0
−0.02
0
0.1
0.2
0.3
0.4
0.5
time [sec]
0.6
0.7
0.8
Figure F.4: Trajectories for the blue ball.
0.9
1
F. Ball Parameter Identification
55
0.1
trajectory 1
trajectory 2
trajectory 3
fit
0.08
position [m]
0.06
0.04
0.02
0
−0.02
0
0.1
0.2
0.3
0.4
0.5
time [sec]
0.6
0.7
0.8
0.9
1
Figure F.5: Trajectories for the green ball
0.3
trajectory 1
trajectory 2
trajectory 3
fit
0.25
position [m]
0.2
0.15
0.1
0.05
0
−0.05
0
0.5
1
1.5
time [sec]
Figure F.6: Trajectories for the yellow ball
In figure F.6, the trajectories seems to be shifted, this is because the yellow ball is not precisely round, it
has a little bit an egg form. In the beginning the fit seems to be right, after the shift takes place the fit
does not look right anymore. When the fit of the yellow ball is shifted a little to the right, the last part
of the plot fits good while the first bit is shifted.
Of course this egg form is very dramatically when the ball has to stay on top of the wheel and therefore
the yellow ball is not used. The blue and green ball are very similar and so the blue one is taken to test
the controllers. The red one is not taken since it is too fragile.
The green and red ball are used in the end to show differences in the results. Specially the red ball will
show better behavior since it is very symmetric. The surface of this ball however is too smooth and with
too fast acceleration of the wheel, slip between this ball and the wheel occurs.
G All Results
In this appendix the results from several controllers are shown.
Linear controller with reduced observer with y =
1
ϕ2
ωw
measurement
0
omega
w
−1
−2
−3
−4
−5
−6
0
5
10
15
time [sec]
20
25
30
0.1
measurement
0.08
0.06
0.04
phi
2
0.02
0
−0.02
−0.04
−0.06
−0.08
0
5
10
15
time [sec]
20
25
30
0.5
measurement
0.4
omega
2
0.3
0.2
0.1
0
−0.1
−0.2
0
5
10
15
time [sec]
20
25
Figure G.1: Results of linear controller with reduced observer with y =
is stabilized at the top is pushed several times.
57
30
ϕ2
ωw , while the ball which
G. All Results
58
10
measurement
8
6
4
omega
w
2
0
−2
−4
−6
−8
−10
0
5
10
15
20
25
time [sec]
30
35
40
45
0.2
measurement
0.15
0.1
0.05
phi
2
0
−0.05
−0.1
−0.15
−0.2
−0.25
0
5
10
15
20
25
time [sec]
30
35
40
45
0.3
measurement
0.2
0.1
omega
2
0
−0.1
−0.2
−0.3
−0.4
−0.5
0
5
10
15
20
25
time [sec]
30
35
40
45
Figure G.2: Results of linear controller with reduced observer with y =
equilibrium points.
ϕ2
ωw , while switching
G. All Results
59
2
measurement
1
0
omega
w
−1
−2
−3
−4
−5
−6
0
2
4
6
8
10
time [sec]
0.35
measurement
0.3
0.25
0.2
phi
2
0.15
0.1
0.05
0
−0.05
−0.1
0
2
4
6
8
10
time [sec]
1.2
measurement
1
0.8
0.6
omega
2
0.4
0.2
0
−0.2
−0.4
−0.6
−0.8
0
2
4
6
8
10
time [sec]
Figure G.3: Results of linear controller with reduced observer with y =
swept on top of the wheel (slow controller used).
ϕ2
ωw , while the ball is
G. All Results
60
Linear controller with reduced observer with y = [ϕ2 ]
4
measurement
3
2
omega
w
1
0
−1
−2
−3
−4
0
5
10
15
time [sec]
20
25
30
0.06
measurement
0.04
phi
2
0.02
0
−0.02
−0.04
−0.06
0
5
10
15
time [sec]
20
25
30
0.6
measurement
0.4
omega
2
0.2
0
−0.2
−0.4
−0.6
−0.8
0
5
10
15
time [sec]
20
25
30
Figure G.4: Results of linear controller with reduced observer with y = [ϕ2 ], while the ball which is
stabilized at the top is pushed several times.
G. All Results
61
5
measurement
0
omega
w
−5
−10
−15
−20
0
2
4
6
8
10
time [sec]
0.5
measurement
0.4
0.3
phi
2
0.2
0.1
0
−0.1
−0.2
0
2
4
6
8
10
time [sec]
1
measurement
0.5
0
omega
2
−0.5
−1
−1.5
−2
−2.5
−3
−3.5
0
2
4
6
8
10
time [sec]
Figure G.5: Results of linear controller with reduced observer with y = [ϕ2 ], while the ball is swept on
top of the wheel (slow controller used).
G. All Results
62
Feedback linearising controller with full state trajectory observer with y =
2
ϕ2
ωw
ϕ2
ωw , while
measurement
desired trajectory
0
omega
w
−2
−4
−6
−8
−10
−12
0
5
10
15
time [sec]
20
25
30
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
time [sec]
20
25
30
0.5
measurement
desired trajectory
0.4
0.3
omega
2
0.2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
time [sec]
20
25
30
Figure G.6: Results of feedback linearizing controller with full state observer with y =
taking a trajectory for ϕ2 .
G. All Results
63
6
measurement
desired trajectory
4
omega
w
2
0
−2
−4
−6
0
5
10
15
20
25
time [sec]
30
35
40
45
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
20
25
time [sec]
30
35
40
45
0.4
measurement
desired trajectory
0.3
0.2
omega
2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
20
25
time [sec]
30
35
40
45
Figure G.7: Results of feedback linearizing controller with full state observer with y =
changing equilibrium points.
ϕ2
ωw , while
G. All Results
64
4
measurement
3
2
omega
w
1
0
−1
−2
−3
−4
−5
0
5
10
15
time [sec]
20
25
30
0.08
measurement
0.06
0.04
0.02
phi
2
0
−0.02
−0.04
−0.06
−0.08
−0.1
−0.12
0
5
10
15
time [sec]
20
25
30
0.6
measurement
0.4
0.2
omega
2
0
−0.2
−0.4
−0.6
−0.8
−1
0
5
10
15
time [sec]
20
25
30
Figure G.8: Results of feedback linearizing controller with full state observer with y =
stabilizing the ball on top of the wheel, several pushes are given to the ball.
ϕ2
ωw , while
G. All Results
65
2
measurement
1
0
omega
w
−1
−2
−3
−4
−5
−6
0
2
4
6
8
10
time [sec]
0.35
measurement
0.3
0.25
0.2
phi
2
0.15
0.1
0.05
0
−0.05
−0.1
−0.15
0
2
4
6
8
10
time [sec]
0.4
measurement
0.2
0
omega
2
−0.2
−0.4
−0.6
−0.8
−1
−1.2
−1.4
0
2
4
6
8
10
time [sec]
Figure G.9: Results of feedback linearizing controller with full state observer with y =
taking the ball from the begin position to the top of the wheel.
ϕ2
ωw , while
G. All Results
66
Feedback linearizing controller with full state trajectory observer with y = [ϕ2 ]
5
measurement
desired trajectory
omega
w
0
−5
−10
0
5
10
15
time [sec]
20
25
30
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
time [sec]
20
25
30
0.4
measurement
desired trajectory
0.3
0.2
omega
2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
time [sec]
20
25
30
Figure G.10: Results of feedback linearizing controller with full state observer with y = [ϕ2 ], while taking
a trajectory for ϕ2 .
G. All Results
67
10
measurement
desired trajectory
8
6
omega
w
4
2
0
−2
−4
−6
0
5
10
15
20
25
time [sec]
30
35
40
45
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
20
25
time [sec]
30
35
40
45
0.4
measurement
desired trajectory
0.3
0.2
omega
2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
20
25
time [sec]
30
35
40
45
Figure G.11: Results of feedback linearizing controller with full state observer with y = [ϕ2 ], while
changing equilibrium points.
G. All Results
68
4
measurement
2
omega
w
0
−2
−4
−6
−8
−10
0
5
10
time [sec]
15
20
0.08
measurement
0.06
0.04
phi
2
0.02
0
−0.02
−0.04
−0.06
0
5
10
time [sec]
15
20
0.2
measurement
0.1
omega
2
0
−0.1
−0.2
−0.3
−0.4
−0.5
0
5
10
time [sec]
15
20
Figure G.12: Results of feedback linearizing controller with full state observer with y = [ϕ2 ], while
stabilizing the ball on top of the wheel, several pushes are given to the ball.
G. All Results
69
Feedback linearising controller with reduced trajectory observer with y =
ϕ2
ωw
ϕ2
ωw , while
4
measurement
desired trajectory
2
0
−2
omega
w
−4
−6
−8
−10
−12
−14
−16
0
5
10
15
time [sec]
20
25
30
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
time [sec]
20
25
30
0.4
measurement
desired trajectory
0.3
0.2
omega
2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
time [sec]
20
25
30
Figure G.13: Results of feedback linearizing controller with reduced observer with y =
taking a trajectory for ϕ2 .
G. All Results
70
6
measurement
desired trajectory
4
omega
w
2
0
−2
−4
−6
−8
0
5
10
15
20
25
time [sec]
30
35
40
45
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
20
25
time [sec]
30
35
40
45
0.4
measurement
desired trajectory
0.3
0.2
omega
2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
20
25
time [sec]
30
35
40
45
Figure G.14: Results of feedback linearizing controller with reduced observer with y =
changing equilibrium points.
ϕ2
ωw , while
G. All Results
71
2
measurement
1
omega
w
0
−1
−2
−3
−4
−5
0
5
10
15
time [sec]
20
25
30
0.08
measurement
0.06
0.04
0.02
phi
2
0
−0.02
−0.04
−0.06
−0.08
−0.1
−0.12
0
5
10
15
time [sec]
20
25
30
0.4
measurement
0.2
omega
2
0
−0.2
−0.4
−0.6
−0.8
−1
0
5
10
15
time [sec]
20
25
30
Figure G.15: Results of feedback linearizing controller with reduced observer with y =
stabilizing the ball on top of the wheel, several pushes are given to the ball.
ϕ2
ωw , while
G. All Results
72
1
measurement
0
omega
w
−1
−2
−3
−4
−5
−6
0
2
4
6
8
10
time [sec]
0.35
measurement
0.3
0.25
0.2
phi
2
0.15
0.1
0.05
0
−0.05
−0.1
−0.15
0
2
4
6
8
10
time [sec]
0.4
measurement
0.2
0
omega
2
−0.2
−0.4
−0.6
−0.8
−1
−1.2
0
2
4
6
8
10
time [sec]
Figure G.16: Results of feedback linearizing controller with reduced observer with y =
taking the ball from the begin position to the top of the wheel.
ϕ2
ωw , while
G. All Results
73
Feedback linearizing controller with full state trajectory observer with y =
control of the green ball
ϕ2
ωw ,
ϕ2
ωw ,
2
measurement
desired trajectory
0
omega
w
−2
−4
−6
−8
−10
−12
0
5
10
15
time [sec]
20
25
30
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
time [sec]
20
25
30
0.5
measurement
desired trajectory
0.4
0.3
omega
2
0.2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
time [sec]
20
25
30
Figure G.17: Results of feedback linearizing controller with full state observer with y =
while taking a trajectory for ϕ2 . The green ball is used.
G. All Results
74
6
measurement
desired trajectory
4
omega
w
2
0
−2
−4
−6
0
5
10
15
20
25
time [sec]
30
35
40
45
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
20
25
time [sec]
30
35
40
45
0.4
measurement
desired trajectory
0.3
0.2
omega
2
0.1
0
−0.1
−0.2
−0.3
−0.4
0
5
10
15
20
25
time [sec]
30
35
40
45
Figure G.18: Results of feedback linearizing controller with full state observer with y =
while changing equilibrium points. The green ball is used.
ϕ2
ωw ,
G. All Results
75
4
measurement
3
2
omega
w
1
0
−1
−2
−3
−4
−5
0
5
10
time [sec]
15
20
0.08
measurement
0.06
0.04
0.02
phi
2
0
−0.02
−0.04
−0.06
−0.08
−0.1
−0.12
0
5
10
time [sec]
15
20
0.6
measurement
0.4
0.2
omega
2
0
−0.2
−0.4
−0.6
−0.8
−1
0
5
10
time [sec]
15
20
Figure G.19: Results of feedback linearizing controller with full state observer with y = ϕ2 ωw ,
while stabilizing the ball on top of the wheel, several pushes are given to the ball. The green ball is used.
G. All Results
76
2
measurement
1
0
omega
w
−1
−2
−3
−4
−5
−6
0
2
4
6
8
10
time [sec]
0.35
measurement
0.3
0.25
0.2
phi
2
0.15
0.1
0.05
0
−0.05
−0.1
−0.15
0
2
4
6
8
10
time [sec]
0.4
measurement
0.2
0
omega
2
−0.2
−0.4
−0.6
−0.8
−1
−1.2
−1.4
0
2
4
6
8
10
time [sec]
Figure G.20: Results of feedback linearizing controller with full state observer with y = ϕ2
while taking the ball from the begin position to the top of the wheel. The green ball is used.
ωw ,
G. All Results
77
Feedback linearizing controller with full state trajectory observer with y =
control of the red ball
ϕ2
ωw ,
ϕ2
ωw ,
2
measurement
desired trajectory
0
−2
omega
w
−4
−6
−8
−10
−12
−14
0
5
10
15
time [sec]
20
25
30
0.25
measurement
desired trajectory
0.2
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
time [sec]
20
25
30
0.4
measurement
desired trajectory
0.3
0.2
omega
2
0.1
0
−0.1
−0.2
−0.3
−0.4
−0.5
0
5
10
15
time [sec]
20
25
30
Figure G.21: Results of feedback linearizing controller with full state observer with y =
while taking a trajectory for ϕ2 . The red ball is used.
G. All Results
78
6
measurement
desired trajectory
4
omega
w
2
0
−2
−4
−6
0
5
10
15
20
25
time [sec]
30
35
40
45
0.2
measurement
desired trajectory
0.15
0.1
phi
2
0.05
0
−0.05
−0.1
−0.15
−0.2
0
5
10
15
20
25
time [sec]
30
35
40
45
6
measurement
desired trajectory
4
omega
w
2
0
−2
−4
−6
0
5
10
15
20
25
time [sec]
30
35
40
45
Figure G.22: Results of feedback linearizing controller with full state observer with y =
while changing equilibrium points. The red ball is used.
ϕ2
ωw ,
G. All Results
79
0.5
measurement
0
−0.5
omega
w
−1
−1.5
−2
−2.5
−3
−3.5
0
5
10
15
time [sec]
20
25
30
0.04
measurement
0.03
0.02
0.01
phi
2
0
−0.01
−0.02
−0.03
−0.04
−0.05
0
5
10
15
time [sec]
20
25
30
0.5
measurement
0
−0.5
omega
w
−1
−1.5
−2
−2.5
−3
−3.5
0
5
10
15
time [sec]
20
25
30
Figure G.23: Results of feedback linearizing controller with full state observer with y = ϕ2 ωw ,
while stabilizing the ball on top of the wheel, several pushes are given to the ball. The red ball is used.
List of Symbols
Symbol
dw
dx
dy
g
i
km
m
q
r
rv
uA
v
zi,d
I, J
K
K̂
MO
MR
P
Q
RA
T
V
θi
ξ
ϕ
ω
Θ
Quantity
distance between discs of wheel
Horizontal distance between laser and wheel axis
Vertical distance between laser and wheel axis
Gravitational accelleration
Transmission coefficient
Constant of turning moment
Mass
Generalized coordinates (ωw and ϕ2 )
Radius
Viscous friction parameter
Input voltage for DC motor
Velocity
Desired trajectory of zi
Moment of inertia
Linear state feedback gain
Observer gain
Linear Observabillity matrix
Linear Reachabillity matrix
State transformation matrix
Vector with generalized forces
Time dependent observabillity matrix
Anchor resistance
Kinetic energy
Potential energy
Transformation vector for output i
Statevector in observer normal form
Angle
Angular velocity
Transformation matrix
Table G.1: List of symbols
Subindice
X2
Xb
Xb,red
Xm
Xw
XO
Quantity of position of the ball
Quantity of ball
Reduced quantity of ball
Quantity of DC motor
Quantity of wheel
Matrix in Observer normal form
Table G.2: Subindices of symbols
80
Unit
[m]
[m]
[m]
[m/s2 ]
[Nm/A]
[kg]
[m]
[Nms/rad]
[V]
[m/s]
[kgm2 ]
[Ω]
[J]
[J]
[rad]
[rad/s]
-
Bibliography
[1] Luenberger D.G.: Introduction to Dynamic Systems, Theory, Models and Applications, Stanford
1979
[2] Khalil, H.K.: Nonlinear Systems, third edition, New Jersey 1996
[3] Rothfuß, R.: Anwendung der flachheitsbasierten Analyse und Regelung nichtlinearer Mehrgrößensysteme, VDI Verlag GmbH, Düsseldorf 1997
[4] Schlacher K.: Automatisierungstechnik II, SS 2001
[5] Straka, K.: Diploma thesis with title, Analysis and Passivity Based Control of the Model “Ball on
the Wheel”, 2002
[6] Grabmair, G.: Diploma thesis with title, Design and Flatnessbased Control of the Model “Ball on
the Wheel”, 2003
[7] Pölzer, M.: Diploma thesis with title, Design of a Period Measurement for a Digital Incremental
Encoder and Design of a Flatnessbased Ttrajectory Observer for the Model “Ball on the Wheel”,
2004
[8] Brenner, K.: Diploma thesis with title, Realtime Control under Linux, Design of a PC/104 System
to Control the Model “Ball on the Wheel”, 2005
[9] Fuchshumer, S.: Doctoral thesis with title, Algebraic Linear Identification, Modelling and Applications of Flatnessbased Control.
[10] Mailinglist RTAI: http://www.rtai.org
[11] Mailinglist COMEDI: http://www.comedi.org
[12] http://regpro.mechatronik.uni-linz.ac.at/downloads/nls2
81
© Copyright 2026 Paperzz