# Designing Fuzzy Controller – Step by Step Guide

Designing fuzzy controller requires knowledge of fuzzy inference systems such as Mamdani approach of Takagi-Sugeno approach. Fuzzy logic controllers are based on fuzzy logic. Most of the embedded devices are nowadays implements one or other kind of FLC, for example air conditioner, washing machine, traffic light controller, flight navigation system and many more.

Following steps should be followed to for designing fuzzy controller:

• Identification of variables: Input, output and state variables must be identified of the plant
• Fuzzy subset configuration: The universe of information spanned by each variable is divided into number of fuzzy subsets and each subset is assigned a linguistic variable
• Obtaining membership function: Obtain membership function for each fuzzy subset
• Fuzzy Rule Base Configuration: Formulate fuzzy rule base by assigning relationship between fuzzy input and output
• Normalizing and scaling factors: Appropriate scaling factors for input and output variables must be chosen to normalize variables between [0, 1] and [-1, 1] intervals
• Fuzzification: The Fuzzification process is done in this step with the help of Fuzzifier
• Identification  of output: Identify the output from each rule using fuzzy approximate reasoning and combine the fuzzy output obtained from each rule
• Defuzzification: Initiate Defuzzification process to form crisp output

Let us try to understand this with an example:

## Example:

Consider the design of a fuzzy controller for a steam turbine. Assume the input of the fuzzy controller as temperature and pressure. The output will be the throttle setting of a steam turbine. Use 3 descriptors for input and 5 descriptors for output variables. Derive the set of rules for controller action and get the defuzzified values.

Assume that the current temperature is 30% and pressure is 40% and we have to determine the throttle position of the turbine for this particular condition

Solution:

Step 1: Identification of variables

• Inputs: Temperature and pressure
• Output: Throttle setting of steam turbine

Step 2: Fuzzy subset configuration

Assign a linguistic descriptor for each fuzzy subset

• Temperature: Cool, Nominal, Warm
• Pressure: Low, Ok, Strong
• Throttle Setting:
• N2: Large Negative
• N1: Small Negative
• Z: Zero
• P1: Small Positive
• P2: Large Positive

Step 3: Obtain Membership Function

Define membership functions for descriptors (Temperature)

The fuzzy membership function for temperature is depicted in following figure:

From similar triangle rule we know that, (y2 – y1) / (x2 – x1) = (y – y1) / (x – x1)

For fuzzy set COOL:

[0, 20] ⇒ (0 – 1) / (20 – 0) = (y – 1) / (x – 0)

μCool = (20 – xT) / 20

For fuzzy set NOMINAL:

[0, 20] ⇒ (1 – 0) / (20 – 0) = (y – 0) / (x – 0)

⇒ μ =xT / 20

[20, 40] ⇒ (0 – 1) / (40 – 20) = (y – 1) / (x – 20)

⇒ μ = (40 – xT) / 20

Combining both in single equation,

For fuzzy set WARM:

[20, 40] ⇒ (1 – 0) / (40 – 20) = (y – 0) / (x – 20)

μwarm = (xT – 20) / 20

Define membership functions for descriptors (Pressure)

The fuzzy membership function for pressure is depicted in following figure:

For fuzzy set LOW:

[0, 50] ⇒ (0 – 1) / (50 – 0) = (y – 1) / (x – 0)

μlow = (50 – xP) / 50

For fuzzy set OK:

[0, 50] ⇒ (1 – 0) / (50 – 0) = (y – 0) / (x – 0)

⇒ μ = xP / 50

[50, 100] ⇒ (0 – 1) / (100 – 50) = (y – 1) / (x – 500)

⇒ μ = (100 – xP) / 50

Combining both in single equation,

For fuzzy set STRONG:

[50, 100] ⇒ (1 – 0) / (100 – 50) = (y – 0) / (x – 50)

μStrong = (xP – 50) / 50

Define membership functions for descriptors (Rotation)

In similar way, we can compute the membership function for rotation, as shown below:

Step 4: Fuzzy rule base configuration

As we assumed, this controller has 3 fuzzy sub sets for temperature and 3 fuzzy subsets for pressure. So rule base will contain 3 x 3 i.e. 9 rules.

The rule base for given inputs and fuzzy sub sets is depicted in following table:

Step 6: Fuzzification

30 % of temperature:

xT = (40 ∗ 30) / 100 = 12

μCool = (20 – xT) / 20 = (20 – 12) / 20 = 8 / 20 = 2/5

μNominal = xT / 20 = 12 / 20 = 3/5

40 % of pressure:

xP = (100 ∗ 40) / 100 = 40

μlow = (50 – xP) / 50 = (50 – 40) / 50 = 10 / 50 = 1/5

μOk = xP / 50 = 40 / 50 = 4/5

Fired rules and the rule base for them is shown here:

Step 7: Identification of output

From rule base of fired rules, we can derive following rules,

1. Rule 1: If temperature is cool and pressure is low, then throttle setting is P2
2. Rule 2: If temperature is cool and pressure is ok, then throttle setting is Z
3. Rule 3: If temperature is nominal and pressure is low, then throttle setting is P2
4. Rule 4: If temperature is nominal and pressure is ok, then throttle setting is Z

Step 8: Defuzzification

Firing strength of each rule is highlighted in different colors in above figures. To compute the corresponding crisp value, we shall aggregate all output functions by placing them on same axis.

We can apply any defuzzification method on above aggregated output function to find the crisp value. Let us apply weighted average method.

Thus, for 40% of temperature (xT = 12) and 30% of pressure (xP = 30), we shall rotate the throttle by 16.984o.

## Watch on YouTube: Designing Fuzzy Controller

### 2 Responses

1. Tohid Abedini says:

Thanks for your complete tutorial. I think in the last formula for computing x*, denominator should be sum of miu1 and miu2. It matches with the final answer.

• codecrucks says:

Yes dear. Thanks for bringing it to my notice. Good observation. I will correct the typo mistake.