9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System...

77
9. Fuzzy Control Systems 2012

Transcript of 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System...

Page 1: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

9. Fuzzy Control Systems

2012

Page 2: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

2012

IntroductionA simple example of a control problem is a vehicle“cruise control” that provides the vehicle with thecapability of regulating its own speed at a driver-specifiedset-point (e.g., 60 Km/hr). One solution to the automotivecruise control problem involves adding an electroniccontroller that can sense the speed of the vehicle via thespeedometer and actuate the throttle position so as toregulate the vehicle speed as close as possible to thedriver-specified value even if there are road grade changes,head winds, or variations in the number of passengers oramount of cargo in the vehicle.

Page 3: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

2012

FuzzyKnowledge base

Fuzzifier InferenceEngine Defuzzifier Plant Output

Input

Page 4: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

2012

u(t) = input: throttle positiony(t) = output: vehicle speedr(t) = reference: desired speedd(t) = disturbance

Page 5: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

Hany Selim 5

Basically, while differential equations are the language ofconventional control, heuristics and “rules” about how tocontrol the plant are the language of fuzzy control.Design Constraints:•Disturbance rejection properties (e.g., for the cruisecontrol problem, that the control system will be able todampen out the effects of winds or road grade variations).•Insensitivity to plant parameter variations (the controlsystem will be able to compensate for changes in the totalmass of the vehicle)•Stability•Rise-time•Overshoot•Settling time•Steady-state error

2012

Page 6: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

6

Fuzzy Control System Design• What is the motivation for turning to fuzzy control?Basically, the difficult task of modeling and simulatingcomplex real-world systems for control systemsdevelopment represents usually a hurdle.• It is for this reason that in practice conventionalcontrollers are often developed via simple models of theplant behavior that satisfy the necessary assumptions, andvia the ad hoc tuning of relatively simple linear ornonlinear controllers.• Conventional control engineering approaches that useappropriate heuristics (Heuristics are “rules of thumb”, orcommon sense rules) to tune the design have beenrelatively successful.

2012

Page 7: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

7

• Now how much of the success can be attributed to the useof the mathematical model and conventional control designapproach, and how much should be attributed to the cleverheuristic tuning that the control engineer uses uponimplementation?• And if we exploit the use of heuristic information throughoutthe entire design process, can we obtain higher performancecontrol systems?• Fuzzy control provides a formal methodology forrepresenting, manipulating, and implementing a human’sheuristic knowledge about how to control a system.

2012

Page 8: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

8

Fuzzy Controller

Fuzzy controller embedded in a closed-loop control system

2012

Page 9: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

9

(1) The “rule-base” holds the knowledge, in the form of aset of rules, of how best to control the system.(2) The inference mechanism evaluates which control rulesare relevant at the current time and then decides what theinput to the plant should be.(3) The fuzzification interface simply modifies the inputs sothat they can be interpreted and compared to the rules inthe rule-base.(4) the defuzzification interface converts the conclusionsreached by the inference mechanism into the inputs to theplant.

Basically, you should view the fuzzy controller as anartificial decision maker that operates in a closed-loopsystem in real time. The rule-base is constructed so that itrepresents a human “expert in-the-loop.”

2012

Page 10: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

10

Fuzzy Controller ElementsFuzzy control system design essentially amounts to(1) choosing the fuzzy controller inputs and outputs.(2) choosing the preprocessing that is needed for thecontroller inputs and possibly postprocessing that is neededfor the outputs.(3) designing each of the four components of the fuzzycontroller shown.

2012

Page 11: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

11

For instance, one rule that a human driver may use is“If the speed is lower than the set-point, then pressdown further on the accelerator pedal.”A rule that would represent even more detailed informationabout how to regulate the speed would be“If the speed is lower than the set-point AND thespeed is approaching the set-point very fast, thenrelease the accelerator pedal by a small amount.”This second rule characterizes our knowledge about how tomake sure that we do not overshoot our desired goal (theset-point speed).

2012

Page 12: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

2012

