0% found this document useful (0 votes)
4 views13 pages

Unit-02 Note - R2

The document discusses fuzzy logic control, focusing on its application in systems like washing machines and temperature controllers. It explains fuzzy IF-THEN rules, linguistic variables, and the structure of fuzzy inference systems (FIS), which utilize fuzzy membership functions and rules to make decisions based on imprecise inputs. Additionally, it outlines the fundamental concepts of image processing and the modeling of energy-efficient devices using fuzzy logic.

Uploaded by

Harsh Dewangan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views13 pages

Unit-02 Note - R2

The document discusses fuzzy logic control, focusing on its application in systems like washing machines and temperature controllers. It explains fuzzy IF-THEN rules, linguistic variables, and the structure of fuzzy inference systems (FIS), which utilize fuzzy membership functions and rules to make decisions based on imprecise inputs. Additionally, it outlines the fundamental concepts of image processing and the modeling of energy-efficient devices using fuzzy logic.

Uploaded by

Harsh Dewangan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K.

Sahoo

Unit-02
FUZZY LOGIC CONTROL
Lecture-01: Review of Fuzzy membership functions and rule base (FIS)
It is a known fact that a human being is always comfortable making conversations in natural
language. The representation of human knowledge can be done with the help of following
natural language expression −
IF antecedent THEN consequent
The expression as stated above is referred to as the Fuzzy IF-THEN rule base.
Canonical Form
Following is the canonical form of Fuzzy Logic Rule Base −
Rule 1 − If condition C1, then restriction R1
Rule 2 − If condition C1, then restriction R2
-
Rule n − If condition C1, then restriction Rn
Interpretations of Fuzzy IF-THEN Rules
Fuzzy IF-THEN Rules can be interpreted in the following four forms −
Assignment Statements
These kinds of statements use “=” (equal to sign) for the purpose of assignment. They are of the
following form −
a = hello
climate = summer
Conditional Statements
These kinds of statements use the “IF-THEN” rule base form for the purpose of condition. They
are of the following form −
IF temperature is high THEN Climate is hot
IF food is fresh THEN eat.
Unconditional Statements
They are of the following form −
GOTO 10
turn the Fan off
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

Linguistic Variable
We have studied that fuzzy logic uses linguistic variables which are the words or sentences in a
natural language. For example, if we say temperature, it is a linguistic variable; the values of
which are very hot or cold, slightly hot or cold, very warm, slightly warm, etc. The words very,
slightly are the linguistic hedges.
Characterization of Linguistic Variable
Following four terms characterize the linguistic variable −
• Name of the variable, generally represented by x.
• Term set of the variable, generally represented by t(x).
• Syntactic rules for generating the values of the variable x.
• Semantic rules for linking every value of x and its significance.
Propositions in Fuzzy Logic
As we know that propositions are sentences expressed in any language which are generally
expressed in the following canonical form −
s as P
Here, s is the Subject and P is Predicate.
For example, “Delhi is the capital of India”, this is a proposition where “Delhi” is the subject
and “is the capital of India” is the predicate which shows the property of subject.
We know that logic is the basis of reasoning and fuzzy logic extends the capability of reasoning
by using fuzzy predicates, fuzzy-predicate modifiers, fuzzy quantifiers and fuzzy qualifiers in
fuzzy propositions which creates the difference from classical logic.
Propositions in fuzzy logic include the following −
Fuzzy Predicate
Almost every predicate in natural language is fuzzy in nature hence, fuzzy logic has the
predicates like tall, short, warm, hot, fast, etc.
Fuzzy-predicate Modifiers
We discussed linguistic hedges above; we also have many fuzzy-predicate modifiers which act
as hedges. They are very essential for producing the values of a linguistic variable. For example,
the words very, slightly are modifiers and the propositions can be like “water is slightly hot.”
Fuzzy Quantifiers
It can be defined as a fuzzy number which gives a vague classification of the cardinality of one
or more fuzzy or non-fuzzy sets. It can be used to influence probability within fuzzy logic. For
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

