INTRODUCTION
During the past decades, many modern control methodologies such as nonlinear
control, optimal control, adaptive control and variable structure control
have been widely proposed for control approaches (Gaing, 2004). However,
these methods are theoretically complex and difficult to implement. PID
controller design covering treatment to both transient and steady state
responses offers the simplest and most efficient solutions to various
control problems (Visioli, 2001). Unfortunately, it has been difficult
to tune PID controller gains accurately because many industrial plants
are often very complex consisting of issues such as higher order, time
delays and nonlinearities (Kwok et al., 1993; Gaing, 2004). The
ability of using numerical methods for efficiently and accurately characterizing
the quality of a particular design has excited control engineers to apply
stochastic global optimizers. Over the past years, several heuristic methods
are employed for tuning of controllers. Ziegler and Nichols proposed the
first method utilizing the classical tuning rules. Though, it is hard
to determine optimal PID controller parameters with ZieglerNichols formula
in general (Visioli, 2001; Gaing, 2004).
To overcome these difficulties, various methods are employed. Many random
search methods, such as Genetic Algorithm (GA), Tabu Search (TS) and Simulated
Annealing (SA) have recently received great attention for searching global
optimal solution and achieving high efficiency (Zhou and Birdwell, 1994;
Haupt and Haupt, 1998). GA method is usually faster than TS and SA methods
because of employing parallel search techniques. Though, the GA method
has been employed successfully for global optimization, recent research
has identified some deficiencies in GA performance. This degradation in
efficiency is apparent in applications with highly epistatic objective
functions (where the parameters being optimized are highly correlated),
the crossover and mutation operations cannot ensure better fitness of
offspring because population chromosomes have similar structure and their
fitness are high toward the end of the process (Gaing, 2004; Kennedy and
Eberhart, 1995). To overcome GA difficulties, a novel method is proposed
using PSO approach. PSO is one of the modern heuristic algorithms developed
through simulation of a simplified social system. Generally, it is characterized
as a simple concept, easy to implement and computationally efficient.
Because PSO method is a superior optimization technique than recent heuristic
methods, in this study developments of PSOPID controller to determine
optimal PID parameters are considered.
ROTARY INVERTED PENDULUM SYSTEM
The rotary inverted pendulum system is a wellknown test platform for
evaluating various control algorithms. It has also some significant real
life applications such as pointing control, aerospace vehicles control,
robotics, etc (Muskinja and Tovornik, 2006). The system consists of a
rotary arm and a pendulum where the rotary arm is actuated by a motor
with the objective of balancing the pendulum in an inverted position.
A schematic diagram of the RIP system is shown in Fig. 1,
where u, l_{p}, m_{p}, α, r, θ and J_{b}
are the motor input, the pendulum length, the pendulum mass, the pendulum
angle, the arm length, the arm angle and effective mass moment of inertia,
respectively.

Fig. 1: 
Schematic view of RIP system 

Fig. 2: 
Built in RIP system (Advanced robotics research lab) 
The plane of the pendulum is orthogonal to the radial arm. Figure
2 shows the RIP system built in robotics research lab in our department.
Also, the block diagram of whole system is shown in Fig.
3.
Here, the dynamic equations of the RIP system considering backlash and
friction effects are presented. The RIP dynamics are governed by Yan (2003)
and Muskinja and Tovornik (2006):
The above nonlinear model can be found in the following equations:

Fig. 3: 
Block diagram of whole system 
Table 1: 
Parameters of the RIP system 

