You are on page 1of 12

Design of PID and FOPID Controllers tuned by Firefly

Algorithm for Magnetic Levitation System


1

Lalbahadur Majhi, 2Prasanta Roy, 3Binoy Krishna Roy


1, 2, 3

Department of Electrical Engineering


National Institute of Technology, Silchar
Silchar, India

lbmajhi@gmail.com, proylinux@gmail.com, bkrnits@gmail.com

Abstract. This paper concerns design and implementation of PID and Fractional
Order PID (FOPID) controllers to control position of an electromagnetically suspended ferromagnetic ball in a Magnetic Levitation (Maglev) system in real time.
The Maglev system, manufactured by Feedback Instruments (Model No 33-210)
is used as a platform to test the performance of proposed controllers. Parameters
of PID and FOPID controllers are tuned by Firefly Algorithm (FA). FA is a
metaheuristic algorithm based on movement of fireflies towards more attractive
and brighter ones. PID and FOPID controllers are implemented in MATLAB and
Simulink environment inside PC. The PC is connected to the Maglev system
through Advantech card. Effectiveness of proposed controllers is tested by
checking the ability of the suspended ball to track a reference signal. Step change,
sine wave, and square wave are used as reference signals. Real time results have
revealed satisfactory transient and steady state responses over the contemporary
existing controllers. FOPID controller showed better results compared to PID.
Keywords: Magnetic levitation; PID; FOPID; Firefly Algorithm;

Introduction

1.1

Basic Principle of Magnetic Levitation system

In a Maglev system a ferromagnetic object is levitated against gravity and its position
is controlled using electromagnetic force of attraction [1]. Due to absence of mechanical contact frictional forces get eliminated. Hence, system efficiency get enhanced.
Magnetic levitation technology is used in various engineering applications like highspeed trains, levitation of wind turbine, personal rapid transit etc. Actual position of the
levitated object is measured by a sensor. Based on the difference between desired and
actual position of the suspended object a controller can inject suitable current to electromagnetic coil which generates required force on the ferromagnetic object to control
its position and make it able to track a reference signal [1]. Without the presence of a
controller Maglev system is inherently unstable. The relation between force, current,
and position is nonlinear.

1.2

PID & FOPID Controller

As discussed in section 1.1, presence of a controller in Maglev system is mandatory


otherwise system will become unstable. PID controller is simple to design and implement as well as cost-effective. It also shows acceptable robustness. Therefore, in spite
of availability of sophisticated and advanced controllers, PID controller has been chosen
in this paper. Many researchers have shown in recent past that FOPID controller has
greater potential over PID due to its extra two degrees of freedom in term of its noninteger order of derivative and integration. One of such literatures is given in [2]. Therefore, FOPID controller has been chosen as another controller for this system.
1.3

What is Firefly Algorithm (FA) and why to tune PID and FOPID by FA?

Firefly Algorithm was based on social behavior of fireflies flying in the tropical summer sky. They communicate with each other, search for mates and prey using bioluminescence with varied flashing patterns. Mimicking the characteristics of their movement, an optimization algorithm was designed by Yang in 2010 [3]. Brightness of flashing of fireflies was taken proportional to the objective function. Details of the algorithm
will be discussed later in this paper. In [5], Firefly algorithm has been successfully used
to tune the PID parameters for a set of test plants.
Fractional order controller dynamics is governed by fractional order differential equation. Fractional order differential equation is very complex to analyze mathematically.
Hence, finding out FOPID parameters by classical mathematics is a challenging task.
Intelligent algorithm like FA, does not require to analyze or solve the internal dynamics
of the controller. Rather, it does a methodical search to find suitable values of PID
parameters

( K P , K I and K D ) and

FOPID parameters

( K P , K I , K D , and )

for

which a performance index (PI) is minimized. The PI is a measure of controller performance. It is generally a function of error signal.

Functional description of Magnetic Levitation System