example, the words many, most, frequently are used as fuzzy quantifiers and the propositions
can be like “most people are allergic to it.”
Fuzzy Qualifiers
Let us now understand Fuzzy Qualifiers. A Fuzzy Qualifier is also a proposition of Fuzzy
Logic. Fuzzy qualification has the following forms −
Fuzzy Qualification Based on Truth
It claims the degree of truth of a fuzzy proposition.
Expression − It is expressed as x is t. Here, t is a fuzzy truth value.
Example − (Car is black) is NOT VERY True.
Fuzzy Qualification Based on Probability
It claims the probability, either numerical or an interval, of fuzzy proposition.
Expression − It is expressed as x is λ. Here, λ is a fuzzy probability.
Example − (Car is black) is Likely.
Fuzzy Qualification Based on Possibility
It claims the possibility of fuzzy proposition.
Expression − It is expressed as x is π. Here, π is a fuzzy possibility.
Example − (Car is black) is Almost Impossible.
Inference system:
Fuzzy Inference System is the key unit of a fuzzy logic system having decision making as its
primary work. It uses the “IF…THEN” rules along with connectors “OR” or “AND” for
drawing essential decision rules.
Characteristics of Fuzzy Inference System
Following are some characteristics of FIS −
• The output from FIS is always a fuzzy set irrespective of its input which can be fuzzy or
crisp.
• It is necessary to have fuzzy output when it is used as a controller.
• A Defuzzificaiton unit would be there with FIS to convert fuzzy variables into crisp
variables.
Functional Blocks of FIS
The following five functional blocks will help you understand the construction of FIS −
• Rule Base − It contains fuzzy IF-THEN rules.
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

• Database − It defines the membership functions of fuzzy sets used in fuzzy rules.
• Decision-making Unit − It performs operation on rules.
• Fuzzification Interface Unit − It converts the crisp quantities into fuzzy quantities.
• Defuzzificaiton Interface Unit − It converts the fuzzy quantities into crisp quantities.
Following is a block diagram of fuzzy interference system.

Lecture-02: Application of Fuzzy inference system (FIS) in washing machine


When one uses a washing machine, the person generally select the length of wash time based on the
amount of clothes he/she wish to wash and the type and degree of dirt cloths have. To automate this
process, we use sensors to detect these parameters (i.e. volume of clothes, degree and type of dirt).
The wash time is then determined from this data. Unfortunately, there is no easy way to formulate a
precise mathematical relationship between volume of clothes and dirt and the length of wash time
required. Consequently, this problem has remained unsolved until very recently. Conventionally,
people simply set wash times by hand and from personal trial and error experience. Washing
machines were not as automatic as they could be. The sensor system provides external input signals
into the machine from which decisions can be made. It is the controller's responsibility to make the
decisions and to signal the outside world by some form of output. Because the input/output
relationship is not clear, the design of a washing machine controller has not in the past lent itself to
traditional methods of control design. We address this design problem using fuzzy logic. Fuzzy logic
has been used because a fuzzy logic controlled washing machine controller gives the correct wash
time even though a precise model of the input/output relationship is not available.
The two inputs are:
1. Degree of dirt
2. Type of dirt
Figure 1 shows the basic approach to the problem. The fuzzy controller takes two inputs (as stated
for simplification), processes the information and outputs a wash time. How to get these two inputs
can be left to the sensors (optical, electrical or any type). The working of the sensors is not a matter
of concern in this part. We assume that we have these inputs at our hand. Anyway the two stated
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

points need a bit of introduction which follows. The degree of dirt is determined by the transparency
of the wash water. The dirtier the clothes, less transparent the water being analyzed by the sensors is.
On the other hand, type of dirt is determined by the time of saturation, the time it takes to reach
saturation. Saturation is a point, at which there is no more appreciable change in the color of the
water. Degree of dirt determines how much dirty a cloth is, whereas Type of dirt determines the
quality of dirt. Greasy cloths, for example, take longer for water transparency to reach transparency
because grease is less soluble in water than other forms of dirt. Thus a fairly straight forward sensor
system can provide us the necessary input for our fuzzy controller.

Before the details of the fuzzy controller are dealt with, the range of possible values for the input
and output variables are determined. These (in language of Fuzzy Set theory) are the
membership functions used to map the real world measurement values to the fuzzy values, so
that the operations can be applied on them. Figure 2 shows the labels of input and output
variables and their associated membership functions. Values of the input variables
degree_of_dirt and type_of_dirt are normalized range -1 to 100) over the domain of optical
sensor.
Lecture-03: Practical implementation of FIS in washing machine.
The decision which the fuzzy controller makes is derived from the rules which are stored
in the database. These are stored in a set of rules. Basically the rules are if-then statements that
are intuitive and easy to understand, since they are nothing but common English statements.
Rules used in this part are derived from common sense, data taken from typical home use, and
experimentation in a controlled environment.
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

