Robust Computer Control An Inverted Pendulum: Medrano-Cerda
Robust Computer Control An Inverted Pendulum: Medrano-Cerda
Inverted Pendulum
G.A. Medrano-Cerda
' ,
wherex=[r 8 i 61, y = [ r 0 - a i], x(t) = CxXe(t), (5c)
0 where X' = [v,, x' V),,~I',vin is the input filter state, vOUt is the
'
A=l 0 0 0
B,=
0 2.805 -5.2563 0 ' 3.7545
10 18548 -7.7283 01 55200
Ba=[ 0 ],BT=l
"' = [-0:678l'
-03862
c=o
[
1 0 0 0
1 0 0
0 0 1 0
[
D, = :l].
(3c)
The model (3a) shows how the disturbances interact with the sys-
tem dynamics. Eq. (3b) also shows that the angle sensor reading
is directly affected by the rail inclination (this sensor is mounted
on the cart and calibrated to read zero when the rail is horizontal).
Since BF, = -B, I a, this model also suggests that when Fs is
known, a simple control law of the form
(4)
June 1999 59
~ ~~
ai" is a scalar, aoutis a 3x3 diagonal matrix, I3 and 14 denote 3x3 Table 1. Parameter definitions and values.
and 4x4 identity matrixes, respectively. For this model a com-
MC 2.3900 Kg Cart mass including motor intertia and
pensation scheme similar to (4) will not cancel the Coulomb fric-
tion term, even when Fs is known. pulley-belt drive
(6c)
Fs N Coulomb friction coefficient
For this model a compensation scheme similar to (7) will be less where x"(k)' = [x(k)' w(k)], R is a positive scalar and Q is a pos-
effective in cancelling the term N'(i(k);k) even when Fs is itive semi-definite matrix. The optimal state feedback takes the
known and no cart velocity reversals occur. form [ l ]
0.15 0.03
0.1 0.02
rad
m 0.05 0.01
0 0
-0.05 -0.01
4.’ -0.02
1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
Seconds Seconds
Cart Velocitv: State Feedback Simulation Pendulum Anaular Velocitv: State Feedback Simulation
0.4 0.6
0.3 0.5
0.4
0.2
0.3
d.
S 0.1
radls 0.2
0
0.1
4.1 0
-0.2 -0.1
Seconds Seconds
Volts 3
-1
0 1 2 3 4 5 6 7 8 9 10
Seconds
June 1999 61
u(k) = -[F, F,]xa(k)
, ,
[F, ,P(Da,
F,]=(R+r," ,PrUa)-'rua (10)
where Pis the unique positive definite solution of the discrete al- we obtain from the block diagram in Fig. 2
gebraic Riccati equation
I , I ,
P = aapaa- aaprua(R+ r; Pr;)-'r; paa+ Q.
U(Z)= -11 + K(z)G,,(z)l-'K(z>[G,,(z)a(z)+ GxT(z)7(z)1.
The selection of Q and R affect both the performance and the
(14)
relative stability of the closed loop system [ 11. For simplicity Q is Disturbance transmission characteristics are therefore quanti-
chosen to be a diagonal matrix. The following specifications are fied via magnitude Bode diagrams of the entries in the correspond-
used to obtain a suitable feedback matrix. The transfer from the ing transfer function matrixes (13)-(14). The relative stability of
equilibrium state ~'(0)'= [0.17 0 0 0 01 (i.e., pendulum bal- the closed loop system can also be evaluated in terms of the
anced but cart is at one end of the rail) to the zero equilibrium Nyquist plot of the return difference at the plant input,
state should satisfy: (l+K(z)Gxu(z)),or equivalently using the Nyquist diagram of the
loop gain at the plant input, K(z)Gxu(z).Note that here we have
Irl I 0 . 2 m , 101 I O.OSrad, li-(I 0 5 m / s , used the return difference at the plant input, however the same re-
I
101I Irad/s, Iu 5 6volt. sults can be obtained using the return difference at the plant output
since (l+K(z)Gxu(z)) = det(I+G,,(z)K(z)). The final state feed-
back that has been chosen is a compromise between speed of re-
Occasionally the limits on the control signal U may be exceeded sponse and good relative stabilityproperties. The actual values are
during short time intervals. In this formulation the controller will
bring the pendulum-cart system to the zero equilibrium state. Q = diag([10 2000 2 25 0.001]), R = 01,
Note however that by replacing r(k) by (r(k)-ref) in (9)-(10) the
controller would drive the system to the equilibrium state [F, F,]=[-35.8128 174.7939 - 353298 321409 - 0.0885].
[ref 0 0 0 O r (here ref denotes a constant setpoint specifying
the desired cart position). (15)
The relative stability properties of the closed loop system and These values for Q and R have been obtained after extensive
disturbance transmission characteristics can be quantified via trials. Simulation results for this feedback are shown in Fig. 3. In
frequency response diagrams. Combining (9)-( 10) and taking particular the large overshoot in the cart's position indicates that
Z-transforms we have the transfer of the cart from one extreme of the rail to the opposite
end would violate the rail's physical limits (k0.25 m). In such a
U(Z)= -K(z)x(z) (11) case the cart position setpoint can be smoothed by a suitable unity
gain low pass digital filter. Alternatively,the overshoot could also
be reduced by adjusting the state weights (for example, by mod-
K(z) = F, + F,[1 0 0 O](z -l)-'. (12) estly increasing the cart position weight Ql1 and decreasing the in-
tegrator weight Q55). We point out that increasing Ql1 produces
Defining larger angles and velocities during the transient while decreasing
2, I
Fig. 4. Loop gain Nyquist plots: ( a ) Overall Nyquist (not scaled), (b) Nyquist in the neighbourhood of the critical point (-1,O).
-20 -
Db
\
120- /
140- , /
Controller
Filters
June 1999 63
State Feedback
L,C + L,T = I
there are cases when this might fail. Examples can be found where IE and ID denote identity matrixes of sizes consistent with
within the class of unstable systems that are not strongly stabil- E and @, respectively.
izable [19], [8], [14], i.e., systems that can only be stabilized by To guarantee the existence of the inverse in (20) we only need
unstable controllers. to set t/l different from zero, for simplicity we take t4 = 1. Also,
The disturbance transmission properties for the observer since the observer is to estimate the pendulum angular velocity,
based controller are evaluated from the corresponding closed ml can be set to zero, thus making the observer independent of
loop transfer function matrices. Let the cart's position. These additional constraints can be written as
where
(28)
r' O 0 I 01
Eqs. (26)-(29) yield Disturbance transmission plots for the observer based control-
ler are shown in Figs. 5 and 6 (dash-dot lines). The effects of rail
inclinations are shown in Fig. 5. These plots indicate that the
controller is quite effective in eliminating the effects of con-
stant rail inclinations. Fig. 6 shows disturbance torque trans-
mission plots. There is a small degradation in the low frequency
region and for frequencies above 2 Hz there is a modest im-
The matrix S is now square and depends only on the chosen provement.
observer dynamics. For a given E and setting H = 0, solving
(30) yields a unique solution whenever S'' exists. The above Filter Cut-off Frequency Selection
scheme is easily implemented as a Matlab M-file. In our imple- Since the smoothing and anti-aliasing filters are not taken into
mentation the observer eigenvalue was chosen as E = 0.9 and account in the design of the controller, the relative stability of the
represents a compromise between the speed of response of the closed loop system will degrade as the cut-off frequencies de-
observer and disturbance transmission characteristics of the crease. An upper bound for the cut-off frequencies is usually
closed loop system. In general, as E+O, the closed loop system taken as one-half of the sampling frequency (in our case 100 Hz).
becomes more sensitive to disturbances. The actual values for To select suitable frequencies we assess the loop gain and distur-
the observer are bance transmission properties of the observer based controller
June 1999 65
applied to the model with the filters. The controller (22) is now and Y is a constant to be selected experimentally. As pointed out
acting on the model (8). Defining previously, (35) will not completely eliminate the terms arising
from Coulomb friction, but as the experimental results will show
Ae(z) = (zl-W-', G:,(z) =CxAe(z)r:, G:,(z) =CxX(z)r:, substantial reductions in the amplitude of the limit cycles can be
obtained by suitably selecting the gain Y.
G:(z) = cxx(z)r:,
G;JZ) = ceAe(z)r;, G;,(z) = cex(z)r:,
G:,(z) = CeAe(z)rz, Q'(z) = G:,(z)[l +K(z)G;,(z)]-'K(z), Experimental Results
The observer based controller was implemented in a 386
the disturbance tansmission properties of the closed loop system DW20 MHz personal computer in the C language. The overall
are given by program includes code to capture experimental data and store
this information in the hard disk. The program is compiled to op-
timize execution speed but not memory requirements. All calcu-
lations are carried out in floating point arithmetic using a math
co-processor. In all experiments the observer and integrator ini-
tial conditions were set to zero. The transient response for an ini-
tial condition x(0) = [0.171 0.02 0 O r is displayed in Fig. 7,
while Fig. 8 shows the cart position after 300 seconds. These fig-
ures indicate that the design specifications given earlier are satis-
fied. The gain Y for the nonlinear compensation scheme (35)
was experimentally determined and set to 0.8. This value reduces
K(z)G;"(z). (34) the amplitude of the cart's position limit cycle by a factor of 3.
Additional experiments were carried out varying the sampling
The Nyquist plot of the loop gain (34) is shown in Fig. 4(b) (solid time interval from 3 ms to 13 ms, as well as removing the alumi-
line) for ain = 259.4707 rads (41.3 Hz) and aout = 227.2727 13 num disk at the top of the pendulum (0.227 kg). In all cases the
rads (36.17 Hz). The phase margin for this case is about 30 de- system performance was stable, confirming the robustness prop-
grees and the upper gain margin is reduced to 4. The magnitude erties of the control system.
Bode plots for rail inclination and torque disturbances are dis-
played in Figs. 5 and 6 (solid lines).
Conclusions
A robust computer control system for balancing a single in-
Coulomb Friction Compensation
verted pendulum on a moving cart was successfully designed us-
It is well known that Coulomb friction (including stiction)
ing a blend of state space and frequency domain methods. In
can produce limit cycle oscillations in a control system. To re-
particular, the controller design illustrates how the available
duce the amplitude of these limit cycles the state feedback gains
freedom inherent in reduced order observer theory can be used to
could be increased at the expense of reducing the relative stabil-
avoid degrading relative stability of observer based controllers
ity of the closed loop system. Alternatively,suitable dither signals
and whenever possible to fully recover state feedback robustness
could be used to reduce the amplitude of these oscillations [4]. In
at the plant inputs (the case H = 0). The analysis of c l o s e d loop
this section we consider a simple scheme based on velocity-sign
disturbance transmission properties provides useful benchmarks
compensation using the signal at the output of the corresponding
for the stabilization problem of the now classical pendulum-cart
anti-aliasing filter, i.e.,
system. Experimental results show that a simple velocity-sign
compensation with a fixed gain Y can be quite effective in reduc-
u(k) = + Ysign([O 0 lly'(k)), u,(z) = -K(z)y'(z),
ing limit cycle oscillations arising from nonlinear friction. Cur-
(35)
rent research work involves techniques for on-line estimation of
the gain and the use of neural networks to counteract Coulomb
Cart Position Limit Cycle: Experimental Results friction effects. Future work will focus on modeling the effects of
0.04 I * - Coulomb friction as an external disturbance and the design of a
0.02
0.03
0.01
t
1 f
1
/
/
' \
\
\
control system which is insensitive to this type of disturbance.
Double and triple inverted pendulum-cart systems are also being
developed.
References
I
[ l ] B.D.O. Anderson and J.B. Moore, Optimal Control: Linear Quadratic
Methods, Prentice-Hall, 1989, chapters 5 and 8.
--
rerted
ndulum
Controller Cards
Cou ledTank
cone-01 -
Apparatus
Dual Process
Fan & Plate Simulator
Control
Apparatus