0% found this document useful (0 votes)
12 views6 pages

Automatic Control of Ball and Beam System Using Particle Swarm Optimization

Uploaded by

Emelyn Rodriguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

Automatic Control of Ball and Beam System Using Particle Swarm Optimization

Uploaded by

Emelyn Rodriguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CINTI 2011 • 12th IEEE International Symposium on Computational Intelligence and Informatics • 21–22 November, 2011 • Budapest, Hungary

Automatic Control of Ball and Beam System Using


Particle Swarm Optimization
Muhammad Asif Rana, Zubair Usman, Zeeshan Shareef
Department of Electrical Engineering
Lahore University of Management Sciences
Lahore, Pakistan
[email protected], [email protected], [email protected]

Abstract— Over the last few decades, many evolutionary flocks. It was in 1995, that particle swarm optimization was
algorithms have emerged. One such algorithm is Particle Swarm first presented as a tool for optimization of functions by
Optimization which emulates social and cognitive behavior of Kennedy and Eberhart [7].
bird-flocks. In this paper, particle swarm optimization algorithm
is presented as a robust and highly useful optimization technique The algorithm works on the scenario of birds randomly
to tune the gains of the PID controllers in the two feedback loops searching for food. It begins with a swarm of birds/particles
of the classic Ball and Beam Control System. As the name being initialized at random positions in the problem-space.
implies, Ball and Beam control system tends to balance a ball on Typically, the numbers of birds in the swarm (n) is kept in the
a particular position on the beam as defined by the user. Various range 20-40. During the journey, each bird keeps track of its
trials of the algorithm with varying parameters is implemented coordinates in the problem space. A record is also kept of the
on the control system and the fitness of the response of the system least distance (fitness value) from the food achieved by each
to a unit step input is used as a criterion for judging the most individual bird so far, called pbest (personal best). The
optimal solution. A slight variation in the fitness value function is minimum value of pbest in the swarm is called gbest (global
also introduced, rather than using conventional performance best), that is, the minimum distance achieved by any of the
integrals as a criterion. Furthermore, the results from PSO birds in the swarm so far.
tuning are quantitatively compared to ITAE equations method of
PID tuning and Fuzzy-logic controller to reach a conclusion on On each iteration, the velocity of each bird is updated and
the most efficient controlling technique. added to the current coordinates of the respective birds.
Keywords- Particle Swarm optimization; Ball and Beam system;
fitness function; ITAE equations; Fuzzy-logic controller positionnew [ ] = positionold [ ] + velocitynew [ ] (1)

I. INTRODUCTION The velocity is governed by three factors: (1) inertia