As shown in Fig. 1, the Maglev unit, manufactured by Feedback Instruments (Model


No 33-210) consists of a connection interface panel with a mechanical unit on which
an electromagnetic actuator coil is mounted. A ferromagnetic ball is used as levitated
object. An infra-red (IR) sensor is attached at the middle of the unit. A desktop computer is connected with the mechanical unit through Advantech card. MATLAB and
Simulink environment inside computer serve as main control unit [6]. Infra-red sensor
measures the vertical position of the ferromagnetic ball and passes this information to
the controller inside the digital computer through an ADC interface. Controller compares measured position of the ball with reference input position. It adjusts the current
through the electromagnetic actuator to control the required force so that the levitated
ball position is stable and it can follow a reference trajectory about an operating point.
Manufacturer of the Maglev system (Model No 33-210) has also provided an inbuilt
PID controller [6].

Modelling of Maglev System by System Identification

As discussed in 1.1, Maglev system is an open loop unstable system. So, open loop
identification is not possible. However it can be identified by close loop identification.
Identification is carried out following the steps given in [6] and [7].

Fig. 1. Magnetic Levitation system (Feedback 33-210)

In [6] and [7] a PD controller is used to make the system stable as shown in Fig. 2.
Excitation signal r t was chosen to be a random binary sequence. Using offline real
time data in MATLAB CONTSID Toolbox, a transfer function is obtained between
r t and y t .From the block diagram of Fig. 2 eqn. (1) can be written as below.

Y (s)
G(s)

R
(
s
)
1

C
( s )G ( s )

yd 0

T (s)

(1)

C (s) (4 0.2s)

(2)

The PD controller has a transfer function

G(s) has been calculated using eqn. 1 and eqn.2 and given in eqn. 3.

G( s)

0.00296s3 0.7351s 2 87.08s 4581


s3 83.86s 2 2158s 1352

(3)

Fig. 2. System with PD controller

Controller Design

4.1

PID & FOPID controller dynamics

The transfer function of PID and FOPID controllers are given in eqn. 4 and eqn. 5
respectively with usual notations. The parameter and stands for the order of integration and derivative respectively.

K
E (s)
U (s)
K
E (s)

U (s)

4.2

KI

I K D s

s
K

KD s

(4)

(5)

Selection of Performance Index

Performance index of a controller is generally a function of error signal e(t ) . It gives


a quantitative measure to evaluate the performance of a controller. For a PID and
FOPID controlled system Integral Square Error (ISE) is one of the obvious choices as
performance index. Therefore, ISE has been taken as performance index for Firefly
Algorithm in this paper. Mathematical description of ISE is given in eqn. 6.

J ISE

e t dt ;
2

(6)

4.3

Tuning of controller parameters using Firefly Algorithm

Firefly Algorithm is a nature inspired algorithm based on the movement and flashing
characteristics of fireflies. It consists of three particular idealized rules which are based
in major flashing characteristics of fireflies [3, 4]. These are as follows:
All fireflies are unisex, so that one firefly will be attracted to all other fireflies regardless of their sex [3, 4].
Attractiveness is proportional to their brightness. Thus between any two firefly the
less brighter one will move towards more brighter one. The degree of attractiveness
is proportional to the brightness which decreases as their distance increases. If there
is no brighter one than a particular firefly, then it will move randomly [3, 4].
The brightness of the firefly is determined by the landscape of the objective function
or performance index [3, 4].
For an optimization problem, the brightness is associated with the fitness function in
order to obtain efficient optimal solutions. In this algorithm, when searching for solutions two main procedures are followed: i) attractiveness and ii) movement, which are
defined as follows:
Attractiveness.
The form of attractiveness function of a firefly is the following monotonically decreasing function [3, 4].
r
r 0e ; m 1
m

In eqn. 7, r is the distance between any two fireflies,

(7)

is the initial attractiveness at

r 0 , and is the absorption parameter which controls the decrease of light intensity.
The distance rij between ith and jth fireflies, at position
governed by eqn. 8 [3, 4].

rij X i X j

Xi

and X j respectively, is

