Sei sulla pagina 1di 7

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/224164858

Digital implementation of general purpose fuzzy logic controller for


photovoltaic maximum power point tracker

Conference Paper · July 2010


DOI: 10.1109/SPEEDAM.2010.5542207 · Source: IEEE Xplore

CITATIONS READS

7 699

3 authors:

Ali M. Eltamaly Abdulrahman Alolah


Mansoura University King Saud University
115 PUBLICATIONS   754 CITATIONS    94 PUBLICATIONS   949 CITATIONS   

SEE PROFILE SEE PROFILE

Mohamed Yousef Abdulghany


ARM
4 PUBLICATIONS   11 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

HVDC System Control between Different Frequencies Networks and Fault Analysis with HVAC System View project

Multilevel Converter View project

All content following this page was uploaded by Ali M. Eltamaly on 04 June 2014.

The user has requested enhancement of the downloaded file.


SPEEDAM 2010
International Symposium on Power Electronics,
Electrical Drives, Automation and Motion

Digital Implementation of General Purpose Fuzzy Logic Controller for


Photovoltaic Maximum Power Point Tracker
Ali. M. Eltamaly A. I. Alolah M. Y. Abdulghany
EE Dept., King Saud University, Riyadh, Saudi Arabia

Abstract—This paper introduces an implementation of a Logic Controller (GPFLC) is used in a Maximum Power
general purpose fuzzy logic controller for use with general Point Tracker (MPPT) of PV power system as an example
purpose embedded processors. This controller is used in the as shown in Fig.1.
applications of maximum power point tracker of photovoltaic
energy system as an application. However, the proposed model II. DESIGN METHDOLOGY
is very flexible to be applied in various and different C language is the standard language for embedded
applications. The design is made to be scalable in terms of
number of inputs and number of membership functions (MFs)
system programming, most of new processors generations
in both inputs side and output side. The proposed model was are optimized to be efficiently programmable in C. Beside
written in C language due its popularity and efficiency in its nature as a high level programming language, C is very
embedded and control applications. An example of maximum efficient in bit-manipulation which makes C an attractive
power point tracker of photovoltaic energy system with 2- alternative to assembly programming. Adding to all
inputs/7-MFs each and 1-output/7-MFs is used for mentioned advantages of, C is a machine-independent
demonstration and verification purpose. The general purpose language as long as the programmer avoids using of
fuzzy logic controller shows consistency with the result machine-specific features. The proposed model is intended
obtained from simulation. to be a GPFLC that can run on any machine without any
Keywords- Fuzzy, Modeling, Photovoltaic, MPPT, C, restrictions, therefore, C was used as a standard language to
Embedded Control develop this model. An embedded development
environment used to compile and debug the model. Pre-
I. INTRODUCTION computed results compared to system responses for known
Design reuse involves various activities that utilize test vectors.
existing technologies to address new design problems. The
ultimate aim of design reuse is to assist the designers to III. A TYPICAL FUZZY CONTROLLER DESIGN
develop products that maximize the value of the designed A design and optimization methodology suitable for
artifacts with minimal resources, cost and effort [1]. The FLC is presented in [7]. It is illustrated in Fig.2, the block
modern design methodologies involve standard styles of diagram of a FLC inserted in closed loop together with the
programming that allow one piece of code to be used in plant under control. Physically, FLC itself corresponds to
different applications. Such kind of methodologies started the shaded block, wherein the three basic fuzzy operations
with the invention of object-oriented programming are highlighted. The knowledge base provided by an expert
concepts. In order to have a design that is reusable in is also represented in Fig.2. It comprises a data base and a
different applications and can run efficiently on different rule base. The first provides the linguistic variables, their
embedded processors, the designer must take into his term sets, the membership functions shape and position, the
account the underlying architecture of new modern inference method and the de-fuzzification method. The rule
embedded processors and their capabilities. In this paper an base includes the source and the contents of the set of rules,
efficient model of a general purpose fuzzy logic controller which can be derived from modeling the human operator’s
(FLC) is introduced. The model was designed with the actions or from the linguistic description of the controlled
goals to be reusable and in the same time it adheres the plant (i.e. a kind of "fuzzy inverse modeling"). Finally,
computation capabilities of modern embedded processors learning or tuning algorithm adapts the parameters of the
and the underlying architectures. Implementation of FLC on controller by minimizing, for instance, the RMSE (Root
digital tools like FPGA, microcontrollers and DSP has been Mean Square Error) between the desired and actual outputs
shown in the literatures [2-6] but most of them are used in of the plant.
specific application as PV and it can't be used in any other
application without changing in the logic. A. Fuzzification
FLC methods and algorithms, including many In fuzzification stage, each input to FLC is mapped to a
specialized software and hardware are available on the set of MFs. A FLC can have any number of inputs with any
market today. But still the general purpose FLC that can be number of MFs for each input. The most common shape of
used in any application with any numbers of input and MFs is the triangular shape. Fig.3 shows an example of 2-
output parameters and any number of membership functions inputs/7-MFs in triangular shape. For each input/MF pair, a
(MFs) for each parameters are still not available. This is the fuzzy value is computed. A triangle with one side lies on
motivation of this research. The General Purpose Fuzzy the X-axis can be characterized by four constants S, M, E,

