75
1 Part I: Fuzzy Logic Control Prof. Marzuki Bin Khalid CAIRO Fakulti Kejuruteraan Elektrik Universiti Teknologi Malaysia [email protected] Module 3 Case Studies and Applications of Fuzzy Logic UTM 2 Module 3 Objectives To understand several fuzzy logic control applications. To understand how to apply fuzzy logic in practical applications. To be able to understand the implementation of fuzzy logic control in several applications. To study several applications of fuzzy logic in consumer products and industrial systems. Discussions on the trends of fuzzy logic research and applications. At the end of the course the student should understand how fuzzy logic is applied in practical applications. Fuzzy Logic Control Systems

Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

1

Part I: Fuzzy Logic Control

Prof. Marzuki Bin KhalidCAIRO

Fakulti Kejuruteraan ElektrikUniversiti Teknologi Malaysia

[email protected]

Module 3

Case Studies and Applications of Fuzzy Logic

UTM

2

Module 3 Objectives• To understand several fuzzy logic control applications.

• To understand how to apply fuzzy logic in practical applications.

• To be able to understand the implementation of fuzzy logic control in several applications.

• To study several applications of fuzzy logic in consumer products and industrial systems.

• Discussions on the trends of fuzzy logic research and applications.

• At the end of the course the student should understand how fuzzylogic is applied in practical applications.

Fuzzy Logic Control Systems

Page 2: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

3

Module 3 Contents

• 3.1 Fuzzy control of an inverted pendulum• 3.2 Fuzzy control of a water bath• 3.3 Fuzzy control of traffic lights• 3.4 Intelligent Diagnosis of Power Transformers• 3.5 Several issues in the application of fuzzy logic for

real-time control• 3.6 Industrial/Commercial examples of fuzzy logic

control– 3.6.1 Fuzzy washing machine– 3.6.2 Canon’s fuzzy auto-focus camera– 3.6.3 Minolta’s fuzzy camera– 3.6.4 Sendai’s fuzzy subway train

• 3.7 Summary of Module 3

4

3.1 Fuzzy Control of an Inverted Pendulum

• An inverted pendulum is a classic example of a nonlinear and an unstable system

• The control objective is to stabilize the inverted pendulum in an upright manner

• Several simulation packages have been developed.• In this course students are required to use a

simulation package developed by Togai InfralogicInc., U.S.A. as an assignment.

• The simulation objectives are:– To understand how to design a fuzzy logic controller– To understand the components of a fuzzy logic

controller– To understand the operations of a fuzzy logic

controller

Case Study #1

Page 3: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

5

Initial steps to take when designing a fuzzy controller• Plan your design• What are its objectives?• What are the process inputs and outputs?• What are the inputs to the controller?• What are the controller outputs?

Fuzzy logic inverted pendulum control system

Vertical line∆θ

θ Fuzzy LogicController

+

-

θ

θ

∆θ

vMotorv

Study the system

6

Observing the inverted pendulum system

Bob Mass

Shaft

Motor, v

Vertical Axis

θ

∆θAngular velocity,

Angle

Fuzzy Controller Variables

Input: ~ Angle between pendulum shaftand vertical line, θ

~ Angular velocity of pendulum shaft ,∆θ

Output: ~ Motor current or velocity, v(In this case, it is not necessary to take the change of the control signal as the output)

Through observations the input and output fuzzy variables can be identified. This inverted pendulum has a fixed base.

Page 4: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

7

• The fuzzy variables have to be broken into smaller modules which we call quantization.

• Quantize the input and output variables into several modules which we call fuzzy subsets and assign the appropriate labels as given in this example.

• You may quantize your variables according to complexity of the problem (in this case, we quantize each fuzzy variable into five fuzzy subsets).

• Assign appropriate membership functions to each fuzzy subset.

• You may choose any kind of shape or size of the membership functions.

Negative Medium

Negative Small

Zero

Positive Small

Positive Medium

NM

NS

ZE

PS

PM

(a).Gaussian

(b). Triangular

(c). Trapezoidal

Three different shapes of membership functions

Quantize the fuzzy variables

8

• For simplicity let’s choose triangular membership functions for each of the fuzzy subsets of the three fuzzy variables.

Membership Functions

• Membership functions (fuzzy subsets) of the three fuzzy variables. The fuzzy subsets are overlapped by about 25%.

PMPSZENSNM

Pendulum Angle, θ

00

1

PMPSZENSNM

Motor Velocity, v

mv

00

1

PMPSZENSNM

Angular Velocity, ∆θ

m∆θ

00

1

Page 5: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

9

Designing the Inference Engine

• The inference engine consists of the following:– Rule base– Encoding technique (compositional operator)

• We need to develop rules to solve the stabilization problem.• This can be done by observing the states of the pendulum.• Rules are in the form of:

IF Conditions THEN Actions

• The rules can be formulated through experience or through the use of examples given by others (see Module 2).

• In most control problem the encoding technique use is the max-min composition.

10

Example of rules to control the pendulum

∆θ = ΖΕ

v = PM

θ = NM

IF θ =NM AND ∆θ =ZE THEN v=PM

If pendulum angle is negative but medium and the angular velocity is about zero then motor velocity should be position and medium

∆θ = ΖΕ

v = NS

θ = PS

IF θ=PS AND ∆θ =ZE THEN v=NS

If pendulum angle is positive and small and the angular velocity is about zero then motor velocity should be negative small

∆θ = ΖΕ

v = ZE

θ = ZE

IF θ=ZE AND ∆θ =ZE THEN v=ZE

If pendulum angle is about zero and the angular velocity is about zero then motor velocity should be about zero

Page 6: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

11

• Basic fuzzy rules for controlling the pendulum.

Antecedents

IF X AND/OR Y (= Antecedents) THEN Z (= Consequent)

PS

PM

NM

NM

NS

NS

ZE

PS

PS

PS NM

NM

NS

NS

ZE

ZE

ZE

PM

PM

PMZE

Pendulum Angle, θ

Consequent

Steady-state rule

Rule Base

12

• Normally we would use matrix for simplicity to observe these rules.

• For a 5x5 antecedents there would be a total of 25 rules.• However, not all the banks in the matrix need to be filled up as

some rules do not necessarily need to be fired.• The basic fuzzy rules to control the pendulum are given as

follows:

Pendulum Angle, θ

PS

PM

NM

NM

NS

NS

ZE

PS

PS

PS NM

NM

NS

ZE

ZE

ZE

PM

PM

PMZE

Consequent

Steady-state rule

NS

Page 7: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

13

Choice of Encoding or Inference Techniques

• As discussed we can choose either correlation minimum encoding or correlation product encoding schemes.

• Examples are given here.IF e is PL AND ∆ e is ZE THEN ∆u is PL

e=PL at 0.5 ∆e=ZE at 0.2 ∆u=PL at 0.2

Correlation-minimum-inference procedure

Input Fuzzy Variables Output Fuzzy Variable

me m∆e m∆u

e ∆e ∆u

Correlation-product-inference procedure∆ e

IF e is PL AND ∆e is ZE THEN ∆u is PL

e=PL at 0.5 ∆e=ZE at 0.2Input Fuzzy Variables Output Fuzzy Variable

me m∆e m∆u

e ∆u

m ∆uPL = me

PL • m∆eZE