The parameters of nonlinear model of the system are shown in Table
1.
From Eq. 3, the corresponding nonlinear model is given
by:
where, A, B and E matrices are as follows:
with
From the above Equations, the RIP system is easily simulated using Simulink^{®}
and Matlab^{®}. The controller parameters generated by PSO
algorithm are employed iteratively in relevant simulation blocks and the
cost function is calculated in the manner presented in next section.
PARTICLE SWARM OPTIMIZATION
Considering the social behavior of swarm of fish, bees and other animals,
the concept of PSO is developed. PSO is a robust stochastic evolutionary
computation method based on the movement of swarms looking for the most
fertile feeding location (RahmatSamii, 2003). In general, PSO implementation
is easier than GA. Indeed, PSO only has one operator; velocity calculation,
so the computation time is decreased significantly. The reason is PSO
does not perform the selection and crossover operations in evolutionary
process.
Another difference between GA and PSO is the ability to control convergence.
Crossover and mutation rates can affect the convergence of GA, but nothing
can compare to the level of control achieved through manipulating of the
inertial weight. The more decrease of inertial weight the more increase
the swarm`s convergence. This type of control allows determining the rate
of convergence and the level of stagnation eventually achieved. Stagnation
occurs in GA when all of the individuals have the same genetic code. In
that case the gene pool is uniform, crossover has little or no effect
on population and each successive generation is essentially same as the
first. However, in the PSO, this effect can be controlled or prevented
(Kennedy and Eberhart, 1995; RahmatSamii, 2003).
All solutions in PSO can be represented as particles in a swarm. Each
particle has a position and velocity vector and each position coordinate
represents a parameter value. Similar to the most optimization techniques,
PSO requires a fitness evaluation function relevant to the particle`s
position. X_{PB} and X_{GB} are the personal best (P_{best})
position and global best (G_{best}) position of the ith particle.
Each particle is initialized with a random position and velocity. The
velocity of each particle is accelerated toward the global best and its
own personal best based on the following equation (Gaing, 2004):
Here, rand() and Rand() are two random numbers in the range [0,1]; c_{1}
and c_{2} are the acceleration constants and w is the inertia
weight factor. The parameter w helps the particles converge to G_{best},
rather than oscillating around it. Suitable selection of w provides a
balance between global and local explorations. In general, w is set according
to the following equation (RahmatSamii, 2003):
The positions are updated based on their movement over a discrete time
interval (Δt) as follows:
where, Δ_{t} usually is set to 1. Then the fitness at each
position is reevaluated. If any fitness is greater than G_{best},
then the new position becomes G_{best} and the particles are accelerated
toward the new point. If the particle`s fitness value is greater than
P_{best}, then P_{best} is replaced by the current position.
The flowchart of PSOPID controller design procedure is shown in Fig.
4. PSO algorithm parameters are set based on trial and error as follows:
No. of particles for each controller = 30
Acceleration constants c_{1} = c_{2} = 1.5
Maximum
generation = 20 

Fig. 4: 
Flowchart of PSOPID controller design procedure 
PROBLEM FORMULATION AND CONTROLLER DESIGN
The controller transfer function, G_{c}(s), is:
where, K_{p}, K_{i} and K_{d} are the proportional,
integral and derivative gains, respectively. The performance index including
Integrated Absolute Error (IAE) is employed in this research. The proposed
control criterion is as follows:
where, t_{f} = 10 sec subject to control input constraint1 < u < 1.
PSO algorithm stages for searching proper parameters of PID controller
are:
First, specify the lower and upper bounds of controller parameters and
initialize the particles of the population randomly. Each particle, i.e.,
K (controller parameters) is sent to Simulink^{® }model. Then,
the value of performance criterion is calculated iteratively in Matlab^{®}
environment. After that, cost function is evaluated for each particle
according to this performance criterion. If the cost for local best solution
is less than cost of the current global best solution, the global solution
is replaced with the local solution. According to Eq. 11,
the velocity of each particle K is modified. At the end of each iteration,
program checks the stop criterion. If the number of iterations reaches
the maximum designated by the user, the latest global best solution is
recorded and the algorithm brings to an end.
In order to examine the dynamic behaviors and convergence characteristics
of the proposed method, two statistical indexes, namely the mean value
(μ) and the standard deviation (σ) of cost values of all individuals
during the computation processes, are used (Haupt and Haupt, 1998). The
mean value displays the accuracy of the algorithm and the standard deviation
measures the convergence speed of the algorithm. The formulas for calculating
these values are as follows, respectively:
where, IAE_{Pi} is the cost value of the individual and n is the population
size.
SIMULATION RESULTS
The lower and upper bounds of the three controller parameters are shown
in Table 2. The Simulink^{®} block diagram
of RIP system with PID controller is shown in Fig. 5.
In order to highlight the advantages of the proposed method, it also implemented
GAPID controller. GA parameters according to the trial and error manner
are given as follows:
• 
Population size = 30 CCrossover rate = 0.5 
• 
Mutation rate = 0.02 CMaximum generation = 20 
The best controller parameters obtained by GA and PSO algorithms are
as follows:
GA: Arm controller k_{P} = 4.237, k_{i}
= 4.642, k_{d} = 5.329
Pendulum controller k_{P} = 2.349, k_{i} = 21.145,
k_{d} = 0.509
PSO: Arm controller k_{P}
= 1.615, k_{i} = 2.6103, k_{d} = 0.0393
Pendulum controller k_{P} = 2.027, k_{i} = 11.229,
k_{d} = 0.0318 
Figure 6 and 7 shows the arm and pendulum
angles using PSO and GA methods. Also, Fig. 8 and 9
shows the system velocities.
Table 2: 
Range of three controller parameters 


Fig. 5: 
Block diagram of RIP system with PID controller 

Fig. 6: 
The arm angle using GA and PSO based PID control 

Fig. 7: 
The pendulum angle with GA and PSO based PID control 

Fig. 8: 
The arm velocity via GA and PSO based PID control 
The integral absolute error of system angles are shown
in Table 3. As it can be seen, PSObased controller
makes fine responses, indicating the superiority over GAPID controller.
Furthermore, under the same conditions, we performed several simulations
to compare the controllers` convergence characteristics. After each generation,
the mean value (μ) and the standard deviation (σ) of the cost
values of all individuals are recorded for observing the dynamic convergence
behavior of the individuals in population. As seen in simulations in Fig.
10 and 11, though both controllers can obtain stable
mean cost value under the same cost function and simulation conditions,
the GAPID controller brings premature convergence such that the cost
value and mean value are bigger. Conversely, the PSOPID controller has
better cost value and mean value, showing that it can achieve better accuracy.

Fig. 9: 
The pendulum velocity via GA and PSO based PID control 

Fig. 10: 
Convergence tendency of mean values of pendulum angles
using both methods 

Fig. 11: 
Convergence tendency of standard deviation values of
pendulum angles using both methods 
Table 3: 
Integral Absolute Error (IAE) of system angles 

Simultaneously, we can also find that the convergence tendency of the
standard deviation of cost values in the PSOPID controller is much faster
than the GAPID controller. This can prove that the PSO method has better
convergence efficiency.
CONCLUSION
In this study, a PSObased controller for nonlinear model of the rotary
inverted pendulum system is presented. Through the simulation results,
the proposed controller performs an efficient search for proper PID parameters.
This study demonstrates that PSO method can solve searching and tuning
the controller parameters more efficiently than GA. The proposed method
could be considered as a promising way for nonlinear control systems in
general. The topic of our future researches is to utilize other cognitive
methods in order to achieve better results for designing controller and
improving the performance in real time. Also, implementation of heuristic
algorithms for designing adaptive controllers will be our future challenging
task. Furthermore, teleoperation control of RIP system using haptic device
would be another challenge.
ACKNOWLEDGMENT
The authors would like to appreciate Mr. Abbas Harifi for his assistance
in conducting this research.