978-1-4244-4987-3/10/$25.00 ©2010 IEEE


622
and h as shown in Fig. 4. Where h represents the height of {LowerLimit, UpperLimit}. If the crisp input lies within the
the triangular which should be a constant value for all MFs. MF boundaries; the fuzzy value is calculated and stored to
Given any point on the X-axis (crisp input) lies structure variable Result. Before the routine exists; the
between S and E; the height (fuzzy output) of the structure variable IsActive is set to TRUE or 1. If the crisp
intersection between the vertical line drawn from this point input lies outside the MF boundaries; the routine sets the
and the triangle can be calculated using (1). Equation (1) structure variable IsActive to FALSE or 0 and exits. The
can be reduced to (2) to avoid division operations. The Fuzzy_CalcInputMF C function is generic and can work
following segment in C code is used to model of input MFs. with any input MF regardless of neither its parameters nor
the crisp input.
Segment.1 C Model of an input membership function.

௖௥௜௦௣௜௡௣௨௧ିௌ
݄ൈ ǡ ܵ ൏ ܿ‫ ݐݑ݌݊݅݌ݏ݅ݎ‬൏ ‫ܯ‬
ெିௌ
‫ ݐݑ݌ݐݑ݋ݕݖݖݑܨ‬ൌ ൞݄ ൈ ாି௖௥௜௦௣௜௡௣௨௧ ǡ ‫ ܯ‬൑ ܿ‫ ݐݑ݌݊݅݌ݏ݅ݎ‬൏ ‫ܧ‬ (1)
ாିெ
Ͳǡ‫݁ݏ݅ݓݎ݄݁ݐ݋‬ Fig.1 PV energy system with MPPT.

݇ଵ ൈ ሺܿ‫ ݐݑ݌݊݅݌ݏ݅ݎ‬െ ܵሻǡ ܵ ൏ ܿ‫ ݐݑ݌݊݅݌ݏ݅ݎ‬൏ ‫ܯ‬


‫ ݐݑ݌ݐݑ݋ݕݖݖݑܨ‬ൌ ቐ݇ଶ ൈ ሺ‫ ܧ‬െ ܿ‫ݐݑ݌݊݅݌ݏ݅ݎ‬ሻǡ ‫ ܯ‬൑ ܿ‫ ݐݑ݌݊݅݌ݏ݅ݎ‬൏ ‫ܧ‬ (2)
Ͳǡ‫݁ݏ݅ݓݎ݄݁ݐ݋‬

Where ଵ , and  ଶ are constants given by:


௛ ௛
݇ଵ ൌ , and ݇ଶ ൌ ாିெ
ெିௌ
A data object defined to be used as a variable
representing input MF. A variable of this object should be
declared whenever an input MF is needed. This structure
consists of seven internal variables. The first five variables
define the five constants of MF shown in (2). These five
Fig.2 Block Diagram of design methodology of Fuzzy Logic Controller.
variables must be initialized with respective values
depending on the characteristics of the MF. Variable
number six is used to hold the fuzzy outputs results from
applying any input to this MF. The seventh variable flags
that the MF is active if and only if the input is within the
boundaries {S, E}. The C code segment.1 is the definition
of a new structure type representing an input MF object.
The presented model is scalable in terms of number of
inputs and number of MFs for each input. For a two inputs
fuzzy system; the code segment.2 declares an array of 2x7
elements where the first dimension represent the input
index and the second dimension represents the MF index.
Adding new inputs is as simple as increasing the first
dimension of the array, and adding more MFs is as simple
as increasing the second dimension of the array. Fig.3 Example of 2-input/7-MFs in triangular shape. Typically used
in PV MPPT fuzzy controllers
Segment.2 Example C code to define a system of multi-inputs/multi-MFs.

The calculation of fuzzy value from crisp input is done