Causes for concern when employlng a strategy of gatheringheuristic control knowledge:• Will the behaviors that are observed by a human expertand used to construct the fuzzy controller include allsituations that can occur due to disturbances, noise, orplant parameter variations?• Can the human expert realistically and reliably foreseeproblems that could arise from closed-loop systeminstabilities?• Will the human expert be able to effectively incorporatestability criteria and performance objectives (e.g., rise-time,overshoot, and tracking specifications) into a rule-base toensure that reliable operation can be obtained?

Page 13: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

13

Examples of Application Areas Aircraft/spacecraft: Flight control, engine control, avionicsystems, failure diagnosis, navigation, and satellite attitudecontrol. Automobiles: Brakes, transmission, suspension, andengine control. Manufacturing systems: Scheduling and depositionprocess control. Power industry: Motor control, power control/distribution,and load estimation. Process control: Temperature, pressure, and levelcontrol, failure diagnosis, distillation column control, anddesalination processes. Robotics: Position control and path planning. Home automation.

2012

Page 14: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

2012

Fuzzy Controller Designconsider a simple problem of balancing an invertedpendulum on a cart, as shown in Figure 1. This is a verysimple and academic nonlinear control problem, and manygood techniques already exist for its solution. Indeed, forthis standard configuration, a simple PID controller workswell even in implementation.

Fig.1

Page 15: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

15

y denotes the angle that thependulum makes with thevertical (in radians),

l is the half-pendulum length(in meters),

F is the force input that movesthe cart (in Newtons)

r denotes the desired angularposition of the pendulum.

The goal is to balance thependulum in the uprightposition (i.e., r = 0) when itinitially starts with somenonzero angle off the vertical(i.e., y ≠ 0).

Fig.1 (again!)

2012

Page 16: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

Hany Selim 16

I. Choosing Fuzzy Controller Inputs and OutputsConsider a human-in-the-loop whose responsibility is to controlthe pendulum. The fuzzy controller is to be designed toautomate how a human expert who is successful at this taskwould control the system.Suppose that the expert needs to use

e(t) = r(t) − y(t) ,andd/dt(e(t))

as the variables on which to base decisions.Next, we must identify the controlled variable. In our case weare allowed to control only the force that moves the cart.

Fig. 2 Human in the loop

2012

Page 17: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

17

The designer may implement some filtering or otherprocessing of the plant outputs.The fuzzy control system for our system is shown in Figure3.

Fig. 3

2012

Page 18: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

18

Putting Control Knowledge into Rule-BaseSuppose that the human expert provides a description ofhow best to control the plant in natural language. We seekto take this “linguistic” description and load it into the fuzzycontroller, as indicated by the arrow in Figure.The “linguistic variables” that describe each of the timevarying fuzzy controller inputs and outputs are given by:

“error” describes e(t)“change-in-error” describes d/dt (e(t))“force” describes F(t)

2012

Page 19: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

19

The linguistic variables assume “linguistic values.” That is,the values that linguistic variables take on over time changedynamically. Suppose for our case that “error,” “change-in-error,” and “force” take on the following values:

“negative large” represented by “NL”“negative small” represented by “NS”“zero” represented by “Z”“positive small” represented by “PS”“positive large” represented by “PL”

2012

Page 20: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

20

Recallthat for the inverted pendulumr = 0 ande = r − y so thate = −yandd/dt (e) = − d/dt (y)since d/dt (r) = 0.

2012

Page 21: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

21

For the inverted pendulum each of thefollowing statements quantifies adifferent configuration of the pendulum(refer to Figure1):• The statement “error is PL” canrepresent the situation where thependulum is at a significant angle tothe left of the vertical.• The statement “error is NS” canrepresent the situation where thependulum is just slightly to the right ofthe vertical, but not too close to thevertical to justify quantifying it as“zero” and not too far away to justifyquantifying it as “NL.”

Fig. 1 (another time!)

2012

Page 22: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

22

•The statement “error is zero” canrepresent the situation where thependulum is very near the verticalposition (a linguistic quantificationis not precise, hence we are willingto accept any value of the erroraround e(t) = 0 as beingquantified linguistically by “zero”since this can be considered abetter quantification than “PS” or“NS”).• The statement “error is PL andchange-in-error is PS” canrepresent the situation where thependulum is to the left of thevertical and, since d/dt(y) < 0, thependulum is moving away fromthe upright position (note that inthis case the pendulum is movingcounterclockwise).

