Fuzzy

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

Fuzzy Room temperature control

Abstract:
This project paper describes the design of a room temperature controller using fuzzy logic. The
proposed model consists of fuzzy logic controllers to control temperature. The controller accepts
two input values- the current temperature as detected by temperature sensor and its deviation
from user set-temperature, and controls the speed of heat-fan and cool-fan accordingly. This
research work will increase the capability of fuzzy logic control systems in process automation
with potential benefits. MATLAB-simulation is used to achieve the designed goal.

1 Introduction
This proposed design work of room temperature controller can be used in a processing plant to
maintain comfortable atmosphere in the room the basic model of the proposed structure consists
of room temperature controller with fuzzy logic control system. The room atmosphere controller
has a heating fan, a cooling fan to heat or cool the room according to user demand; temperature
sensors used to monitor the environment of room are mounted in the room and are connected
with the fuzzifiers of the fuzzy logic control system.

The fuzzy controller is composed of the following four elements:


1. A rule-base (a set of If-Then rules), which contains a fuzzy logic quantification of the
expert’s linguistic description of how to achieve good control

2.An inference mechanism (also called an “inference engine” or “fuzzy inference” module),
which emulates the expert’s decision making in interpreting and applying knowledge about how best to
control the plant.

Group two Page 1


Fuzzy Room temperature control

3.A fuzzification interface, which converts controller inputs into information that the inference
mechanism can easily use to activate and apply rules.

4.A defuzzification interface, which converts the conclusions of the inference mechanism into
actual inputs for the process

Figure 1: Fuzzy controller

Group two Page 2


Fuzzy Room temperature control

e(t)
FLC Y(t)
Heater fan Plant

Cooler fan

Ce(t)

Figure 2: Block diagram of temperature control by fuzzy

2 Determining linguistic variables for the system.


Input Variables:-

1 Current Temperature (error)

It is the current temperature of the room as recorded by the temperature sensor mounted
in the room

2. Deviation From Set Temperature(change in error)

It gives the difference between the user preferred temperature and current temperature of
the room as recorded by the temperature sensor in the room

Output Variables

1.Heat-Fan-Speed

Group two Page 3


Fuzzy Room temperature control

The heat fan can either be in ON or OFF state depending on the temperature preference in the
room

2.Cool-Fan-Speed

The cool fan can either be in ON or OFF state depending on the temperature preference in the
room

3 Determine the linguistic values of the given


linguistic variables
 linguistic values for Current Temperature (error OR input 1)
Linguistic values for Current Temperature are Very COOL(VC), COOL(C),
NORMAL(N), HOT(H) and VERY-HOT(VH).
The sensor range should be wide enough to take care of climatic and regional
fluctuations. The proposed model works perfectly at any temperature within range 8oC-
44oC

Table 1: Membership Functions For Current-Temperature

MEMBERSHIP RANGE (oC)


FUNCTIONS
Very COOL 8-16
COOL 15-23
NORMAL 22-30

HOT 29-37

VERY-HOT 36-44

 linguistic values for Deviation Current Temperature (change in error OR input 2)

Linguistic values for Deviation Current Temperature are negative large(NL), negative
small(NS), zero(Z), positive small(PS) and positive large(PL).

Group two Page 4


Fuzzy Room temperature control

As this model can work between temperature range 8-44’C and user can set any desired
temperature from 18-26’C, so temperature difference between the current and the user
preferred temperature can never go beyond -26’C (18’C – 44’C) and 18’C (26’C - 8’C).
Thus (-26’C) & (+18’C) are the lower and upper limits of the input variable “ deviation
from set-temperature”).

Table 2: Membership Functions for “Deviation from current temperature”

MEMBERSHIP RANGE(oC)
FUNCTIONS
NL -26 to -12
NS -13 to 0
O -2 to 2
PS 1 to 10
PL 9 to 18

 linguistic values for Heat-Fan-Speed(out put 1)

The heta-fan-speed is categorized into 1. stop 2.heat-slow(hs) 3. heat-medium(hm) 4. heat-fast 5.