using the introduced formula in (2). A C routine (function)
in code segment.3 accepts a pointer to the MF
(FuzzyInputMF structure type) to be calculated and the
crisp input to be applied to this MF. The routine first
compares the crisp input to the MF boundaries {S, E} or Fig.4 Model of an input membership function.

623
Segment.3 C code calculates fuzzy output of a MF from a crisp input. COGx is computed as shown in Fig.5 and given by (4). In
addition to COG, the shaded area shown in Fig.5 is
computed using equations (5) and (6). To have the final
crisp output after the de-fuzzification process, the
equivelant X-coordinate of the cenetr of gravity of all active
output MFs must be computed as shown in Fig.6 and given
by (7). The division operations used in equations (4)-(6) are
completely avoided by choosing H as a power of 2 constant,
therefore the division can be replaced by a simple shift-to-
right operation. In this model, H is set to 214.
In order to simplify output MFs calculations in
suggested implementation; a new data structure written in C
to define a new data type called FuzzyOutputMF which
must be used whenever a new output MF is added to the
system. Code segment.5 is used to define the new data
structure provided to handle output MFs in C code. The
data object FuzzyOutputMF includes all constants required
Each input must be applied to its set of MFs. A C to calculate the required output as stated in (4), (5), and (6)
routine in code sgment.4 implement a loop accepts the and shown in Fig.5. All FuzzyOutputMF object members
index of the input and the crisp input value. In the loop a must be initialized prior to use it.
call to the routine Fuzzy_CalcInputMF is done with new Segment.5 C Model of an output membership function.
MF each time. The loop continues until the crisp input is
applied to all respective MFs.
Segment.4 C routine calculates all MFs fuzzy outputs for a given input.

As in input MFs; a set of MFs can be defined in an


array of type FuzzyOutputMF. Code segment.6 maybe
used to define any number of outputs with any number of
MFs in a single two-dimensional array. Using this
technique, any number of fuzzy outputs may be defined
B. Rules Inference and De-Fuzzification which makes the design applicable to multi-outputs fuzzy
To better understand the fuzzy rules concept, consider designs. For every output, a rules table must be provided.
an example of 2-inputs fuzzy system with 7 MFs each, this
Segment.6 Example C code to define a system of multi-outputs/multi-MFs.
configuration is usually used in PV MPPT tracking system.
Fig.3 shows the MFs used with each input and output. Each
input and output has seven MFs with a maximum
overlapping of 2 MFs at any given input value. The fuzzy C routine shown in code sgement.7 (function
rules help to define which output MF will be active if any Fuzzy_CalcOutputMF) uses the formulas given in (4), (5),
single pair of input MFs are active. and (6) to compute the area and COG output from any
For a two inputs fuzzy system; the fuzzy rules can be FuzzyOutputMF.
written in a two dimensional table as shown in Table-1. The σ೙ ೙
೔సభ ௫೔ σ೔సభ ௬೔
top index in Table-1 is the names of first input MFs. The ‫ܩܱܥ‬ሺܺǡ ܻሻ ൌ ቀ ǡ ቁ (3)
௡ ௡
left index is the names of the second input MFs. Table
௟భ ା௟మ ൈி
entries define the active output MF for every active pair of ‫ܩܱܥ‬௫ ൌ (4)
ସൈு
inputs MFs. Fuzzy outputs from these two functions are
passed to output MFs according the respective fuzzy rule. ிൈ௅
݈௙ ൌ     (5)
There are two fuzzy values result from each fuzzy rule. ு
Only the smallest fuzzy value applied to the output MF. ௟೑ ା௅
The output MF is modeled by the parameters shown in ‫ ܽ݁ݎܣ‬ൌ ‫ ܨ‬ൈ (6)