The ball and beam control system has always remained one (velocityold); (2) cognitive influence(pbest); and (3) social
of the favorite introductory control system problems for control influence(gbest). The directions of cognitive and social
engineers. As the name implies, in this system, a ball is placed influences depend on the direction vector of the bird’s position
on a beam and the control system should tend to balance the from pbest and gbest respectively. Both these influences are
ball at particular position on the beam as prescribed the user. updated on each iteration, and added to inertia to get the new
Since the ball position is unstable in open-loop, there is a need velocity. Furthermore, randomness is maintained in the system
for a feedback loop with a suitable controller to minimize the by weighing the influences with random numbers between 0
error. The work of a robust controller should be to provide least and 1, called learning factors (c1 and c2) and the inertia with
possible transients in the step-response, while minimizing the another random number in the same range, called inertia factor
steady-state error. PID (Proportional, Integral, and Derivative) (w) [8].
controllers have always remained one of the highly-demanded
choices for such applications [1]. However, tuning a PID velocitynew[ ] = w×velocityold[ ]
controller to acquire the most optimum results is a tricky task + c1×rand× (pbest[ ] – position[ ])
and many tuning techniques have been used in the past to do + c2×rand× (pbest[gbest] – position[ ]) (2)
so. The traditional PID tuning methods include: Ziegler-
Nichol’s method [2], Gain & phase margin tuning method [3], Innovations have been continually introduced into the
ITAE equations method [4], SISO tool and so on [5]. algorithm, with almost all having the objective of decreasing
Furthermore, many unconventional techniques have been the time required to achieve the optimum solution. These
developed over the past few decades which have proven to be include use of linearly decreasing inertia factor(w) [8],
very fruitful in control systems. Fuzzy-logic and Evolutionary introduction of constriction factor( [9], development of
algorithms [6] are examples of such unconventional methods. Binary PSO[10], Bare Bone PSO[11], and Fully informed
Particle Swarm Optimization algorithm is one such PSO (FIPS) [12].
evolutionary algorithm which can be used in tuning PID
Experiments have also been carried out to find out the most
controllers. The algorithm simulates the movement of birds in
optimum values for the parameters in the PSO algorithm and

978-1-4577-0045-3/11/$26.00 ©2011 IEEE – 529 –


Authorized licensed use limited to: Pontificia Universidad Javeriana. Downloaded on November 08,2024 at 00:02:08 UTC from IEEE Xplore. Restrictions apply.
M. A. Rana et al. • Automatic Control of Ball and Beam System Using Particle Swarm Optimization

the most optimum bounds to be imposed on the parameters to


be tuned[8][13]. The parameters must be such that there is a θ(s) K (3a)
balance between the social and cognitive behavior, side-by-side Gm(s) = V(s) = s(τs + 1)
maintaining equilibrium between stability and randomness in
the swarm. However, there is no proper method as to how the Based on experimental deduction of the motor parameters,
parameters should be calculated. We have considered the work
K= O.7/rev/sec/volts, τ = 0.014 sec,
by Shi and Eberhart as our starting point in selecting the PSO
parameters [8]. An analysis of the 30 trials performed by them
makes it evident that decreasing the inertia weight factor, 0.7 (3b)
Gm(s) = s(0.014s + 1)
decreases the number of iterations required to achieve the
global optimum. However, having a smaller inertia weight
increases the probability of failure in achieving the global
B. Model for Ball and Beam system
optimum. On the other hand, a very large inertia weight also
leads to a higher failure rate. The PSO parameters are further According to Rosales [16] and others [17][18][14], the
varied by hit and trial unless a feasible solution is achievable linearized model of the ball and beam setup within small angles
within the given number of iterations. around θ = 0o is:
The rest of the paper deals with the implementation of (4a)
Particle Swarm Optimizer to ball and beam control system. A X(s) g
Gbb(s) = θ(s) = 2 a
quantitative comparison is then made with ITAE equations
method and Fuzzy-logic control method, to decide the most s2[1 + 5 (a' )2]
efficient method.
II. DYNAMICS OF BALL AND BEAM SYSTEM Where, a is the radius of the ball, a’ is the distance between
the axis of rotation of the ball and point of contact of the ball
The practical setup is the same as used by Amjad et al [14] with the beam, and g is the acceleration due to gravity.
and the system is shown in figure 1. Hence the system
dynamics remain intact. The transfer functions are mentioned Taking g to be 9.81 m/s2 and substituting in the
in this section again briefly. mathematical expression will yield:
To understand the complete dynamics of the setup
1
accurately, the transfer functions of the motor and the ball on Gbb(s) = 1.713s2 (4b)
beam system need to be analyzed separately. The results can
later be used to obtain the overall response of the system.
C. Model for the whole system
Combining the results from the previous subsections, the
open-loop transfer function of the ball and beam setup as well
as the motor becomes,

0.7
Gtotal(s) = Gm(s) ×Gbb(s) = s3(0.02398s + 1.713) (5)

III. CONTROLLER TUNING AND IMPLEMENTATION


The block diagram of the whole system is shown in
Figure 2. The system consists of two loops: (1) Inner motor
control loop, (2) outer ball and beam control loop. The design
strategy is to first stabilize the inner loop followed by the outer
loop.
This section presents three methods for controlling the
loops: (1) PID control with Particle Swarm Optimization, (2)
PD and PI control with standard ITAE equations, (3) PD and
fuzzy-logic control
Figure 1. A cross sectional view of the system

A. Model for Motor


The position of a DC motor is observed to have a transfer
function [15]: Figure 2. Block-diagram of the ball and beam system. PID controllers
highlighted in green are to be tuned

– 530 –
Authorized licensed use limited to: Pontificia Universidad Javeriana. Downloaded on November 08,2024 at 00:02:08 UTC from IEEE Xplore. Restrictions apply.
CINTI 2011 • 12th IEEE International Symposium on Computational Intelligence and Informatics • 21–22 November, 2011 • Budapest, Hungary

A. PID tuning with Particle Swarm Optimization


Before implementing the particle swarm optimization Initialize an n×6 position[ ][ ] matrix birds at random positions inside the
technique on a problem, one has to consider first the number of bounds, where n is the no. of birds and 6 is the no. of PID gains.
variables to be tuned in order to optimize the solution to the Initialize an n×6 velocity[ ][ ] matrix to all zeros.
problem. The number of dimensions of the matrices in the Initialize pbest[ ][ ] = position[ ][ ]
algorithm must equal the number of variables in the system.

1) Defining the PSO parameters and bounds on PID gains


Evaluate current_fitness[i]
In our case, the food is analogous to reference position of
the ball, defined by the user. The problem-space at hand is 6
for
dimensional, since we are required to tune 6 PID gains. if (current_fitness[i] < fitness at pbest[i][:]) i =1:n
pbest[i][:] = position[i][:]
Since each iteration takes a moderately large time, we wish
to achieve the global optimum within a comparatively small
number of iterations, hence we keep w=0.4 so that there is a
gbest = row no. of pbest[][] with least fitness value
higher probability of attaining global optimum within the given
number of iterations. On the other hand, we have not kept w≈0
since this would greatly increase the failure rate [8]. The velocity[i][:] = 0.4×velocity[i][:]
number of birds is kept at n=70 which is more than enough for +1.2×rand× (pbest[i][:] – position[i][:])
our control problem. c1 is kept at 1.2 and c2 is set to 1.6. This + 1.6×rand× (pbest[gbest][:] – position[i][:]) for
gives a higher weightage to the social influence. i =1:n
velocitynew[ ] = 0.4×velocityold[ ] position[i][:] = position[i][:] + velocity[i][:]
+ 1.2×rand× (pbest[ ] – position[ ])
+ 1.6×rand× (pbest[gbest] – position[ ]) (6) YES

if
Table I show the upper and lower limits set for the 6 PID (current_iterations<max_iterations)
controller gains. The birds/particles are initialized at random
positions within these limits and are not allowed to trespass NO
during the algorithm.
Stop loop
TABLE I. THE BOUNDS IMPOSED ON PID PARAMETERS

Figure 3. Flowchart of the PSO algorithm

Outer-loop PID Inner-loop PID


KP KD KI KP KD KI
Lower bound 5 2 0 5 0 0 Alternatively, any performance integral can also be used as
Upper bound 15 8 1 15 1 2 fitness criterion e.g. IAE (Integral Absolute Error), ITAE
(Integral Time Absolute Error), ISE (Integral Squared Error)
etc.
2) Fitness Value 3) Finding most optimum solution
The fitness value needs to be selected according to the
design requirements. The following fitness criterion is A unit step for ball-position is applied as a reference to the
proposed and applied. In this function, the weighing factors can system in figure 1. The algorithm, as explained in figure 3, is
be varied according to the design requirements. For example, a run around 50 times with varying number of iterations from 20
control designer concerned with minimizing overshoot alone to 300. During the whole process, it also becomes apparent that
would set a1=1 and other factors to zero. a local or global optimum is usually achievable within the
given number of iterations if they are kept more than 50.
fitness = a1×Mp + a2×tr + a3×ts + a4×|ess| (7)