xik x jk

k 1

Where xik is the kth component of the spatial is coordinate of the ith firefly
and d is the dimension number.

(8)

( Xi )

Fig. 3. Flow chart of Firefly Algorithm

Movement.
Movement of ith firefly which is attracted by a brighter jth firefly is governed by eqn. 9
[3, 4].

X in 1 X in 0 e

r X n X n rand () 1
j i

ij

(9)

X in and X in1 are the present and future position of a firefly respectively. The second term in eqn. 9 is used for considering a fireflys attractiveness to light intensity
seen by adjacent fireflies. The third term in eqn. 9 is used for the random movement of
a firefly in case there are not any brighter ones. The coefficient is a randomization
parameter determined by the problem of interest, while rand () generates is a vector of

uniformly distributed random number in d dimensional space. Whole optimization


process can be summarized in a flowchart given in Fig.3 [3, 4, 5].
A pseudo code representation of Firefly Algorithm is given in Table 1 [3, 4, 5].
Table 1. Pseudo code representation of Firefly Algorithm

Procedure for the Firefly Algorithm


Begin
Initialize algorithm parameters
Define the objective function of f(x), where
x=(x1,.xd)
Generate the initial population of fireflies of
xi (i=1, 2, n)
Determine the light intensity of Ii at xi via
f(xi)
While (t<MaxGen)
For i=1 to n (all n fireflies)
For j=1 to n (n fireflies)
If (Ij>Ii),move firefly i towards j;
end if
Attractiveness varies with distance r via
exp(- r2);
Evaluate the new solutions and update light
intensity;
End for j loop;
End for I loop;
Sort and rank the fireflies and find the current
best one;
End while;
Post process results and visualization;
End procedure
For PID and FOPID tuning purpose, initializing parameters chosen for FA are shown
in Table 2.
Table 2. Initializing parameters for Firefly Algorithm

Number of fireflies (n) 40


Randomness ( ) 0.5

Absorption coefficient ( ) 1
Initial attractiveness, (0 ) 0.2

Generation number ( N g ) 500

Index of r (m) 2

The optimization process is continued until there is no significant changes in the value
of PI is found for 100 consecutive iterations or when all the generations are completed.
Optimized controller parameters are shown in Table. 3.
Table 3. Optimized controller parameters found by FA

Controller
PID
FOPID

KP
3.6947
4.06893

KI
1.7276
1.8281

KD
0.45143
0.12244

----0.4356

----0.1707

The simulated step responses of the system using PID and FOPID tuned by FA is shown
in Fig. 4.

Fig. 4. Simulated step responses using PID and FOPID controllers tuned by Firefly algorithm

4.4

Implementation PID and FOPID controllers in Maglev system

Designed PID and FOPID controllers in sec 4.3 are implemented in real time using
MATLAB and Simulink environment through digital computer which is connected to
the Maglev mechanical unit through Advantech Card. An additional MATLAB
toolbox, Fractional Order Modelling and Control (FOMCON) is installed inside Simulink environment to generate fractional order transfer function of FOPID controller
[8]. Due to large initial error integral action at initial stage may increase the control
signal to a very high value. It can cause a high overshoot and can also make the system
unstable. Even it can push the ball beyond the sensor operating region. Hence, in the
first 15 sec only PD controller is used to stabilize the ball. After 15 sec integral action
is turned on to reduce steady state error.

Results and discussions

In the simulated step responses in Fig. 4 FOPID controller tuned by FA shows the
better result (overshoot 0.528% and settling time 0.327 sec) than that of PID (overshoot
0% and settling time 0.783 sec). Although in terms of overshoot PID is better but 0.582
% overshoot is negligible in case of FOPID. Moreover due to very short settling time,
tracking of a reference signal will be better in case of FOPID. Real time results in Fig
5 to Fig. 10 clearly indicate that FOPID controller tuned by FA is working much better
than PID controller in terms of tracking of a reference signal.

Fig. 5. Real time response using PID controller tuned by FA with step change as reference input.
(Only PD controller is applied for 1st 15 sec)

