You are on page 1of 5

International Journal of Computer Applications (0975 – 8887)

Volume 73– No.4, July 2013

Algorithm for a PSO Tuned Fuzzy Controller of a DC


Motor

Debasmit Das Arka Ghosh


Department of Electrical Engg. Department of Electrical Engg.
Indian Institute of Technology, Indian Institute of Technology,
Roorkee, India Roorkee, India

ABSTRACT 2.1 Membership Functions


Determination of the parameters of the membership functions Each of the inputs have 3 membership functions – for
of a fuzzy logic control process is the crucial factor for Negative, Zero and Positive. The MFs are chosen to be
providing optimum performance of the system. These triangular in shape. There is only one output i.e. Voltage
parameters are regarded as variables and are tuned through which is fed to the armature of the DC Motor . The Voltage
Particle Swarm Optimization (PSO). The shape of the also has 3 MFs – Negative, Zero, positive but it is not required
membership functions vary according to the variables. to be optimised. Since the input to the fuzzy controller deals
Consequently, the fuzzy control output changes and so does with the quantity to be controlled only the Input MF is
the performance. The results give an insight to the efficiency sufficient to be optimised. Mamdani (Fuzzy inference System)
of PSO in producing optimum membership functions in real FIS has been used. For each triangular membership function
time. This controller can be applied to various control systems there are 3 parameters a,b,c. Since there are 3 MFs for a
like AGC(Automatic Generation Control), DC motors etc.. particular input there are a total of 9 parameters for a
Demonstration for the latter is shown in this paper. particular input. Since there are 2 inputs so there are a total of
18 parameters for each input. The membership functions of
General Terms one input is shown.
Swarm Optimization Algorithms, Fuzzy Controller
Optimization

Keywords
MF, MATLAB, SIMULINK, PSO, Fuzzy.

1. INTRODUCTION
For the tuning of the parameters of the membership
functions of a fuzzy controller a novel PSO algorithm has
been developed. The algorithm for the fuzzy controller has
been encoded in MATLAB but a block diagram strategy is Fig 1: Membership Functions and their Parameters
enabled to explain the algorithm. A SIMULINK model has
been used.The Plant used is an armature controlled DC Motor. As can be seen in Fig1 a1,b1,c1 corresponds to membership
Conventional controllers like PI and PID controllers fail in function Negative . a2,b2,c2 corresponds to membership
case of non linearities and may generate steady state error[1]. function Zero. a3, b3, c3 corresponds to membership function
In such a case a fuzzy controller is used which is basically a Positive. These parameters have to be tuned such that the
non-linear element whose parameters are tuned using Particle steady state error is zero. Again in this case a1 ,b1 and b3,c3
Swarm Optimization Technique (PSO) subject to the will be fixed since they deal with extreme or maximum errors
condition that steady state error is to be minimized. The or change in errors and b2 will be fixed and centred at zero.
quantity to be controlled is the speed of the DC Motor. Conditions like a1<b1<a2 and c2<b3<c3 also need to be
Therefore error in speed is to be minimized. PSO technique is satisfied. a2<c1 ; c1<b2; b2<a3; a3<c2. These conditions are
a very uncertain algorithm that may or may not converge to dealt with by the PSO algorithm to be explicated later. So it
the optimized values. Nevertheless we got optimistic can be seen that there are 8 parameters to be tuned. The PSO
simulation results. As such it could overcome the limitations algorithm is required to be discussed. The PSO is an
of conventional controllers[1]. optimization technique that optimizes a problem by
sequentially trying to improve the candidate solution. It does
2. FUZZY CONTROLLER AND PSO not guarantee an optimal solution[2]. There is a need to
A Fuzzy Controller is characterised by inputs and outputs. produce zero steady state error in speed by we optimising the
The inputs and outputs are correlated by Membership parameters of the fuzzy controller. In a way fixing the
Functions (MF). In this case there are two inputs 1) Error of objective function as a function of speed is not possible as it is
speed. 2) Change in Error of speed. not the output of the fuzzy controller. The output of the fuzzy
controller is voltage. But the voltage more precisely has a
dependence on the speed we want. So the objective function
should include voltage rather than speed . In other words the

37
International Journal of Computer Applications (0975 – 8887)
Volume 73– No.4, July 2013

objective function for PSO should be a function of output of k iteration number