Where a1, a2, a3, a4 are weighing factors and MP, tr, ts and ess
are peak-overshoot, rise-time, settling-time, and steady-state
error respectively. We have set a1=a2=a3=a4=1.

– 531 –
Authorized licensed use limited to: Pontificia Universidad Javeriana. Downloaded on November 08,2024 at 00:02:08 UTC from IEEE Xplore. Restrictions apply.
M. A. Rana et al. • Automatic Control of Ball and Beam System Using Particle Swarm Optimization

TABLE II. PID GAINS OBTAINED FOR THE 5 BEST PSO TRIALS

Outer-loop PID Inner-loop PID


KP KD KI KP KD KI
trial 1 14.9998 7.9094 1.3186 x 10-5 11.9813 0.0017 0.1258
trial 2 14.9915 7.6728 1.2423 x 10-7 14.9023 1.2511x10-8 1.2701
trial 3 13.7210 7.4379 0.0097 14.9699 5.3954x10-8 1.9487
trial 4 14.9986 8.0000 0.0398 13.9506 1.7297x10-13 0.1424
trial 5 14.8617 7.9298 7.9953 x 10-15 14.9999 0.2138 1.9365

Figure 6. Rise times of the 5 best PSO trials


Figure 4. Step-responses of the 5 best PSO trials

Based on the comparison in TABLE III, trial 4 seems the


Figures 5 and 6 show the zoomed-in versions of the step most optimum solution to our ball and beam control system
responses in figure 4.
with a negligibly small peak overshoot and peak undershoot
and a pretty fair rise time and settling-time. The steady-state
error in trial 4, although larger than other trials, is still very
small.

TABLE III. COMPARISON OF PSO TRIALS