The sets of rules used here to derive the output are:


1. If dirtness_of_clothes is Large and type_of_dirt is Greasy then wash_time is VeryLong;
2. If dirtness_of_clothes is Medium and type_of_dirt is Greasy then wash_time is Long;
3. If dirtness_of_clothes is Small and type_of_dirt is Greasy then wash_time is Long;
4. If dirtness_of_clothes is Large and type_of_dirt is Medium then wash_time is Long;
5. If dirtness_of_clothes is Medium and type_of_dirt is Medium then wash_time is Medium;
These rules have been shown as membership functions in figure

The rules too have been defined in imprecise


sense and hence they too are not crisp but fuzzy
values. The two input parameters after being read
from the sensors are fuzzified as per the
membership function of the respective variables.
These in additions with the membership function
curve are utilized to come to a solution (using
some criteria). At last the crisp value of the
wash_time is obtained as an answer.

Lecture-04: Fundamental concept of Image processing


An image refers to a 2D light intensity function f(x,y), where (x,y) denote spatial coordinates and
the value of f at any point (x,y) is proportional to the brightness or gray levels of the image at
that point.
• A digital image is an image f(x,y) that has been discretized both in spatial coordinates and
brightness.
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

• The elements of such a digital array are called image elements or pixels.
A simple image model:
• To be suitable for computer processing, an image f(x,y) must be digitalized both spatially and
in amplitude.
• Digitization of the spatial coordinates (x,y) is called image sampling.
• Amplitude digitization is called gray-level quantization.
Fundamental steps in image processing:
1. Image acquisition: to acquire a digital image
2. Image preprocessing: to improve the image in ways that increase the chances for success of
the other processes.
3. Image segmentation: to partitions an input image into its constituent parts or objects.
4. Image representation: to convert the input data to a form suitable for computer processing.
5. Image description: to extract features that result in some quantitative information of interest or
features that are basic for differentiating one class of objects from another.
6. Image recognition: to assign a label to an object based on the information provided by its
descriptors. 7. Image interpretation: to assign meaning to an ensemble of recognized objects.

Elements of digital image processing systems:


• The basic operations performed in a digital image processing systems include (1) acquisition,
(2) storage, (3) processing, (4) communication and (5) display.
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

Lecture-06: Modeling of Energy efficient fan using Fuzzy Logic


The model is based on fuzzy logic and Raspberry Pi. Figure 1 shows the recommended method
for fan control. In the proposed system first, the temperature and humidity values are detected
through temperature and humidity sensors connected to Raspberry Pi. The temperature and
humidity values are then fed to the fuzzy logic module. The fuzzy logic gets the temperature and
humidity as crisps values, the fuzzification converts these temperature and humidity vales to
fuzzy values by using fuzzy membership functions, fuzzy rules are deployed on these fuzzy
values, and the output of these rules are assigned to defuzzification and converts again to crisp
output. We have designed the rules in such a way that it provides the adjusted power for the fan.
In this work, we have defined for each input parameter five membership functions are
determined, and five membership functions for output parameter that is required speed. Total 25
rules are defined in each fuzzy logic.

The figure below shows the Flow chart of fan control using Fuzzy Logic.
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

The membership functions are shown in the figure below


STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

Lecture-07: Modeling of temperature controller using Fuzzy logic:

The system is aimed at controlling the temperature of an environment by regulating a heater and
the speed of a fan. The Microcontroller has to make decisions based on external temperature
condition. The variable “temperature” which is inputted on the system can be divided into a
range of states such as “Cold”, “Cool”, “Moderate”, “Warm”, “Hot”, “Very hot”. Defining the
bounds of these states is a bit tricky.
An arbitrary threshold might be used to separate “warm” from “hot”, but this would result in a
discontinuous change when the input value passes over that threshold. The way to make the
states “fuzzy” is to allow them change gradually from one state to the next. The input
temperature states can be defined using “membership functions” as in figure 1.