the fuzzy controller. The details of how the objective function v velocity
is found out is given in the next section. Now discussion will x particle co-ordiante
be on the PSO algorithm[3]. The PSO search space is c1,c2 acceleration constant normally set to 2
multidimensional. The dimension is determined by the w inertia weight factor
number of variables whose value we are to find. In this case rand() random number between 0 and 1
the dimension is 8. A point in the space is referred to as a
particle. Each particle moves in the search space with a In this way the particle moves about in space and for each
velocity dependent on its own flying experience and it’s iteration it checks for the optimization of the objective
companions’ flying experience. Each particles keeps a note of function. The next section will be about the working model
its best solution (best evaluating value of the objective and the implementation of the algorithm.
function) which is termed as personal best (pbest). The global
best (gbest) is the best solution in the whole group. In each
iteration the velocity and the position is updated according to
3. SIMULINK MODEL AND THE
the following rule[4]. ALGORITHM
2.2 PSO Variables The SIMULINK model[5][6] used is given in Fig 2. As can be
seen the error and rate of change of error of speed has been
For example let the jth particle be represented by x j=
normalized and is fed into the fuzzy controller as Input [7].
(xj1,xj2,xj3,...xjg) in the g dimensional space. The best previous
The Minor Feedback loop in the model is that of a Armature
position of the jth particle is pbest j=(pbestj1,pbestj2,...pbestjg).
Controlled DC Motor. Hence, the input of the Minor
The best particle corresponds to gbestg. The velocity of the
Feedback loop is the Armature voltage which is also the
particle j is represented as vj=(vj1,vj2,.....vjg). The new velocity
output of the Fuzzy controller. The Minor Feedback path is
and new position for a particular iteration k+1 is as :
that of the Back EMF of the DC Motor. The Output MF
vjg(k+1)=w.vjg(k)+c1*rand()*(pbestjg–xjg(k))
parameters need not be optimized. The objective function
+c2*rand()*(gbestg – xjg(k))
F(i)=0.5 – Output of the Fuzzy Controller. The output of the
Fuzzy controller has been evaluated using the evalfis() of
xjg(k+1) = xjg(k)+vjg(k+1)
MATLAB[8]. The value 0.5 has been calculated as per the
set point speed of 23 SI Units. Using the equation E=K*N
j=1,2.......n
putting N=23 SI we get E as 0.5 and since the normalisation
g=1,2,.......m
constant (in the SIMULINK Block diagram) is unity. The
where
constant load torque has been assumed for the motor and
n number of particles in a group
shown by the input to the second summer in the minor loop.
m number of members in a particle

Fig 2: The Simulink Model

38
International Journal of Computer Applications (0975 – 8887)
Volume 73– No.4, July 2013

Description of the algorithm for tuning the fuzzy 4. RESULTS


controller[9]: Results are obtained for two cases firstly by keeping the set
point constant and then varying the set point.
1) The no. of particles (n) is to be 30. The number of
iterations (i) is 20. 4.1 Fixing Set Point
2) Since 8 variables need to be optimised therefore the The set point of the speed is set to 23 SI units and the PSO
paricle is 8 dimensional. code is executed two times. Therefore two transient responses
3) For each particle (1 to 30) the following is done: are obtained with negligible steady state error. As expected
a) The particle’s position i.e. the parameters of oscillations occur because the presence of inductance in
MFs is initialized using the rand(). For e.g. armature circuit has been assumed. So the following tables
rand(1) gives a random number between 0 and and graphs are plotted.
1. -1+rand(1)*2 gives random number between
-1 and +1. So the lower and upper boundaries Table 1. Parameters for setpoint 23 SI Units for first PSO
of the search space are also set in this way. execution
Thus the constraints on the MF parameters can
be set
Error in speed
b) The particle’s best known position is initialized
to initial position.pi < - xi -1.8 -1 -0.0596
c) If F(pi)<F(g) the swarm’s global best position
is updated g < - pi -0.0942 0 0.1270
d) The initial velocity is set to 0. 0.0124 1 1.8
4) Until i>20 or minimum error tolerance has been
achieved the following is repeated : Error in rate of speed
a) For each particle (1 to 30) :
(i) For each dimension (1 to 8) : -1.8 -1 -0.0673
 Velocity of each particle is -0.0941 0 0.1982