very fast. If the current temperature of the room is below the desired temperature then this fan
automatically gets on varies speed according to temperature difference.

Table 3:-Membership Functions For “heat-fan-speed”

Group two Page 5


Fuzzy Room temperature control

MEMBERS RANGE %
HIP
FUNCTION
S
STOP 0-5
HEAT- 0-30
SLOW
HEAT- 25-50
MEDIUM
FAST 45-80
very-FAST 75-100

 linguistic values for cool-Fan-Speed(out put 2)

The cool-fan-speed is categorized into 1. STOP 2.COOL-SLOW 3. COOL-MEDIUM 4. COOL-


FAST. If the current temperature of the room is above the desired temperature then this fan
automatically gets on varies speed according to temperature difference.

MEMBERSHIP RANGE %
FUNCTIONS
STOP 0-5
COOL-SLOW 0-30
COOL-MEDIUM 25-50
COOL-FAST 45-80
COOL-V.FAST 75-100

Form rule based on the input and output variables to control speed of heat fan and
cool fan.

Group two Page 6


Fuzzy Room temperature control

4 Rule generate
Rules that relate input and output variables for fuzzy controllers:

1. If (input1 is VC) and (input2 is NL) then (output1 is STOP) and (output2 is STOP)

2. If (input1 is VC) and (input2 is NS) then (output1 is HS) and (output2 is STOP)

3. If (input1 is VC) and (input2 is ZERO) then (output1 is HM) and (output2 is STOP)

4. If (input1 is VC) and (input2 is PS) then (output1 is HF) and (output2 is STOP)

5. If (input1 is VC) and (input2 is PL) then (output1 is HVF) and (output2 is STOP)

6. If (input1 is C) and (input2 is NL) then (output1 is STOP) and (output2 is CS)

7. If (input1 is C) and (input2 is NS) then (output1 is STOP) and (output2 is STOP)

8. If (input1 is C) and (input2 is ZERO) then (output1 is HS) and (output2 is STOP)

9. If (input1 is C) and (input2 is PS) then (output1 is HM) and (output2 is STOP)

10. If (input1 is C) and (input2 is PL) then (output1 is HF) and (output2 is STOP)

11. If (input1 is N) and (input2 is NL) then (output1 is STOP) and (output2 is CF)

12. If (input1 is N) and (input2 is NS) then (output1 is STOP) and (output2 is CM)

13. If (input1 is N) and (input2 is ZERO) then (output1 is STOP) and (output2 is STOP)

14. If (input1 is N) and (input2 is PS) then (output1 is HM) and (output2 is STOP)

15. If (input1 is N) and (input2 is PL) then (output1 is HF) and (output2 is STOP)

Group two Page 7


Fuzzy Room temperature control

16. If (input1 is H) and (input2 is NL) then (output1 is STOP) and (output2 is CVF)

17. If (input1 is H) and (input2 is NS) then (output1 is STOP) and (output2 is CF)

18. If (input1 is H) and (input2 is ZERO) then (output1 is STOP) and (output2 is CM)

19. If (input1 is H) and (input2 is PS) then (output1 is STOP) and (output2 is STOP)

20. If (input1 is H) and (input2 is PL) then (output1 is HS) and (output2 is STOP)

21. If (input1 is VH) and (input2 is NL) then (output1 is STOP) and (output2 is CVF)

22. If (input1 is VH) and (input2 is NS) then (output1 is STOP) and (output2 is CF)

23. If (input1 is VH) and (input2 is ZERO) then (output1 is STOP) and (output2 is CM)

24. If (input1 is VH) and (input2 is PS) then (output1 is STOP) and (output2 is CS)

25. If (input1 is VH) and (input2 is PL) then (output1 is STOP) and (output2 is STOP)

NB

Input 1=current temperature

Input 2= Deviation From Set Temperature

Output 1= Heat-Fan-speed

Output 2= cool-Fan-speed

Group two Page 8


Fuzzy Room temperature control

5 Member ship function


 Membership function of Current Temperature (error)

Where

VC=very cool temperature