14

Defuzzification Techniques• There are several defuzzification techniques.• Suppose the centroid defuzzification is used the following will be observed.

Example showing centroid defuzzificationwith correlation-minimum encoding scheme

PS ZE

ZE ZE ZEme

m∆ePS

m∆u

m∆um∆e

me

Value of e at instant t

Value of ∆eat instant t

0 0 0

0 0 0

0

IF e=PS AND ∆e=ZE

IF e=ZE AND ∆e=ZE

THEN ∆u = PS

THEN ∆u = ZE

Fuzzy centroid, ∆u

m∆uZE

m∆uPS

Page 8: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

15

Test run the fuzzy controller

• When the control system has been configured, we can test the system.• Run your controller.• If results not satisfactory then make minor modifications or

adjustments to the following:– (1). Scaling factors– (2). Overlap of membership functions– (3). Check if rules are correct– (4). Increase rules if necessary– (5). Increase quantization if necessary

• Re-run the system.

Main objective• To design a Fuzzy Logic Controller to balance the

inverted pendulum at a specific orientation within a limited range.

To control and stabilize the rotary inverted pendulum using fuzzy logic control through:

software simulation (Visual Basic 5.0) and real-time control on hardware via PC-based using DOS platform (Borland C++ 5.02 as editor and iC-96 as compiler)

FUZZY CONTROL OF AN INVERTED ROTARY PENDULUM

Page 9: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

SOFTWARE REQUIREMENTS

• Visual Basic 5.0 • Borland C++ 5.02 • iC-96 Compiler V2.3 • MCS-96 Relocator and Linker V2.4• iECM-96 V2.3 • Fuzzy Output weights offline self-tuning

program

HARDWARE REQUIREMENTS

The Micro-controller board UC96-SD version 2.0KRi Inverted pendulum model PP-300

rotary inverted pendulum structureservo drive unitpower supply

Page 10: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

FUZZY LOGIC CONTROL SYSTEM DESIGN METHODOLOGY

Start

Study the System-determine objectives-identify process and controller's input and output

Fuzzification-quantize the input and output variables-define the membership function

Inference Mechanism-derive fuzzy control rules- based-define fuzzy inference engine

PerformanceOK ?

End

Yes

No

Defuzzification-choose defuzzification method

Fuzzy ControllerOperation

-Fuzzification-Fuzzy Inference-Defuzzification

Simulation & testing

Parameters Tuning-mapping of membership function-fuzzy inference rules

Page 11: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

FUZZY LOGIC CONTROL SYSTEM BLOCK DIAGRAM

FuzzyLogic

Controller1

Motor

Set-point(Vertical line) u θ

derr

errFuzzyLogic

Controller2

∆θθ

v

err2

derr2

∆α

α

αu2

θ

Input: 1) Angle between pendulum shaft and vertical line, 2) Angular Velocity of pendulum shaft, 3) Angle between motor arm and horizontal line, 4) Angular Velocity of motor arm,

Output: 1) Motor PWM, u

∆θ

α∆α

DYNAMIC EQUATIONS OF THE INVERTED PENDULUM

( )

=

0

sinm- 0

+ C 2sin-

2sin +sinm-2sin +

+ m + J cos

cosm sin + Lm +

1111

11o12

1121

112

1121

111 112

1121

1 2

111 1011

111122

12

o1

τθ

θ

θ

θθ

θθθθθ

θ

θθ

θθ

g

m

mLmC

LmLJ

ooo

ooo

λ

&

&

&λλ&λ

&&

&&

λλ

λλ

~

1

1

1

1u

ad-bc*cg

0ad-bc*dg-

0

+

ad-bccf-ah

ad-bcai

ad-bcce-ag 0

1 0 0 0ad-bcbd-df

ad-bcbi-

ad-bcbg-de 0

0 0 1 0

=

θ

θθ

θ

θ

θ

θ

θ

&

&

&&

&

&&

&

o

o

o

o

[ ]

=

1

10 1 0 0

θ

θθ

θ

&

&o

o

y

Page 12: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

REAL TIME FUZZY LOGIC CONTROLLER DESCRIPTION

• Singleton fuzzy output is chosen due to its faster processing speed

=

== n

tn

n

tnn

B

KBZ

1

1*

Bn = the weight of the rule which is fired

Kn = singleton output value for that specific rule

INPUT MEMBERSHIP FUNCTIONS

0 2.7o 5.4o

NM NS ZE PS PM1

0 err

µ

-2.7o-5.4o 0

NM NS ZE PS PM1

0 derr

µ

2.7o 5.4o-2.7o-5.4o

• Input membership functions for both controllers are similar

• Single tone controller does not have output membership function

First Input Membership Function

Second Input Membership Function

Page 13: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

FUZZY CONTROL RULESerr \ derr NM NS ZE PS PM

NM 855 837 804 346 0

NS 694 316 281 0 -290

ZE 641 271 0 -288 -600

PS 259 0 -284 -272 -713

PM 0 -324 -763 -796 -852

First FuzzyController

err \ derr NM NS ZE PS PM

NM -698 -539 -425 -250 -155

NS -74 -94 -72 -233 -477

ZE 47 43 12 -41 -52

PS 200 192 254 517 675

PM 226 243 259 396 699

Second Fuzzy Controller

EXPERIMENTAL RESULT OF REAL TIME CONTROL

Pendulum Position Vs Number of Sample

-500-300-100100300500

1 92 183

274

365

456

547

638

729

820

911

1002

Number of Sample

Pend

ulum

Po

sitio

n

Pendulum Velocity Vs Number of Sample

-500-300-100100300500

1

105

209

313

417

521

625

729

833

937

Number of Sample

Pen

dulu

m

Vel

ocity

Arm Position Vs Number of Sample

-500-300-100100300500

1 94 187

280

373

466

559

652

745

838

931

Number of Sample

Arm

Pos

ition

Arm Velocity Vs Number of Sample

-500-300-100100300500

1 103 205 307 409 511 613 715 817 919 1021

Number of Sample

Arm

Vel

ocity

Page 14: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

EXPERIMENTAL RESULT AFTER DISTURBANCE IS ADDED

Arm Position Vs Number of Sample

-500-300-100100300500

1 134 267 400 533 666 799 932

Number of Sample

Arm

Pos

ition

Pendululm Position Vs Number of Sample

-300-100100300500

1

101

201

301

401

501

601

701

801

901

1001

Number of Sample

Pen

dulu

m

Posi

tion

Pendulum Velocity Vs Number of Sample

-500-300-100100300500

1

109

217

325

433

541

649

757

865

973

Number of Sample

Pen

dulu

m

Velo

city

Arm Velocity Vs Number of Sample

-500-300-100100300500

1

103

205

307

409

511

613

715

817

919

1021

Number of Sample

Arm

Vel

ocity

EXPERIMENTAL RESULTS WHEN SOME CONTROL RULES ARE TAKEN OUT

Both Controllers with only (3x3) rules, instead of (5x5) rules

Pendulum Position Vs Number of Sample

-500-300-100100300500

111

522

9

343

457

571

685

799

913

Number of Sample

Pen

dulu

m

Pos

ition

Arm Position Vs Number of Sample

-500-300-100100300500

1 131 261 391 521 651 781 911

Number of Sample

Arm

Pos