trial 1 trial 2 trial 3 trial 4 trial 5
Rise time 0.5880 0.6060 0.6540 0.6290 0.6520
Peak 1.700 2.070 1.357 0.496 1.264
overshoot
(%)
Decay ratio 0.4529 0.0580 0.0442 0.4028 0.0395
Steady-state 1.7949 3.1566 3.8728 1.400 5.382
error x10-6 x10-6 x10-4 x10-3 x10-4
IAE value 0.5382 0.5312 0.5584 0.5462 0.5642
Settling- 0.9120 0.9240 0.9940 0.9660 0.9930
time (±5%)

B. PD and PID controller designing using ITAE equations


There are number of classic techniques to design the PID
controller which involves Ziegler and Nichols, SISO Tool,
ITAE Equations, root locus etc. In this design, we have used
Figure 5. Over-shoots and under-shoots of the 5 best PSO trials
the ITAE equations for the outer-loop PD and inner-loop PID
gains computation

– 532 –
Authorized licensed use limited to: Pontificia Universidad Javeriana. Downloaded on November 08,2024 at 00:02:08 UTC from IEEE Xplore. Restrictions apply.
CINTI 2011 • 12th IEEE International Symposium on Computational Intelligence and Informatics • 21–22 November, 2011 • Budapest, Hungary

The main advantage for using the ITAE equation method better option for tuning PID than the conventional ITAE
over other conventional tools is that there is no requirement method of tuning.
for any graph or chart like the root locus and the bode plot.
These equations can easily be used for the gains calculation of V. CONCLUSION
up to 6th order characteristics equation. After calculating the In this paper, Particle swarm optimization algorithm is
gains from the ITAE equations we usually require a little bit successfully presented as a useful tool for optimizing the step-
tuning of the gains. response of a ball on beam control system. An analytical
approach has been used to choose the best trial among the
The ITAE performance integral is defined as:
various trials of the algorithm on the system model. Finally, the
step-response is compared with a step-response optimized
T
through ITAE equations and Fuzzy-logic Controller. The
t|e(t)| dt
ITAE =  (8) Particle Swarm Optimizer out-classes the other two techniques.
0 This is mainly because this algorithm efficiently searches the
entire 6-dimensional problem space for the optimum solution.
The procedure for calculating the PID gains using the Unlike conventional methods, it provides a general and easy-
ITAE equations is as follows. These steps are carried out for to-use method for tuning any control problem, without the need
first for inner-loop and then the outer-loop: of complex analysis of the system.
Step-1: We multiply the general form of the PID controllers
with the open loop transfer function.
Step-2: The characteristics equation is compared with the
standard ITAE equations. The value of damping ratio (ζ) is
constant that is 0.6.
Using standard equations of ITAE, the PID controllers
designed for the inner and outer loop respectively can be
written as [14], [4]:
Inner loop PD controller: KP = 11; KD = 2
Outer loop PID controller: KP = 6; KI = 0.2; KD = 5

C. Fuzzy-logic controller and PD controller implementation


Fuzzy-logic controller has been of high interest to control
engineers who deal with complex industrial control problems
which cannot be tuned by conventional methods. Unlike PSO,
fuzzy-logic controller makes use of human thinking and logic
(fuzzy-logic) rather than behavior of birds in flocks. [19]
Figure 7. Step responses of ball and beam system with various controllers
Implementation of a fuzzy-logic controller (FLC) on this
system has been presented by Amjad et al [20]; the same FLC TABLE IV: COMPARISON OF STEP RESPONSE CHARACTERISTICS
has been used here. A FLC for the outer loop and a PD OF THE CONTROLLERS
controller using ITAE equations (found in previous section) for
PSO ITAE Fuzzy-logic
the inner loop, of this ball and beam system were implemented. Rise time 0.6290 1.2380 1.4800
In this controller for the fuzzification process the triangular Peak overshoot 0.4958% 4.9501% 0.3217%
member functions are used for input as well as for output. The Steady-state error 1.400x10-3 2.5900x10-2 1.1256x10-6
defuzzification technique in this case that gave the least IAE value 0.5462 1.3255 1.1742
integral square error was the Center of Gravity approach. The Settling time (±5%) 0.9660 2.7420 2.3400
response of the system with fuzzy logic controller is shown in
REFERENCES
Figure-7(green curve) for comparison.
[1] Araki M., “PID control”, Control systems, robotics, and automation, vol.
2, Encyclopedia of Life Support Systems (EOLSS).
IV. COMPARISON OF PSO WITH OTHER TECHNIQUES [2] Ziegler J. G. et al,“Optimum settings for automatic controllers”,
Transactions of ACME, 1942, vol.64, pp. 759-768.
The input step response of the control system tuned by PSO [3] Astrom K. J. and Hagglund T., “Automatic tuning of simple regulators
has negligible transients as compared to that tuned by ITAE with specifications on phase and amplitude margins”, Automatica, 1984,
equations. The steady-state error is however minimum for vol. 20, pp. 645-651.
FLC controller, but the trade-off between steady-state error and [4] D’Azzo J. J. and Houpis C.H., “Linear control system analysis and
design: conventional and modern”, McGraw-Hill Series in Electrical
the rise-time is large enough that the steady-state error can be and Computer Engineering, New York 1995, 4th edition.
ignored. Hence, it can be concluded that PSO tuning is a much [5] Astrom K. J. and Hagglund T., “PID Controllers: Theory, Design, and
Tuning”, Instrument Society of America, 1995, 2nd ed., pp. 134-229.