C= cool temperature

N= normal temperature

H=hot temperature

VH=very hot temperature

Group two Page 9


Fuzzy Room temperature control

Membership function for Deviation Current Temperature (change in error)

Where
NL=the Deviation Current Temperature is very hot or negative large
NS=the Deviation Current Temperature hot or negative small
Zero=the Deviation Current Temperature is normal or zero
PS= the Deviation Current Temperature is cool or positive small

Group two Page 10


Fuzzy Room temperature control

PL= the Deviation Current Temperature is very cool or positive large

Membership function for Heat-Fan-Speed

Where

Group two Page 11


Fuzzy Room temperature control

Stop=the speed of heat-fan is stop


HS= the speed of heat-fan is slow
HM= the speed of heat-fan is medium
HF= the speed of heat-fan is fast
HVF fast= the speed of heat-fan is very

Membership function for cool-Fan-Speed

Where

Stop=the speed of cool-fan is stop


CS= the speed of cool-fan is slow
CM= the speed of cool-fan is medium

Group two Page 12


Fuzzy Room temperature control

CF= the speed of cool-fan is fast


CVF= the speed of cool-fan is very fast

6 Fuzzy quantification of knowledge


Give a specific crisp values (numerical values) for the inputs and determine the recommended
output value .use the following operations:
Membership function: symmetrical triangle
AND operation: product
Implication: minimum
Aggregation: sum
Defuzzification method: center average

To find the crisp value first determines one appropriate rule from 25 rules.
A crisp set of input data are gathered and converted to a fuzzy set using fuzzy linguistic
variables.
The rule selected for inference process is:

7 Determining Which Rules Are On:


Determining the applicability of each rule is called “matching.” We say that a rule is “on
at time t” if its premise membership function μ𝒑𝒓𝒆𝒎𝒊𝒔(e(t), 𝑑𝑒(𝑡)𝑑𝑡) > 0.
Hence, the inference mechanism seeks to determine which rules are on to find out which rules
are relevant to the current situation.
compute the rules that are on. Suppose that: e(t) = 15.75 and de(t)dt= 12.375

Figure shows the membership functions for the inputs and indicates with thick black vertical
lines the values above for e(t) and de(t)dt.

Group two Page 13


Fuzzy Room temperature control

Notice that μvcool(e(t)) = 0.0625 and μcool(e(t)) = 0.1875 but that the other membership
functions for the e(t) input are all “off” (i.e., their values are zero). For the 𝑑(𝑡)𝑑𝑡 input we see
that μ𝒑𝒐𝒔large (𝑑𝑒(𝑡)𝑑𝑡) = 0.75 and that all the other membership functions are off.

This implies that rules that have the premise terms: “error is very cool”
“error is cool”

Group two Page 14


Fuzzy Room temperature control