Fig. 6. Real time response using PID controller tuned by FA with square wave signal as reference
input. (Only PD controller is applied for 1st 15 sec)

Proposed controllers in this paper work better than the system inbuilt PID controller
[6] designed by the manufacturer, in terms of tracking a reference signal. In [9] FOPID
controller is designed for a magnetic levitation system by minimizing various performance indices like ISE, ITSE, IAE, ITAE using classical optimization technique. But
real time results in [9] contains much higher overshoot (10% to 15 %) and settling time
(8 to 10 sec.) than this paper.

Fig. 7. Real time response of the system using PID controller tuned by FA with sine wave signal
as reference input. (Only PD is applied for 1st 15 sec).

Fig. 8. Real time response of the system using FOPID controller tuned by FA with step change
signal as reference input. (Only FOPD is applied for 1st 15 sec)

Fig. 9. Real time response using FOPID controller tuned by FA with square wave signal as reference input. (Only FOPD is applied for 1st 15 sec).

Fig. 10. Real time response using FOPID controller tuned by FA with sine wave signal as reference input. (Only FOPD applied for 1st 15 sec)

Conclusions and future scope

Results justify that Firefly Algorithm is a suitable and reasonably simple tool to tune
PID and FOPID controllers parameters. Although several tuning procedures are available for PID controller but most of them are applicable for linear system only. However,

number of techniques to find FOPID controller parameter is very limited till date, due
to its fractional order dynamics. FOPID works better than PID due to its extra two degrees of freedom in terms of non-integer order of derivative and integration. Comparisons with literatures also justify that FOPID controllers tuned by Firefly Algorithm
works better than several existing controllers. Step change, square wave and sine wave
are used as reference signals in this paper. A more complex reference signal like random signal will be used in future. The robustness of the controller due to variation of
system parameters and external disturbances is not tested which may be taken into account in future.

References

1. I. Ahmad, and M. A. Javaid, Nonlinear model & controller design for Magnetic levitation
system, 9th WSEAS international conference on Signal processing, robotics and automation, 2010, Cambridge, UK.
2. I. Podlubny, L. Dorcak, and I. Kostial,On fractional derivatives, fractional-order dynamic
systems and PID controllers, 36th IEEE Conference on Decision and Control, 1997, San
Diego, US.
3. X. S. Yang, Firefly Algorithm in Nature Inspired Metaheuristic Algorithm, 2nd ed., UK
Luniver Press, 2010, ch 10 pp.81-89
4. A. H Gandomi, Xin-She Yang, and A.H. Alavi, Mixed Variable Structural Optimization
using Firefly Algorithm, Computers and Structures, ELSEVIER, vol. 89, pp 2325-2336,
2011.
5. O. Bendjeghaba, S. I. Boushaki and N. Zemmour, Firefly algorithm for optimal tuning of
PID controller parameters, Fourth International Conference on Power Engineering, Energy
and Electrical Drives, 2013, Istanbul, Turkey.
6. http://www.feedback-instruments.com/products/education/control_instrumentation/magnetic_levitation_system (Manual of Maglev system Model No 33-210)
7. L. Majhi, M. Borah and P. Roy, Fractional Order System Identification of Maglev Model
from Real-Time Data, IEEE International Conference on Advanced Communication Control and Computing Technologies, 2014, Ramanathapuram, India.
8. A. Tepljakov, E. Petlenkov, and J. Belikov, A Flexible MATLAB Tool for Optimal Fractional-order PID Controller Design Subject to Specifications, in Proceedings of the 31st
Chinese Control Conference, Hefei, Anhui, China, 2012, pp. 46984703.
9. H. Gole, Harshit, P. Barve, A. A. Kesarkar, and N. Selvaganesan, Investigation of fractional
control performance for magnetic levitation experimental set-up, International Conference
on Emerging Trends in Science, Engineering and Technology (INCOSET), 2012, Tiruchirappalli, India.

You might also like