ition

Page 15: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

ANALYSIS OF RESULTS

•• The research has shown The research has shown the robustness of the the robustness of the fuzzy logic controller fuzzy logic controller under disturbances and under disturbances and plant uncertaintiesplant uncertainties

Next project- coming up

• Swing up the inverted pendulum and balance at a specific position

• Using neuro-fuzzy controller for better performance

Page 16: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

31

3.2 Application of fuzzy logic control to a water bath temperature control system

• A water bath as shown above is an example of a temperature control system.

• Its objective is to control the temperature of the liquid product in the bath.

• Example of applications are in the production of a variety of drink products such as chocolate drink, strawberry milk products, etc.

• Example of industries are Nestle, Yeoh Hiap Seng, F&N, etc.• A stirrer is used so that the product is evenly mixed and the control of

the temperature is evenly distributed.• This example is intended to show how a fuzzy controller can be

designed for such purpose.• A math-model of the plant can be obtained by deriving from first

principles.

Case Study #2

32

Thermal Transducer A/D Microcomputer

Stirrer

SensorThyristor

Water Bath

Heater AC

Control Signal

Schematic diagram of the water bath system

Control ObjectiveTo control the water/liquid temperature in a water bath following a given set-point.

Page 17: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

33

Block diagram of the water-bath temperature control system

Practical system complexity• Non-linearity in sensors and relays• Noise• Disturbance• Non-adiabatic• Controller Limits: 0V(min)-5V(max)• (However, these characterisitcs are not

present in the above math-model exceptfor controller limits)

Sensor

Reference(Desired Temp.)

Fuzzy LogicController

+

-

OutputTemp.

Error signal Control signal (Heater)

Water Bath