!!

2012

Page 23: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

23

•The statement “error is NSand change-in-error is PS” canrepresent the situation wherethe pendulum is slightly to theright of the vertical and, sinced/dt (y) < 0, the pendulum ismoving toward the uprightposition (note that in this casethe pendulum is also movingcounterclockwise).

!!!

2012

Page 24: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

24

II. Rule-BaseThe rule-base captures the expert’s knowledge about howto control the plant. In particular, for the three positions

shown in Figure 4, we have the following rules

Fig. 4 Inverted Pendulum in various positions

2012

Page 25: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

25

Rule 1If error is NL and change-in-error is NL Then force is PL

This rule quantifies the situation in Figure 4a where thependulum has a large positive angle and is moving clockwise;hence it is clear that we should apply a strong positive force (tothe right) so that we can try to start the pendulum moving inthe proper direction.

2012

Page 26: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

26

Rule 2If error is zero and change-in-error is PS Then force is NS

This rule quantifies the situation in Figure 4b where thependulum has nearly a zero angle with the vertical (a linguisticquantification of zero does not imply that e(t) = 0 exactly) andis moving counterclockwise; hence we should apply a smallnegative force (to the left) to counteract the movement so thatit moves toward zero (a positive force could result in thependulum overshooting the desired position).

2012

Page 27: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

27

Rule 3If error is PL and change-in-error is NS Then force is NS

This rule quantifies the situation in Figure 4c where thependulum is far to the left of the vertical and is movingclockwise; hence we should apply a small negative force (tothe left) to assist the movement, but not a big one since thependulum is already moving in the proper direction.

2012

Page 28: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

28

Each of the three rules listed above is a “linguistic rule”since it is formed solely from linguistic variables and values.

Since linguistic values are not precise representations of theunderlying quantities that they describe, linguistic rules arenot precise either. They are simply abstract ideas abouthow to achieve good control that could mean somewhatdifferent things to different people. They are, however, at alevel of abstraction that humans are often comfortable within terms of specifying how to control a process.

2012

Page 29: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

29

The general form of the linguistic rules listed above is

If antecedent Then consequent

As you can see from the three rules listed above, theantecedents are associated with the fuzzy controller inputsand the consequents (sometimes called “actions”) areassociated with the fuzzy controller outputs.

• Notice that each antecedent (or consequent) can becomposed of the conjunction of several “terms” (e.g., rule 3above). The number of fuzzy controller inputs and outputsplaces an upper limit on the number of elements in theantecedents and consequents. Note that there does notneed to be a antecedent (consequent) term for each input(output) in each rule, although often there is.

2012

Page 30: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

30

Using the above approach, we could continue to write downrules for the pendulum problem for all possible cases.Note that for the pendulum problem, with two inputs andfive linguistic values for each of these, there are at most 52

= 25 possible rulesA tabular representation of one possible set of rules for theinverted pendulum is shown in Table1.

Table1 Rule Table for the inverted pendulum

2012

Page 31: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

31

III. Fuzzy Quantification of Knowledge(Membership Functions):Figure 5 is a plot of a function μ versus e(t) that takes onspecial meaning. The function μ quantifies the certainty thate(t) can be classified linguistically as “PS.”

Fig.5

2012

Page 32: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

32

• For some applications if we are absolutely certain that anyvalue of e(t) near π/ 4 is still “PS” and only when you getsufficiently far from π/ 4 do we lose our confidence that it is“PS.” One way to characterize this understanding of themeaning of “PS” is via the trapezoid-shaped membershipfunction in Figure 6a.• For other applications you may think of membership inthe set of “PS” values as being dictated by the Gaussian-shaped membership function (not to be confused with theGaussian probability density function) shown in Figure 6b.

Fig.6a,b

2012

Page 33: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

33

• For still other applications values far away from π/ 4 are notaccepted as being PS,” so you may use the membershipfunction in Figure 6c to represent this.• Finally, while we often think of symmetric characterizationsof the meaning of linguistic values, we are not restricted tothese symmetric representations. For instance, in Figure 6dwe represent that we believe that as e(t) moves to the left ofπ/ 4 we are very quick to reduce our confidence that it is“PS,” but if we move to the right of π/ 4 our confidence thate(t) is “PS,” diminishes at a slower rate.

