Rotary Inverted Pendulum Tan Kok Chye Teo Chun Sang School
Rotary Inverted Pendulum Tan Kok Chye Teo Chun Sang School
SUBMITTED
BY
April 1999
Abstract
The Rotary Inverted Pendulum System is an excellent test-bed for teaching digital
control techniques. The system is excited by a DC motor, and is equipped with
sensors to measure the angular displacement of the pendulum and the angular
velocity and position of the DC motor. A micro-controller is used to implement a
range of real-time digital control techniques. It can be used to demonstrate the
various practical aspects involved in designing a control system. Used as a teaching
tool, it allows students to gain hands-on experience with an actual system, from
collecting, filtering and analyzing data to obtain a dynamic model of the system, to
deciding an appropriate sampling interval and designing a digital controller to
balance the pendulum in the upright position.
Deriving a mathematical model for the inverted pendulum system is the first step in
the design process. The model must be able to describe the response of the actual
system as closely as possible. Lagrange’s equation of motion was used in the
derivation of the dynamic non-linear model. The model gives the exact relationships
among all the variables involved. Using the dynamic non-linear model, we can
derive the linear model. The unknown parameters of this model will be estimated in
the System Identification.
Data is collected from experiments to identify the unknown physical quantities that
are required to complete the model. System Identification using Least Squares
Approximation is used to estimate the parameters. Once the parameters are
identified, the model is used for design of controllers to balance the pendulum.
The controllers are designed using pole placement technique. Besides balancing the
pendulum in the upright position, it is desired to control the position as well as the
movement of the rotating arm. Controllers with proportional and/or integral actions
were designed. Digital controllers such as the Generalised Predictive Controller and
Discrete Incremental controller were also implemented for better performance.
Page I
To complete the project, a Graphical User Interface was developed to provide
courseware to cater to users with different background knowledge. This will enhance
the system so that it will become a good test-bed for control study.
Page II
Acknowledgement
Firstly, we would like to thank our supervisor Dr. Ling Keck Voon for his guidance
throughout the course of the project. His comments and suggestions have contributed
significantly to the success of the project.
We would also like to thank the Laboratory Technicians in Control Engineering Lab,
Ms. Joanne Tham, Ms. Song Lee Sin and Ms. Felicia Lim for their support
throughout the past year. Without their help, many administrative matters would not
have been performed as efficiently. Their friendly disposition have created a pleasant
environment to work in.
Next, we would like to thank our peers in Control Engineering Lab for their opinions
and appraisals. Their companionship have made staying long hours a lesser chore.
Last of all, we would like to thank all those who have, in one way or another,
contributed to the success of this project.
Page III
Contribution
FYP PROJECT
Page IV
Content
Page
Abstract I
Acknowledgments III
Contribution IV
Table of Contents V
Chapter 1 Introduction
1.1 Background and Motivation 1
1.2 Objectives 3
Page V
3.6 Discrete-Time State Space Model 14
3.7 Discrete-Time Incremental Model 14
Page VI
5.5 Discussion on Parameter Estimation Method 2 35
5.5.1 Reference Values for φ1 to φ8 35
5.5.2 Overview of Estimation Results 36
5.5.3 Effects of Difference Approximation
Method 36
5.5.4 Effects of Using Unforced Oscillation
Response for Estimation 37
5.5.5 Results of Estimation 37
Page VII
Chapter 7 Experimental Results and Discussion, Controller
Design
7.1 Introduction 57
7.2 State Feedback Controller
(Discrete and Continuous Time Model) 59
7.3 State Feedback Controller with Integral Action
(Continuous Time) 63
7.4 State Feedback Controller with Proportional
Action (Continuous Time) 65
7.5 State Feedback Controller with Proportional
and Integral Action (Continuous Time) 67
7.6 State Feedback Controller
(Discrete Time Incremental Model) 68
7.7 Generalized Predictive Controller 72
7.8 Swing-Up Controller 74
7.9 Effect of Dead Zone Mapping 75
Page VIII
8.4.10 Controller Design 95
8.4.11 Demonstration 98
Chapter 9 Conclusion 99
Chapter 10 Recommendations
10.1 DC Motor 100
10.2 Swing Up Controller 100
10.3 Parameter Estimation 102
10.4 Simulation with Animation 103
References 104
Appendix A
Appendix B
Appendix C
Appendix D
Appendix E
Appendix F
Appendix G
Appendix H
Page IX
INTRODUCTION
Chapter 1 Introduction
Early studies of the inverted pendulum system was motivated by the need to design
controllers to balance rockets during vertical take-off. At the instance of time during
launch, the rocket is extremely unstable. Similar to the rocket at launch, the inverted
pendulum requires a continuous correction mechanism to stay upright, since the
system is unstable in open loop configuration. This problem can be compared to the
rocket during launch. Here, rocket boosters have to be fired in a controlled manner,
to maintain the rocket upright.
The simple linear pendulum has long proved a useful model for more complicated
physical systems, and its behavior in the small-amplitude limit provides a realistic
yet solvable example for students in introductory classes. While the force-free,
frictionless pendulum can be solved exactly for all amplitudes in terms of elliptic
integrals, the solution is hardly illuminating, rarely found useful, and when damping
and external driving are included, the equations of motion become intractable (except
for small oscillations). With the advent of desktop computers, however, it has
become possible to study in some detail the rich nonlinear dynamics of the damped,
force-driven pendulum and gain significant insight into its sensitivity to initial
conditions for certain values of the system parameters.
Equally interesting, but much less studied in physics texts, is the state in which the
plane pendulum can be stabilized in a small-oscillation mode about the vertical by
means of a sinusoidal driving force. Although the external force can be applied to
the pivot in either the vertical or horizontal direction, or in some linear combination,
a vertically oscillating pivot is the most common scenario as in our case. It appears
that this system was first studied by Stephenson in 1908 and somewhat later by van
der Pol and Strutt.
Page 1
INTRODUCTION
Figure 1
Page 2
INTRODUCTION
1.2 Objectives
1. To verify the mathematical model of the inverted pendulum system and the
control algorithms implemented by the previous FYP group [1].
2. To estimate the system parameters of the inverted pendulum system.
3. To design controllers that can balance the pendulum and to compare the
performance of different controllers.
4. To have an Interactive User Interface for both beginners and advanced users
of this system and to provide courseware that integrates theory with practice.
Page 3
SYSTEM SETUP
2.1 Introduction
This chapter will describe the various modules of the system. The system comprises
six major modules, which will be described in the following pages. They are:
System Software
Personal Computer System
Universal Controller UC96 Microcontroller Board
Motor Driver Board
Power Supply
Inverted Pendulum Apparatus Kri PP-300
Potentiometer
Encoder
Page 4
SYSTEM SETUP
Page 5
SYSTEM SETUP
Page 6
SYSTEM SETUP
Figure 2.5
The Universal Controller UC96 Microcontroller Board
is powered by the Intel 80C196KC high performance
microcontroller, complemented by PSD401A2 a field-
programmable peripheral IC. The combination allows
the hardware structure to be programmed with
firmware, which makes the board extremely versatile.
Page 7
SYSTEM SETUP
Page 8
SYSTEM SETUP
2.8.1 Potentiometer
Page 9
SYSTEM SETUP
Figure 2.10
2.8.2 Encoder
Position of the arm is fed-back by the encoder in the
motor shaft (Figure 2.11). With this 1000 line encoder,
it is able to give a differential output signal, which gives
a total of 4000 counts per revolution.
Figure 2.11
Page 10
MATHEMATICAL MODELLING
3.1 Introduction
z
l1 β
α
L0
θ
y
Figure 3.1
The models presented in this chapter are based on the co-ordinate system shown in
Figure 3.1 above. The standard right-handed Cartesian co-ordinate system is used.
The angular position of the arm, α, is assigned to be increasing when the arm is
rotating about the z-axis in the right-handed sense (when the thumb points in the
direction of the axis, the fingers point in the direction of increasing angle). The
reference of α is taken to be the x-axis.
The angular position of the pendulum, β and θ, are assigned to be increasing when
the pendulum is rotating about an axis passing through the arm section from the
Page 11
MATHEMATICAL MODELLING
origin to the pivot point of the pendulum, in the right-handed sense. The reference of
β is taken from the upward vertical and the reference of θ is taken from the
downward vertical.
The non-linear dynamic model describes the system completely. It gives the exact
relationships among all the variables involved. All the linear models used for
controller design are derived from this non-linear model. As shown in Appendix A,
equation (A6), the dynamic model with the pendulum in the upright position is:
J 0 + m1 L20 + m1l12 sin 2 β − m1 L0 l1 cos β α&&
+
− m1 L0l1 cos β J 1 + m1l12 β&&
C 0 + KRt K b + 12 m1l12 β& sin 2 β m1 L0 l1 β& sin β + 12 m1l12α& sin 2 β α& (3.1)
a
& +
− 2 m1l1 α sin 2 β
& β
1 2
C1
0 KRt Ka u
− m gl sin β = u
1 1 0
The dynamic model with the pendulum in the downward position, Appendix A
equation (A11), is:
J 0 + m1 L20 + m1l12 sin 2 θ m1 L0l1 cosθ α&&
+
m1 L0l1 cosθ J 1 + m1l12 θ&&
C 0 + KRt Kb + 12 m1l12θ& sin 2θ − m1 L0l1θ& sin θ + 12 m1l12α& sin 2θ α&
a
& + (3.2)
− 2 m1l1 α sin 2θ
& θ
1 2
C1
0 KRt Ka u
m gl sin θ = u
1 1 0
Page 12
MATHEMATICAL MODELLING
1 1 0
Define:
a = J 0 + m1 L20 c = m1 L0l1 e = KRt Ka u h = m1 gl1
b = m1l12 d = C0 + KRt Ka b f = J 1 + m1l12 (3.4)
Writing equation (3.3) in state space form with 3 state variables, we obtain, as shown
in Appendix B equation (B6):
x&3 = A 3 x3 + B 3u
α&& − df ch − cC1 α& ef
β& = 1 0 af − c 2 β +
1 0 u
af − c 2 0 af − c 2 (3.5)
β&& − cd ah − aC1 β& ce
Augmenting the state variables with the arm position α, the following model is
obtained as shown in Appendix B equation (B7):
x& 4 = A 4 x4 + B 4 u
α& 0 af − c 2 0 0 α 0
α&&
= 1 0 − df ch − cC1 α& 1 ef
+ u
β& af − c 2 0 0 0 af − c 2 β af − c 2 0
&& (3.6)
β 0 − cd ah − aC1 β& ce
Page 13
MATHEMATICAL MODELLING
Note that for the above models, the output(s) can be defined as any linear
combination(s) of the state variables specified by the following:
y = Cx
where x is the state variables (x3 or x4).
The discrete-time model is required when using digital control techniques. When a
system described by state space equations,
x& = Ax + Bu
y = Cx
is discretized with respect to a sampling interval Ts, the corresponding discrete state
space model is obtained:
x(k + 1) = A d x(k ) + Bd u (k )
y (k ) = C d x (k ) (3.7)
where k is the discrete time index,
Ts
Ad = e , B d = ∫ e Aγ Bdγ , C d = C
ATs
0
The discretization technique can be applied to the continuous time models as stated
in equations (3.4) and (3.5) to obtain the discrete models for design or analysis
purposes.
The incremental model [2] is an alternative form of representation and will be used
in the design and implementation of the Generalised Predictive Controller. Define
the state variables to be:
x (k )
xi (k ) =
u (k − 1)
Page 14
MATHEMATICAL MODELLING
As shown in Appendix C equation (C3), the incremental model used for this project
is:
xi (k + 1) = A di xi (k ) + B di ∆u (k )
y (k ) = C di xi (k ) (3.8)
where
A Bd B
A di = d , B di = d , C di = [C d 0]
0 1 1
Page 15
PARAMETER ESTIMATION
4.1 Introduction
In the mathematical models derived in Chapter 3, the parameters of the models need
to be determined for the model to be useful. In this chapter, two techniques used for
parameter estimation are presented. Both the techniques involve the same principles,
except that the equations used for estimation are slightly different. To be able to
estimate the parameters, we excite the system with a known test signal and collect
the data of the response of the system. With the mathematical model derived in
Chapter 3, we then try to find the best values of the parameters that will produce
theoretical results that are as close as possible to the experimental results. The
process is illustrated in Figure 4.1 below.
Test Signal System Response
Physical
System
Comparison
Parameter
Estimation
Model Response
Mathematical
Model
Figure 4.1
For parameter estimation, the system will be excited with a known test signal from
its downward hanging position. The response of the system to the test signal will
adhere to the dynamics described by the non-linear downward model. Hence it will
be more convenient to use the downward model to estimate the parameters. The
Page 16
PARAMETER ESTIMATION
H (z ) =
0.15
1 − 0.85 z −1
The frequency response of the filter is shown in Figure 4.2 (a) below.
(a) (b)
Figure 4.2
Page 17
PARAMETER ESTIMATION
( )
H e jω =
0.15
1 − 0.85e − jω
0.15
=
1 − 0.85 cos ω + j 0.85 sin ω
( )
H e jω =
0.15
(1 − 0.85 cosω )2 + (0.85 sin ω )2
0.15
=
1 − 1.7 cos ω + 0.85 2
Since the filter is of IIR type, it will introduce some phase distortion to the filtered
signal. To perform IIR filtering without phase distortion, the filtered signal is
reversed in sequence and passed through the filter again. By this action, all the
frequency components of the signal pass through the filter twice, once in each
direction. Their individual delays will be the same and hence there will be no phase
distortion. This is implemented by the MATLAB command “filtfilt()”. The
equivalent filter by this action is double the original filter order. The effective
frequency magnitude response, shown in Figure 4.2 (b), is |H(ejω)|2. Hence the cut-off
frequency can be found as follows:
( )
H e jω
21
=
2
2
0.15 1
=
1 − 1.7 cosω + 0.85 2
2
cos ω =
1
1.7
(
1 + 0.852 − 0.15 2 2 )
ω = 0.1048 rad / sample
2πf = 0.1048 rad / sample
f = 0.01667 cycle / sample
For a sampling frequency Fs of 100Hz, the analogue cut-off frequency fc, is Fs×f
=1.6673Hz.
Page 18
PARAMETER ESTIMATION
From the raw data collected, the arm acceleration, pendulum velocity and pendulum
acceleration can be estimated. For sampling interval Ts and sample index k, there are
3 possible ways to estimate these.
Taking the forward difference, the arm acceleration, pendulum velocity and
pendulum acceleration can be estimated as:
α& (k + 1) − α& (k )
α&&(k ) =
Ts
θ (k + 1) − θ (k )
θ&(k ) =
Ts
θ&(k + 1) − θ&(k )
θ&&(k ) =
Ts
θ (k + 2) − θ (k + 1) − [θ (k + 1) − θ (k )]
=
Ts2
θ (k + 2) − 2θ (k + 1) + θ (k )
=
Ts2
Taking the central difference, the arm acceleration, pendulum velocity and
pendulum acceleration can be estimated as:
α& (k + 1) − α& (k − 1)
α&&(k ) =
2Ts
θ (k + 1) − θ (k − 1)
θ&(k ) =
2Ts
θ&(k + 1) − θ&(k − 1)
θ&&(k ) =
2Ts
θ (k + 2 ) − θ (k ) − [θ (k ) − θ (k − 2 )]
=
4Ts2
θ (k + 2 ) − 2θ (k ) + θ (k − 2)
=
4Ts2
Page 19
PARAMETER ESTIMATION
Taking the backward difference, the arm acceleration, pendulum velocity and
pendulum acceleration can be estimated as:
α& (k ) − α& (k − 1)
α&&(k ) =
Ts
θ (k ) − θ (k − 1)
θ&(k ) =
Ts
θ&(k ) − θ&(k − 1)
θ&&(k ) =
Ts
θ (k ) − θ (k − 1) − [θ (k − 1) − θ (k − 2 )]
=
Ts2
θ (k ) − 2θ (k − 1) + θ (k − 2)
=
Ts2
(a)
(c)
Figure 4.3
From Figure 4.3, observe that we can segment the data into forced response and
unforced oscillatory response where the unforced response is characterised by:
u = 0 α& = 0 α&& = 0
Page 20
PARAMETER ESTIMATION
All the estimation methods presented here are based on the Least Squares Technique
[7]. Stated simply, for a system of linear equations described by
y = Ax (4.1)
where A is an n × m matrix and n > m,
y is a column vector of n elements,
x is a column vector of m unknowns,
the Least Squares solution of the system of equations is given by:
x = (ATA)-1ATy (4.2)
The raw data and the estimated data will be used in the estimation of the unknown
parameters. Method 1 was used by the previous FYP group and has been a proven
technique. It will be used as the reference method for comparison purposes.
4.6.1 Method 1
Page 21
PARAMETER ESTIMATION
+ m1L0l1θ& 2 sin θ + Kt Ku
Ra
u
J1θ&& + C1θ& = − m1L0l1α&& cosθ − m1l12θ&& + 12 m1l12α& 2 sin 2θ − m1gl1 sin θ
In matrix form, the above can be written as:
− m1 L20α&& − m1l12α&& sin 2 θ − m1 L0 l1θ&&cosθ − KRt Kb α& J
a
= [α&& α& ] 0
− m1l12α&θ& sin 2θ + m1 L0l1θ& 2 sin θ + Rt a u u (4.3)
C0
K K
[ ] [
− m1 L0l1α&& cosθ − m1l12θ&& + 12 m1l12α& 2 sin 2θ − m1 gl1 sin θ = θ&& θ&
J1
] (4.4)
C1
The left-hand side of equations (4.3) and (4.4) are known quantities. The
terms contain the determinable parameters and data which are obtainable
from the response of the system. When the data from each sampling instance
are formed into equations (4.3) and (4.4), we get an equation similar to (4.1)
which is then used for estimation. Mathematically, for N samples of the
response of the system, we can form N equations from (4.3) as:
y = Ax
y k (k ) α&&(k ) α& (k )
y (k + 1) α&&(k + 1) α& (k + 1)
J
y= A= x= 0
k
M M M C0
y k (k + N − 1) α&&(k + N − 1) α& (k + N − 1)
where k is the sample index,
y k (k ) = − m1 L20α&&(k ) − m1l12α&&(k )sin 2 [θ (k )] − m1 L0 l1θ&&(k )cos[θ (k )] − KRt Ka b α& (k )
[ ]
− m1l12α& (k )θ&(k )sin [2θ (k )] + m1 L0l1 θ&(k ) sin [θ (k )] +
2 Kt K u
Ra u (k )
The parameters J0 and C0 can be estimated from equation (4.2). The same
technique is used for all the estimation methods and will not be stated again.
1 (4.5)
The linear model can then be constructed from equation (B8) in Appendix B.
Page 22
PARAMETER ESTIMATION
4.6.2 Method 2
a = J 0 + m1 L20 c = m1 L0l1 e= Kt Ku
Ra h = m1 gl1
b=ml 2
1 1 d = C0 + Kt Kb
Ra f = J1 + m l 11
2
With reference to the variables above, the downward model can be written as:
(4.6)
aα&& + bα&& sin 2 θ + cθ&&cosθ + dα& + bα&θ& sin 2θ − cθ& 2 sin θ − eu = 0
cα&& cosθ + fθ&& − 1 bα& 2 sin 2θ + C θ& + h sin θ = 0 (4.7)
2 1
Define:
b d b C1
φ1 = φ3 = φ5 = φ7 =
a a f f
c e c h
φ2 = φ4 = φ6 = φ8 = (4.8)
a a f f
φ1
φ
[α&&] = [(− α&& sin 2 θ − α&θ& sin 2θ ) (θ& 2
sin θ − θ&&cosθ ) − α& ]
u 2
φ 3 (4.9)
φ 4
φ 5
φ
[θ&&] = [ α&
1
2
2
sin 2θ − α&& cosθ − θ& ]
− sin θ 6
φ 7
(4.10)
φ8
φ
[θ&&] = [− θ& ]
− sin θ 7
φ8 (4.11)
Page 23
PARAMETER ESTIMATION
From these results, φ5 and φ6 can be estimated, using the full response, by:
φ
[θ&& + φ θ& + φ ] [
sin θ = 12 α& 2 sin 2θ
− α&& cosθ 5 ]
φ 6
7 8
(4.12)
Note that the linear model can be constructed from equation (B9) in
Appendix B.
Figure 4.4
The results from parameter estimation are used to modify the Simulink model’s
parameters. The simulated response to the same test signal will give an indication of
the accuracy of the estimated parameters.
Page 24
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
5.1 Introduction
This chapter presents the results of the parameter estimation techniques as described
in Chapter 4. Previous work has shown that certain patterns of test signals produce
consistently good results. Figure 4.3 (a) shows one such test signal. It is a step signal
that drops to zero after a finite duration. This type of test signals provides good
excitation for the transient response and allows the system to exhibit the unforced
oscillation response. The discussion will be limited to parameter estimation using
this particular type of test signals. As there are 2 methods and a few options available
for estimation, a comprehensive treatment is not possible. Selected cases will be
highlighted where appropriate. All discussions are based on data collected on System
II as mentioned in Appendix F.
Assuming that noise affecting the signals has a mean value of zero, it would be ideal
to use as many samples as possible for estimation such that its effects will be
minimised. However, there is a physical limitation on the memory of the micro-
controller and this in turn limits the number of samples of data that can be collected.
Each set of data used is 1800 samples wide. For a sampling period of 10ms, this
corresponds to the first 18 seconds of excitation.
Page 25
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
Ten sets of data are collected for analysis. The test signals for these are as described
above in increasing duration of 1-second steps. The data collected for analysis are
presented here in Figure 1 to Figure 10. These will be referred to as “data set 1”,
“data set 2”, to “data set 10” respectively.
Page 26
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
The results obtained from parameter estimation are tabulated in Appendix H for ease
of reference. For each method, there is an alternative to use the unforced oscillation
response to estimate some of the parameters. This has been described in Chapter 3.
Furthermore, there are 3 ways to estimate the arm acceleration, pendulum velocity,
and pendulum acceleration. The total combinations produce a substantial amount of
data not suitable to be presented in this chapter.
The results are verified using the Simulink model. If we take the results from the
simulation as the reference, we can have an indication of the accuracy of the
estimation by defining the following error constants.
Page 27
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
Let
α& S be the arm velocity obtained from simulation ,
θ S be the pendulum position obtained from simulation ,
α& E be the arm velocity obtained from experiment ,
θ E be the pendulum position obtained from experiment .
Define:
N N
∑ [α& S (k ) − α& E (k )] ∑ [θ (k ) − θ (k )]
2 2
S E
Error A = k =1
Error B = k =1
N N
The error constants defined above are normalised with respect to the total number of
samples N so that the errors for different sample size would not differ by too much.
These error constants are also tabulated in Appendix H.
Page 28
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
For data set 1, using the full response for estimation, the results are shown in
Figure 5.11, 5.12 and 5.13 for forward, backward, and central difference
approximation respectively.
Figure 5.13
The bold line represents the simulated results whereas the thin line represents
the experimental results. Observing the results visually, it can be said that the
Page 29
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
use of the central difference method produces more accurate results than
using the forward or backward difference methods. This is true for the 10
data sets even though the numerical error constants defined in section 5.3
may indicate otherwise for certain data sets.
The transfer functions for these approximation methods are shown below.
To plot the frequency response for comparison purposes, we shift the output
by one sample into the past and plot its response defined by:
Page 30
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
The frequency response for the shifted Forward HFS(z), Backward HBS(z) and
Centre HCS(z) Difference Approximation Methods are shown in Figure 5.14,
5.15 and 5.16 respectively, for Ts of 10ms.
Figure 5.16
Since the transfer functions are Finite Impulse Response (FIR) type, all the
phase responses are linear, which implies that there will not be any phase
distortion of the output signal. However, since the input and output sequences
are used in the estimation process, the delays on the individual frequency
components from the different sequences could have some effects on the
results.
Page 31
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
The unforced oscillation response of the data segment can be used to estimate
J1 and C1. Tables H1, H3 and H5 are the results using the full response for
estimation. Tables H2, H4 and H6 are the results obtained using the unforced
oscillation response. Examining the individual tables, we see that the
distribution of values for J1 and C1 within each table is quite small.
Comparing among Table H1 and H2, H3 and H4, H5 and H6, we observe that
the results of estimation using the unforced response generally produces
slightly lower values. Since the distribution of the results is small for these
data sets, we can conclude that results using the full response and the
unforced oscillation response are both valid.
From 5.4.1, we have shown that using the central difference approximation
produces more accurate results than using the forward or backward difference
approximation. From 5.4.2, we observed that using the full response or the
unforced oscillation response would produce quite reasonable results. From
5.4.3, we see that even though data sets 1 and 2 produce values of C1 that are
inconsistent with the rest of the data sets, we cannot discard these results
because their simulated results are the closest to the experimental results.
Page 32
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
The linear model (Appendix B, equation (B8)) formed from these results is:
x&3 = A 3 x3 + B3u
α&& − 1.3705 3.8557 − 0.01242 α& 0.5721
β& = 0 0 1 β + 0 u
(5.2)
β&& − 0.9367 51.5747 − 0.1661 β& 0.3910
The simulated responses from all the data sets are shown below for the results
shown in Table 5.1 above. The bold line is the simulated response and the
thin line is the experimental data.
Page 33
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
Page 34
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
The bode plot of the linear model can then be obtained. For the output being
defined as the arm velocity, the bode plot is shown in Figure 5.27. Figure
5.28 shows the case when the pendulum position is defined as the output.
From the reference model obtained in Section 5.4.4, we can establish some
reference values that are expected of φ1 to φ8 for comparison purposes. The
reference values can be calculated from (4.8) and (3.4) to be:
φ1 = 0.08578 φ2 = 0.07476 φ3 = 1.30050 φ1 φ 5
= = 1.1474
φ4 = 0.54290 φ5 = 0.78415 φ6 = 0.68338 φ2 φ6
φ7 = 0.15717 φ8 = 48.93428
Page 35
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
Similar effects where using the central difference approximation gives a more
accurate model can be demonstrated with some of the data sets obtained. For
data set 1, using the unforced oscillation response for estimation, the results
are shown in Figure 5.29, 5.30 and 5.31 for forward, backward, and central
difference approximation respectively.
Page 36
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
Figure 5.31
Comparing with the reference values against Tables H8, H10 and H12, we
see that H12 has the average values of φ3, φ7, φ8 closest to the reference.
Since it has been found that using the central difference for approximation of
the derived quantities produce better results, and using the unforced
Page 37
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
Taking the average values so as to minimise the overall errors, the final
results are tabulated below.
Data Set φ1 φ2 φ3 φ4
Average(1 to 10) -0.124165 -0.000866 0.933609 0.380896
Data Set φ8 φ7 φ6 φ5
Average(1 to 10) -0.062969 0.637546 0.134671 49.548102
Table 5.2
The linear model (Appendix B, equation (B9)) formed from these results is:
x&3 = A 3 x3 + B3u
α&& − 0.9331 − 0.04288 0.0001166 α& 0.3807
β& = 0 0 1 β + 0 u
β&& − 0.5949 49.5208 − 0.1346 β& 0.2427
Page 38
EXPERIMENTAL RESULTS AND DISCUSSION FOR PARAMETER ESTIMATION
The bode plot of the linear model can then be obtained. The bode plot of this
model is plotted against that of the reference model for comparison purposes.
For the output being defined as the arm velocity, the bode plot is shown in
Figure 5.32. Figure 5.33 shows the case when the pendulum position is
defined as the output.
From the above results, we see that despite the errors present in the
estimation process, Method 2 still produces a fairly accurate linear model
when compared to Method 1.
Page 39
CONTROLLER DESIGN
6.1 Introduction
In a regulatory type control system, the controller regulates the output and maintains
it at a desired level as specified by some reference. When the reference is time
varying, the controller will attempt to excite the system in such a way that the output
will track the reference as closely as possible. Usually, the control signal applied to
the plant or system is a function of the difference between the reference input and the
actual output, commonly referred to as the error signal. For a real system,
disturbances will act on the plant. An effective control system should be insensitive
to external disturbances and responsive to changing inputs.
For this project, the primary objective is to balance the pendulum in its upright
position. The secondary objective is to maintain the arm at a fixed position. Various
controllers were implemented to achieve these. To bring the pendulum from its
downward stable position to its upright position, a swing-up controller was
implemented. This chapter presents the controllers used in this project and the
theoretical background associated with them.
The controllers used for balancing are linear state feedback controllers. They are
designed based on a known model of the system. In Chapter 5, the parameters of the
linear model were estimated. For presentation of this report, the model used is as
described by (5.2). It is reproduced here for ease of reference.
x&3 = A 3 x3 + B3u
α&& − 1.3705 3.8557 − 0.01242 α& 0.5721
β& = 0 0 1 β + 0 u
β&& − 0.9367 51.5747 − 0.1661 β& 0.3910
Page 40
CONTROLLER DESIGN
Figure 6.1
The following are the thirteen controllers being implemented based on different
models used:
3 State Feedback Controller (Continuous Time Model)
4 State Feedback Controller (Continuous Time Model)
3 State Feedback Controller with Integral (I) Action (Continuous Time Model)
4 State Feedback Controller with Integral (I) Action (Continuous Time Model)
3 State Feedback Controller with Proportional (P) Action (Continuous Time Model)
4 State Feedback Controller with Proportional (P) Action (Continuous Time Model)
3 State Feedback Controller with PI Action (Continuous Time Model)
4 State Feedback Controller with PI Action (Continuous Time Model)
3 State Feedback Controller (Discrete Time Model)
4 State Feedback Controller (Discrete Time Model)
4 State Feedback Controller (Incremental Model)
5 State Feedback Controller (Incremental Model)
Generalised Predictive Controller
Page 41
CONTROLLER DESIGN
6.2 Controllability
To be able to use the Pole Placement Technique for controller design, the system
must be completely state controllable. Therefore, before designing any controller, the
controllability of the system must be checked first.
The system is completely state controllable if the rank of the n × n matrix, Sct, is n.
[
Sct = B AB A 2 B L A n -1B ]
Similarly, for a system described by:
x(k + 1) = A d x(k ) + B d u (k )
The system is completely state controllable if the rank of the n × n matrix, Sdt, is n.
[
Sdt = B d A d Bd A d2 B d L A nd-1B d ]
Page 42
CONTROLLER DESIGN
u x& x y u x& x y
B ∫ C B ∫ C
A A
-K
The selection of the desired closed loop poles is a compromise between the speed of
the response of the error vector and its sensitivity to disturbances and measurement
noise. That is, if we increase the speed of response, then the adverse effects of
disturbances and measurement noise will generally increase.
For a second order system, the system dynamics (response characteristics) can be
precisely correlated to the location of the desired closed loop poles and zeros of the
plant. But for higher order systems, the location of the closed loop poles and the
system dynamics (response characteristics) are not easily correlated.
Hence, in our system, in determining the state feedback gain matrix (K) for the
system, we need to examine the response characteristics of the system for several
sets of controller gains (K) and choose the one that gives the best overall system
performance.
Page 43
CONTROLLER DESIGN
r u x& x y
∫
−
B C
+
A
Figure 6.4
Figure 6.4 shows the block diagram of the inverted pendulum system with state
feedback. The derivation of the closed loop control system with state feedback is as
shown
x& = Ax + Bu
y = Cx
u = r − Kx
x& = Ax + B(r − Kx )
Below is the final state space model, where A can be 4x4 matrix for 4 state or 3x3 for
3 state.
x& = ( A − BK ) x + Br
y = Cx
Ackermann's formula is used to calculate the feedback gain matrix (K). Using Matlab
‘acker (A,B, poles)’ the values of the feedback gain matrix (K) can be easily
calculated.
Page 44
CONTROLLER DESIGN
r u x& x y
∫
− −
Kp B C
+
A
Figure 6.5
Figure 6.5 shows the block diagram of the inverted pendulum system with state
feedback and proportional controller. The derivation of the closed loop control
system with state feedback and proportional control is as shown
x& = Ax + Bu
y = Cx
u = − Kx + Kp (r − Cx )
x& = Ax + B(− K − KpC ) x + BKpr
Where A can be a 4x4 matrix for 4 state or 3x3 for 3 state. Matrix C will be
dependent on what is being defined as the output. If the user chose the proportional
gain to act on the pendulum position for 4 state, matrix C will be [0 0 1 0].
Ackermann's formula is used to calculate the feedback gain matrix (K). Using Matlab
‘acker(A,B, poles)’ the values of the feedback gain matrix (K) can be easily found.
The user will design a value for proportional gain (Kp). The system will then check
the locations of the poles with Kp included. This can be done using Matlab ‘eig(A-
BK-KpBC)’.
Page 45
CONTROLLER DESIGN
Figure 6.6
Figure 6.6 shows the block diagram of the inverted pendulum system with state
feedback and integral controller. The derivation of the closed loop control system
with state feedback and integral control is as shown
x& ( A − BK ) B x 0
e& = − KiC +
0 e Ki
r
x
y = [C 0]
e
Where A can be a 4x4 matrix for 4 state or 3x3 for 3 state. Matrix C will be
dependent on what is being defined as the output. If the user chose the integral gain
to act on the pendulum position for 3 state, matrix C will be [0 1 0].
Ackermann's formula is used to calculate the feedback gain matrix (K). Using Matlab
‘acker(A,B, poles)’ the values of the feedback gain matrix (K) can be easily
calculated. The user will design a value for integral gain (Ki). The system will then
check the locations of the poles with Ki included. This can be done using Matlab
( A − BK ) B
‘ eig ’.
− KiC 0
Page 46
CONTROLLER DESIGN
6.7 3 and 4 State Pole Placement with Proportional and Integral Controller
(Continuous Time Model)
r z e& e w u x& x y
∫ ∫ C
− −
Ki B A
+ +
Kp A
Figure 6.7
Figure 6.7 shows the block diagram of the inverted pendulum system with state
feedback and both proportional and integral controller. The derivation of the closed
loop control system with state feedback and proportional and integral control is as
shown
x& = Ax + Bu
y = Cx
z=r − y
u = − Kx + w
w = e + Kpz
e& = zKi
Page 47
CONTROLLER DESIGN
Where A can be a 4x4 matrix for 4 state or 3x3 for 3 state. Matrix C will be
dependent on what is being defined as the output. If the user chose the proportional
and Integral control to act on the pendulum velocity for 4 state, matrix C will be
[0 0 0 1].
Ackermann's formula is used to calculate the feedback gain matrix (K). Using Matlab
‘acker(A,B, poles)’ the values of the feedback gain matrix (K) can be easily
calculated. The user will design a value for proportional gain (Kp) and integral gain
(Ki). The system will then check the locations of the poles with Kp and Ki included.
( A − BK − KpBC) B ’.
This can be done using Matlab ‘ eig
− KiC 0
Page 48
CONTROLLER DESIGN
Ad
Figure 6.8
Using Ackermann’s formula, the controller gains defined by K can be determined for
a given set of closed loop poles. The controller can then be found by:
u (k ) = r (k ) − Kx(k )
For r(k) = 0,
u (k ) = −Kx (k )
When the 3 states continuous time model is discretized to obtain Ad, the resulting
controller is the 3 states feedback controller (designed using the discrete time model).
Similarly, if the 4 states continuous time model is discretized instead, the resulting
controller is the 4 states feedback controller (discrete time model). Functionally, the
state feedback controller designed using the continuous or discrete time model is
identical if the controller gains K are the same. Since the system is essentially a
digital system, it would be more appropriate to use digital control techniques for
design and analysis.
Page 49
CONTROLLER DESIGN
Adi
Figure 6.9
Using Ackermann’s formula, the controller gains defined by K can be determined for
a given set of closed loop poles. The controller can then be found by:
∆u (k ) = r (k ) − Kxi (k )
u (k ) = u (k − 1) + ∆u (k )
= u (k − 1) + r (k ) − Kxi (k )
x (k )
= u (k − 1) + r (k ) − [K1 K 2 ]
u (k − 1)
= u (k − 1) + r (k ) − K1 x (k ) − K 2 u (k − 1)
= r (k ) + (1 − K 2 )u (k − 1) − K 1 x(k )
For r(k) = 0,
u (k ) = (1 − K 2 )u (k − 1) − K 1 x(k )
Note that the controller gains K1 acts on the state variables whereas K2 acts on the
previous controller output. This technique can be applied to the 3 states discrete
model or the 4 states discrete model to obtain the 4 states incremental model or 5
states incremental model respectively.
Page 50
CONTROLLER DESIGN
Predictive Control belongs to the class of model based controller design concepts.
The concept of Predictive Control [2] is presented in Appendix D. For this project,
the 5 states incremental model is used for design of the Generalised Predictive
Controller. The derivation of the GPC control law is presented in Appendix E. The
controller can be written as
u (k ) = u (k − 1) + k1w1 (k ) + k 3 w3 (k ) + K 2 xi (k )
where
1
k1 = [1 0 L 0 ] ( T −1
σ 1G1 G1 + σ 3 G3 G3 + λI σ 1G1
T T 1
M
)
1
1
( −1
k 3 = [1 0 L 0] σ 1G1 G1 + σ 3 G3 G3 + λI σ 3G3
T T T 1
M
)
1
( )(
−1
K 2 = −[1 0 L 0] σ 1G1 G1 + σ 3 G3 G3 + λI σ 1G1 Φ1 + σ 3G3 Φ 3
T T T T
)
For the details on the actual calculation of the controller gains k1, k3 and K2, refer to
Appendix E. This particular controller is actually a special case of the 5 states
feedback controller described in Section 6.9 above. However, the concept behind the
controller is more complex. For a comprehensive treatment of this subject, refer to
“State Space Predictive Control of Inverted Pendulum” [2] by Yong Tet Leong.
Page 51
CONTROLLER DESIGN
The swing up controller is required to swing the pendulum from its downward or
pendant position to its upright position. The swing up controller used for this project
is an adaptation of the controller proposed by K Furuta and M Yamakita in “Swing-
up control of inverted pendulum using pseudo-state feedback” [3]. The swing-up
control is based on the subspace projected from the state space. The partitioned state
composed of the pendulum’s angular position and velocity, which are selected as
pseudo-state, are assigned different accelerations of the arm. Based on the vector
fields in the partitions of the subspace, the trajectories connecting the pendant state to
the upright state in the pseudo-state space is determined. Each vector field
corresponds to a control law giving the prescribed acceleration. In the trajectory
determination, the angular velocity of the motor is neglected, and it is assumed that
the acceleration is of the bang-bang type.
( )
m1 L0 l1α&& cosθ + J 1 + m1l12 θ&& − 12 m1l12α& 2 sin 2θ + C1θ& + m1 gl1 sin θ = 0
( 1 1 1 )
J + m l 2 θ&& + C θ& + m gl sin θ = − m L l α&& cosθ + 1 m l 2α& 2 sin 2θ
1 1 1 1 0 1 2 1 1
(6.1)
Now, suppose that the last term of the right-hand side equation (6.1) can be
neglected, that is,
1
2 m1l12α& 2 sin 2θ = 0
This assumption is valid provided that the pendulum is light enough to be swung up
with small arm velocity. Consequently, equation (6.1) is reduced to:
(J 1 )
+ m1l12 θ&& + C1θ& + m1 gl1 sin θ = −m1 L0 l1α&& cosθ (6.2)
When the arm acceleration is considered as an input to equation (6.2), the pendulum
acceleration can be determined as:
θ&& =
1
J 1 + m1l12
(− C1θ& − m1 gl1 sin θ − m1 L0 l1α&& cosθ )
Page 52
CONTROLLER DESIGN
For a given state of the pendulum’s angular position and velocity, the incremental
position and velocity can be calculated as:
∆θ = θ&Ts
∆θ& = θ&&T
s
where Ts is the sampling interval.
The projected vector fields onto the subspace can then be found for a given arm
acceleration. The projected vector fields are shown in Figures 6.10, 6.11 and 6.12 for
arm acceleration of 0rad/s, 60rad/s and –60rad/s respectively.
Figure 6.12
In the above vector fields, the downward pendant state is marked by the symbol ‘O’.
The desired state for the upright position where the pendulum position is ±π and
velocity is 0, is marked by the symbol ‘X’. The horizontal axis specifies the
pendulum’s angular position and the vertical axis specifies the angular velocity.
Page 53
CONTROLLER DESIGN
Observe from Figure 6.10 that the subspace will converge at the origin where the
angular position and velocity are both zero.
The next step combines these projected vector fields to construct a bang-bang state
feedback. For simplicity, it is assumed here that there is a direct proportional
relationship between the motor’s driving command, u, and the arm acceleration.
It can be observed that there are many switching patterns of the arm acceleration that
can swing the pendulum from the pendant position to the upright position. The
switching pattern implemented in this project is shown in Figure 6.13 below:
Region A, u = -u0
Region B, u = u0
Figure 6.13
This switching pattern is chosen because it is simple, easy to adapt for different
systems, and it is intuitively clear as to how the control action acts to swing up the
pendulum. The control action is applied only in regions A and B. Region A can be
specified as:
π
0 <θ ≤ , θ& ≥ 0
2
Region B can be specified as:
π
− ≤ θ ≤ 0, θ& ≤ 0
2
There are no control actions when the pendulum is above the horizontal. In this
region above the horizontal, we use the force of gravity to retard the pendulum
before it reaches its desired state. Note that the subspace trajectories, upon leaving
regions A and B, will have a higher velocity magnitude or larger absolute angular
position when compared to the unforced system. Over a few cycles of swinging, the
Page 54
CONTROLLER DESIGN
angular position will reach ±π with a low velocity. To allow adjustments for the
speed of swing-up action and the number of swings, let:
u0 = K S × uM
where Ks is a user supplied constant between 0 and 1,
uM is the maximum allowable motor driving command.
Page 55
CONTROLLER DESIGN
When the motor’s torque cannot overcome the effective moment of inertia of the
load and the friction on the axis of rotation, the arm will be stationary. This is called
the dead zone effect of the motor. The ideal and actual torque-input relationship is
illustrated in Figures 6.14 and 6.15 respectively. Here, a simplistic linear model is
assumed.
τ τ
τM τM
u -dz u
-uM uM -uM dz uM
-τM -τM
Dead zone mapping may be used to compensate for this effect. It is a simple
mapping function that maps all driving signals that are within the dead zone to the
boundary of the dead zone. The resulting torque-input relationship is shown in Figure
6.16 below.
τ
τM
-dz u
-uM dz uM
-τM
Figure 6.16
Note that the dead zone boundary for positive and negative commands need not be
the same. It is illustrated as such for simplicity of presentation only.
Page 56
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
7.1 Introduction
This chapter presents the results obtained from the different controllers. It has to be
stated that because of the dead zone of the motor, the experimental results have
deviated too far from the simulated results that there cannot be any meaningful
comparisons. As such, in this report, no attempts have been made to compare the
results with the simulated results. Furthermore, there are no apparatus available to be
able to introduce a consistent disturbance to the different controllers. However, the
performance of the different controllers can be compared with respect to other
controllers. All the results are obtained from System II as stated in Appendix F.
The controllers were designed based on models derived from (5.2) of Chapter 5.
Except for the GPC controller, all the other controllers were designed using Pole
Placement technique. The measurable quantities are the pendulum position and the
incremental arm position. As no state observers were implemented, the unmeasurable
state variables are approximated by:
α (k ) = α (k − 1) + ∆α (k )
∆α (k )
α& (k ) =
Ts
β (k ) − β (k − 1)
β& (k ) =
Ts
where ∆α(k) is the incremental arm position,
k is the sample index.
Page 57
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
The design process is mostly through trial and error as there are no particular
specifications to meet. The best responses are then adopted for presentation in this
chapter. The results for the controllers are obtained with dead zone mapping turned
off. The effects of dead zone mapping will be discussed separately.
Page 58
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
The 3 state and 4 state feedback controllers are designed using pole placement
technique. The discrete and continuous time models are shown below, based on the
reference model obtained in Chapter 5.
x&3 = A 3 x3 + B3 u
α&& − 1.3705 3.8557 − 0.01242 α& 0.5721
β& = 0 0 1 β + 0 u
β&& − 0.9367 51.5747 − 0.1661 β& 0.3910
x3 (k + 1) = A 3d x3 (k ) + B3d u (k )
α& (k + 1) 0.9864 0.0383 0.0001 α& (k ) 0.0057
β (k + 1) = 0 1.0026 0.0100 β (k ) + 0 u (k )
β& (k + 1) - 0.0093 0.5156 1.0009 β& (k ) 0.0039
x& 4 = A 4 x4 + B 4 u
α& 0 1 0 0 α 0
α&& 0 − 1.3705 3.8557 − 0.01242 α& 0.5721
= + u
β& 0 0 0 1 β 0
&& &
β 0 − 0.9367 51.5747 − 0.1661 β 0.3910
x4 (k + 1) = A 4d x 4 (k ) + B 4d u (k )
α (k + 1) 1 0.0099 0.0002 0 α (k ) 0
α& (k + 1) 0 0.9864 0.0383 0.0001 α& (k ) 0.0057
= + u (k )
β (k + 1) 0 0 1.0026 0.01 β (k ) 0
&
β (k + 1) 0 − 0.0093 0.5156 1.0009 β& (k ) 0.0039
Page 59
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
Since all the controllability matrices have full rank, the pole placement technique can
then be used to design the state feedback controllers.
The closed loop poles for the 3 state feedback system are chosen to be at:
0.9881 + 0.0591i
0.9881 - 0.0591i
0.9572 (3 State Discrete Time Model)
and:
-1.1547 + 5.8415i
-1.1547 - 5.8415i
-4.4259 (3 State Continuous Time Model)
The feedback controller’s gains (K3) that correspond to the above poles are shown
below. This set of gains will be used throughout this chapter for comparison and
discussion.
K3 = [-8 250 25]
Page 60
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
Figure 7.1
From Figure 7.1, we can see that the system was able to balance itself upright. Note
that the arm position information is wrapped around such that it will always be
within the range of ±π. There is no control over the arm position. Furthermore, the
arm velocity has a non-zero steady state error and the arm can be seen to be rotating
in the clockwise direction at a fairly constant speed. The arm position is not a state
variable in the model and hence the controller output will be independent of the arm
position.
The arm position can be better controlled using the 4 states feedback controller as the
arm position is a state variable of the 4 states linear model. The closed loop poles for
the 4 state feedback system are chosen to be at:
0.9964 + 0.0437i
0.9964 - 0.0437i
0.9840
0.9100 (4 state Discrete Time Model)
-0.2802 + 4.3139i
-0.2802 - 4.3139i
-1.6142
-9.2821 (4 State Continuous Time Model)
Page 61
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
The feedback controller’s gains (K4) that correspond to the above poles are shown
below.
K4 = [-10 -10 250 40]
Figure 7.2
From Figure 7.2, we can see that the arm position is now restricted within some finite
bounds. There is an improvement on the control of the arm position using the 4 states
feedback controller as compared to the 3 states feedback controller as expected.
For the 3 state feedback controller, the output can be defined as the arm velocity,
pendulum position, and pendulum velocity. For the 4 state feedback controller, the
output can also be defined as the arm position. The integral controller (I), or
proportional controller (P), and the proportional and integral controller (PI) can be
configured to act on each of these outputs. As such, the number of possible
combinations is very large and a treatment of every controller would be very
intensive. The discussion on the I controller, P controller and PI controller will be
limited to its effect on the system with 3 state feedback, taken as a plant to be
controlled.
Page 62
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
When an integrator is added to a system and the loop closed, the steady state error
due to step inputs will reduce to zero. This increases the system type by 1. The
integral controller is used primarily to improve the steady state response of control
systems. This section explores the effects of using the integral controller to improve
the steady state response of the 3 state feedback system taken as a whole.
Taking the system with 3 state feedback as the plant to be controlled, the poles are
reproduced below:
-1.1547 + 5.8415i
-1.1547 - 5.8415i
-4.4259
With an integral gain of –8 which acts on the arm velocity, the closed loop poles are:
-1.2606 + 5.4840i
-1.2606 - 5.4840i
-1.9809 + 1.7837i
-1.9809 - 1.7837i
The system’s response is shown below:
Figure 7.3
By having the integral action on the arm velocity, the arm velocity should reduce to
zero theoretically. From the results above, we see that the arm position is fluctuating
Page 63
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
about zero. Even though the arm velocity cannot reduce to zero, as it should, the
mean of the arm velocity over a period of time can be said to be near zero. The
reason for this disparity is due to the prominent effect of the dead zone. When the
correcting error signal falls within the dead zone of the motor, it will not be able to
drive the motor and hence the error will increase until a level that is outside the dead
zone before the controller can take effective action.
Page 64
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
The gain values (K matrix) that correspond to the poles are as below which is similar
to the one use in the 3 state controller.
-8
250
25
With a proportional gain of 1000 (Kp = 1000) acting on the pendulum position. The
closed loop poles shifted from
-1.1547 + 5.8415I
-1.1547 - 5.8415I
-4.4259
to
-0.3241
-3.0794 +20.8685i
-3.0794 -20.8685i
Page 65
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
Figure 7.4
From figure 7.4 above, we can see that the driving input had increased. This verified
the proportional controller action, which acts like an amplifier to the input error
signal. From the figure, we can see that the system response is faster. The velocity is
about three or four times that of the 3 state feedback controller.
Page 66
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
7.5 3 State and 4 State Feedback Controller with Proportional and Integral
Control (Continuous Time)
The Proportional and Integral is basically a lag compensator. This controller can
improve the steady state characteristics. By properly designing the PI controller, it is
possible to make the transient response relatively small, but may cause the speed of
response to slow down. This is because the PI controller, being a low pass filter, will
attenuate the high frequency components of the signal.
-1.1547 - 5.8415I
-4.4259 for the 3 state feedback to
-2.0947 + 7.7369i
-2.0947 - 7.7369i
-2.2935
-9.6101e-018 With PI control action on pendulum position.
Figure 7.5
With PI action, the system performance compared to the 3 state feedback controller
is just slightly better. This is due to the additional parameters (P gain and I gain) that
made it difficult to fine tune.
Page 67
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
The incremental models used have included an extra state variable u(k-1).
Examination of this state variable reveals that it is effectively performing an integral
action over all the other state variables. Assuming that all the initial states of the state
variables are all zero, then the following can be written:
u (0 ) = 0
u (1) = − K 1 xi (1) + (1 − K 2 )u (0 )
= − K 1 xi (1)
u (2 ) = − K 1 xi (2 ) + (1 − K 2 )u (1)
= − K 1 xi (2 ) + (1 − K 2 )[− K 1 xi (1)]
= − K 1 xi (2 ) − K1 (1 − K 2 )xi (1)
u (3) = − K 1 xi (3) + (1 − K 2 )u (2 )
= − K 1 xi (3) + (1 − K 2 )[− K 1 xi (2 ) − K 1 (1 − K 2 )xi (1)]
= − K 1 xi (3) − K 1 (1 − K 2 )xi (2 ) − K 1 (1 − K 2 ) xi (1)
2
Observe that the controller output is performing an integral action, that is, summing
up all the previous state variables over a period of time. As such, we would expect
good steady state response from the controllers designed using this incremental
model.
Page 68
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
For the 4 state incremental model, the poles are located at:
z1 = 0.9295, z2 = 0.9871, z3 = 1, z4 = 1.0733
For the 5 state incremental model, the poles are located at:
z1 = 0.9295, z2 = 0.9871, z3 = 1, z4 = 1, z5 = 1.0733
Since all the controllability matrices have full rank, the pole placement technique can
then be used to design the state feedback controllers.
The closed loop poles for the 4 state (incremental model) feedback system are chosen
to be at:
0.9207 + 0.0539i
0.9207 - 0.0539i
0.9101
0.7633
The feedback controller’s gains (K4i) that correspond to the above poles are shown
below.
K4i = [-8 210 30 0.4]
Page 69
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
Figure 7.6
From Figure 7.6, we see that its response is much more superior compared to the 3
states feedback controller. The arm velocity, in this case, is very low. The pendulum
position is fluctuating very closely about zero. However, the motor driving command
is quite large.
The closed loop poles for the 5 state (incremental model) feedback system are chosen
to be at:
0.9728 + 0.0676i
0.9728 - 0.0676i
0.9747
0.8907
0.7156
The feedback controller’s gains (K4i) that correspond to the above poles are shown
below.
K5i = [-15 -10 200 30 0.4]
Page 70
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
Figure 7.7
From Figure 7.7, we can observe that among all the controllers, the 5 state feedback
controller gives the best response. The arm position can be constrained within a very
small region of approximately ±10 degrees while the pendulum is kept upright.
Page 71
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
The model used for implementation of the GPC controller is the 5 state incremental
model as stated in Section 7.6 above. In “State Space Predictive Control of Inverted
Pendulum” [2] by Yong Tet Leong, the author gave a comprehensive treatment of
the subject and a systematic way of tuning the controller. The controller designed for
this report has the following parameters:
Ny1 = 120, Ny3 = 10, Nu = 10, σ1 = 1, σ3 = 0, λ = 0.01
Figure 7.8
It can be seen that the GPC response is very similar to the 5 state feedback controller
response designed using pole placement technique. The GPC controller and the 5
state feedback controller are both based on the incremental model which has the
Page 72
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
effect of integrating all the state variables. This effectively reduces the steady state
errors even though the dead zone of the motor had shown to overwhelm other forms
of steady state compensation. Therefore we can conclude that using the 5 state
incremental model for design of controllers will give the best response among all the
controllers presented here.
Page 73
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
The swing-up controller can be fine tuned such that the pendulum is swung up to its
upright position in 2 motions, one swing in either direction to gain momentum, and
the second swing in the opposite direction to reach the upright position. This fine-
tuning is done by adjusting the amplitude of the driving signal. The amplitude where
the swing-up can be achieved in 2 motions will be referred to as the “critical
amplitude”.
Figure 7.9
We see that the pendulum is swung up with 2 clean motions, after which the
balancing controller took over control. Note that the glitch appearing at around the
30th to 40th sample of the pendulum position is caused by an instrumentation error.
The critical amplitude can be easily found for a particular set by the trial and error
approach. It should be noted that it will give consistently good results only if the
same initial conditions are met every time, that is, the pendulum’s starting position is
at the downward position and the velocity is zero. However, this initial condition will
not be met if the balancing controller was to fail and the swing-up controller was to
take over control. It would start off from some non-zero pendulum position and
velocity and subject to that, the swing-up may fail because the final velocity may be
too high for the balancing controller to catch on.
Page 74
EXPERIMENTAL RESULTS AND DISCUSSION FOR CONTROLLER DESIGN
The effects of dead zone mapping can only be observed if the controller driving
output signals are small. To demonstrate the effects, a 5 state feedback controller was
designed using the pole placement technique which will produce small driving
signals. The controller gains are:
K5i = [-2.7007 -2.8342 91.4134 12.7323 0.2548]
The controller response without dead zone mapping is shown in Figure 7.10 below.
Figure 7.10
The controller response with dead zone mapping is shown in Figure 7.11 below.
Figure 7.11
Comparing the above 2 responses, it can be seen that the arm position, as well as the
pendulum position, is regulated better with the dead zone mapping turned on. This
can only be said for controllers that produce small control signals which lie within
the dead zone. Otherwise, there are no noticeable effects
Page 75
GRAPHICAL USER INTERFACE
The operations for various processes are often interconnected and rather complicated
and tedious to perform. Even the operation of getting the pendulum running, various
shelling processes that to be done. This can prove to be repelling to the user, cause
not only does he need to waste precious time. He also needs to understand and
perform the messy, tedious and unfriendly operations. In process, careless mistaken
will also arise.
This is due to the fact that most of the pendulum control software e.g. ECM, LIB96
etc are Dos environment programs. While all the computation and calculation are
done in Matlab environment. Constant shelling between Dos, ECM, Windows and
Matlab environment has to be performed.
Frustration and confusion always hinder the user in many instances, as we have
experienced. Taking to retrieve data from the pendulum as an example, user will
have to shell out of Matlab, out to Windows and then into ECM (Dos) environment.
Then he will have to wait for the data to be downloaded, after that he will have to
toggle back to Windows and run Raw2mat (Dos) to convert the data into Matlab data
file. After this he will have to shellback to Matlab environment which is anchor in
Window environment. To do this, without the help of an integrated GUI, can prove
to be very repelling and error prone.
Page 76
GRAPHICAL USER INTERFACE
8.2 Objectives
Most engineering courses contain abstract concepts that are important for the
understanding of material especially in control study. The main objective for
implementing a GUI is make complicated and tedious operations transparent to the
user. The idea is to let the user have all the time and concentration to design and
implement their design.
In that aspect, the transparent operations of the GUI have been designed in such a
thought in mind. It must be user-friendly, captivating, easy to operated and aid user
understanding. Yet it must not limit the freedom of design and must also be
stimulating to the user. In this 98 version of the GUI, we have maximized Matlab ver
4.2 graphical ability to it’s fullest to create a beautiful front-end interface for the
user.
With an integrated GUI, the problem of data storage will also be solved at the same
time. As the number controllers and design increases, files and programs handling
will be more complicated. With a standard database system that comes with the GUI,
user will have no problems figuring out where are the files and program. It will also
allow different users to quickly carry on research and study on any computer system
that have been installed with this GUI interface.
Section 8.4 will serve as guide and an instruction set to operate the GUI.
Page 77
GRAPHICAL USER INTERFACE
8.3 Features
The GUI is built fully in Matlab environment. User with different knowledge in
control engineering has been considered while designing the GUI. The GUI is
designed to provide a common platform for both advance user and beginner user.
The whole interface will integrate all the operations and make it transparent to the
user. This enables the user to be fully concentrate in the learning process. The
program also divides the process into various modules, which allow user to perform
the desire process at any time he wants.
A common database system will inter-link each part of the process. This solve messy
file storage problem. Thus allowing data to be common in all part of the program.
A Pentium 200 system with 64MB of ram is recommended to run this program. This
is because the GUI Interface program is built will intensive graphical enhancement
and error checking.
Page 78
GRAPHICAL USER INTERFACE
Page 79
GRAPHICAL USER INTERFACE
Page 80
GRAPHICAL USER INTERFACE
Page 81
GRAPHICAL USER INTERFACE
Figure 8.7
Page 82
GRAPHICAL USER INTERFACE
Figure 8.8
Figure 8.9
Figure 8.10
Page 83
GRAPHICAL USER INTERFACE
Page 84
GRAPHICAL USER INTERFACE
The Mathematical Modeling Interface can only be access under the Beginner Interface
Option. This set of interface consists of 10 screen. Just like the System Setup Interface, it is
design to provide new user to this system to provide them with some basic background
knowledge of control theory using those that used here.
This set of interfacing screen wills describes the derivations of the mathematical model use
by the system. It will cover the whole mathematical derivation process. How we use the
Lagrange’s Equation of Motion of formulate the dynamic model. How we finally get the
incremental model for 5 state incremental controller and General Predictive controller.
Figure 8.12
Figure 8.13
Page 85
GRAPHICAL USER INTERFACE
Figure 8.14
Figure 8.15
Figure 8.16
Page 86
GRAPHICAL USER INTERFACE
8.4.8 Miscellaneous
This interface (figure 8.17) can be access both under the Beginner or Advance
Interface Option. This interface is design to find out (measure) two sets of parameters
of the system. The dead zone and swing-up reference parameters are important,
because they are need in balancing the system. (Refer to chapter 6.51 )
The user should access this interface from time to time or when the pendulum set is
change. This is because of the different pendulum have different characteristic due to
wear and tear.
Figure 8.17
Page 87
GRAPHICAL USER INTERFACE
This set of interfaces can be access both under the Beginner or Advance
Interface Option. But user may experience some differences when access this
interface from the different two option. This is due to the design of the system
catering for different user knowledge level in the system. This interface is
design to collect the data from the system and perform the estimation process
to complete the process of system modelling.
The objectives of this interface are to provide a platform for user to collected
data in an easy and hassle free matter. The interface is also equipped with
verification facility so that the user can check if the data collected are correct.
Beside that this interface will serve as a guide to the user to guide him along
step by step in the process of System Identification.
This set of interface is one of the most graphical intense of the whole GUI. It
pushes Matlab Ver4.2 graphical capability to it’s fullest especially in the
single parameter estimation Interface. Where the data have to be process,
display and graphically enhance while keeping track of the user control
changes.
Page 88
GRAPHICAL USER INTERFACE
Figure 8.18
Figure 8.19
Figure 8.20
Page 89
GRAPHICAL USER INTERFACE
Figure 8.23
Page 90
GRAPHICAL USER INTERFACE
Figure 8.24
Figure 8.25
Page 91
GRAPHICAL USER INTERFACE
Page 92
GRAPHICAL USER INTERFACE
Design of a test signal for System Identification is not only to let the user have some
variety and fun. The main objective is to make System Identification of the Modelling
Process more accurate and versatile.
Letting the user design a test signal, he can compare the system response and see the
different in the data obtain. Due to wear and tear due to prolong use, shafts and joints will
may exhibit different friction constant. Other factor such as dead zone of the motor etc
can be better map and thus data obtain will be more accurate.
Figure 8.30
Page 93
GRAPHICAL USER INTERFACE
Figure 8.31
Page 94
GRAPHICAL USER INTERFACE
The most interesting part of the program. This is the finale in the whole courseware.
The user will design a controller to balance the Pendulum System here. The
controller design will make use of the linear model estimated form the System
Identification Interface.
Using the model estimated in System Identification. The controller design will base
on that model to design the controller using Pole Placement Method (Refer to chapter
3). There are a total of 12 controllers implemented for the user to choose from.
Figure 8.34
Figure 8.35
Page 95
GRAPHICAL USER INTERFACE
Figure 8.36
Page 96
GRAPHICAL USER INTERFACE
Page 97
GRAPHICAL USER INTERFACE
8.4.11 Demonstration
Note : Maltlab only accept raw format graphic file type. You have to visit
http://:www.alchemy.com to convert your graphic file into 8 bit HIS raw format. Matlab
command like ‘imread’ will produce great image compare to reading in directly as
bmp or jpg format.
Page 98
CONCLUSION
Chapter 9 Conclusion
In conclusion, we have fulfilled all the objectives given to us. We have verified the
mathematical model of the inverted pendulum system and the control algorithms by
the previous FYP group [1].
With the mathematical model, we have implemented two methods of estimation thus
allowing the user to compare the results. We have estimated the system parameters
of the inverted pendulum system and verified our results.
We had designed thirteen types of controllers that can balance the pendulum and
comparisons between the different controllers were made. We have implemented the
controllers that were designed by the previous FYP group [1] and made
improvements on it. Further, we introduced and implemented a few digital
controllers of which the 5 state incremental model based controllers were shown to
have superior performance.
Page 99
RECOMMENDATIONS
Chapter 10 Recommendations
10.1 DC Motor
It was observed that a major limitation of this system is the low sensitivity of the
motor, caused by the motor’s dead zone. Because of this dead zone effect, the system
will be very inaccurate when the driving signal is low in amplitude, which is usually
the case when the pendulum is near its upright position. The dead zone mapping
function was implemented to try to compensate for it. This is a non-linear function
and as such, even if there are any effects, the system behavior could not be compared
against that of the linear controllers used. From the experimental results, we
observed that the dead zone mapping function would only produce noticeable
differences in performance when the controller used has a small gain, that is, if the
driving signals are small in amplitude.
Another aspect is related to safety. When the motor is driven to its maximum speed,
it is very powerful and it becomes a safety hazard. We noticed that for this system,
the mechanical parts are relatively light and not much power would be required for
proper control.
We recommend a change of motor to one that is high in precision and sensitivity, and
low in power. With such a motor, it would be more appropriate for this system in
terms of performance and safety.
The swing up controller used was not tested fully due to time constraints. Notice that
for the active regions where the control action is applied, there is no upper bound set
for the pendulum velocity. When the swing up controller was tuned to its critical
Page 100
RECOMMENDATIONS
amplitude such that the upright position can be reached in two motions, the initial
conditions must be satisfied for the controller to function properly.
The swing up controller can be improved by setting an upper bound for the
pendulum position in the active regions. This upper bound should be the velocity on
exit of Regions A and B such that the force of gravity will decelerate the pendulum
to zero velocity on reaching the upright position. This velocity may be found
analytically or through testing of the real system. However, since the equation
describing the motion of the pendulum is non-linear, and the system parameters are
not known exactly, it may be easier to adopt the second approach to determine this
quantity.
Once determined, Regions A and B can be easily programmed to account for the
upper bound such that there will not be any control action when the upper bound
velocity is reached. This effectively limits the velocity on exit of the active regions to
this maximum value, which will bring the pendulum to upright position at zero
velocity. This will improve the reliability of the swing up controller under all
possible initial conditions. The final active regions (shaded) are illustrated in Figure
10.1 below:
Figure 10.1
Page 101
RECOMMENDATIONS
Notice from (4.8) that if the parameter estimation is error free, then the following
relationship should hold:
φ1 φ5
=
φ2 φ6
From the experimental results, it was shown that this relationship does not exist most
of the time. We can then conclude that Method 2 of parameter estimation will
produce some estimation errors. The advantage of using Method 2 is that no prior
knowledge of any system parameters is required. The observation that it will produce
conflicting results prompted the search for a mathematically non-conflicting way of
estimation that does not require much knowledge of the system parameters. Below is
one such method of estimation which is a direct extension of Method 2.
Equations (4.6) and (4.7) are reproduced here for convenience of reference.
aα&& + bα&& sin 2 θ + cθ&&cosθ + dα& + bα&θ& sin 2θ − cθ& 2 sin θ − eu = 0 (4.6)
cα&& cosθ + fθ&& − 1 bα& 2 sin 2θ + C θ& + h sin θ = 0
2 1
(4.7)
Define:
a c e h
µ1 = µ3 = µ5 = µ7 =
f f f f
b d C
µ2 = µ4 = µ6 = 1
f f f
Page 102
RECOMMENDATIONS
Using the unforced oscillation response, µ3, µ6 and µ7 can be estimated by:
µ3
[ ] [(
θ&& = − θ&&cosθ − θ& 2 sin θ ) ]
θ sin θ µ 6
& (10.3)
µ 7
From these results, the rest of the parameters can be estimated by:
µ1
µ
[θ&& + µ (θ&&cosθ − θ&
3
2
) ] [ (α&&sin
sin θ + α&& cosθ + µ 6θ& + µ 7 sin θ = − α&& 2
θ + α&θ& sin 2θ − 12 α& 2 sin 2θ ) α& ]
−u
2
µ4 (10.4)
µ5
Preliminary results have shown that this method is very unreliable. More studies
could be conducted to investigate if this method is a good alternative for parameter
estimation.
The Simulink model is shown in Figure 4.4. An animation of the system has been
developed (‘sim_ani.m’). However, it had not been integrated with the final version
of the GUI due to time constraints. Improvements to the Simulink model can be
made by modelling the effects of the dead zone as well as the different controllers
used. The user can then simulate the response of the controllers and see how the
controllers would perform.
Page 103
REFERENCES
References
[1] S.H. Ang and M.B. Tan, Final Year Project 4029 Report, 1997.
[2] T.L. Yong, “State Space Predictive Control of Inverted Pendulum”, 1998.
[4] H.L. Langhaar, “Energy Methods in Applied Mechanics”, John Wiley and
Sons Inc, pp 233-249, 1962.
[9] S.C. Tan and K.V. Ling, “Parameters Identification of a Rotary Inverted
Pendulum”, 1998.
Page 104
APPENDIX A
Definition of Symbols
Page A-1
APPENDIX A
Co-ordinate System
m1
z
l1 β
α
L0
θ
y
Figure A1
Figure A1 above shows the co-ordinate system used for the derivation of the
dynamic model. The inverted pendulum system consists of two sections, namely the
arm and the pendulum bob section. The standard right-handed Cartesian co-ordinate
system is used. The angular position of the arm, α, is assigned to be increasing when
the arm is rotating about the z-axis in the right-handed sense (when the thumb points
in the direction of the axis, the fingers point in the direction of increasing angle). The
reference of α is taken to be the x-axis.
The angular position of the pendulum, β and θ, are assigned to be increasing when
the pendulum is rotating about an axis passing through the arm section from the
origin to the pivot point of the pendulum, in the right-handed sense. The reference of
β is taken from the upward vertical and the reference of θ is taken from the
downward vertical.
Page A-2
APPENDIX A
d ∂L ∂L
− = Qi
& i ∂Θ i
dt ∂Θ
L = T −V
The above is Lagrange’s equation of motion [4]. It will be used in the derivation of
the dynamic model.
DC Motor Characteristics
The DC motor used in the Rotary Inverted Pendulum System exerts a torque on the
system. The motor torque can be derived [5] as follows:
Ra La
+ + +
PWM
U Amplifier Vm Eb
Ku τ, α
- - Ia -
Figure A2
The terminal voltage, Vm, after amplification, is:
Vm = K u u
where Ku is the gain of the PWM amplifier.
Applying Kirchoff’s Voltage Law,
dI a
Vm = I a Ra + La + Eb
dt
where Ia is the armature coil current,
Ra is the armature coil resistance,
La is the armature coil inductance,
Eb is the motor’s back EMF.
Page A-3
APPENDIX A
The motor’s back EMF, Eb, is proportional to the rate of change of magnetic flux and
hence proportional to the angular velocity of the motor.
dα
Eb = K b
dt
= K bα&
For a constant field current, the torque exerted by the motor, τ, is proportional to the
armature current. Assuming that the effects of the coil inductance, La, are negligible,
the torque can be written as:
τ = Kt Ia
K t (Vm − Eb )
=
Ra
Kt Ku KK
τ= u − t b α& (A1)
Ra Ra
The dynamic model describes the system completely. It gives the exact relationships
among the variables involved. For the Rotary Inverted Pendulum System, the
dynamic model is highly non-linear. The dynamic model with the pendulum in the
upright position [3] can be derived as shown below.
Using the co-ordinate system shown in Figure A1, the kinetic energy of the arm, T0,
and the potential energy, Vo, can be written as:
T0 = 12 J 0α& 2
V0 = 0
The top view of the system is shown in Figure A3. For the pendulum section, the
L0cosα
following can be written: x
x&1 = − L0α& sin α + l1α& cosα sin β + l1 β& sin α cos β l1sinβ
Page A-4
APPENDIX A
(
x&12 = L20α& 2 sin 2 α + l1α& cosα sin β + l1 β& sin α cos β )
2
0 (
− 2 L α& sin α l α& cosα sin β + l β& sin α cos β
1 1 )
= L α& sin α + l α& cos α sin β + l12 β& 2 sin 2 α cos 2 β
2
0
2 2 2
1
2 2 2
+ 2l12α&β& sin α cosα sin β cos β − 2 L0l1α& 2 sin α cosα sin β − 2 L0l1α&β& sin 2 α cos β
(
y&12 = L20α& 2 cos 2 α + l1α& sin α sin β − l1 β& cosα cos β ) 2
0 (
+ 2 L α& cosα l α& sin α sin β − l β& cosα cos β
1 1 )
= L α& cos α + l α& sin α sin β + l12 β& 2 cos 2 α cos 2 β
2
0
2 2 2
1
2 2 2
− 2l12α&β& sin α cosα sin β cos β + 2 L0l1α& 2 sin α cosα sin β − 2 L0l1α&β& cos 2 α cos β
z&12 = l12 β& 2 sin 2 β
The squared magnitude of the velocity of the pendulum bob can be written as:
x&12 + y&12 + z&12 = L20α& 2 + l12α& 2 sin 2 β + l12 β& 2 cos 2 β − 2 L0 l1α&β& cos β + l12 β& 2 sin 2 β
= L2α& 2 + l 2α& 2 sin 2 β + l 2 β& 2 − 2 L l α&β& cos β
0 1 1 0 1
The kinetic energy of the pendulum bob, T1, and the potential energy, V1, can be
written as:
(
T1 = 12 J 1 β& 2 + 12 m1 x&12 + y&12 + z&12 )
= 12 J 1 β& 2 + 12 m1 L20α& 2 + 12 m1l12α& 2 sin 2 β + 12 m1l12 β& 2 − m1 L0 l1α&β& cos β
2 1 0 2 ( 1 1 1 )
= 1 m L2α& 2 + 1 J + m l 2 β& 2 + 1 m l 2α& 2 sin 2 β − m L l α&β& cos β
2 11 1 0 1
V1 = m1 gz1
= m1 gl1 cos β
The energy equation used in Lagrange’s Equation, L, can then be formulated as:
L0 = T0 − V0
L1 = T1 − V1
L = L0 + L1
= T0 + T1 − V0 − V1
( )
= 12 J 0α& 2 + 12 m1 L20α& 2 + 12 J 1 + m1l12 β& 2 + 12 m1l12α& 2 sin 2 β − m1 L0 l1α&β& cos β
− m1 gl1 cos β
= 1
2 (J 0 ) ( )
+ m1 L20 α& 2 + 12 J 1 + m1l12 β& 2 + 12 m1l12α& 2 sin 2 β − m1 L0l1α&β& cos β − m1 gl1 cos β
Page A-5
APPENDIX A
+ m1 L0 l1 β& 2 sin β
( )
= J 0 + m1 L20 α&& + m1l12α&& sin 2 β − m1 L0 l1 β&& cos β + m1l12α&β& sin 2 β
+ m1 L0 l1 β& 2 sin β
d ∂L ∂L
− = τα
dt ∂α& ∂α
(J 0 )
+ m1 L20 α&& + m1l12α&& sin 2 β − m1 L0 l1 β&& cos β + m1l12α&β& sin 2 β + m1 L0 l1 β& 2 sin β = τ α
The total torque acting on the axis of rotation in a direction that increases α is τα. It
comprises of the torque supplied by the motor and the counteracting frictional torque.
τ α = τ m − C 0α&
where τm is the torque exerted by the DC motor,
C0 is the viscous friction co-efficient of the axis of rotation of α.
(J )
+ m1 L20 α&& + m1l12α&& sin 2 β − m1 L0 l1 β&& cos β + m1l12α&β& sin 2 β + m1 L0l1 β& 2 sin β
0
= τ m − C 0α&
( )
J 0 + m1 L20 α&& + m1l12α&& sin 2 β − m1 L0 l1 β&& cos β + C0α& + m1l12α&β& sin 2 β
+ m L l β& 2 sin β = τ
1 0 1 m (A2)
( 1 0 )
J 0 + m L α&& + m l α&& sin β − m1 L0 l1 β&& cos β + C0α& + m1l12α&β& sin 2 β
2 2
11
2
(J 0 ) ( )
+ m1 L20 α&& + m1l12α&& sin 2 β − m1 L0 l1 β&& cos β + C 0 + KRt Ka b α& + m1l12α&β& sin 2 β
+ m1 L0 l1 β& 2 sin β − KRt Ka u u = 0 (A3)
∂L
= m1l12α& 2 sin β cos β + m1 L0 l1α&β& sin β + m1 gl1 sin β
∂β
= 1 m l 2α& 2 sin 2 β + m L l α&β& sin β + m gl sin β
2 1 1 1 0 1 1 1
∂L
&
( )
= J 1 + m1l12 β& − m1 L0 l1α& cos β
∂β
Page A-6
APPENDIX A
d ∂L
&
dt ∂β
( )
= J 1 + m1l12 β&& − m1 L0 l1α&& cos β + m1 L0 l1α&β& sin β
d ∂L ∂L
− =τβ
dt ∂β& ∂β
( )
J 1 + m1l12 β&& − m1 L0 l1α&& cos β + m1 L0 l1α&β& sin β − 12 m1l12α& 2 sin 2 β − m1 L0 l1α&β& sin β
− m1 gl1 sin β = τ β
( )
− m1 L0l1α&& cos β + J 1 + m1l12 β&& − 12 m1l12α& 2 sin 2 β − m1 gl1 sin β = τ β
The total torque acting on the axis of rotation in a direction that increases β is τβ. For
this axis, this torque comprises solely of the counteracting frictional torque.
τ β = −C1 β&
where C1 is the viscous friction co-efficient of the axis of rotation of β.
( )
− m1 L0l1α&& cos β + J 1 + m1l12 β&& − 12 m1l12α& 2 sin 2 β − m1 gl1 sin β = −C1 β&
1 0 1 ( 1 11 )
− m L l α&& cos β + J + m l 2 β&& − 1 m l 2α& 2 sin 2 β + C β& − m gl sin β = 0
2 11 1 1 1 (A4)
In matrix form, equations (A2) and (A4) can be written compactly as follows:
With the motor torque characteristics described by equation (A1), the dynamic model
in the upright position described by equations (A3) and (A4) can then be written as:
Page A-7
APPENDIX A
Define θ to be the angular position of the pendulum taken from the downward
vertical. The following relationship between terms involving β and θ can be
established:
β =θ −π cos β = cos(θ − π ) sin β = sin (θ − π ) sin 2 β = sin 2(θ − π )
β& = θ& = − cosθ = − sin θ = sin (2θ − 2π )
β&& = θ&& = sin 2θ
(J 0 )
+ m1 L20 α&& + m1l12α&&(− sin θ ) − m1 L0 l1θ&&(− cosθ ) + C0α& + m1l12α&θ& sin 2θ
2
+ m L l θ& 2 (− sin θ ) = τ
1 0 1 m
(J 0 1 0 )
+ m L α&& + m l α&& sin θ + m1 L0 l1θ&&cosθ + C 0α& + m l α&θ& sin 2θ
2 2
1 1
2 2
1 1
− m L l θ& 2 sin θ = τ
1 0 1 m (A7)
( )
− m1 L0l1α&&(− cosθ ) + J 1 + m1l12 θ&& − 12 m1l12α& 2 sin 2θ + C1θ& − m1 gl1 (− sin θ ) = 0
1 0 1 ( 1 11 )
m L l α&& cosθ + J + m l 2 θ&& − 1 m l 2α& 2 sin 2θ + C θ& + m gl sin θ = 0
2 11 1 1 1
(A9)
In matrix form, equations (A7) and (A9) can be written compactly as follows:
Page A-8
APPENDIX A
With the motor torque characteristics described by equation (A1), the dynamic model
in the downward position described by equations (A8) and (A9) can then be written
as:
J 0 + m1 L20 + m1l12 sin 2 θ m1 L0l1 cosθ α&&
+
m1 L0l1 cosθ J 1 + m1l12 θ&&
C 0 + KRt Kb + 12 m1l12θ& sin 2θ − m1 L0l1θ& sin θ + 12 m1l12α& sin 2θ α&
a
& +
− 2 m1l12α& sin 2θ θ
1
C1
0 KRt Ka u
m gl sin θ = u (A11)
1 1 0
Page A-9
APPENDIX B
The linear approximation method [6] is based on the expansion of the non-linear
function into a Taylor series about the operating point and the retention of only the
linear terms. For n variables, x1, x2, …, xn, it can be briefly stated as:
y = f (x1 , x 2 ,..., xn )
y = f (x1 , x2 ,..., x n )
∂f ∂f ∂f
y − y ≈ (x1 − x1 ) x1 = x1 + ( x2 − x2 ) x1 = x1 + ... + (x n − xn ) x1 = x1
∂x1 x2 = x2 ∂x 2 x2 = x2 ∂x n x2 = x2
... ... ...
xn = xn xn = xn xn = xn
= f (0,0,0 )
∂f ∂f
= = C0 + KRt Ka b + m1l12 β& sin 2 β
∂x1 ∂α&
∂f
α& = 0 = C 0 + KRt Ka b
∂α& β =0
β& = 0
∂f ∂f
= = 2m1l12α&& sin β cos β + m1 L0l1 β&& sin β + 2m1l12α&β& cos 2 β + m1 L0 l1 β& 2 cos β
∂x 2 ∂β
Page B-1
APPENDIX B
∂f
α& = 0 =0
∂β β =0
β& = 0
∂f ∂f
= & = m1l12α& sin 2 β + 2m1 L0 l1 β& sin β
∂x3 ∂β
∂f
α& = 0 =0
∂β& β =0
β& = 0
y − y ≈ (α& − 0 )
∂f
∂α&
α& = 0 + (β − 0 )
∂f
∂β
(
∂f
+ β& − 0 &
α& = 0
∂β
) α& = 0
β =0 β =0 β =0
β& = 0 β& = 0 β& = 0
y ≈ y + (α& − 0)
∂f
∂α&
α& =0 + (β − 0 )
∂f
∂β
α& = 0 ( ∂f
+ β& − 0 &
∂β
) α& =0
β =0 β =0 β =0
β& = 0 β& = 0 β& =0
( )
= J 0 + m1 L20 α&& − m1 L0 l1 β&& − KRt Ka u u + C 0 + KRt Ka b α& ( )
Therefore, linearising equation (A3) yields:
(J 0 ) ( )
+ m1 L20 α&& − m1 L0 l1 β&& + C0 + KRt Ka b α& − KRt Ka u u = 0 (B1)
∂f ∂f
= = m1 L0 l1α&& sin β − m1l12α& 2 cos 2 β − m1 gl1 cos β
∂x 2 ∂β
∂f
α& = 0 = − m1 gl1
∂β β =0
β& = 0
∂f ∂f
= = C1
∂x3 ∂β&
Page B-2
APPENDIX B
∂f
α& = 0 = C1
∂β& β =0
β& = 0
y − y ≈ (α& − 0 )
∂f
∂α&
α& = 0 + (β − 0 )
∂f
∂β
α& = 0 (
+ β& − 0
∂f
∂β&
) α& = 0
β =0 β =0 β =0
β& = 0 β& = 0 β& = 0
y ≈ y + (α& − 0)
∂f
∂α&
α& =0 + (β − 0 )
∂f
∂β
(
+ β& − 0
α& = 0
∂f
∂β&
) α& =0
β =0 β =0 β =0
β& = 0 β& = 0 β& =0
( )
= −m1 L0 l1α&& + J 1 + m1l12 β&& − m1 gl1 β + C1 β&
In matrix form [3], equations (B1) and (B2) can be written as:
J 0 + m1 L20 − m1 L0l1 α&& C0 + KRt Ka b 0 α& 0 0 α KRt K u
+ +
& β =
a
u (B3)
− m1 L0l1 J 1 + m1l12 β&& 0 β
C1 0 − m1 1
gl 0
Define:
The linearised equations, (B1) and (B2) can then be written as:
aα&& − cβ&& + dα& − eu = 0 (B1a)
β&& =
af − c 2
1
(− cdα& − aC β& + ahβ + ceu ) 1 (B4)
(B1a) × f, (B2a) × c,
afα&& − cfβ&& + dfα& − efu = 0 (B1c)
− c 2α&& + cfβ&& + cC1 β& − chβ = 0 (B2c)
Page B-3
APPENDIX B
(B1c) + (B2c),
α&& =
1
af − c 2
(− dfα& − cC β& + chβ + efu )
1
(B5)
To formulate the 3 states linear model, we define the state variables to be:
α&
x3 = β
β&
From equations (B4) and (B5), the 3 states linear model can then be written as:
x&3 = A 3 x3 + B 3u
α&& − df ch − cC1 α& ef
β& = 1 0 2
0 af − c β +
1
0 u (B6)
af − c 2 af − c 2
&& ah − aC1 β&
β − cd ce
To formulate the 4 states linear model, we define the state variables to be:
α
α&
x4 =
β
&
β
The 4 states linear model can then be written as:
x& 4 = A 4 x4 + B 4 u
α& 0 af − c 2 0 0 α 0
α&& &
= 1 0 − df ch − cC1 α 1 ef
+ u (B7)
β& af − c 2 0 0 0 af − c 2 β af − c 2 0
&&
β 0 − cd ah − aC1 β& ce
Page B-4
APPENDIX B
( )( )
af − c 2 = J 0 + m1 L20 J 1 + m1l12 − (m1 L0 l1 )
2
Define:
d C 0 + Ra
Kt Kb
b m1l12 b m1l12 C1 C1
φ1 = = φ3 = = φ5 = = φ7 = =
a J 0 + m1 L20 a J 0 + m1 L20 f J 1 + m1l12 f J 1 + m1l12
Kt Ku
c m1 L0 l1 e c mLl h m1 gl1
φ2 = = φ4 = = φ6 = = 1 0 12 φ8 = =
Ra
c 2 af − c 2
1 − φ 2φ 6 = 1 −=
af af
− df − df af ch ch af − cC1 − cC1 af
= × = × = ×
af − c 2
af af − c 2 af − c 2
af af − c 2
af − c 2
af af − c 2
−d af c h af − c C1 af
= × = × × = × ×
a af − c 2 a f af − c 2
a f af − c 2
− φ3 φ 2φ 8 − φ 2φ 7
= = =
1 − φ 2φ 6 1 − φ 2φ 6 1 − φ 2φ 6
− cd − cd af ah ah af − aC1 − aC1 af
= × = × = ×
af − c 2
af af − c 2 af − c 2
af af − c 2 af − c 2
af af − c 2
−c d af h af − C1 af
= × × = × = ×
f a af − c 2 f af − c 2 f af − c 2
− φ 3φ 6 φ8 − φ7
= = =
1 − φ 2φ 6 1 − φ 2φ 6 1 − φ 2φ 6
Page B-5
APPENDIX B
Page B-6
APPENDIX C
The discrete time model [2] of the system is required when using digital control
techniques. When a system described by state space equations,
x& = Ax + Bu
y = Cx
is discretized with respect to a sampling interval Ts, the corresponding discrete state
space model is obtained:
x(k + 1) = A d x(k ) + Bd u (k )
y (k ) = C d x (k )
(C1)
Ad = e , B d = ∫ e Aγ Bdγ , C d = C
ATs
Incremental Model
The incremental model [2] is an alternative form of representation and will be used
in the design and implementation of the Generalised Predictive Controller.
x(k + 1) = A d x(k ) + B d [u (k − 1) + ∆u (k )]
= A d x(k ) + B d u (k − 1) + B d ∆u (k )
x (k )
xi (k ) =
u (k − 1)
The incremental model can be written as:
x(k + 1) A d B d x (k ) B d
u (k ) = 0 + ∆u (k )
1 u (k − 1) 1
(C2)
x(k )
y (k ) = [C d 0]
u (k − 1)
Page C-1
APPENDIX C
xi (k + 1) = A di xi (k ) + B di ∆u (k )
y (k ) = C di xi (k )
(C3)
where
A Bd B
A di = d , B di = d , C di = [C d 0]
0 1 1
Page C-2
APPENDIX D
Predictive control [2] belongs to the class of model-based controller design concepts.
That is, a model of the process is explicitly used to design the controller. The concept
of predictive control for a single-input, single-output digital system where the
sampling period is Ts, can be illustrated by Figure D1.
N2 N2
(a) (b)
w w
y^ y^
samples samples
k k+N2 k k+N2
k-1 k+1 k-1 k+1
From Previous
(c) (d) Prediction Result
u
u
From Present
Prediction Result
k samples k samples
past k-1 k+1 future past k-1 k+1 future
t time t time
t-Ts t+Ts t-Ts t+Ts
Figure D1
In Figure D1, the time scales in parts (a), (b), (c) and (d) are time scales relative to
the sample k, which denotes the present. The time scales with axes labelled as “time”
are absolute time scales. First, consider Figure D1 (a) and (c), and suppose that the
current time is denoted by sample k which corresponds to the absolute time t.
Further, u(k), y(k) and w(k) represents the controller output, the process output, and
the desired output at sample k respectively. Now, define:
u = [u (k ), u (k + 1), L, u (k + N 2 − 1)]
T
yˆ = [ yˆ (k + 1), yˆ (k + 2 ), L, yˆ (k + N 2 )]
T
where N2 is the prediction horizon and the symbol ^ denotes prediction. Then, a
predictive controller calculates a future controller output sequence u so as to make
the predicted output of the process ŷ close to the desired process output w. The
Page D-1
APPENDIX D
process output is predicted using a model of the process that describes the
relationship between the input and the output of the process. The controller output
sequence u is shown in Figure D1 (c). Desired process output w, together with
predicted output ŷ is shown in Figure D1 (a). This desired process output is often
called the set point or reference trajectory and it can be an arbitrary sequence of
points.
Rather than using the controller output sequence determined in the above way to
control the process in the next N2 samples, only the first element of this controller
output sequence (that is, u(k)) is used to control the process. At the next sample, the
whole procedure is repeated using the latest measured information. This is called the
receding horizon principle and is illustrated by Figure D1 (b) and (d), which show
what happens at time t+Ts.
Again, a future controller output sequence is calculated such that the predicted
process output is close to the reference trajectory. In general, this controller output
sequence will be different from the one obtained at the previous sample, as is
illustrated by Figure D1 (d). The reason for using the receding horizon approach is
that this provides compensation for future disturbances or modelling errors. For
example, due to a disturbance or modelling error, the predicted process output
yˆ (k + 1) predicted at time t is not equal to the process output y(k) measured at t+Ts.
Then, it is intuitively clear that at time t+Ts, it is better to start the predictions from
the measured process output rather than from the process output predicted at the
previous sample. The predicted process output is now corrected for disturbances and
modelling errors. A feedback mechanism is thus activated. As a result of the receding
horizon approach, the horizon over which the process output is predicted shifts one
sample into the future at every sample instant.
Page D-2
APPENDIX E
The Generalised Predictive Control (GPC) law [2] can be derived by minimising a
criterion function. Generally, the controlled variables can be any linear combinations
of the state variables. For the inverted pendulum system, we define the controlled
variables to be the pendulum position and the arm position to simplify the problem.
The criterion function must be such that it is at a minimum when the controlled
variables follow the reference trajectory exactly. The criterion function used for this
system is:
Ny1 Ny3
J c = σ 1 ∑ [w1 (k + n ) − α (k + n )] + σ 3 ∑ [w3 (k + m ) − β (k + m )] +
2 2
n =1 m =1
Nu
λ ∑ [∆u (k + j − 1)]2 (E1)
j =1
where
Jc is the criterion function to be minimised at sample k,
Ny1 is the prediction horizon for the arm position,
Ny3 is the prediction horizon for the pendulum position,
Nu is the control horizon,
σ1 is the arm position weight,
σ3 is the pendulum position weight,
λ is the incremental control command weight,
α is the arm position,
β is the pendulum position,
∆u is the incremental control command,
w1 is the reference for the arm position,
w3 is the reference for the pendulum position,
k is the sample index.
subject to
∆u (k + j − 1) = 0 ∀j > Nu
Page E-1
APPENDIX E
The parameters Ny1 and Ny3 are known as the prediction horizon for the arm and
pendulum position respectively. They are defined as the intervals over which the
tracking errors are to be minimised. w1 is the reference for the arm-position and w3 is
the reference for the pendulum position. The control horizon Nu defines the degrees
of freedom available for the minimisation. The incremental control command weight
λ can be used to penalise excessive control activity.
α (k )
α& (k )
xi (k ) = β (k )
&
β (k )
u (k − 1)
α (k )
α& (k )
1 0 0 0 0
y (k ) = β (k )
0 0 1 0 0 β& (k )
u (k − 1)
c
= 1 xi (k )
c 3
Page E-2
APPENDIX E
where
c1 = [1 0 0 0 0]
c 3 = [0 0 1 0 0]
To derive the controller, we first write a set of prediction equations for the plant
output. For the arm position, we have:
α (k + 1) = c1 xi (k + 1)
= c1 [A di xi (k ) + B di ∆u (k )]
= c1A di xi (k ) + c1B di ∆u (k )
α (k + 2 ) = c1 xi (k + 2 )
= c1 [A di xi (k + 1) + B di ∆u (k + 1)]
= c1A di xi (k + 1) + c1B di ∆u (k + 1)
= c1A di [A di xi (k ) + B di ∆u (k )] + c1B di ∆u (k + 1)
= c1A di2 xi (k ) + c1A di B di ∆u (k ) + c1B di ∆u (k + 1)
α (k + 3) = c1 xi (k + 3)
= c1 [A di xi (k + 2 ) + B di ∆u (k + 2 )]
= c1A di xi (k + 2 ) + c1B di ∆u (k + 2 )
[ ]
= c1A di A 2di xi (k ) + A di B di ∆u (k ) + B di ∆u (k + 1) + c1B di ∆u (k + 2 )
= c1A 3di xi (k ) + c1A 2di B di ∆u (k ) + c1A di B di ∆u (k + 1) + c1B di ∆u (k + 2 )
M
α (k + Ny1) = c1A diNy1 xi (k ) + c1A diNy1-1B di ∆u (k ) + c1A diNy1-2 B di ∆u (k + 1) + L
+ c1A 2di B di ∆u (k + Ny1 − 3) + c1A di B di ∆u (k + Ny1 − 2 ) + c1 B di ∆u (k + Ny1 − 1)
Page E-3
APPENDIX E
α (k + 1) c1A di ∆u (k )
α (k + 2 ) c A2 ∆u (k + 1)
1 di
Y1 = M Φ 1 = M ∆U = M
Ny1-1
α (k + Ny1 − 1) c1A di ∆u (k + Nu − 2 )
α (k + Ny1) c1A diNy1 ∆u (k + Nu − 1)
c1B di L
cA B c1B di L
1 di di
G1 = M M M M M
Ny1-2 Ny1-3 Ny1- Nu Ny1- Nu -1
c1A di B di c1A di B di L c1A di B di c1A di B di
c1A diNy1-1B di c1 A diNy1-2 B di L c1 A diNy1- Nu +1 B di c1A diNy1-Nu B di
Y1 = Φ1 xi (k ) + G1 ∆U
Thus, for the arm position,
Y3 = Φ 3 xi (k ) + G3 ∆U (E3)
Define
Page E-4
APPENDIX E
Substitute (E2), (E3) and (E4) into the criterion function (E1),
2 2 2
J c = σ 1 W1 − Y1 + σ 3 W3 − Y3 + λ ∆U
= σ 1 W1 − Φ 1 xi − G1 ∆U + σ 3 W3 − Φ 3 xi − G3 ∆U + λ ∆U
2 2 2
Let
W1 = W1 − Φ1 xi W3 = W3 − Φ 3 xi
Then
2 2
J c = σ 1 W1 − G1∆U + σ 3 W3 − G3 ∆U + λ ∆U
2
[
= σ 1 W1 W1 − W1 G1∆U − ∆U T G1 W1 + ∆U T G1 G1∆U
T T T T
]
[
+ σ 3 W3 W3 − W3 G3 ∆U − ∆U T G3 W3 + ∆U T G3 G3 ∆U + λ∆U T ∆U
T T T T
]
Minimising of Jc with respect to ∆U,
dJ c
=0
d∆U
[(
σ 1 − W1 G1) − G W + G G ∆U + (∆U G G ) ]
T T T T T T T
σ [− G W − G W + G G ∆U + G G ∆U ]
T T T T
1 1 1 1 1 1 1 1 1
+ σ [− G W − G W + G G ∆U + G G ∆U ]+ λ∆U + λ∆U = 0
T T T T
3 3 3 3 3 3 3 3 3
σ [− 2G W + 2G G ∆U ]+ σ [− 2G W + 2G G ∆U ]+ 2λ∆U = 0
T T T T
1 1 1 1 1 3 3 3 3 3
(σ G
1 1
T
G1 + σ 3G3 G3 + λI ∆U = σ 1G1 W1 + σ 3G3 W3
T
) T T
(
∆U = σ 1G1 G1 + σ 3G3 G3 + λI
T T
) −1
[σ G T
W1 + σ 3G3 W3
T
]
= (σ G + λI ) [σ G (W1 − Φ1 xi ) + σ 3G3 T (W3 − Φ 3 xi )]
1 1
−1
G1 + σ 3G3 G3
T T T
= (σ G + λI ) [σ G ]
1 1 1 1
−1
G1 + σ 3G3 G3 W1 − σ 1G1 Φ1 xi + σ 3G3 W3 − σ 3G3 Φ 3 xi
T T T T T T
= (σ G + λI ) [σ G W −σ G Φ x −σ G Φ x ]
1 1 1 1
−1
G1 + σ 3G3 G3 W1 + σ 3G3
T T T T T T
= (σ G + λI ) [σ G W − (σ G Φ + σ G Φ )x ]
1 1 1 1 3 1 1 1 i 3 3 3 i
−1
G1 + σ 3G3 G3 W1 + σ 3G3
T T T T T T
1 1 1 1 3 1 1 1 3 3 3 i
Page E-5
APPENDIX E
Using the receding horizon strategy, at each control-updating instant, only the first
element of the control vector in the above equation is applied to the plant. The
control calculation is then repeated at the next control-updating instant. For constant
reference vectors W1 and W3, the controller is given by:
u (k ) = u (k − 1) + ∆u (k )
∆u (k ) = [1 0 L 0]∆U
= k1w1 (k ) + k 3 w3 (k ) + K 2 xi (k )
u (k ) = u (k − 1) + k1w1 (k ) + k3 w3 (k ) + K 2 xi (k )
where
1
( −1 T 1
k1 = [1 0 L 0] σ 1G1 G1 + σ 3 G3 G3 + λI σ 1G1
T T
M
)
1
1
( −1
k 3 = [1 0 L 0] σ 1G1 G1 + σ 3 G3 G3 + λI σ 3G3
T T
)
T 1
M
1
(
K 2 = −[1 0 L 0] σ 1G1 G1 + σ 3 G3 G3 + λI
T T
) (σ G
−1
1 1
T
Φ1 + σ 3G3 Φ 3
T
)
Page E-6
APPENDIX F
The parameters in the dynamic model need to be determined before the model can be
used. These parameters can be broadly classified into 2 categories, the
“determinable” and the “undeterminable”. By “determinable”, we refer to those
quantities that can be determined from some reliable sources or through performing
some simple experiments. The determinable quantities are presented in Table F1
below, after which the method of estimation of these quantities will follow.
Quantity Units System I System II Source
m1 kg 0.0319 Measured and Estimated
l1 m 0.1572 Measured and Estimated
L0 m 0.1370 Measured
g m/s2 9.8100 Universal Constant
Ku V/count 0.0523 0.0636 Experiment
Kt N-m/A 0.1144 0.0706 Specifications
Kb V-s/rad 0.1146 0.0707 Specifications
Ra Ω 2.3 0.9 Specifications
Table F1
The physical dimensions of the pendulum section are illustrated in Figure F1 below.
270mm
The mass of the pendulum rod and pendulum bob are measured and tabulated below.
Description Units Value
Mass of pendulum rod g 24.5
Mass of pendulum bob g 8.9
Table F2
Page F-1
APPENDIX F
Figure F2 below shows the effective mass m1 acting at effective length l1 about the
pivot point.
lbob
l1 lrod
m1 mrod mbob
Figure F2
Assuming that the mass is equally distributed along the pendulum rod,
270 − 17
mrod = × 24.5g
270
= 22.9574g
Ignoring the effects of the mass at the smaller end of the pendulum section,
m1 = mrod + mbob
= 22.9574g + 8.9g
= 31.8574g
= 0.0319kg
l1 =
1
(mrod l rod + mbob lbob )
m1
1 270mm − 17 mm 25mm
= 22.9574g × + 8.9g × 224mm +
31.8574g 2 2
= 157.2307mm
= 0.1572m
Page F-2
APPENDIX F
The motor characteristics can be found from the specifications. These are tabulated
below.
Quantity Units System I System II
Kt Oz-In/A 16.2 10
N-m/A 0.1144 0.0706
Kb V/Krpm 12 7.4
V-s/rad 0.1146 0.0707
Ra Ω 2.3 0.9
Table F4
Note: 1 Ounce Force (Oz) = 0.2780139 Newton (N)
Page F-3
APPENDIX G
Directory Allocation
The courseware directory structure is as below. The program operating directory will be
Run. The directory consist of twelve subdirectories which are
Page G-1
APPENDIX G
M-Files Description
This section will provide a description for the m-files used and created for the
courseware.
Page G-2
APPENDIX G
Page G-3
APPENDIX G
Collect2 Sid For ‘View raw data’ button. Process collected data, tracking
system processes and display for System ID Parameter
Estimation.
Collect3 Sid For ‘View filtered data’ button. Filter collected data, tracking
system processes and display for System ID Parameter
Estimation.
Collect4 Sid For ‘View estimated data’ button. Estimate collected data, ,
tracking system processes and display for System ID Parameter
Estimation.
Collect5 Sid For ‘Estimate’ button. Estimate collected data, , tracking system
processes and display for System ID with comparison with
simulated using our model.
Collect6 Sid For ‘View Results’ button. Display linear model, poles for
System ID and tracking system processes for Parameter
Estimation.
Display Sid Plot Test wave for System ID Test Signal.
Idm Sid Combine what Collect1 to Collect6 does.
Phyp Sid Show parameters that is use by Methods 1 of System ID.
Phyp1 Sid Allow use to change the parameters and save them. (Link with
Phyp)
Result Sid Display linear model, poles for System ID Parameter Estimation
(Single).
Result1 Sid Display linear model, poles for System ID Parameter Estimation
(Multiple).
Sid Sid System ID introduction screen (access from Beginner Interface
option)
Sid1 Sid Test Signal Interface main option screen.
Sid2 Sid Test Signal Interface (Modify Standard Waveform)
Sid3 Sid Test Signal Interface (Design test waveform)
Sidin Sid System ID introduction screen (access from Advance Interface
option)
Sidintro Sid System ID introduction screen (access from Advance Interface
option)
Sidm Sid System ID main screen (Single Parameter Estimation)
Sidvar1 Sid Load default test signal.
Sms Sid System ID main screen (Multi Parameter Estimation)
Page G-4
APPENDIX G
Page G-5
APPENDIX G
Get_fit M-files Function for obtaining the "fit curves" for dda, ddb, & da.
Get_raw M-files Function for reading the raw data, where filename is specified by
input argument x.
Get_upr M-files Function for performing experiment to determine reference
value for pendulum in upright position.
Getpara M-files Function for obtaining system parameters as specified by
method in System ID.
Read_dat M-files Function for reading and return in vector A the data in file
specified by pathname 'x'.
Read_dz M-files Function for reading in dead zone data from 'data/dz.sdt'.
Read_p M-files Function for reading in physical data from 'data/physical.sdt'.
Read_s M-files Function for reading in system data from 'data/system.sdt'.
Refval M-files File for storing system parameters.
Sig_ch M-files Function for displaying the signal characteristics using N point
FFT.
Sim_exp M-files Simulink function for estimating results.
Startexp M-files Function for running the command in 'source' directory.
View_dat M-files Function for plotting the signal from index x to index y.
View_dat2 M-files Function for plotting two signals, A and B on the same graph
from index x to index y.
Write_h M-files Function for saving gain to H file
Write_h1 M-files Function for control option to H file
Write_p M-files Function for generating the physical data file, 'data\physical.sdt'.
Write_s M-files Function for generating the system data file, 'data\system.sdt'.
Write_t M-files Function for generating the header file 'source\sys_id\input.h'
Page G-6
APPENDIX G
Page G-7
Results of Estimation Using Method 1