With this scheme, the input variable state no longer jumps abruptly from one state to the next.
Instead as the temperature changes, it loses value in one membership function while gaining
value in the next.
The input variables in a fuzzy control system are mapped by sets of membership functions,
known as “fuzzy sets”. The process of connecting a crisp input value to a fuzzy value is called
fuzzification. A fuzzy-based control system can also incorporate the analog inputs of 0, 1 into its
fuzzy functions that are either one value or another.
Given “mappings” of inputs variable into membership functions and truth values, the
microcontroller then makes decision of what action to take based on a set of “rules” for each of
the form. For instance, if the external temperature is warm, then the fan speed is not very fast,
but heater is low. In this example, the input variable temperature has values defined by fuzzy set.
The output variables which are the speed of fan and heater temperature are also defined by a
fuzzy set that can take values like “static”, “slightly increased”, “slightly decreased”, and so on.
The considerations to make are that:
1) All the rules that apply are invoked using membership functions and truth values obtained
from the input to determine the result of the rule.
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

2) This result in turn will be mapped into a membership function and truth value controlling the
output variable.
3) These results are combined to give a specific (crisp) answer ie. the actual room temperature
through a procedure known as defuzzification.
Fuzzy-based control process consists of an input stage, processing stage and an output stage. The
input stage maps sensor or other inputs such as switches, thumbwheels and so on, to an
appropriate rule and generates a result for each. The processing stage then combines the results
of the rules; and finally the output stage converts the combined result back to a specific control
output value.
The processing stage is based on a collection of logic rules in the form of If-Then statements,
where the IF part is called the “antecedent” and the THEN part is called the “consequent”.
Typical fuzzy control systems have dozens of rules [6].
Consider a rule for a thermostat, IF (temperature is “cold”) Then (heater is “high”).
This rule uses the truth value of the “temperature” input which has truth value of “cold” to
generate a result in a fuzzy set for the “heater” output, which has truth value of “high”. This
result is used with the results of other rules to finally generate the crisp composite output.
Obviously, the greater the truth value of “cold”, the higher the truth value of “high”, though this
does not necessarily mean that the output itself will be set to “high” since this is only one rule
among many.
In some cases the membership functions can be modified by “hedges” using “about”, “near”,
“close to”, “approximately”, “very”, “slightly”, “too”, “extremely” and “somewhat”. The
operations of these may have precise definitions, though the definitions can vary considerably
between different implementations.
Fuzzy logic incorporates a simple rule-based IF X and Y Then Z approach to solve a control
problem. The fuzzy logic model is empirically-based, relying on operational experience rather
than technical understanding of the system. For example, rather than dealing with temperature
control in terms such as “Temp < 1000F” or 210C < Temp < 220C”; terms like “IF (process is too
cool) AND (process is getting colder) THEN (add heat to the process)” or “IF (process is too
hot) AND (process is heating rapidly) THEN (cool the process quickly)” are used. These terms
are imprecise and yet very descriptive of what must actually happen.

Lecture-08& 09: Neuro-Fuzzy controller through a practical Implementation:

The idea in this part was to try to automatically develop a FIS to control the water tank problem.
The overall system would be like shown below, where x_d(n) is the input/desired water level,
e(n) is the difference between the actual level, x(n), and desired level and u(n) is the output of the
fuzzy logic controller.
STUDY MATERIALS ON NEURAL NETWORK & FUZZY LOGIC BY: Dr. P.K. Panigrahi and Mr. A.K. Sahoo

As it can be seen this is similar to what was done in the part, where the FIS was generated
manually by a human expert. But of course it would be desirable to be able to automatically fine-
tune or maybe even automatically design the FIS from “scratch”.
The first idea was simply to use ANFIS to train the controller. However it soon became clear that
this was not directly possible. This is because ANFIS both need the input signal, e(n), and the
desired output from the FIS, u(n). But clearly the desired response u(n) of is unknown in this
part. (Otherwise we would actually be back at the human expert generating the FIS)
From the model it can quite easy be seen what an appropriate FIS would be expected to do. The
rules of the FIS would be something similar to the following 3 rules.
1. IF e(n) is positive, then output should be positive. This is equal to say water level should
increase, and thus valve should be opened.
2. IF e(n) is negative, then output should be negative. This is equal to say water level should
decrease, and thus valve should be closed.
3. IF e(n) is close to zero, then output should be zero. This is equal to say water level is ok, and
thus valve should not be changed.
These basic ideas of an appropriate behaviour of the controller could of course be used to design
a not to bad FIS and from this make the tuning using ANFIS. However this would not change the
fact that the desired output of the FIS would be required,

You might also like