Fig.6c,d

2012

Page 34: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

34

For the output F, themembership functionsat the outermost edgescannot be saturated forthe fuzzy system to beproperly defined. Thebasic reason for this isthat we want to indicateto a process actuator,“any value of F biggerthan, say, 30, is notacceptable.”

Fig.8 Membership functions for aninverted pendulum over a cart

2012

Page 35: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

35

Note that e(t) changes its value over time. For instance, ase(t) changes from –π/2 to π/2 the various membershipfunctions will change their values. For example, at e(t) =−π/2 we are certain that the error is “NL,” and as the valueof e(t) moves toward –π/4 we become less certain that it is“NL” and more certain that it is “NS.”

2012

Page 36: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

36

IV. FuzzificationIt is actually the case that for most fuzzy controllers thefuzzification block on slide 7 can be simplified and undercertain conditions virtually ignored.The fuzzification process is the act of obtaining a value ofan input variable and finding the numeric values of themembership function(s) that are defined for that variable.For example,If e(t) = 0 and d/dt( e(t)) = 3π/16,the fuzzification process amounts to finding the values ofthe input membership functions for these. In this caseμZ(e(t)) = 1 ; with all other values of membershipfunctions=0andµZ (d/dt(e(t) ) = 0.25 and µPS (d/dt(e(t) ) = 0.75

2012

Page 37: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

37

This information is then used in the fuzzy inference processthat starts with “matching.”:The antecedent of all the rules are compared to thecontroller inputs to determine which rules apply to thecurrent situation.

Fig.9 Input membership functions with input values.2012

Page 38: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

38

Now take the Rule:If e(t) is Z and d/dt(e(t)) is Z then F is Z

If we are not very certain about the truth of one statement,how can we be any more certain about the truth of thatstatement “and” the other statement? For this reason, weuse the minimum of both degrees of membership i.e.μantecedent= min (1,0.25) = 0.25

Table 2 Rule Table with Rules That Are “On” Highlighted2012

Page 39: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

Hany Selim 39

V. Inference Step: Determining Consequences:We now consider the rules that are on or match:1st Rule:

If error is Z and change-in-error is Z Then force is Zµ1 = min {1,0.25} = 0.25so that we are 0.25 certain that this rule applies to the currentsituation.

Fig.10 Implied fuzzy set with membership function μ1(F) for Rule 1

2012

Page 40: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

40

2nd Rule:If error is Z and change-in-error is PS Then force is NS

µ2 = min {1,0.75} = 0.75

Fig. 11 Implied fuzzy set with membership function μ2(F) for Rule 2

2012

Page 41: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

41

VI. Converting Decisions into Actions(Defuzzification)Next, we consider the defuzzification operation, which is thefinal component of the fuzzy controller. Defuzzificationoperates on the implied fuzzy sets produced by theinference mechanism and combines their effects to providethe “most certain” controller output (plant input). In otherwords we want to find the one output, which we denote by“Fcrisp” ,that best represents the conclusions of the fuzzycontroller that are represented with the implied fuzzy sets.

2012

Page 42: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

42

Fig.12 Implied fuzzy sets

2012

Page 43: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

43

In fig.8 it was stated that the Force F cannot be saturated,otherwise we would have got an output membershipfunctions that have infinite area.Now we use the “center of gravity” (COG) or “Centroid”defuzzification method for combining the recommendationsrepresented by the implied fuzzy sets from all the rules.Using simple geometry, we get for the area under a triangle“chopped off” at a height of h and with base width w:

A = w(h – h2/2)and in our case

Fcrisp =[ (0).(20(0.25-0.5(0.25)2) + (-10).(20(0.75-0.5(0.75)2)]/[(20(0.25-0.5(0.25)2) + (20(0.75-0.5(0.75)2)

Fcrisp = -93.75/[4.375+9.375] = -6.81 N

2012

Page 44: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

44

It is interesting to note that the method of Center of gravitylimits the range of force between -20N and+20N (see fig.13). Practically speaking, this ability to limit the range ofinputs to the plant is useful; it may be the case thatapplying a force of greater than 20N is impossible for thisplant.

Fig. 13 Output membership functions

2012

Page 45: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

Hany Selim 45

Summing up:

Fig.14 Graphical representation of fuzzycontroller operations

2012

Page 46: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

46

Fuzzy Systems Are Universal ApproximatorsFuzzy systems have very strong functional capabilities. Thatis, if properly constructed, they can perform very complexoperations. There always exists a way to define the fuzzysystem f(u) by picking the membership function parametersso that the achieved error is arbitrarily small. But this doesnot say how to find the fuzzy system. Furthermore, forarbitrary accuracy you may need an arbitrarily largenumber of rules.

2012

Page 47: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

47

For control, practically speaking, it means that there isgreat flexibility in tuning the nonlinear functionimplemented by the fuzzy controller. Generally, however,there are no guarantees that you will be able to meet yourstability and performance specifications by properly tuninga given fuzzy controller. You also have to choose theappropriate controller inputs and outputs, and there will befundamental limitations imposed by the plant that mayprohibit achieving certain control objectives no matter howyou tune the fuzzy controller.

2012

Page 48: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

48

VII. Simulation results for the inverted pendulumconsider the initial conditions:e(0) = 0.1 radians (= 5.73°)and,e˙(0) = 0,and the initial condition for theactuator stateF(t) = 0.The results are shown in Fig.15,where we see in the upper plotthat the output appropriatelymoves toward the invertedposition, and the force input inthe lower plot that moves backand forth to achieve this. fig.15 First design of the Fuzzy Controller

2012

Page 49: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

49

To speed up the settling of the pendulum we may usestandard ideas from control engineering to conclude that weought to try to tune the “derivative gain.” To do this weintroduce gains on the proportional and derivative terms, asshown in Fig.16.

fig.16 Fuzzy controller for inverted pendulum with scaling gains

2012

Page 50: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

50

(a) (b)

fig.17 Fuzzy controller balancing with (a) g0=1, g1=0.1 and h=1(b) g0=2, g1=0.1 and h=1

2012

Page 51: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

51

fig.18 Fuzzy controller balancing with g0=2, g1=0.1 and h=5

2012

Page 52: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

52

We see that the change in the scaling gains at the input andoutput of the fuzzy controller can have a significant impacton the performance of the resulting fuzzy control system,and hence they are often convenient parameters for tuning.The effect of the input scaling gain g1=0.1 results in scalingthe horizontal axis of the membership functions by 1/g1=10as shown in fig.19.

fig.19 effect of g1=0.1 on the membership function

2012

Page 53: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

53

Tuning of Membership FunctionsIt is important to realize that the scaling gains are not theonly parameters that can be tuned to improve theperformance of the fuzzy control system. Indeed, sometimesit is the case that for a given rule-base and membershipfunctions you cannot achieve the desired performance bytuning only the scaling gains. Often, what is needed is amore careful consideration of how to specify additionalrules or better membership functions.The problem with this is that there are often too manyparameters to tune (e.g., membership function shapes,positioning, and number and type of rules) and often there isnot a clear connection between the design objectives (e.g.,better rise-time) and a rationale and method that should beused to tune these parameters.

2012

Page 54: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

54

Output Membership Function TuningIn the following one of the methods that are very useful forthe tuning by real implementations of fuzzy control systemswill be examined:In fig.13 the centers of the membership functions were at-20 , -10 , 0 , 10 , 20 that isCenter = 10 . iand if we scale by h thenCenter = 10. h . iWe see that a linear relationship in the equation produces alinear (uniform) spacing of the membership functions.Suppose that we instead choose:Center = 5. h . sign(i ) . i2 orCenter = 5. h . i3

2012

Page 55: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

55

Both equations will have the effect of making the outputmembership function centers near the origin be moreclosely spaced than the membership functions farther outon the horizontal axis. The effect of this is to make the“gain” of the fuzzy controller smaller when the signals aresmall and larger as the signals grow larger. Hence, the useof the equations above for the centers indicates that if theerror and change-in-error for the pendulum are near wherethey should be, then do not make the force input to theplant too big, but if the error and change-in-error are large,then the force input should be much bigger so that itquickly returns the pendulum to near the balanced position.

2012

Page 56: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

Hany Selim 56

Ultimately, the goal of tuning is to shape the nonlinearitythat is implemented by the fuzzy controller. Thisnonlinearity, sometimes called the “control surface,” isaffected by all the main fuzzy controller parameters.

Fig.20 Control surfaceof the fuzzy controllerfor g0 = 2.0, g1 = 0.1,and h = 5.

2012

Page 57: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

Hany Selim 57

When we tune the fuzzy controller, it changes the shape ofthe control surface, which in turn affects the behavior of theclosed-loop control system.Note, that the slope of the surface is greater for largersignals in Fig.21 than in Fig.20. This further illustrates theeffect of the choice ofthe nonlinear spacingfor the outputmembership functioncenters.

Fig.21 Control surface ofthe fuzzy controller for g0 =2.0, g1 = 0.1, and h = 10and center = 5.h.sign(i ).i2

2012

Page 58: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

58

Basic Design Guidelines1.Be careful to choose the proper inputs to the fuzzycontroller. Carefully assess whether you need proportional,integral, and derivative inputs (using standard controlengineering ideas). Consider processing plant data into aform that you believe would be most useful for you to controlthe system if you were actually a “human-in-the-loop.”Specify your best guess at as simple a fuzzy controller aspossible (do not add inputs, rules, or membership functionsuntil you know you need them).2.Try tuning the fuzzy controller using the scaling gains, aswe discussed in the previous section.3.Try adding or modifying rules and membership functions sothat you more accurately characterize the best way to controlthe plant (this can sometimes require significant insight intothe physics of the plant).

2012

Page 59: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

59

4. Try to incorporate higher-level ideas about how best tocontrol the plant. For instance, try to shape thenonlinear control surface using a nonlinear function ofthe linguistic-numeric values, as explained in theprevious section.

5. If there is unsmooth or chattering behavior, you mayhave a gain set too high on an input to the fuzzycontroller (or perhaps the output gain is too high).Setting the input gain too high makes it so that themembership functions saturate for very low values,which can result in oscillations (i.e., limit cycles).

6. Sometimes the addition of more membership functionsand rules can help. These can provide for a “finer” (or“higher-granularity”) control, which can sometimesreduce chattering or oscillations.

2012

Page 60: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

60

Example: Air Conditioner Fuzzy Control1a. Specify the problem:Air-conditioning involves the delivery of air which can bewarmed or cooled and have its humidity raised or lowered.

An air-conditioner is an apparatus for controlling, especiallylowering, the temperature and humidity of an enclosedspace. An air-conditioner typically has a fan whichblows/cools/circulates fresh air and has cooler and thecooler is under thermostatic control. Generally, the amountof air being compressed is proportional to the ambienttemperature.

2012

Page 61: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

61

1b. Define linguistic variablesConsider an air conditioner which has five control switches:COLD, COOL, PLEASANT, WARM and HOT. Thecorresponding speeds of the motor controlling the fan onthe air-conditioner has the graduations: MINIMAL, SLOW,MEDIUM, FAST and BLAST.Thus we have:

• Ambient Temperature

• Air-conditioner Fan Speed

2012

Page 62: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

62

2. Determine Fuzzy Sets: TemperatureTemp(0C).

COLD COOL PLEASANT WARM HOT

0 Y* N N N N5 Y Y N N N

10 N Y N N N12.5 N Y* N N N

15 N Y N N N17.5 N N Y* N N

20 N N N Y N22.5 N N N Y* N

25 N N N Y N27.5 N N N N Y

30 N N N N Y*

Temp(0C).

COLD COOL PLEASANT WARM HOT

0< (T)<1

(T)=1

(T)=0

2012

Page 63: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

63

and corresponding fuzzy membership functions

Temperature Fuzzy Sets

00.10.20.30.40.50.60.70.80.9

1

0 5 10 15 20 25 30

Temperature Degrees C

Tru

th V

alu

e ColdCoolPleasentWarmHot

Temperature Fuzzy Sets

00.10.20.30.40.50.60.70.80.9

1

0 5 10 15 20 25 30

Temperature Degrees C

Tru

th V

alue

ColdCoolPleasentWarmHot

2012

Page 64: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

64

Fuzzy Sets: Fan Speed

Rev/sec(RPM)

MINIMAL SLOW MEDIUM FAST BLAST

0 Y* N N N N10 Y N N N N20 Y Y N N N30 N Y* N N N40 N Y N N N50 N N Y* N N60 N N N Y N70 N N N Y* N80 N N N Y Y90 N N N N Y

100 N N N N Y*

2012

Page 65: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

65

and corresponding fuzzy membership functions

Speed Fuzzy Sets

0

0.2

0.4

0.6

0.8

1

0 10 20 30 40 50 60 70 80 90 100

Speed

Tru

th V

alue

MINIMALSLOWMEDIUMFASTBLAST

2012

Page 66: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

66

3. construct fuzzy rules

RULE 1: IF temp is cold THEN speed is minimalRULE 2: IF temp is cool THEN speed is slowRULE 3: IF temp is pleasant THEN speed is mediumRULE 4: IF temp is warm THEN speed is fastRULE 5: IF temp is hot THEN speed is blast

2012

Page 67: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

67

Consider now a temperature of 16oC, use the systemto compute the optimal fan speed.

Operation of a Fuzzy Expert System

• Fuzzification• Inference• Composition• Defuzzification

4. Encode into an Expert System......

2012

Page 68: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

68

• Fuzzification

Affected fuzzy sets: COOL and PLEASANT

COOL(T) = – T / 5 + 3.5= – 16 / 5 + 3.5= 0.3

PLSNT(T) = T /2.5 - 6= 16 /2.5 - 6= 0.4

Temp=16 COLD COOL PLEASANT WARM HOT

0 0.3 0.4 0 0

2012

Page 69: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

69

• Inference

RULE 1: IF temp is cold THEN speed is minimalRULE 2: IF temp is cool THEN speed is slowRULE 3: IF temp is pleasant THEN speed is mediumRULE 4: IF temp is warm THEN speed is fastRULE 5: IF temp is hot THEN speed is blast

2012

Page 70: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

70

RULE 2: IF temp is cool (0.3) THEN speed is slow (0.3)

RULE 3: IF temp is pleasant (0.4) THEN speed is medium (0.4)

• Inference

2012

Page 71: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

71

• Composition

speed is slow (0.3) speed is medium (0.4)+ ∑

2012

Page 72: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

72

• Composition

speed is slow (0.3) speed is medium (0.4)+ ∑

2012

Page 73: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

73

• Defuzzification

COG = 0.125(12.5) + 0.25(15) + 0.3(17.5+20+…+40+42.5) + 0.4(45+47.5+…+52.5+55) + 0.25(57.5)0.125 + 0.25 + 0.3(11) + 0.4(5) + 0.25

= 45.54rpm

2012

Page 74: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

Hany Selim 74

Another Fuzzy ControlExampleWe want to conduct a simulation of the finaldescent and landing approach of anaircraft. The desired profile is shown in Fig.The two state variables for this simulationwill be the height above ground, h, and thevertical velocity of the aircraft, v. The

2012

control output will be a force that, when applied to the aircraft, will alterits height, h, and velocity, v.The differential control equations are derived as follows.. Mass mmoving with velocity v has momentum p = mv. If a force f is appliedover a time interval Δt, a change in velocity of Δv = f.Δt/m will result. Ifwe let Δt = 1.0 (s) and m = 1.0 (lb s2/ft), we obtain Δv = f (lb), or thechange in velocity is proportional to the applied force. In differencenotation we get

vi+1 = vi + fihi+1 = hi + vi ·Δt

Page 75: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

75

Define the membership functions as:

2012

Page 76: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

76

Control force (output) membership function

And given the Rules

2012

Page 77: 9. Fuzzy Control Systems - Stay Hungry Stay Foolish ... · 09/01/2013 · 6 Fuzzy Control System Design • What is the motivation for turning to fuzzy control? Basically, the difficult

77

If:Initial height, h0: 1000 ftInitial Vertical velocity, v0:−20 ft/s

We calculate the defuzzified force and apply it for Δt =1s ; afterwhich:vi+1 = vi + fihi+1 = hi + vi

we then conduct a simulation for four cycles.

2012