Disturbance

)(222.0)(998.0)1( kukyky +=+Math-model of system:

The performance of the system can be measured from the error between the output and the reference

34

Configuration of the fuzzy controller

• Two input variables:– Error in temperature of the liquid, e(k) = y(k) - r(k)– Rate of change of error, ∆e(k) = e(k) - e(k-1)

• One output variable:– Change in the control signal, ∆u(k)

FLC

Error

Derivativeof Error

Change inControl Signal

e

∆e

∆u

Page 18: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

35

e, ∆e, and ∆u

LinguisticTerm Label

Positive

Zero

Negative NZP

Quantization of the Fuzzy Variables

For simplicity the 3 fuzzy variables can be broken into 3 fuzzy subsets and the membership functions can be overlapped as follows:

PZN

e

µe

PZN

∆e

µ∆e

PZNµ∆u

∆u

The universe for the 3 variables can be set accordingly through observation.

36

Scaling the universes of discourse

• We need to quantify each universe of discourse correctly within the range of the respective variables.

• Scaling factors can be used to scale the universes of discourse.• They act like gain control.

FLC

Error

Derivativeof Error

Change inControl Signal

e

∆e

∆u

G

G∆e

e

G∆u

Page 19: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

37

Determining the rule base

• Every fuzzy logic system must have a rule base.• The rule base is used to infer the actions that need to be taken

based on the current conditions.• Example the centre rule which is the steady-state rule can be

written as follows: IF Error in Temperature is about ZeroAND the Derivative of Error is about ZeroTHEN the Change in Control Input is about Zero(IF e=Z AND ∆e=Z THEN ∆ u=Z)

• A rule can be written in triple form such as this:(Z, Z; Z)

• A matrix of the rule base can be set up as shown.• The 1st row and the 1st column are the antecedents

and the boxes in the matrix are the consequents.

Error, e

Derivativeof Error, ∆e

N Z PNZ

P

ze ∆e ∆u

38

Determining the rules

• The choice of the consequents is based on observation and engineering experience.

• A simple way to fill up the rule base matrix is to use the information given in Module 2.

• Fill up the matrix such that the rule base is complete.

Error, e

Derivativeof Error, ∆e

N Z P

N

Z

P

Page 20: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

39

Determining the encoding technique

• In many control application the Mamdani’s max-min composition technique is largely used.

• An error reading that is observed will fire the appropriate rule or rules in the rule base.

• Example 3.1 shows how the minimum encoding technique determines the output suppose the rule (Z,Z;Z) is fired.

• Max composition is used to determine if more than 1 of the same consequent resulted. This occurs when several rules are fired.

• A defuzzification technique will be used to give a crisp output value.

PZN

e

µe

PZN

∆e

µ∆e

PZNµ∆u

e(k)

∆e(k)

∆u

Determined output ∆u(k)

0.6

0.7

0.6

Example 3.1

40

Defuzzification

• Defuzzification is required to produce the actual signal that the plant can use.

• Thus, the fuzzy output value need to be defuzzified.

• The output of the fuzzy controller is usually the change in the control signal.

• The actual control signal to the plant is thus:

u(k+1) = u(k) + ∆u(k)

• In Example 3.1 suppose only one rule is fired (Z, Z; Z) as shown, if the max defuzzificationtechnique is used, the output crisp value is:

µc(z*) ≥ µc(z) for all z ∈Z• For centroid defuzzification, the value is given as

follows:

∑∑

=)(

).(*

z

zzz

C

C

µµ

Max defuzzification

Centroid defuzzification

Z

Z

µc

µc

Page 21: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

41

Example 3.2

• Suppose the following rules are fired:Rule1=(P,Z;P), Rule 2= (P,N;Z), Rule 3=(N,P;Z) and Rule 4=(Z,P;P).

• In this case the max-min composition would be computed.

• First the min computation is used to obtain the consequents from each of rules fired which are: Rule 1=P, Rule 2=Z, Rule 3=Z and Rule 4=P.

• This shows that there are 2 consequents for “P” from Rules 1 and 4 and 2 consequents for “Z” from Rules 2 and 3.

• Now the max computation is used for obtaining only 1 “P” consequent and 1 “Z” consequent.

• Then any of the defuzzification technique can be used to get the crisp output value.

• In this example we show how the centroid defuzzification strategy is used to solve this problem.

42

• Consider the first 2 rules fired:

Rule1=(P,Z;P) and Rule 4=(Z,P;P), this means that (e, ∆e; ∆u).• Suppose Rule 1: µP=0.75, µZ =0.3, thus, min (µP, µZ) --> µP at 0.3

PZN

e

µe

PZN

∆e

µ∆e

PZNµ∆u

∆u

PZN

e

µe

PZN

∆e

µ∆e

PZNµ∆u

∆u

P, Z; P Z, P; P

∆u at µP =0.3 ∆u at µP =0.4

0.75

0.3

0.8

0.4

0.40.3

Page 22: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

43

• Suppose Rule 4: µZ =0.8, µP=0.4, thus, min (µZ, µP) --> µP at 0.4

• Since the consequent P is fired twice having 2 membership values, 0.3 and 0.4 thus, we need to use the max compositional operator to obtain only 1 P value of the consequent.

• Thus, max (µP=0.3, µP=0.4) will give µP=0.4.

• Similarly for Rules 2 and 3, the same computation will be done to obtain only 1 N consequent (see next slide).

• Consider the next 2 rules fired:Rule2=(P,N;Z) and Rule 3=(N,P;Z)

• Suppose Rule 2: µP=0.5, µN =0.6, thus, min (µP, µN) --> µZ at 0.5• Suppose Rule 3: µN =1.0, µP=0.4, thus, min (µN, µP) --> µZ at 0.4

44

• As the consequent N is fired twice having 2 membership values, 0.5 and 0.4 thus, we need to use the max compositional operator to obtain only 1 N value of the consequent.

• Thus, max (µZ=0.5, µZ=0.4) will give µZ=0.5.• Suppose we use the centroid defuzzification strategy. The next slide

will show how this is done to get the crisp output.

PZN

e

µe

PZN

∆e

µ∆e

PZNµ∆u

∆u

PZN

e

µe

PZN

∆e

µ∆e

PZNµ∆u

∆u

P, N; Z N, P; Z

∆u at µZ =0.5 ∆u at µZ =0.4

0.5

0.6

1.0

0.4

0.40.5

Page 23: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

45

• For the example given, suppose the centroid defuzzification technique is used to calculate the crisp output.

• Graphically this can be shown as follows.

• The first consequent P was obtained at µP =0.4 and the second consequent Z at µZ =0.5.

• The centroid defuzzificationalgorithm will calculate the crisp value of ∆u from the following equation:

where k is the sample number across the universe for ∆u.

PZNµ∆u

∆u∆u at µP =0.4

0.4

PZNµ∆u

∆u∆u at µZ =0.5

0.5

PZNµ∆u

∆uCrisp value of ∆u

∑∑

∆=∆

)(

).(

k

kku

u

u

µµ

46

Exercise Based on Simulations

• Study the output of the water bath fuzzy control system at the particular sampling interval.

• Note down the sampling interval, the setpoint (r), the output (y), error (e), and del_error (∆e).

• By studying the rule-base matrix, write down the rules that are fired at this interval in triple form, eg. (P, Z; N), etc..

• Study the membership functions table of e and De and indicate the appropriate alpha cut-set based on the input values of e and ∆e.

Page 24: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

47

(continued)

• Supposing the controller is designed using the max-min inference algorithm, show in the graph the firing angles of all the consequents based on the rules fired. Plot the resultant waveform at this sampling interval on a graph paper.

• Using the centroid defuzzification strategy, calculate the output ∆u. (Approximately divide the waveform into discrete samples of 0.5). Show how ∆u is calculated.

48

Membership Function Table of e, ∆e and ∆uof Water Bath Fuzzy Controller

PZN

e

µe

PZN

∆e

µ∆e

PZNµ∆u

∆u

0

0

0

25

25

+2.5

-25

-25

-2.5

1.0

1.0

1.0

0.5

0.5

0.5

+5-5

+50

+50-50

-50

Page 25: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

49

3.3 Fuzzy Traffic Lights Control

Case Study #3

• Objective: To control traffic lights that can respond to density of vehicles in an efficient manner.

• At CAIRO a traffic lights control simulator has been developed which can use:

– a fuzzy logic controller– conventional preset timer

50

Control Objectives• To control traffic flow optimally at an isolated

junction• To minimise waiting time• To reduce fuel costs• To reduce waste of man-hours

Simulation Objectives• Understanding fuzzy logic application for traffic

lights control• Understanding the components of a fuzzy logic

controller• Able to set up rules for controlling traffic

conditions• Able to compare and understand the advantages

of fuzzy logic controller over fixed-time controller of traffic lights

Fuzzy Traffic Lights Control

Page 26: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

51

Comparison between Conventional and Fuzzy traffic controllers

Conventional traffic lights controller• use a preset cycle time to change lights• combine preset cycle time with proximity sensors

Fuzzy traffic lights controller• mimic human intelligence for control of traffic conditions• example of a traffic lights control rule

IF traffic from the north of the city is HEAVY AND the traffic from the west is LESS THEN allow movement of traffic from the north LONGER.

52

Sensor Readings

Traffic FlowFuzzy LogicController

Control signal

Traffic Lights

Relays/Switches

FLC

Traffic Condition

Lights(Arrival)

Traffic Condition

(Queue)

RAG

Switches

Simulation of Traffic Lights Control

Configuration of the Fuzzy Controller

Fuzzy Traffic Lights Control

Page 27: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

53

Counter - Queue -Arrival

FLC

State Machine

Traffic Light Interface

Traffic Lights

Sensors

Block diagram of the fuzzy traffic lights controller

54

Design Assumptions

• Traffic conditions are considered in 4 directions but constraint to two: (1) Arrival and (2) Queue

• Also North and South are assummed as one direction whereas East and West as another

• Only straight traffic flow is considered (no trunings)

• Fuzzy controller has 2 inputs (Quantity of Traffic at Arrival and Queue) and 1 output (Extension of Green Lights of the Arrival Traffic Lights (Green))

• All fuzzy variables are quantized into 4 fuzzy subsets

• The shape of membership functions are trapezoidal at the sides and triangular in the middle.

• Flow density of cars can be controlled for each direction.

CAIRO’s Fuzzy Traffic Lights Simulator

Fuzzy Traffic Lights Control

N

S

W E

Page 28: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

55

Fuzzy Input Variables

LinguisticTerm Label

Few Many

Too Many TMMY

FAlmost None AN

Fuzzy Output: Variable:Extension of Green Lights

LinguisticTerm Label

Short MediumLonger L

MS

Zero Z

Fuzzy Controller Design

Quantization of Fuzzy VariablesFor simplicity, we quantize all the three fuzzy variables in a similar way, i.e. into four fuzzy subsets:

Fuzzy Traffic Lights Control

LinguisticTerm Label

Small Many

Large LMS

Very Small VS

Arrival Queue

56

Membership Functions

• For simplicity, triangular membership functions are used for each variable.

• In this case, the cardinals for the universes of discourse are integers.

• The membership functions are overlapped by about 25% to allow smooth transition from 1 fuzzy subset to another.

TMYMYF

No. of Cars

µArrival

AN

LMS

No. of Cars

µQueue

VS

LMS

Extension Time (Secs)

µE.TimeZ

ARRIVAL

QUEUE

EXTENSION TIME (Green)

Page 29: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

57

Determining the rules

Arrival

Queue

AN F MY

VS

S

M

L

TMY

• A rule base can be developed in the following manner.• Two examples of rules:

IF there are too many cars (TMY) at the arrival side

AND very small number of cars (VS) queueingTHEN extend the green light longer (L).

IF there are few cars (F) at the arrival side AND very small number of cars (VS) queueingTHEN extend the green light short (S).

• Fill up the rule base matrix as shown:• In this application the centroid defuzzification is used.

Rule#1

Rule#2

58

Simulation procedure for Traffic Lights Simulation

• Get into Windows Environment• Execute the Fuzzy Traffic Control Software (FTC)• Select fuzzy controller and configure your fuzzy controller

appropriately as have been discussed in the class• You need to select BOTH from the controller menu• You need to configure the density of cars for each direction. Try:

N=90, W=50, S=80, E=40• Then select <GO>• Fixed-time controller mode will operate first for 2 minutes• Observe the traffic conditions until the fixed-time controller operation

is completed

Page 30: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

59

• Write down the maximum number of cars you observed stopping at the junction (any direction)

• After the fixed-time cycle has finished, the fuzzy controller mode wilautomatically run for 2 minutes

• Observe traffic conditions and write down the maximum number of cars you observed stopping at the junction (any direction)

• Highlight Graph and Plot:– (1). Flow density– (2). Wait Time– (3). Cost Function

• Your fuzzy controller should show better results• If not, you need to reconfigure your fuzzy controller• Try simulating other conditions

3.4 Intelligent Fault Diagnosis of Power Transformers

Type of Research: Contract ResearchGrant: ~ RM90,000Collaborators: Tenaga Nasional Berhad ResearchProject Leader: Professor Dr. Marzuki Bin KhalidResearch Team: (1) Syed Fuad Syed Zain

(2) Wan Yat How(3) Mohd. Aizam Talib

Duration: 1.4.1998 – 31.3.2000 (2 years)

Page 31: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Major faults in transformers cause extensive damage, interruption of electricity supply and results in large revenue losses to power utility company.

Condition monitoring of transformers is an effective technique to identify incipient or potential faults inside the transformers.

Summary

62

Newspaper Report6th February 2000

Page 32: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

63

8th March 2000

64

New Transformer Blast

New Sunday Times23rd July 2000

TNB Distribution Sdn. Bhd. Customer Services GM (Selangor) initial investigations revealed a technical fault in one of the RM1.5 million transformers….

Page 33: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

65

Transformer Blast at Klangdue to improper maintenance

Estimated losses at RM4 million - TNB

Phase 1 Development of a Database

SoftwareADAPT

Phase 2

Automatic Interpretation using Fuzzy Logic

AI Techniques

Project Overview

Page 34: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Benefits - Immediate impacts• Use of Advanced Technology and local expertise

within Malaysia for solving complex industrial problems

• Increased efficiency and reduced operational costs for power transformers maintenance

• Early detection of abnormalities helps prevent unscheduled outages, equipment damage, and safety hazards.

Benefits - Future impacts

• Savings of outflow of Ringgit with less dependency on foreign consultants

• Increased expertise of local consultants

Page 35: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Dissolved Gas Analysis

• Major power transformers are filled with a fluid that serves as a dielectric media, an insulator, and as a heat transfer agent.

• Normal– slow degradation of the mineral oil to yield certain gases.

• Electrical fault – gases are generated at a much more rapid rate.

• Different patterns of gases are generated due to different intensities of energy dissipated by various faults.

• The gases present in an oil sample make it possible to determinethe nature of fault by the gas types and their amount.

DGA• Key Gas Method• Roger Ratio Method

Purpose :To identify fault type base on the

dissolve gases in oil

Page 36: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Gases are produced by degradation of the oil as a result of elevated temperatures which can be cause by :

lighting severe overloadingswitching transientschemical decomposition of oil or insulationoverheated areas of the windingsbad connections which have a high contact resistance

Oil sample from Transformer

Different patterns of gases are generated due to different intensities of energy dissipated by various faults

Gases generated from oil are :Hydrogen (H2) Methane (CH4)Ethane (C2H6) Ethylene (C2H4)Acetylene ( C2H2) C.Monoxide ( CO)Carbon Dioxide (CO2)

Test Result

DGA

Key Gas Method

-Thermal Fault-Corona-Arcing-Cellulose Insulation Breakdown

Roger Ratio Method

-Thermal decomposition-Partial Discharge-Arcing

•H2 – Corona•O2 and N2 – Non-fault related gases•CO & CO2 – Cellulose insulation breakdown•CH4 & C2H6 – Low temperature oil breakdown•C2H4 – High temperature oil breakdown•C2H2 – Arcing

The ranges of ratio are assigned to different codes which determine the fault type.

Methane / Hydrogen Acetylene / Ethane Ethylene / Ethane

Diagnostic Method

Page 37: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

40

60

80

100

120

140

160

180

200

0 1/0 1/1 99 7 06/06 /19 97 01/09 /19 97 25 /12 /19 97 0 1/0 1/1 99 8 0 1/0 6/199 8 11/09 /19 98 11 /11 /19 98

4 5

69 65

958 2

123

199

150

Test Value

H ydrogen S ta tis ticsH ydrogen S ta tis tics

Sam plin g D ate

0

50100150

200250

300350

400450

01/01/1997 06 /06 /1997 01 /09 /1997 25 /12 /1997 01/01/1998 01/06/1998 11 /09 /1998 11 /11 /1998

22 3 7 2 1 3354

3 4 4 1

43 6

Test Value

M e tha n e S tatis tic sM eth a n e S tatistic s

S am p ling D ate

0

10 0

20 0

30 0

40 0

50 0

60 0

70 0

0 1/01 /1 9 97 06 /0 6/19 97 0 1 /0 9/19 97 2 5/12 /1 99 7 0 1 /0 1/19 98 0 1/06 /1 99 8 1 1 /0 9/19 98 1 1/11 /1 99 8

500

323 322

12

651

145

1 4

465

Test Value

E th y le ne S ta tis ticsE th yle ne S tatis tics

S a m p lin g D ate

FUZZY INTERPRETATION

Transformer Condition

☺ Good

Normal

Bad

Automatic Interpretation using Fuzzy Logic

Report & Graphs for Analysis

Crisp to FuzzyFuzzify

Fuzzy Inference Fuzzy to CrispDefuzzify

IF CO=Hi And CO2=Hi

then Condition A

Aggregation

Composition

Real variable to linguistic variable

linguistic variable to real variable

Page 38: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Software output

Reports &

Graphs

Page 39: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Intelligent Fault Diagnosis of Power Transformers by Fuzzy Logic

Type of Research: Contract ResearchGrant: ~ RM90,000Collaborators: Tenaga Nasional Berhad ResearchProject Leader: Professor Dr. Marzuki Bin KhalidResearch Team: (1) Syed Fuad Syed Zain

(2) Wan Yat How(3) Mohd. Aizam Talib

Duration: 1.4.1998 – 31.3.2000 (2 years)

Major faults in transformers cause extensive damage, interruption of electricity supply and results in large revenue losses to power utility company.

Condition monitoring of transformers is an effective technique to identify incipient or potential faults inside the transformers.

Summary

Page 40: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

79

Newspaper Report6th February 2000

80

8th March 2000

Page 41: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

81

New Transformer Blast

New Sunday Times23rd July 2000

TNB Distribution Sdn. Bhd. Customer Services GM (Selangor) initial investigations revealed a technical fault in one of the RM1.5 million transformers….

82

Transformer Blast at Klangdue to improper maintenance

Estimated losses at RM4 million - TNB

Page 42: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Phase 1 Development of a Database

SoftwareADAPT

Phase 2

Automatic Interpretation using Fuzzy Logic

AI Techniques

Project Overview

Benefits - Immediate impacts• Use of Advanced Technology and local expertise

within Malaysia for solving complex industrial problems

• Increased efficiency and reduced operational costs for power transformers maintenance

• Early detection of abnormalities helps prevent unscheduled outages, equipment damage, and safety hazards.

Page 43: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Benefits - Future impacts

• Savings of outflow of Ringgit with less dependency on foreign consultants

• Increased expertise of local consultants

Dissolved Gas Analysis

• Major power transformers are filled with a fluid that serves as a dielectric media, an insulator, and as a heat transfer agent.

• Normal– slow degradation of the mineral oil to yield certain gases.

• Electrical fault – gases are generated at a much more rapid rate.

• Different patterns of gases are generated due to different intensities of energy dissipated by various faults.

• The gases present in an oil sample make it possible to determinethe nature of fault by the gas types and their amount.

Page 44: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

DGA• Key Gas Method• Roger Ratio Method• Nomograph

Purpose :To identify fault type base on the

dissolve gases in oil

Gases are produced by degradation of the oil as a result of elevated temperatures which can be cause by :

lighting severe overloadingswitching transientschemical decomposition of oil or insulationoverheated areas of the windingsbad connections which have a high contact resistance

Oil sample from Transformer

Different patterns of gases are generated due to different intensities of energy dissipated by various faults

Gases generated from oil are :Hydrogen (H2) Methane (CH4)Ethane (C2H6) Ethylene (C2H4)Acetylene ( C2H2) C.Monoxide ( CO)Carbon Dioxide (CO2)

Page 45: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Test Result

DGA

Key Gas Method

-Thermal Fault-Corona-Arcing-Cellulose Insulation Breakdown

Roger Ratio Method

-Thermal decomposition-Partial Discharge-Arcing

•H2 – Corona•O2 and N2 – Non-fault related gases•CO & CO2 – Cellulose insulation breakdown•CH4 & C2H6 – Low temperature oil breakdown•C2H4 – High temperature oil breakdown•C2H2 – Arcing

The ranges of ratio are assigned to different codes which determine the fault type.

Methane / Hydrogen Acetylene / Ethane Ethylene / Ethane

Diagnostic Methods

406080

100120

140160180200

0 1/0 1/1 99 7 06/06 /19 97 01/09 /19 97 25 /12 /19 97 0 1/0 1/1 99 8 0 1/0 6/199 8 11/09 /19 98 11 /11 /19 98

4 5

69 65

958 2

123

199

150

Test Value

H ydrogen S tatis ticsH ydrogen S tatis tics

Sam plin g D ate

0

50100150

200250

300350

400450

0 1/0 1/19 9 7 0 6 /0 6 /1 9 97 0 1 /0 9 /1 9 97 25 /1 2 /1 9 97 0 1/0 1/19 9 8 0 1/0 6/1 99 8 1 1 /0 9 /1 9 98 11 /1 1 /1 9 98

22 3 7 2 1 3354

3 4 4 1

43 6

Test Value

M e tha n e S tatis tic sM eth a n e S tatistic s

S am p ling D ate

0

10 0

20 0

30 0

40 0

50 0

60 0

70 0

0 1/01 /1 9 97 06 /0 6/19 97 0 1 /0 9/19 97 2 5/12 /1 99 7 0 1 /0 1/19 98 0 1/06 /1 99 8 1 1 /0 9/19 98 1 1/11 /1 99 8

500

323 322

12

651

145

1 4

465

Test Value

E th y le ne S ta tis ticsE th yle ne S tatis tics

S a m p lin g D ate

FUZZY INTERPRETATION

Transformer Condition

☺ Good

Normal

Bad

Automatic Interpretation using Fuzzy Logic

Report & Graphs for Analysis

Page 46: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Crisp to FuzzyFuzzify

Fuzzy Inference Fuzzy to CrispDefuzzify

IF CO=Hi And CO2=Hi

then Condition A

Aggregation

Composition

Real variable to linguistic variable

linguistic variable to real variable

Page 47: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Software outputs

Reports &

Graphs

94

3.5 Several issues in the application of fuzzy logic for real-time control

Knowledge required:• Scope of work/project• Whether viable to use fuzzy logic control• Variables that can be measured• Type of actuators• Sensors to be used• PC operating environment• High/Low level programming languages• Hardware knowledge of microchips• Development systems of microchips• Knowledge regarding the process• Digital control theory• Electronics/ Digital electronics• Fuzzy logic control theory• Others

Page 48: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

95

Simulation Exercises

• Using the simulation packages developed by CAIRO, try to design your fuzzy controller and understand fuzzy logic control system.

• Observe different rules and membership values used and their impact on the system.

• There are 5 available packages:– 1. Water bath temperature control– 2. Traffic lights control– 3. Coupled-tank liquid-level control– 4. Vfuzzy Version 1.0– 5. Elevator supervisory system

96

Process

Sensor

Actuator

Interface Card

Personal Computer

(Fuzzy Control Algorithm)

High-levelLanguages

(C++, Pascal,Visual Basic, etc.)

(Adclone, NS, etc.)

Application using a personal computer

Page 49: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

97

Process

Sensor

Actuator

Personal Computer

Micro-Controller(DSP, Fuzzy Chip,MC68HC11, etc.)

(Download)

A/D

D/A

Application using a microprocessor/microcontroller

Fuzzy control development system or LLL

3.5.1 Applications of Fuzzy Micro-Controller (AL220)

Objective:To use a fuzzy logic micro-controller AL220 in practical applications.

Page 50: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

Adaptive Logic AL220

• Analog Micro-Controller• Programmable Analog IC (PAIC)• On-chip A/D and D/A converters• Four 8 bits Analog Inputs and Outputs• EEPROM / ROM versions• Minimum sampling rate up to 0.1 msec• Program directly from INSiGHT IIe Development System

Servo Motor Control Using AL220 micro-controller

GeneratorMotor Drive

LoadTachometer Motor Amplifier

Controller

Coupling Shaft

Flywheel

FeedbackControl Signaly (s) u (s)

Page 51: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

PID Control System

Fuzzy Logic Control System

k kS

k Spi

d+ +0 96

08 1.

( . )S +

PID Controller Servo System

SetpointOutput

_+

kp = 2.5 ki = 1.9 kd = 0.72

Fuzzy Logic Controller

Servo SystemSetpoint

Output

_+ e

de

NL ZRNS PLPS

0 Error

1

0

NL ZRNS PLPS

0 Delta Error

1

0

Fuzzy Inputs Variable

Page 52: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

NL NS ZR

Error

Delta Error

PS PL

NL

NS

ZR

PS

PL

-5 -2 -1

0

+1

+2

+3

0

+1

+2

+3

+5

-3

-1

0

+1

+2

-3 -2

-1

0

+1

-1

-2

0

Fuzzy rules for Servo System

Fuzzy Logic Control Step Response

100 200 300 400 500 600 700Number of Sampling (100 msec)

PID Control Step Response

010002000300040005000

Vol

t (m

V)

100 200 300 400 500 600 700Number of Sampling (100 msec)

010002000300040005000

Vol

t (m

V)

Page 53: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

100 200 300 400 500 600 700 800

Number of Sampling (100 msec)

0

500

1000

1500

2000

2500

3000

3500

4000

4500

5000V

olt (

mV

)

Fuzzy Logic vs PID Control on the Effect of Load Disturbances

Fuzzy Logic

PID

Load Disturbances

106

3.6 Industrial/Commercial Examples of Fuzzy Logic Systems

• Due to the advancement of the microprocessor, many commercial applications of fuzzy logic have been successful since the 1980s.

• In this part of the module, we discuss 3 examples of industrial/commercial applications of fuzzy logic systems.

�Fuzzy washing machine�Canon’s fuzzy auto-focus camera�Minolta’s fuzzy camera�Blood pressure meter�Sendai’s fuzzy subway train

Page 54: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

107

Commercial Example #1

• In 1990 Matsushita (National) produced the first automatic controlled fuzzy logic washing machine -“Aisai Go (Beloved Wife) Day Fuzzy”.

• In 1990, the sales were so successful in Japan that it resulted in an explosion of fuzzy logic home consumer’s products such as rice cookers, camcorders, televisions, refrigerators, etc.

3.6.1 Fuzzy logic washing machine

108

Example of a fuzzy logic washing machine

Samsung SW-5AI(S)

Page 55: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

109

Example of the Samsung’s SW-5AI(S) Fuzzy logic washing machine

Fuzzy course will select the best washing modeautomatically with one touch of the button based on load, dirt, type of fabric, etc.

110

Principle of the fuzzy washing machine

• The fuzzy logic washing machine operates based on the principle of laundering :“When dirt has been removed, then washing is stopped”

• Using fuzzy inference, the optimum washing time is determined from a wash sensor.

• The wash sensor measures the dirtiness (turbidity) of the water through an optical sensor which is installed near the drain valve.

Page 56: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

111

Light(infrared emitting diode)

Receptor

Drained out water

Infrared sensor

A photo-transistor is used as a sensor to measure dirtiness of the water.

112

• The wash sensor consists of an infrared light-emitting diode (LED) and a photo-transistor.

• The light beam generated by the infra-red LED, passing through the wash water in the pipe, enters the phototransistor.

Wash sensor output change over time.

Page 57: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

113

• The photo-transistor produces a voltage in proportion to the intensity of the light.

• If the clothes are dirty, the wash water being drained out will be darker, thus less light will be passed.

• The figures below show the light transmittance over time due to the different types of dirt.

• The change of the output of the wash sensor over time is shown in the previous page.

• When washing started, the dirt in the clothes is gradually washed out and the wash water becomes dirty, causing the transmittance of wash water to decrease as shown in (a).

• The rate of decrease of the transmittance depends on the quality of the dirt:

– Fast for muddy dirt

– Slow for oily dirt

114

• This is because muddy dirt is removed easily by the mechanical force of the water flow produced by the rotation of the pulsator, while oily dirt is not adequately removed until the detergent effect takes place.

• When most of the dirt in the clothes has been removed, the transmittance of the wash water approaches a state of saturation.

• The transmittance at saturation becomes lower when the clothes are dirtier, and the transmittance becomes higher when the clothes are less dirty.

Page 58: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

115

• It is difficult to obtain the optimum relation between dirtiness and washing time experimentally.

• This is because there are many kinds of dirtiness of clothes which gives different wash sensor output patterns, thus collection through experiments are rather impossible.

• Also the relation between the dirtiness and wash time is not linear.• Hence, fuzzy inference technique would be suitable for such application.

Fuzzy inference in the washing machine

116

• Using fuzzy inference, linguistic rules can be used to solve the washing problem and the nonlinear property of the relation is approximated by an interpolation function of the fuzzy inference

• In order to provide the inference 2 inputs are suitable:– saturation time, Ts

– light transmittance, Vs

• and 1 output– Washing time, Wt

• Saturation time is chosen because it is related to the quality of the dirt and light transmittance is chosen because it is related to the amount of dirt and example of the membership functions are given as follows:

Page 59: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

117

• The washing machine can sense the following types of dirt:– Muddy dirt (faster to be washed away)– Oily dirt (need detergent and more time to be washed away)

• When most of dirt has been washed away the washing machine approaches a state of saturation:

– Lower transmittance (heavy dirt)– Higher transmittance (light dirt)

Vs

Ts

Fuzzy rule base Low Middle High

Short

Long T4

T1 T2 T3

T5 T6

118

• Examples of rules (2 rules are given here). A table of rules can be set as shown.

If transmittance (Vs) is Low and Saturation time (Ts) is LongThen Wash time (Wt) is Longer

If transmittance (Vs) is High and Saturation time (Ts) is ShortThen Wash time (Wt) is Shorter

• For simplicity, the consequents of the fuzzy rules are expressed by real numbers, T1 - T6 which are the washing times.

Page 60: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

119

Advantages of the fuzzy logic washing machine:

• It would be very difficult to design a rule base system without using fuzzy logic concepts.

• Thus, with fuzzy logic it reduces amount of required memory.

• Rules are acquired from skilled launderers (experts).

• Nonlinear relationship between degree of dirtiness and wash time can be overcome by the nonlinear fuzzy logic controller.

• Excessive or inadequate washing can be avoided.

• Many fuzzy logic washing machine consists of one-touch button system for the fuzzy wash.

120

• This camera was marketed in 1989. • It uses a 4-bit microcontroller with 500-byte of memory.• Fuzzy logic is used to determine the object of focus by evaluating

the field of view and controlling the autofocus mechanism to focus on the object.

• Earlier cameras used the object centred in the field of view as the desired focus.

• This sometimes led to error as in the case of two objects presented off-center.

• This problem had to be solved by the photographer, who focused on one object, locked the auto-focus, and then re-oriented the camera to get the desired shot.

• This manual process is laborious and awkward to the photographer.

Commercial Example #2

3.6.2 Canon’s fuzzy auto-focus camera

Page 61: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

121

Range of the Canon family of cameras

122

• To overcome the problem, fuzzy reasoning was introduced in cameras.• First, distances to 3 points in the field of view are measured. Using these

locations and the relationships between them, fuzzy logic decides the desired focus point.

• Using these locations and the relationships between them, fuzzy logic decides where the desired focus lies and then focuses on that point.

• In the Canon auto-focus camera the fuzzy rules were obtained by an analysis of 288 photographs taken by 8 people.

• Examples of some rules are given in the next slide.• One example of the rules is as follows:

If the object is near the Leftthen the plausibility for object to be at Left is Very High.

• Or simply,If L is Near Then Pl is High

(Plausibility means “the chance it will happen”.)

Page 62: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

123

Example of 5 rules for the Canon Autofocus camera

124

Example of how rules are fired• Compare figure (a) and (b) below:• We see that figure (a) has main subject on the left and figure (b) has main

subject at the center.• However in both cases, the relationship is L<C<R and both satisfy Rules (b)

and ( e) as given in the rule base in the previous page. • In this case, the decision depends on the values of L, C, and R and this

comparison is done with the help of membership functions.• The actual rule will be fired depending on the highest degree of the

membership function.• It is very difficult for binary logic rules to model this situation which may

require a large number of rules.• However, a few fuzzy rules can easily

deal with this problem.

Page 63: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

125

Conclusion• The performance of this method has been evaluated by using 288 pictures

taken by 8 persons.• The percentage of correctly focused pictures, with and without fuzzy rules are

given in the Table below.

Advantages of the fuzzy auto-focus camera:• Reduce the amount of required memory. • Rules are acquired from analysis of about 300 photographs.• Simplicity of usage as compared to conventional auto-focus technique • Results show an improvement of 23% in auto-focusing

Method Focusing rate

Three measured distances + fuzzy

Distance to the center (conventional)

96.5%

73.6%

126

• Minolta Camera Co. Ltd., Japan uses fuzzy logic to combine the 3mechanisms of focusing, zooming and deciding exposure automatically in its cameras since the early 1990s.

• The figure in the next slide shows the mechanism of a typical Minolta fuzzy camera with the above facilities.

• A number of fuzzy modules make up the auto-focus, auto-exposure and auto-zoom facilities in the camera.

Commercial Example #3

3.6.3 Minolta fuzzy auto-focus, auto-exposure and auto-zoom camera

Page 64: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

127

Auto-focus, auto-exposure and auto-zooming mechanism of a Minolta Camera, Japan.

FS= Fuzzy logic module

128

Operation Principle of the Minolta Camera

Auto-Focus Module• The fuzzy auto-focusing mode has 6 distance distributions to do the

fuzzy reasoning to locate the main subject, which are obtained by pre-processing the outputs of 4 auto-focus sensors, lens information and 1 sensor that detects the camera position.

• 7 fuzzy rules, obtained from the analysis of approximately 1000 pictures, determine the location of the main subject to focus on.

• By adding the fuzzy logic module for decision making leads to animprovement of 15% in the focus hit rate.

Page 65: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

129

Auto-Exposure Module• To implement auto-exposure, fuzzy reasoning is used to determine

exposure value and the best combination of shutter speed and aperture, depending on the type of scene being photographed.

• The exposure value is determined by 3 fuzzy inference modules, using brightness values obtained from 14 zones in the field of view and the position of the main subject (which is determined by the above auto-focus mechanism).

• The first fuzzy module uses the difference in brightness between the main subject and the background to give an output which is a measure of the amount of back-lighting present.

130

• The second fuzzy module decides whether the exposure is to be focused only on the main subject or the entire scene.

• The third fuzzy module uses the outputs of these two fuzzy modules; weighs 3 measures of exposure i.e. at average, at center and at the main subject, and then it outputs the final exposure value.

• The optimal combination of the shutter speed and aperture is determined by fuzzy inference using the type of scene and lens being used (see example in the next slide).

• The type of scene, for example snap, portrait, close-up, or natural scenery, is determined by the distance to the main subject.

• In a scenery shot the depth of field increases.

• Using fuzzy inferencing techniques, fine control according to scenery, lens charatcteristics, etc. can be achieved.

Page 66: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

131

Auto-Zooming Module• To implement auto-zooming, fuzzy reasoning is used to decide

the speed at which to zoom the lens.• When the main subject moves, the size of its image is held at

constant value by zooming appropriately to compensate for the movement.

• Fuzzy reasoning chooses the zooming speed by looking at the ratio of current lens magnification to that 1 unit time ago and its rate of change.

• The rules change the speed of the lens, depending on how the object moves.

132

Basic concepts of the inference rules for auto-exposure of the Minolta camera

KEY

L= Large, S = small, B=Big Consequents

Antecedents

Page 67: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

133

Blood Pressure Meter• Designed by National, Matsushita Electric Co., Japan• By using fuzzy logic technology, measurements taken are

more reliable and accurate• Measure both systolic and diastolic blood pressure

134

• What is blood pressure?• Blood pressure is the pressure exerted by blood pumped

from the heart on the walls of the blood vessels.• Systolic pressure is the pressure exerted when the heart

contracts and pumps blood into the arteries, while diastolic pressure is the pressure exerted when the heart expands.

• Blood pressure can vary according to a variety of factors including age, sex, and physical condition.

• It is lower during sleep and higher when working.

Importance of Maintaining Normal Blood Pressure

Page 68: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

135

• Abnormal blood pressure can indicate a number of illnesses such as:– Cardiovascular problems– Hypertensions– Diabetes– Liver disorder

• Blood pressure will be higher than usual when:– Excited or tense– Taking a bath– Exercising – Cold– Immediately after eating– Smoking tobacco, drinking coffee

• Blood pressure will be lower than usual when– After drinking alcohol– After taking a bath

136

Fuzzy Logic measurement in the Blood Pressure meter

• Blood flow in the veins give pulse-type waveforms. This allows measurement of blood pressure possible using pulse meters such as these.

• A number of factors affect blood pressure measurements such as:– Condition of the blood vessels– Structure of arm

• Thus making using conventional methods difficult.

• National employs fuzzy logic technology which double checks the strength and shape of the pulse wave and then determine the blood pressure.

Page 69: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

137

Fuzzy logic inference engine

Pulse wave shape and its rate of change

Pulse wave strength and its rate of change

Fuzzy Inference

Determination of Actual Blood Pressure

Pressure

Puls

e w

ave

Shap

e

Time

Pre

ssur

e

Pulse wave strength

138

Advantages of Fuzzy logic

• Measurement reliability has been improved for people with the following problems whose blood pressure was difficult to measure:– People with weak pulse– People with irregular pulse– People with unstable pulse

• Error in measurement is detected

Page 70: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

139

• First proposed in 1978 by Hitachi Ltd.• Granted permission to operate in 1986 after 300,000 simulations and

3,000 empty runs• Improved stop position by 3X• Reduced power setting by 2X• Total power use reduced by 10%• Finally, Hitachi was granted contracts for Tokyo Subway in 1991

Industrial Example #4

3.6.4 The Sendai Fuzzy Logic Subway System

140

• To measure the train performance, the following Performance Indices can be used:

• Traceability• Comfort• Safety• Running Time Margin• Stopping Accuracy

Membership functions

Page 71: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

141

142

Constant Speed Control (CSC)• In this mode, trains are started and run at predetermined target speed.

Train Automatic Stopping Control (TASC)• In this mode, trains are stopped in a predetermined target zone of a station

with high accuracy.

• Each component has its own fuzzy inference and rule base.• Rules are developed based on the following procedures:

Step 1 : Provide a description of the typical operating methods used by the operators

Step 2 : Define the performance indices of the systemStep 3 : Define a model for predictingStep 4 : Convert expert human operating methods into control rules

The train has 2 fuzzy components: (1) speed control and (2) stopping control.

Page 72: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

143

Example of the fuzzy rules

• For the CSCIf the control command is “Not Changed” And target speed is followed “Good”Then Command should “Not be Changed”

If control command is changed to “Zero”and coasting and riding comfort is “Good”and the target speed is followed “Very Good”Then Command should be changed to “Zero”

• For the TASCIf control command is changed to “Seventh step of braking”and safety against overrun is “Very Bad”Then Command should be changed to “Emergency Braking”

144

Comparison of the train acceleration between the fuzzy logic computer controller and a human controller.The fuzzy controller shows a more optimal response.

Page 73: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

145

Comparison of the Stop Gap Measure of the fuzzy controller and the PID controller

146

Comparison between the fuzzy system and manual operation of the Sendai Subway operating from one station to another. It can be observed that the fuzzy system is more optimal.

Page 74: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

147

Fuzzy Train Control by Hitachi Ltd.

148

Summary of the Sendai Fuzzy Train

• Fuzzy inference has been used with success in this project.• A number of distinct advantages are present in the fuzzy

train system over conventional train system such as riding comfort, stopping performance, power reduction, etc.

• Improved overall performance.• Human reasoning can be accommodated rather easily.

Page 75: Fuzzy Module 3 - Universiti Malaysia Perlisportal.unimap.edu.my/portal/page/portal30/Lecture... · • To study several applications of fuzzy logic in consumer products ... – 3.6.3

149

• A brief review of control system basics have been discussed for a better understanding of fuzzy logic purpose in control applications.

• Specific case studies of fuzzy logic control applications have been discussed in this module.

• Several commercial examples have also been discussed.

3.7 Summary of Module 3