Fig.5. The de-fuzzification method used here is the center
of gravity (COG) method. The general formula to obtain the σ೘
೘సభ ஺௥௘௔೘ ൈ஼ைீೣ೘
‫ ݐݑ݌ݐݑܱ݌ݏ݅ݎܥ‬ൌ σ೘
(7)
coordinates of COG of a homogonous mass in a 2- ೘సభ ஺௥௘௔೘
dimesional plane is given in (3). Where (š୧ ǡ ›୧ ሻ points are
the coordinates of mass vertices and  is the number of where , ݈ଵ , and ݈ଶ are:
vertices. For every active output MF, the X-coordinate of its ‫ ܮ‬ൌ ‫ ܧ‬െ ܵǡ ݈ଵ ൌ ʹ ൈ ‫ ܪ‬ൈ ሺܵ ൅ ‫ܧ‬ሻǡ ݈ଶ ൌ ʹ ൈ ‫ ܯ‬െ ሺܵ ൅ ‫ܧ‬ሻ

624
Segment.7 C function for output MF calculations.

Fig.6 De-fuzzification using center of gravity.

Figure.7 is a graphical representation of FuzzyRules


The rules inference technique used here enables
array in which multi-dimensional rules lookup table model
maximum design scalability and reuse. The whole idea
is presented. In order to use the FuzzyRules table in the
depends mainly on the power of pointers in C. Every single
design it must be initialized with appropriate pointers to
rule will result in a pointer to the appropriate output MF
output MFs. As an example of initialization process the
object (FuzzyOutputMF ) associated with this rule. The
rules set presented in Table-1 is used. Consider a two input
rules table itself is implemented as 3-dimensional array of a
fuzzy system with single output; the initialization according
type of pointers to FuzzyOutputMF type (pointer to output
to Table-1 for the first rule maybe written in C as shown in
MF associated with each rule in the table). Code segment.8
code segment.9 (assume NB=0, which is the index of NB
defines the rules lookup table. The first dimension of
MF in both input MFs set and output MFs set). If there is a
FuzzyRules array represents the index of associated output
pair of input MFs that have no rule associated with them;
with the subset of rules table. The depth of this dimension
then the pointer maybe set to a NULL pointer which will be
equals to the total number of fuzzy controller output. The
detected by computation routines and skipped as required.
second and third dimension are the indecies of the two input
Code segment.10 shows how to initialize a pointer to
MFs associated with the rule. The depth of the second and
NULL. FuzzyRules maybe extended to support fuzzy
third dimensions should equal the total number of input
systems with more tan 2-inputs. It’s only needed to add a
MFs associated with each input to the FLC.
new dimension to the right of FuzzyRules array for every
Table (2) Rules for a fuzzy system with 2-inputs and 1 output with 7- new input to the system.
membership functions. Segment.9 Example of rules initialization in rules table.
ΔE NB NM NS ZE PS PM PB
E
NB NB NB NB NB NM NS ZE
NM NB NB NB NM NS ZE PS Segment.10 Example of initializing a rule as null (no-rule).
NS NB NB NM NS ZE PS PM
ZE NB NM NS ZE PS PM PB
PS NM NS ZE PS PM PB PB
PM NS ZE PS PM PB PB PB
PB ZE PS PM PB PB PB PB

Segment.8 Array defining rules lookup table.

Fig.7 A Graphical representation of FuzzyRules array.

The rules implication and defuzzification process are


implemented in a single C routine (function
Fuzzy_Defuzzifiy) shown in code segment.11. This
function accepts four argument variables. The first and
second arguments are Input1Index and Input2Index
respectively. Input1Index is the index of an input MFs set
in FuzzyInputs array and Input2Index is the index of
another set. These two sets are the sets on which the rules
Fig.5 Model of output membership function. will be applied. The third variable is OutputIndex which

625
refers to the rules table to be used with this function call Figure-8 is a simplified block diagram showing FPGA
(First dimension in FuzzyRules array). The fourth argument hardware/software configuration used in PV MPPT
CrispOutputPtr is a pointer to a variable in which the controller plus the outside connections to internal logic.
defuzzification result will be returned (the final crisp Xilinx EDK provides a standalone software development
result). The function Fuzzy_Defuzzifiy performs tool (SDK) to develop C software applications to run on
defuzzification using center of gravity technique using MicroBlaze based on configured hardware architecture.
formula shown in (7). Two software projects built and developed in C to run the
presented fuzzy logic controller model. The first project
Segment.11 Example of initializing a rule as null (no-rule). used to verify that logic interprets crisp inputs and perform
all FLC computations and produce the correct output. A
number of test vectors and associated results used to verify
logic functionality. Intensive debugging and tracing to code
execution performed to assure the consistency of the
implemented logic. The second project is the PV control
loop using the fuzzy logic controller presented here.

Fig.8 Simplified block diagram of FPGA controlling PV power system.

To simplify passing of test vectors to FLC and


examining its outputs, a special and simple code written to
allow receiving of test vectors from host computer using a
terminal software (using RS232 port), perform FLC
computation, and return the results back to the host. A
screenshot of the terminal software communicating with
target system is shown in Fig.9. The parameters of
input/output MFs can be introduced to FLC through screen
shown in Fig.9. The measurement shows that the complete
IV. LOGIC VERIFICATION PLATFORM FLC computations can be finished in 22.62us which means
To verify the functionality of the implemented logic, a that FLC can be used in switching frequency less than
sample application used. FLC presented here is used to 44200 Hz.
control a PV power system to operate the PV output at
MPP. The PV controller is based on a Xilinx FPGA
platform. FPGA continues to beat all alternative solutions
due to its high level of configurability. Today the markets
of FPGA expanded and reach low cost control and
embedded applications markets as well as high-end signal
and data processing applications. Xilinx offers Spartan-3E
and Spartan-3A families of FPGAs to address the market
needs for low cost control/embedded applications. A single
FPGA device can hold an embedded soft processor,
processor code and data memory, standard and custom
peripherals, and custom logic at the same time. Due to the
FPGA nature of configurability, one board can be designed
with a single FPGA and can be deployed in different
applications. Xilinx Spartan-3E Embedded Development
Kit (EDK) used here to implement the PV control system Fig.9 Screenshot of terminal software communicating with target to
using the presented fuzzy logic controller. perform fuzzy computations using passed values.

626
the experimental results showing agreet consistance with REFERENCES
the simulation results shown in [8]. Fig.10 shows the [1] S K Ong, Andrew Y C Nee, Q L Xu "Design Reuse in Product
Development Modeling, Analysis and Optimization", World scientific
experimental results of the duty ratio and the voltage output Publishing Co., Singapore, 2008.
from PV system. The signal in the first trace is the output [2] M. Nikoz, H. Dehbonei, C.Naher, A DSP-controlled photovoltaic
from FPGA with a peak voltage 3.3V. The output voltage system with maximum power pointtracking, Electrical engineering and
from the photovoltaic in the next trace is around the values information technology ITEE, 1-6, Australie 2003.
[3] S.Poorani, T.V.S.Urmila Priya, K.Udaya Kumar and
from simulation of [8].
S.Renganarayanan" FPGA Based Fuzzy Logic Controller for Electric
Vehicle" Journal of The Institution of Engineers, Singapore Vol. 45
Issue 5 2005.
[4] M. McKenna and B. M. Wilamowski, ”Implementing a fuzzy system
on a field programmable gate array”, Proc. Int. Joint Conf. on Neural
Networks, Vol. 1, Jul. 2001, pp. 189-194.
[5] G. Mermoud, A. Upegui, C. A. Peña-Reyes, and E. Sanchez, "A
Dynamically- Reconfigurable FPGA Platform for Evolving Fuzzy
Systems", in The 8th International Work-Conference on Artificial
Neural Networks (IWANN'2005), 2005.
[6] A. Cabrera, S. S´anchez-Solano, R. Senhadji, A. Barriga, and C. J.
Jim´enez, ”Hardware/software codesign methodology for fuzzy
controllers implementation”, Proc. IEEE Int. Conf. on Fuzzy Systems,
May 2002, pp. 464-469.
[7] Godjevac J., "Neuro-Fuzzy Controllers Design and Application",
Presses Polytechniques et Universitaires Romandes, Lausanne,
Switzerland, 1997.
[8] Ali. M. Eltamaly " Modeling of Fuzzy Logic Controller for
Photovoltaic Maximum Power Point Tracker", Solar Future 2010
Conf. Proc., Istanbul, Turkey, Feb.2010, pp.4-9.

Fig.10 Experimental results of the duty ratio and the voltage output from
PV system.

V. CONCLUSIONS
This paper introduced an efficient implementation for a
fuzzy logic controller. The model implemented in C language
for portable, flexible and efficient usage on general purpose
embedded processors. Only standard and non-floating data
types are used for maximum portability and efficiency. The
model is scalable in terms of number of inputs, outputs, and
membership functions. Triangular shapes of MFs used as an
example, however irregular shapes maybe implemented
following the same concepts. The rules implication technique is
extremely flexible and efficient using the power of pointers in
C. Pointers in C are well supported by advanced addressing
modes in modern processors. Example project based on a soft
processor inside FPGA has been used for logic verification.
The design proved its correctness by given correct answers to
known test vectors. The design has an outstanding
performance of 44200 loops per second for a typical
configuration used in PV MPPT tracking systems.
Experimental results from the proposed fuzzy logic controller
shows agreed consistence with the previous published
simulation results.

VI. ACKNOWLEDGMENT
Authors would like to thank the research center of faculty
of engineering, King Saud University and SABIC company for
their financial and technical support during the preparation of
this research.

627

View publication stats

Potrebbero piacerti anche