# Designing Fuzzy Controller – Step by Step Guide

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

The following steps should be followed to for designing a fuzzy controller:

• Identification of variables: Input, output and state variables must be identified in the plant
• Fuzzy subset configuration: The universe of information spanned by each variable is divided into a 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 a fuzzy rule base by assigning a 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 a 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 the 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 a 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 the 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 a 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 a 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 subsets 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 the 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 are shown here:

Step 7: Identification of output

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

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

Step 8: Defuzzification

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

We can apply any defuzzification method on the 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

### 4 Responses

1. 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.

2. sudir says:

can you please mail me method of getting 67.937 value?