“change-in-error is poslarge” are on (all other rules have μ𝒑𝒓𝒆𝒎𝒊𝒔𝒆 (e(t), 𝑑𝑒(𝑡)𝑑𝑡) = 0.

the rules that are on are the following:

Rule 1 If (input1 is VCool) and (input2 is PL) then (output1 is HVF)(output2 is STOP)

Rule2 If (input1 is Cool) and (input2 is PL) then (output1 is HF)(output2 is STOP)

Membership function for premise terms

Fig Membership function for Current Temperature is very cool.

Group two Page 15


Fuzzy Room temperature control

Membership function for Deviation Current Temperature is cool or positive large

Current Temperature e(t) is very cool member ship function

E(t)=[8 12 16]

Select e(t)=15.75 on

the Deviation Current Temperature Ce(t )is very cool or positive large member ship function
Ce(e)=[9 13.5 18]

Select Ce(t)=12.375

μ vc e(t)=0.0625 this value is the membership function at e(t)=15.75 on and the other
membership functions for e(t) input are all zero(off).
μ pl Ce(t)=0.75this value is the membership function at Ce(t)=12.375 on and the other
membership functions for Ce(t) input are all zero(off).

For “and” operator we use product rule for premise


μ1premise=product of(μvce(t),μPL Ce(t))
product (0.0625, 0.75)
=0.046875

Rule 2. If (input1 is C) and (input2 is PL) then (output1 is HF)(output2 is STOP)

Group two Page 16


Fuzzy Room temperature control

Fig Membership function for Current Temperature is cool.

Fig Membership function for Deviation Current Temperature is very cool or positive large

Determine which rule is on from the given membership function of the above premise terms
Current Temperature e(t) is cool member ship function

E(t)=[15 19 23]

Select e(t)=15.75

the Deviation Current Temperature Ce(t )is very cool or positive large member ship function
Ce(e)=[9 13.5 18]

Group two Page 17


Fuzzy Room temperature control

Select Ce(t)=12.375

μ c e(t)=0.1875 this value is the membership function at e(t)=15.75on and the other membership
functions for e(t) input are all zero(off).
μ pl Ce(t)=0.75 this value is the membership function at Ce(t)=12.375 on and the other
membership functions for Ce(t) input are all zero(off).

For “and” operator we use product rule for premise


μ2premise=product of(μce(t),μPL Ce(t))
Product (0.1875 0.75)
=0.140625

Implication
Membership function for consequence terms

speed of heat-fan is very fast

Group two Page 18


Fuzzy Room temperature control

speed of cool-fan is stop

we can divide rule 1 in to two

i.e

. If (input1 is VC) and (input2 is PL) then (output1 is HVF)

If (input1 is VC) and (input2 is PL) then (output2 is STOP)

For “implication” we use minimum operator


The membership function for this consequent is μ1

μ1(heat-fan speed ) =minimum {μ1premise ,μv.fast(heat fan speed)}


=minimum {0.046875,1}
=0.046875

Figure speed of heat-fan output( consequent )membership function for rule (1)

μ1(cool-fan speed ) =minimum {μ1premise,μstop(cool fan speed)}


=minimum {0.046875,1}

Group two Page 19


Fuzzy Room temperature control

=0.046875

Figure speed of cool-fan output( consequent )membership function for rule (1)

Membership function for consequence terms rule 2

speed of heat-fan is fast

speed of cool-fan is stop

Group two Page 20


Fuzzy Room temperature control

we can divide rule 2 in to two

i.e

Rule 2. If (input1 is C) and (input2 is PL) then (output1 is HF)

If (input1 is C) and (input2 is PL) then (output2 is STOP)

For “implication” we use minimum operator


The membership function for this consequent is μ2

μ2(heat-fan speed ) =minimum {μ2premise,μfast(heat fan speed)}


=minimum {0.140625, 1}
=0.140625

Figure speed of heat-fan output( consequent )membership function for rule (2)

μ2(cool-fan speed ) =minimum {μ2premise,μstop(cool fan speed)}


=minimum {0.140625, 1}
=0.140625

Figure speed of heat-fan output( consequent )membership function for rule (2)

Group two Page 21


Fuzzy Room temperature control

8 Aggregation
Fuzzy Logic provides a number of functions for aggregating two or more fuzzy sets or fuzzy relations.
When using the aggregation operations, the fuzzy sets or fuzzy relations being combined must be defined
on the same universal space. It does not make sense to combine items defined on different universal
spaces. In this project we use sum for aggregation for the implied fuzzy sets.

10 Deffuzification
It the processes of converting output of inference mechanism into crisp value (numerical
value) .It operate based on implied fuzzy set to provide the most certain controller output.
There are two possible rules:

1 center of gravity (COG)

2 center average.

For our calculation let us use center average as follow

Group two Page 22


Fuzzy Room temperature control

From the two rules

b1= 87.5 µpremise (1) =0.046875

b2=62.5 µpremise (2) =0.140625 for the heater output.

Ucrisp = (87.5*0.046875+62.5*0.140625)/(0.046875+0.140625)

=67 for heater.

b1=2.5 and b2=2.5 for the output of cooler.

Ucrisp= (2.5*0.046875+2.5*0.140625)/(0.046875+0.140625)

=2.5 for cooler

Group two Page 23

You might also like