– 533 –
Authorized licensed use limited to: Pontificia Universidad Javeriana. Downloaded on November 08,2024 at 00:02:08 UTC from IEEE Xplore. Restrictions apply.
M. A. Rana et al. • Automatic Control of Ball and Beam System Using Particle Swarm Optimization

[6] Zang H., Zhang S. and Hapeshi K., “A review of nature-inspired International Conference on Natural Computation, 24-27Aug. 2007,
algorithms”, Journal of Bionic Engineering, September 2010, vol. 7, vol. 3, pp. 823-826.
Supplement 1, pp. S232-S237. [14] Amjad M. et al, “A simplified intelligent controller for ball and beam
[7] Kennedy J. and Eberhart R., “Particle Swarm Optimization”, IEEE system”, 2nd International Conference on Education Technology and
International Conference on Neural Networks, Perth – Australia, 1995, Computer, 22-24 June 2010, vol.3, pp.V3-494-V3-498.
pp. 1942-1948. [15] Cockburn J. C. and Savakis A., “DC Motor Transfer Function”,
[8] Shi, Y. and Eberhart R., “A modified particle swarm optimizer”, http://www.ce.rit.edu/~cockburn/courses/ce553_su02/labs/lab3_r1.pdf
Evolutionary Computation Proceedings, IEEE World Congress on [16] Rosales E. A., “A Ball-on-Beam Project Kit”, Department of
Computational Intelligence, Anchorage– USA, 4-9 May 1998, pp.69-73. Mechanical Engineering, Massachusetts Institute of Technology, June
[9] Clerc M. and Kennedy J., “The particle swarm - explosion, stability, and 2004
convergence in a multidimensional complex space”, IEEE Transactions [17] Hirsch R., “Mechatronic Instructional Systems Ball on Beam System”,
on Evolutionary Computation, Feb 2002, vol.6, no.1, pp. 58-73. Shandor Motion Systems, 1999.
[10] Kennedy J. and Eberhart R., “A discrete binary version of the particle http://www.ro.feri.uni-mb.si/predmeti/skup_sem/projekt1/shandor.pdf.
swarm algorithm”, Systems, Man, and Cybernetics, IEEE International [18] Wellstead P., “Ball and Beam I: Basics”,
Conference on Computational Cybernetics and Simulation, 12-15 Oct http://www.controlsystemsprinciples.co.uk/whitepaperslball-and-beam.
1997, vol. 5, pp. 4104-4108.
[19] Lee C. C., “Fuzzy logic in control systems: fuzzy logic controller -Part I
[11] Kennedy J., “Bare bones particle swarms”, Proceedings of the 2003 and II", IEEE Transactions on System, Man and Cybernetics, Mar-Apr
IEEE Swarm Intelligence Symposium, 24-26 April 2003, pp. 80- 87. 1990,vol. 20, no. 2, pp. 404-435.
[12] Mendes R., Kennedy J. and Neves J., "The fully informed particle [20] Amjad M. et al, "Fuzzy Logic Control of Ball and Beam",2nd
swarm: simpler, maybe better", IEEE Transactions on Evolutionary International conference on Electronic Computer Technology (ICECT
Computation, June 2004, vol.8, no. 3, pp. 204- 210. 2010), Kuala Lumpur, Malaysia, 22-24 June 2010, vol. 2, pp. V3-489 -
[13] Chuan L. and Quanyuan F., “The Standard Particle Swarm Optimization V3-493.
Algorithm Convergence Analysis and Parameter Selection”, Third

– 534 –
Authorized licensed use limited to: Pontificia Universidad Javeriana. Downloaded on November 08,2024 at 00:02:08 UTC from IEEE Xplore. Restrictions apply.

You might also like