calculated and updated
(ii) The particle’s position is also 0.0126 1 1.8
updated
b) If F(xi)< F(pi)
(i) Update the particle’s best known
position pi < - xi
(ii) If F(pi)<F(g) the swarm’s best
known position is updated: g < - pi
5) The M-File where the algorithm is encoded is
executed
6) Hence, the optimum values of the 8 parameters are
found and fed into a matrix. The other fixed values
are clubbed with it to form a 6 X 3 Matrix.
7) The Matrix is fed into the FIS Structure using the
function setfis().
8) The FIS Structure is uploaded into the SIMULINK
Fuzzy controller block and then the Model is
Simulated.
pi positon vector of personal best
g position vector of global best
Fig 3: Speed Response for parameters of Table 1
xi postion vector of a particle
i iteration index
Table 2. Parameters for Set Point 23 SI Units for
For the Set points of 25 and 30 SI the objective function is second PSO execution
calculated using the equation described. For Set Point 25
E=0.543 and objective function F(i F(i)=0.543 – Output of the Error in speed
Fuzzy Controller. For Set Point 30 E=0.543 and objective -1.8 -1 -0.0673
F(i)=0.652 – Output of the Fuzzy Controller. So in the
algorithm the objective function is changed for each set point -0.0942 0 0.1274
in the way mentioned above. Accordingly results are obtained
as shown in the next section. 0.0945 1 1.8
Error in rate of speed
-1.8 -1 -0.0274
-0.0339 0 0.0367
0.0345 1 1.8

39
International Journal of Computer Applications (0975 – 8887)
Volume 73– No.4, July 2013

Table 4. Parameters for Set point 30 SI Units

Error in speed
-1.8 -1 -0.0567
-0.0630 0 0.1296
0.1143 1 1.8
Error in rate of speed
-1.8 -1 -0.0789
-0.0959 0 0.1279
0.0568 1 1.8

Fig 4: Speed Response for parameters of Table 2

4.2 Varying Set Point


Now the PSO algorithm is run for different set point. Only
single execution of the algorithm is used for the two set points
of 25 and 30 SI Units. The results obtained are given below.

Table 3. Parameters for Set point 25 SI Units

Error in speed
-1.8 -1 -0.0396
-0.218 0 0.1345
Fig 6: Speed Response for the parameters of Table 4
0.0745 1 1.8
Error in rate of speed
5. CONCLUSION
-1.8 -1 -0.0890 The PSO tuned Fuzzy controller was simulated on the plant.
-0.9800 0 0.4560 The plant was chosen to be an armature controlled DC Motor
with speed being the quantity to be controlled. The algorithm
0.0345 1 1.8 for tuning the paramaters of the membership functions of the
Fuzzy controller has been developed. The optimized
parameters so obtained is fed into the SIMULINK Block of
the fuzzy controller and results obtained for various Cases.
Steady error has been made zero. Response is oscillatory
because of presence of inductance in armature circuit. Fig. 3
shows the best response with very little overshoot.

6. ACKNOWLEDGEMENTS
We would like to thank Dr. Rajendra Prasad, Department. Of
Electrical Engineering, Indian Institute of Technology,
Roorkee, for constantly supporting and advising on our
project. Moreover we would like to thank Institute Computer
Cente, Indian Institute of Technology, Roorkee for providing
us the software MATLAB/SIMULINK without which the
project would not have been possible.

.
Fig 5: Speed Response for the parmeters of Table 3

40
International Journal of Computer Applications (0975 – 8887)
Volume 73– No.4, July 2013

7. REFERENCES
[1] S.K.Sinha, R.N. Patel, and R. Prasad “Application of GA [5] Dipraj, and Dr. A.K. Pandey, “Speed control of a D.C.
and PSO Tuned Fuzzy Controller for AGC of Three Area Servo Motor By Fuzzy Controller ,” International Journal
Thermal-Thermal-Hydro Power System” International of Scientific & Technology Research Volume 1, Issue 8,
Journal of Computer Theory and Engineering, Vol. 2, September 2012
No. 2 April, 2010 [6] Mehmet Cunkas, Omer Aydogdu “ Realization of Fuzzy
[2] Qinghai Bai “ Analysis of Particle Swarm Optimization”, Logic Controlled Brushless DC Motor Drives using
Computer and Information Science, February 2010 MATLAB/SIMULINK”, Vol.15, No.2, 2010
[3] Saeed Vaneshani and Hooshang Jazayeri-Rad, [7] J.V. de Oliviera “Semantic Constraints for membership
“Optimized Fuzzy Control by Particle Swarm function optimization”, IEEE transactions on Systems,
Optimization Technique for Control of CSTR,” World Man and Cybernetics, January 1999
Academy of Science, Engineering and Technology 59 [8] R.N. Patel, S.K.Sinha, and R. Prasad, “Design of a
2011 Robust Controller for AGC with Combined Intelligence
[4] Zwe-Lee Gaing, “A Particle Swarm Techniques,” World Academy of Science, Engineering
OptimizationApproach for Optimum Design of PID and Technology 21 2008
Controller” IEEE transactions on Energy Conversion, [9] The Wikipedia website. [Online]. Available:
Vol 19, No. 2, June 2004 http://www.wikipedia.org/

41
IJCATM : www.ijcaonline.org

You might also like