Control of Inverted Pendulum

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

CONTROLLING OF REAL INVERTED PENDULUM BY FUZZY LOGIC

Nenad Mukinja, Boris Tovornik Faculty of Electrical Engineering and Computer Science Maribor University of Maribor Smetanova 17, 2000 Maribor, Slovenia nenad.muskinja @ uni-mb.si

Abstract
The basic aim of our work was to swinging up a real pendulum from lower position to upper position and balance in this position in center of course. For this purpose we used fuzzy logic controller with two sets of rules: first for swinging up the pendulum, and second for balancing the pendulum in upper position. Because we controlled the real system and all inputs were noised, we had to use filters. The best results we achieved with combination of fuzzy and state controller.

OMRON FB-30AT. All program was written in C code with Borland C++.

1. Introduction
Controlling the inverted pendulum is a classic experiment that is used in control laboratories. Futura (1992) has developed minimum time controller that is unfortunately not very robust. strom (1996) has proposed an energy control strategy that controls the energy of inverted pendulum in to the steady-state upright position. This strategy depends critically on the available acceleration of the real inverted pendulum. Our goal was to develop a fuzzy rule based controller with similar behavior. The problem is to swinging up a real pendulum from lower position to upper position and balance in this position in center of course.

Figure 1: Inverted pendulum construction

2.

Process description

The figure 1 shows a laboratory inverted pendulum that is constructed in Laboratory of Process Automation. Figure 2 shows the chart with the potentiometer and pole that can swing in vertical plane. The potentiometer measures the pole angle and in the same time it is used as a pole shaft. The chart is elastically connected to a DC motor (figure 3), where chart position is measured over second potentiometer. Control algorithm, data acquisition and visualization was realized on PC-486 with AD/DA converter (PCL 711) and fuzzy processor module

Figure 2: Chart with potentiometer and pole

. In case a) we don't need to know accurate value of angle , so we used rectangle shape. Definition ranges of variables are: chart position:

x [16cm ,16cm ] , pole angle: [ 3.14rad,3.14rad ] , angle velocity: d [ 6rad s, 6rad s ]and DC motor voltage: u [ 10V,10V ]

All this values are calculated in to the range 1 4095 in C program because of 12 bit unsigned logic fuzzy processor board. Figure 4 shows all membership functions. Figure 3: DC motor and potentiometer for chart position measurement

3.

Swinging up of pendulum

From basic position after small impulse the pendulum should swing up to upper position without overstepping of limited course of motion. The principle of swinging up was (while an angle is small) based on increasing of energy, it means: a) For small angles < 89 :
o

if angle is positive (negative) and if angle velocity d is positive (negative) than the action value is positive (negative), if angle and angle velocity d has different sign than the action value is equal 0. b) For medium angles 88 ;145 value is equal 0.
o

u x Figure 4: Membership functions for swinging algorithm

4.

Balance of pendulum

) the

action

c) For big angles close to the upper position

145o;180o :
if the angle velocity is small,

d < 1,47 s and it has same sign like


angle than energy must be increased like in case a), if angle velocity is big, d > 1,47 s and it has the same sign like angle than we break the swinging. All this conditions respect position of pendulum x to not overstep limits. The control algorithm of increasing the energy of inverted pendulum was realized with fuzzy logic system. We use three inputs variables ( ,d in x ) and one output variable u. Input variable has six membership functions symmetrical by center.

Initial for this algorithm is upper position, in that case it is ( = 0,d = 0,x = 0in dx = 0 ). Our aim was to keep the pendulum in or close upper position during activity of defects. Since we should control the position of the pendulum, we had to use four input variables ( ,d , x and dx ). We used membership functions with triangle and trapezoidal shape. Because the balancing is very sensitive we used five membership functions for angle and angle velocity d and three membership functions for chart position x and chart velocity dx. We compensated: chart position x, if angle and angle velocity d were small and angle , if angle and angle velocity d were big We determine the rules with respect to position of the pendulum. In order to use all rules in table we adjusted ranges for: chart position: chart velocity: pole angle:

x [16cm ,16cm ] , dx [ 0.5m s ,0.5m s ] , [ 0.2,0.2] ,

pole angle velocity DC motor voltage:

d [ 0.5 s , 0.5 s ]and u [10V,10V ]

d (k )=

1 [ (k ) (k 1)+ Td d (k 1)](2) Td + Ts

Output membership functions were seven discrete values. The small values 2.44V we used for tuning of position and medium and big (4.88V, 10V) for compensation of big deviations and also for inertia. Figure 5 shows membership functions for balance algorithm.

