A Methadology for Designing Fuzzy Logic Controller using VHDL Virendra K. Verma

advertisement
International Journal of Engineering Trends and Technology (IJETT) – Volume 24 Number 4- June 2015
A Methadology for Designing Fuzzy Logic
Controller using VHDL
Virendra K. Verma#1, sarika sapre#2
#
HOD EC Dept., SIMS Indore, India
#
SIMS Indore, India
*
SIMS Indore, India
Abstract- This paper based on implementation of fuzzy logic
controller (FLC). This paper initiates with the introduction to general
purpose fuzzy logic controller and modernized implemented FLC.
The FLC can be implemented by using Very high speed integrated
circuits Hardware Description Language (VHDL) code. VHDL has
been used to develop simple FLC on FPGA (field programmable
Gate Array). The controller algorithm can be developed synthesized,
simulated and implemented on FPGA Spartan 2E XCV300-6BG432.
In recent years, there is steady increase in development and
implementation of fuzzy logic controller using FPGA and ASIC. To
combine VHDL based logic synthesis for designing complex
hardware and VHDL design capture, there have been many attempts
has taken place. The major benefit of incorporating high level
approach is that, the design time is reduced significantly and
different ways of designing a rule base can be explored.
Keywords -VHDL, FLC, FPGA, Spartan, ASIC.
A.Characteristics of Fuzzy Logic
Fuzzy dedicated circuits are characterized by[18] :
The number of inputs and outputs.
The number and shapes of membership functions
Inference techniques including operators, consequences, and
size of the premises.
Defuzzification method. The number of fuzzy logic inferences
per second,
FLIPS Physical size.
Power consumption.
Software available to support the design
II. BENEFITS OF FUZZY CONTROLLERS
The benefits of fuzzy controllers could be summarized as
follows:
I.INTRODUCTION
Fuzzy logic refers to a logical system that generalizes the
classical two-value logic for reasoning under uncertainty. It is
a system of computing and approximate reasoning based on a
collection of theories and technologies that employ fuzzy sets,
which are classes of objects without sharp boundaries. More
specifically, fuzzy logic generalizes the crisp true-and- false
(or black-and white) concept fundamental to classical logic to
a matter of degree. The two key features of fuzzy logic
include:
(a) A mathematical formalism for representing human
knowledge involving vague concepts.
1. Validation, consistency, redundancy and completeness can
be checked in rule base (knowledge acquisition supervision
)that could speed up automated learning and improve user
interpretability.
2. Fuzzy controllers are more robust than PID controllers
because they can cover a much wider range of operating
conditions than PID can, and can operate with noise and
disturbances of different nature.
3. Developing a fuzzy controller is cheaper than developing a
model-based or other controller to do the same thing.
(b) A natural but effective mechanism for systematically
formulating cost-effective solutions to complex problems
characterized by uncertainty or imprecise information.
4. Fuzzy controllers are customizable, since it is easier to
understand and modify their rule, which not only use a human
operator's strategy, but also are expressed in natural linguistic
terms.
The fuzzifier and defuzzifier components of the fuzzy system
are described using VHDL code as it involves considerable
amount of mathematical computations.There are three parts to
a fuzzy controller, the fuzzification of the inputs, the
defuzzification of the outputs, and the rule-base.
5. It is easy to learn how fuzzy controllers operate and how to
design and apply them to a concrete application. It is also
worth to notice that fuzzy logic can be blended with
conventional control techniques. This means that fuzzy system
does not necessarily replace conventional control methods. In
ISSN: 2231-5381
http://www.ijettjournal.org
Page 217
International Journal of Engineering Trends and Technology (IJETT) – Volume 24 Number 4- June 2015
many cases fuzzy systems augment them and simplify their
implementation [8], [7].
III.SOFTWARE SELECTION
There are a number of different software that could be used as
a template for the fuzzy logic controller. Xilinx can be used to
integrate easy computation widely available toolbox and
dedicatedintegratedcircuit .combine regulation algorithm and
logic reasoning allowing for integrated control scheam.it
become one of the most successful technology for developing
the system which require a real time operation. When a
program execute and implement in anvhdl code can have very
short execution time due to high degree of parallelism of
itsarchitecture. This software has high speed and low cost and
also easily available. Fuzzy logic can be directly implemented
on FPGA as compared to C and matlab so fuzzy gives a better
result. I choose this project because I believe this project will
enhance my knowledge of embedded system and basic
programming.
IV.STRUCTURE OF FUZZY LOGIC CONTROLLER
Fuzzy logic has rapidly become one of the mostSuccessful of
today's technologies for developingsophisticated control
systems. With its aid, complexRequirements may be
implemented in amazingly simple, easily maintained, and
inexpensive controllers. Fuzzy control use only a small portion
of the fuzzy mathematics that is available, this portion is also
mathematically quite simple and conceptually easy to
understand. In this chapter, we introduce some essential
concepts, terminology, and arithmetic of fuzzy sets and fuzzy
logic.
the University of California at Berkeley inthousands of studies
are carried out yearly on this field [19].Today, fuzzy logic is
still well recognized. Worldwide, Universitythousands of
studies are carried out yearly on this field.
B. Linguistic Variable
While variables in mathematics usually take numerical values,
in fuzzy logic applications, the non-numeric are often used to
facilitate the expression of rules and facts.
C. Fuzzyset
In mathematics, fuzzy sets are sets are whose elements have
degrees of membership. In classical set theory, the
membership of elements in a set is assessed in binary terms
according to a bivalence condition an element either belongs
or does not belong to the set. By contrast, fuzzy set theory
permits the gradual assessment of the membership of elements
in a set; this is described with the aid of amembership
function valued in the real unit interval [0, 1]. Fuzzy sets
generalize classical sets, since the indicator functions of
classical sets are special cases of the membership functions of
fuzzy sets, if the latter only take values 0 or 1. In fuzzy set
theory, classical bivalent sets are usually called crisp sets.
A.Fuzzy Logic
Fig. 1 Block diagram of fuzzy control system
1965. He proposed the fuzzy set theory which led to a new
all aspects of our society including industrial manufacturing,
automatic control of steam engine in 1974. During the past
automatic control, automobile production, banks, hospital, etc.
began to gain recognition after Dr. E.H. Mamdani of London
control method called „fuzzy control‟. The work of Zadeh
few decades, Fuzzy Logic has been widely applied in almost
It is a form of many logic values .it deals with approximate,
rather than fixed and exact reasoning. Compared to
traditional binary logic (where variables may take on true or
false), fuzzy logic variables may have a truth value that ranges
in degree between 0 and 1. Fuzzy logic has been extended to
handle the concept of partial truth, where the truth value may
range between completely true and completely false.
Furthermore, when linguistic variables are used these degrees
maybe logic managed by specific functions. The pioneering
work on fuzzy logic was done by ProfessorLofti A. Zadeh of
ISSN: 2231-5381
The fuzzy controller,(as explained in Fig. 1), have four main
components:
The Rule-Base holds the knowledge, in the form of aset of
rules, of how best to control the system.
The Inference Mechanism evaluates which controlrules are
relevant at the current time and thendecides what the input to
the plant should be.
The Fuzzification Interface simplymodifies the inputsso that
they can be interpreted and compared to therules in the rulebase.
The Defuzzification Interface converts theconclusions
reached by the inference mechanisminto the inputs to the plant
[6], [9]
.
http://www.ijettjournal.org
Page 218
International Journal of Engineering Trends and Technology (IJETT) – Volume 24 Number 4- June 2015
IV. TYPES OF CONTROLLERS
There are several types of control systems that use FLC as an
essential system component
A. Self-Tuning Fuzzy Logic Controller
A self-tuning fuzzy controller is that in which the control
rules, the membership function, or the scaling factors are selfadjusted. Among them, the control rules and the scaling
factors play important roles [18]. We have used a real time
tuning for output scaling factors. Its main advantages over a
general
FLC
are
stronger
control
capability,
increasedflexibility and robustness.
B. Fuzzy Supervised Pid Controllers (Fspid)
For controlling of a nonlinear process a conventionalcontroller
is not enough to obtain a desired performance. Toensure good
performances and stability for all the operationset point in
nonlinear process, the controller gains shouldchange to adopt
the variation of physical parameters.Direct controller
,Supervisory controlPID adaptation, Fuzzy intervention The
majority of applications during the past two decades belong to
the class of PID fuzzy controllers. These fuzzy controllers can
be further classified into three types: the direct action (DA)
type, the gain scheduling (GS) type and a combination of DA
and GS types. The majority of PID fuzzy applications belong
to the DA type; here the PID fuzzy controller is placed within
the feedback control loop, and computes the PID actions
through fuzzy inference. In GS type controllers, fuzzy
inference is used to compute the individual PID gains [12], [10],
[11]
. The simplest and most usual way to implement a fuzzy
controller is to realize it as a computer program on a general
purpose computer. However, a large number of fuzzy control
applications require a real-time operation to interface highspeed Constraints. Software implementation of fuzzy logic on
general purpose computers cannot be considered as a suitable
design solution for this type of application, in such cases,
design specifications can be matched by specialized fuzzy
processors. Higher density programmable logic devices such
as FPGA can be used to integrate large amounts of logic in a
single IC [13]-[14]. Semi-custom and full-custom application
specific integrated circuit (ASIC) devices are also used for this
purpose but FPGA provide additional flexibility: they can be
used with tighter time-to-market schedules. The FieldProgrammable Gate Array (FPGA) places fixed logic cell son
the wafer, and the FPGA designer constructs more complex
functions from these cells. The term field programmable
highlights the customizing of the IC by the user, rather than by
the foundry manufacturing the FPGA [17],[15]-[16].
V.FUZZY VARSES. CONVENTIONAL CONTROL
in order to design a conventional controller for controlling a
physical system, the mathematical model of the system is
needed. A common form of the system model is differential
ISSN: 2231-5381
equations for continuous-time systems or difference equations
for discrete-time systems. Strictly speaking, all physical
systems in existence are nonlinear. Unless physical insight and
the laws of physics can be applied, establishing an accurate
nonlinear model using measurement data and system
identification methods is difficult in practice. Even if a
relatively accurate model of a dynamic system can be
developed, it is often too complex to use in controller
development, especially for many conventional control design
procedures that require restrictive assumptions for the plant
(e.g., linearity) [5], [6].As an alternative, fuzzy control provides
a formal methodology for representing, and implementing a
human's heuristic knowledge about how to control a system,
which may provide a new paradigm for nonlinear systems.
Fuzzy controller is unique in its ability to utilize both
qualitative and quantitative information. Qualitative
information is gathered not only from the expert operator
strategy, but also from the common knowledge [5], [6]. Although
much of the opposition to fuzzy logic is based on
misconceptions, fuzzy control is not a cure-all. Fuzzy control
should not be employed if the system to be controlled is linear,
regardless of the availability of its model. PID control and
various other types of linear controllers can effectively solve
the control problem with significantly less effort, time, and
cost. In summary, PID control should be tried first whenever
possible [5]. FLCs have been implemented successfully in
various applications such as process control and robotics [2] ,[3],
[4]
Fuzzy logic provide a certain level of artificial intelligence
to the conventional PID controllers. Fuzzy PID controllers
have self-tuning ability and on-line adaptation to nonlinear,
time varying, and uncertain systems Fuzzy PID controllers
provide a promising option for industrial applications with
many desirable features [1].
VII. DESIGN AND ANALYSIS OF FUZZY LOGIC
CONTROLLER IN VHDL
There are three parts to a fuzzy logic controller, the
fuzzification of the inputs, the defuzzification of the outputs,
and the rule-base. The controller that is implemented here
demonstrates a two input, one output fuzzy controller with
seven membership functions.
A. fuzzifier
The fuzzy controller takes input values from the real world.
These values are referred to as "crisp" values since they are
represented as a single number, not a fuzzy one that is in the
hexadecimal. The inputs, means crisp input has to be
converted to a fuzzy number. This process is called
http://www.ijettjournal.org
Page 219
International Journal of Engineering Trends and Technology (IJETT) – Volume 24 Number 4- June 2015
Fuzzification . This is the code for Declaration of fuzzification
with input and output.
EntityFuzzyfication is
Port (A: in STD_LOGIC_VECTOR (7 downto 0);
NL:out STD_LOGIC_VECTOR (7 downto 0);
NM:out STD_LOGIC_VECTOR (7 downto 0);
NS:out STD_LOGIC_VECTOR (7 downto 0);
Z:out STD_LOGIC_VECTOR (7 downto 0);
PS:out STD_LOGIC_VECTOR (7 downto 0);
PM:out STD_LOGIC_VECTOR (7 downto 0);
PL:out STD_LOGIC_VECTOR (7 downto 0));
End Fuzzyfication;
Wsum<=(S_NL*"00100000")+(S_NM*"01000000")+(S_NS*
"01100000")+(S_Z*"10000000")+(S_PS*"10100000")+(S_P
M*"11000000")+ (S_PL *"11100000");
Sum<=("00000000"&S_NL)+("00000000"&S_NM)+("00000
00"&S_NS)+("00000000"&S_Z)+("00000000"&S_PS)+("000
00000"&S_PM)+ ("00000000"&S_PL);
B. rule base
The next step in the fuzzy control process is to the
implementation of rule base. The rule-base is implemented
with a two input and one output system. All the inputs use
seven membership function as the same linguistic modifier‟s
of positive large (PL), positive medium (PM), positive small
(PS), zero (Z), negative small (NS), negative medium (NM),
and negative large (NL). Based on the linguistics, 49 rules
were established and inputs were chosen based on the desired
output for the system. This is where the fuzzy inputs are
compared and based on the membership of each, fuzzy output
is chosen. For a one input system with seven membership
functions for each input, there would be 49 fuzzy rules to
compute since they are ended together. This is main formula
for rule base applied in code.
Function my Max (A,B: in std_logic_vector(7 downto 0))
return std_logic_vector is
begin
if (A> B) then
return A;
else return B;
end if;
EndmyMax;
EndRulebase;
process
(sd_NL,sd_NM,sd_NS,sd_Z,sd_PS,sd_PM,sd_PL,A_NL,A_N
M,A_NS,A_Z,A_PS,A_PM,A_PL)
begin
if(sd_NL< A_NL) then --if SD is NL AND A is NL then T is
PL
T_PL01<=sd_NL;
else
T_PL01<= A_NL;
end if;
C. Defuzzification
The final step is to convert the fuzzy outputs of the rule-base
to crisp ones. This process is known as defuzzification. This
ISSN: 2231-5381
process will take a fuzzy number and apply it to a membership
function to achieve the crisp number that will be sent to the
real world.this is the formula for common mean of medians in
defuzzification process.
dividor
num<=Wsum;
den<=SUM;
en<=validIn;
Y<=res(7 downto 0);
validOut<=done;
ready<=done;
endBehavioral;
VII. SIMULATION IN XILINX ISE
Simulations have been done in Xilinx ise 9.2i.fig 3 and fig 4.
Shows the test bench waveform and RTL view of FLC using
VHDL respectively.in this figure output have calculated
according to input. Y is the output of defuzzifier, A and sd is
the signal for input offuzzyfier and Tis output signal for rule
base shown in fig 4. The project status report for Fuzzy Logic
Controller shown in fig 2. Following the HDL Synthesis
Report for FLC.
HDL Synthesis Report
Macro Statistics
# Multipliers : 11
14x8-bit multiplier : 4
8x8-bit multiplier : 7
# Adders/Subtractors : 45
21-bit subtractor: 1
22-bit adder : 12
5-bit adder : 1
8-bit adder : 19
8-bit subtractor : 12
# Registers : 48
1-bit register : 45
22-bit register : 2
5-bit register : 1
# Latches : 14
8-bit latch : 14
# Comparators : 124
22-bit comparator greatequal:10
8-bit comparator greatequal :10
http://www.ijettjournal.org
Page 220
International Journal of Engineering Trends and Technology (IJETT) – Volume 24 Number 4- June 2015
8-bit comparator greater:42
8-bit comparator less:71
IX. CONCLUSION
Once the basic design of the fuzzy logic controller have been
implemented.it is very straight forward by coding each
component of the fuzzy inference system in VHDL. By simply
changing some parameters in the codes and design constrain
on specific synthesis tool, one can experiment with different
design circuitry to get best result in order to satisfy the system
requirements, because we have to implement general purpose
FLC. Design time is reduced significantly and different ways
of designing a rule base can be explored Formulating costeffective solutions to complex problems characterized by
uncertainty or imprecise information. The fuzzifier and
defuzzifier components of the fuzzy system are described
using VHDL code as it involves considerable amount of
mathematical computations.
Fig 2. project status for FLC
REFERANCES
Fig.3. test bench waveform using Xilinx ISE
Fig.4.RTL view of FLC using VHDL
VIII. RESULT
We have shown in fig .4 RTLview of general purpose fuzzy
logic controller & in Fig 3 we have shown the test bench wave
form. The output is according to the rule base , Its Maximum
operating frequency 328.15mhz total no of slice registers used
176 & available is 384, so the total utilization is 45% . No of
slice containing only related logic 1373 available 1410 .Used
no of gate clock‟s 3. And available is 4, Means the utilization
is 75%.and no .of 4 LUT 2176 used .No of flip flop used
185,and no of slices used1186.project status of fuzzy logic
controller is shown in fig 2.
ISSN: 2231-5381
[1] Abdullah I. Al-Odienat, Ayman A. Al-Lawama, “The Advantages of PID
Fuzzy Controllers Over The Conventional Types”, American Journal of
Applied Sciences 5, 653-658, 2008.
[2] KapilDev Sharma and Mohammad Ayyub, “Fuzzy Logic Controller(FLC)
with Better Performance as Against Conventional PID Controller ”Presented
in 2nd National Conference on “Recent Advances in Technology and
Engineering (RATE-2013)”, March 15-17, 2013, held at Mangalayatan
University, Aligarh, India.
[3]
ArpitGoel,
AnkitUniyal,
AnuragBahuguna,
Rituraj
S.
PatwalAndHusainAhmed ,“Performance comparison of PID and fuzzy logic
controller using different defuzzification techniques for positioning control of
dc motors”, Journal of Information Systems and Communication Vol.3, Issue
1, pp. 235-238, 2012.
[4] Essam Natsheh1 and Khalid A. Buragga “Comparison between
Conventional and Fuzzy Logic PID Controllers for Controlling DC Motors”,
IJCSI International Journal of Computer Science Issues, Vol. 7,No.5, Sept.
2010.
[5] H. Ying, "Fuzzy Control and Modeling, Analytical Foundations and
Applications", Institute
of Electrical and Electronic Engineers Inc.,
USA,2000.
[6] K. M. Passino and Stephen Yurkovich, "Fuzzy Control",AddisonWeslwey Longman Inc., USA, 1998.
[7] Mathworks, "Fuzzy Logic Toolbox User's Guide ", Mathworks, Inc.,1999.
[8] L. Reznik, "Fuzzy Controllers", Newnes, first edition, 1997.
[9] J. Huang, "Hybrid Fuzzy PID Controller with Adaptive Genetic
Algorithms for the Position Control and Improvement of Magnetic Suspension
System", M. Sc. thesis, Mechanical and Electro-Mechanical Engineering,
June, 2004.
http://etd.lib.nsysu.edu.tw/ETD-db/ETD-search/view_etd?URN=etd-06
24104-182807
[10] G. K. Mann, B. G. Hu, and R. G. Gosine, "Analysis of Direct
ActionFuzzy PID Controller Structures", IEEE Transactions on Systems,
Man,and Cybernetics-Part B: Cybernetics, Vol. 29, No. 3, pp. 371-388,
June,1999.
[11] J. Li, andB. S.Hu, "TheArchitecture of Fuzzy PID Gain Conditioner and
its FPGA Prototype Implementation", Second International Conference on
ASIC, pp. 61-65, 21-24 October, 1996.
http://www.ijettjournal.org
Page 221
International Journal of Engineering Trends and Technology (IJETT) – Volume 24 Number 4- June 2015
[12] I. del Campo, R. Callao, and J. Tarela, "Automatic Implementation of
Different Inference Architectures for Fuzzy Control on PLDs", Computer and
Electrical Engineering Vol. 24, No.1/2, January/March 1998.
[13] MichaelMcKenna and Bogdan M. Wilamowski," Implementing a Fuzzy
System on a Field programmable Gate Array", IEEE International Joint
Conference on Neural Networks, 2001. Proceedings. IJCNN '01, ISBN: 07803-7044-9, Volume: 1, p.189-194, 2001.
[14] Alessandro Gabrielli ,EnzoGandolfi and Massimo Masetti," Design of a
Very High Speed Fuzzy Processor by VHDL Language", Physics Department
University of Bologna VialeBertiPichat 6/240127 Bologna Italy.
www.bo.infn.it/dacel/papers/96_03_parigi_EDTC.pdf
[15] ValentinaSalapura and Volker Hamann," Implementing Fuzzy Control
Systems Using VHDL and Statecharts", Design Automation Conference,1996,
with EURO-VHDL '96 and Exhibition, Proceedings EURO-DAC '96,
European, ISBN: 0-8186-7573-X, p. 53-58, Geneva, Switzerland,1996.
[16] Masmoudi n., hachicha m. and kamoun l." Hardware Design of
Programmable Fuzzy Controller on FPGA", IEEE International Fuzzy
Systems Conference Proceedings, Seoul, Korea, p. -1675- -1679, August 2225, 1999.
[17] Jose l. Gonzalez-vazquez, oscar Castillo and luis t. Aguilar-bustos,” A
Generic Approach To Fuzzy Logic Controller Synthesis On FPGA”,IEEE
international conference on fuzzy systems, p- 2317 - 2322, 2006.
[18] Hung-Yuan Chung, Bor C. Chen,Jin J. Lin “A PI-type fuzzy controller
with self-tuning scaling factors”, Fuzzy Sets and systems, pp. 23-28,1998
[19]International Journal of Engineering Trends and Technology
(IJETT) – Volume 15 Number 5 – Sep 2014 Application of Fuzzy Logic to
the Speed Control of DC Motor Gafari A. Adepoju #1, Ismail A. Adeyemi#1,
Oluwadolapo S. Oni *2 #,*Department of Electronic and Electrical
Engineering LadokeAkintola University of Technology Ogbomoso, Nigeria
.
ISSN: 2231-5381
http://www.ijettjournal.org
Page 222
Download