Computing and filtration of pole angle :

f Tf s + 1 = Tf Ts

f (k ) f (k 1)

1 Tf s + 1

+ f (k )= (k )

( f (k )T f + Ts )= Ts (k )+ T f f (k 1)
f (k )= Ts (k )+ T f f (k 1) T f + Ts

T f f (k ) T f f (k 1)+ Ts f (k )= Ts (k )

(3)

The sampling period was Ts = 0.003s , filtration x dx constant

Tdd

for derivation of chart position was = 0.03s , filtration constant for angle deviation

was Td = 0.04s filtration constant for angle was

T f = 0.005s .
A friction caused that output voltage for DC motor between 0.3V had no effect. Therefore we add output nonlinear element shown on figure 6.

u Figure 5: Membership functions for balance algorithm

5.

Filtration and friction compensation

Because we controlled the real system and all inputs were noised, we had to use filters. Pole angle and chart position x was measured over potentiometer voltage. All other variables must be calculated. We filtered pole angle , angle velocity d and chart velocity dx by 1-st order filter. Variables d and dx were computed from measured values and x. Computation and filtration of chart velocity dx: Figure 6: Output non-linear element for friction compensation This element also solves the problems with oscillations close to zero pole angles. (1)

dx =

s x Tdd s + 1

Tdd [ (k ) dx(k 1)] Ts dx(k )= x(k ) x(k 1) dx + dx(k )= 1 [(k ) x(k 1)+ Tdd dx(k 1)] x Tdd + Ts

dxTdd s + dx = sx

6.

Switching between balance algorithm

swinging

and

a) Fuzzy switching algorithm with state controller of balance

Filtration of pole angle velocity d :

We switched between algorithms if angle a > 3.1 . In this moment we switched the absolute zero of pole angle to zero value as it has in upper position. The swinging value was chosen with respect to pendulum inertia. b) Both fuzzy algorithms

1.5 1 0.5 0 -0.5

The switching was the same like in case a). Because each algorithm uses different shapes of membership function, we needed seven inputs for fuzzy processor board, two tables of rules and two outputs. In the switching moment the table of rules is switched and other output for calculating of action value is used.

-1 0

50

100

150

200

Figure 9: Pole angle and pole angle velocity in balancing the inverted pendulum
0.4

7.

Experiment results

0.2 0 -0.2 -0.4 -0.6 0

All experiments were don in real time on laboratory inverted pendulum shown on figures 1,2 and 3. For swinging up the pendulum we used the algorithm from section 3. Figure 7 shows that the pendulum swings up in only two swings. This for the real inverted pendulum is near of the optimum.
2 1 0 -1 -2 -3 -4 0 200 400 600 800

50

100

150

200

Figure 10: Chart position and chart velocity in balancing the inverted pendulum

8.

Conclusion

Figure 7: Pole angle rad in swinging up the inverted pendulum


10 5 0 -5 -10 -15 0 200 400 600 800

The best result we achieved with swinging algorithm. These algorithms don't need so big initial impulse unlike energy swinging algorithm. It's also closer to time optimal swinging. Our fuzzy algorithm for balance control is not able to compensate bigger deviations unlike state controller. This is the reason why it isn often able to stabilize pendulum if velocity t is big in moment of switching. The best results we achieved with combination of fuzzy and state controller. Because setting of zero pole angles has big influence to stability of system, inaccurate setting of zero was the most frequent cause of desirability after switching of algorithms. To improve the inverted pendulum control we have some recommendations: increase the number of membership functions of dx, because we found out the big influence on system, improve the sensibility of an pole angle sensor, take off sliding during transfer between a motor and a position sensor and

Figure 8: DC motor voltage u V in swinging up the inverted pendulum Balancing the pendulum was controlled with fuzzy state controller. Figures 9 and 10 shows fuzzy logic algorithms. For small pole angle deviation the controller was successful, but for big deviations from upper right position we achieved better results with linear state controller.

include to fuzzy rules influence of motor moment to derivation of position by various angle.

Literature
[1] Furuta, M. Yamakita, and S. Kobayashi, Swinging up control of inverted pendulum using pseudo-state feedback. J. Systems and Control Eng. 206, pp. 263-269, 1992. [2] K. J. strom, and K. Furuta, Swinging up a pendulum by energy control. Proc. 13th IFAC Triennial World Congres, San Francisco, USA, 1996. [3] M. Kabat and R. Ondrejkova, Project report: Inverted pendulum, Process Control Laboratory, Faculty of Electrical Engineering and Computer Science, Maribor, 1997.

You might also like