**2. Fuzzy logic applied to control: Fuzzy control of temperature**

The use of the Fuzzy Logic methodology in real systems is immediately applicable to those systems whose behavior is known based on imprecisely defined rules. This imprecision arises from the complexity of the system itself. The way to approach such a problem is to reduce the complexity by increasing the uncertainty of the variables (J. Sala et al., 2000; Yager & Filev, 1994). Thus, in problems that present non-linearities, and to which classical control techniques are hardest to apply, these techniques are very useful and easy to use (Takana & Sugeno, 1992; Tanaka & Wang, 2001; Wang, 1994).

In the vast majority of systems, be they highly complex or not, the systems' behavior can be given by a set of rules that are often imprecise, or that rely on linguistic terms laden with uncertainty. This results in rules of the type "If the volume is large, the pressure is small", which define the behavior of a system. If we focus on the rules that are defined to control the system, we can formulate different rules of the type "If the cost is small and the quality is good, make a large investment".

This last rule type is the most frequently seen in daily life. For example, to regulate water flow from a faucet, we need only apply rules of the type "If the flow is excessive, close the tap a lot", or "If the flow is low, open the tap a little" in order to carry out the desired action. Using precise magnitudes such as "flow rate of 1.2 gallons/minute" or "turn 45º clockwise" is unnecessary.

Therefore, a general knowledge base for the system is available; that is, a set of rules that aim to model the actions to be carried out on the system so as to achieve the desired action. Said rules are provided by an expert, one whose experience with handling the system provides him with knowledge of how the system behaves.

The Mandani fuzzy inference mechanism is very useful when applying Fuzzy Logic to the control of systems (Passino, 1998). If we consider a classic feedback scheme, the controller has enough information about the system to determine the command that must be applied to said system so as to achieve a desired setpoint. The idea, put forth by Zadeh, for using Fuzzy Control algorithms relies on introducing the knowledge base into the controller such that its output is determined by the control rules proposed by the expert. Said rules contain fuzzy sets (linguistic terms) in the antecedents and in the consequents, and hence they are referred to as a whole as a fuzzy control rule base.

If we wish to apply this control scheme to a real system, the fuzzy controller must be adjusted to existing sensor and actuator technology, which relies on precise magnitudes (Jantzen, 2007). The exact values provided by a sensor must therefore be converted into the

Control Application Using Fuzzy Logic: Design of a Fuzzy Temperature Controller 383

Consider the system shown in Figure 2, where To is the temperature of the liquid that we wish to control and Ta is the ambient temperature. The input produced by the heating element is denoted with the letter q, and the desired temperature is Td. The model for the system, keeping in mind that there are two energy sources (one generated by the heating element and one from the environment), is given by the transfer matrix that results when each of the inputs is considered separately. The expression shown in Equation 1 yields G1(s)

> 1 2 ( ) () () ( ) *T s <sup>o</sup> Gs Gs*

( ) ( ) ( ) <sup>1</sup> *a*

( ) <sup>1</sup> ( ) ( ) <sup>1</sup> *o*

*T s MC*

This is a simple academic problem and many techniques are available for solving it, such as a classic PI controller. We will use it in this text, however, to illustrate the design and

We may conclude then that the procedure for implementing these fuzzy techniques to

1. First stage, to be completed before the control algorithm is executed, and consisting of:

2. Second stage, to be completed with each step of the control algorithm, and consisting of:

b. Fuzzification: Assigning the precise values to the fuzzy input sets and calculating the

a. Establishing the controller's input and output variables (linguistic variables).

e. Defining the fuzzification, inference and defuzzification mechanisms.

*e a*

*T s <sup>A</sup> G s Q s MC*

1

2

3. : heat transfer coefficient between the tank and the environment

*T s G s*

*e*

*s A*

1

*s A*

*Q s* (1)

(2)

(3)

and G2(s), given in Equations 2 and 3, respectively.

where:

1. M: Mass of liquid 2. Ce: Specific heat

4. A: heat transfer area 5. To: temperature of liquid 6. Ta: ambient temperature

operation of a fuzzy controller.

**3. General outline of the fuzzy controller** 

b. Defining each variable's fuzzy sets. c. Defining the sets' membership functions.

a. Obtaining the precise input values.

d. Establishing the rule base.

control systems consists of two very different stages:

degree of membership for each of those sets.

7. Q: heat input

fuzzy values that comprise the variables of the antecedent in the rule base. Likewise, the fuzzy values inferred from the rules must be transformed into exact values for use in the actuators. A diagram of this process is shown in Figure 1.

Fig. 1. Fuzzy controller

A block diagram for a fuzzy control system is given in Figure 1. The fuzzy controller consists of the following four components:


We shall now present a simple temperature control example, shown in Figure 2, to introduce each of the fuzzy controller components.

Fig. 2. Temperature controller.

Consider the system shown in Figure 2, where To is the temperature of the liquid that we wish to control and Ta is the ambient temperature. The input produced by the heating element is denoted with the letter q, and the desired temperature is Td. The model for the system, keeping in mind that there are two energy sources (one generated by the heating element and one from the environment), is given by the transfer matrix that results when each of the inputs is considered separately. The expression shown in Equation 1 yields G1(s) and G2(s), given in Equations 2 and 3, respectively.

$$\frac{T\_o(s)}{Q(s)} = G\_1(s) \* G\_2(s) \tag{1}$$

$$\mathbf{G}\_1(\mathbf{s}) = \frac{T\_a(\mathbf{s})}{Q(\mathbf{s})} = \frac{\frac{1}{\mu A}}{\frac{M \mathbf{C}\_e}{\mu A} \mathbf{s} + 1} \tag{2}$$

$$G\_2(s) = \frac{T\_o(s)}{T\_a(s)} = \frac{1}{\frac{M C\_c}{\mu A} s + 1} \tag{3}$$

where:

382 Fuzzy Inference System – Theory and Applications

fuzzy values that comprise the variables of the antecedent in the rule base. Likewise, the fuzzy values inferred from the rules must be transformed into exact values for use in the

A block diagram for a fuzzy control system is given in Figure 1. The fuzzy controller

1. Rule base: set of fuzzy rules of the type "if-then" which use fuzzy logic to quantify the

2. Inference mechanism: emulates the expert's decision-making process by interpreting and applying existing knowledge to determine the best control to apply in a given

3. Fuzzification interface: converts the controller inputs into fuzzy information that the inference process can easily use to activate and trigger the corresponding rules. 4. Defuzzification interface: converts the inference mechanism's conclusions into exact

We shall now present a simple temperature control example, shown in Figure 2, to

expert's linguistic descriptions regarding how to control the plant.

actuators. A diagram of this process is shown in Figure 1.

Fig. 1. Fuzzy controller

situation.

consists of the following four components:

inputs for the system to be controlled.

Fig. 2. Temperature controller.

introduce each of the fuzzy controller components.


This is a simple academic problem and many techniques are available for solving it, such as a classic PI controller. We will use it in this text, however, to illustrate the design and operation of a fuzzy controller.

### **3. General outline of the fuzzy controller**

We may conclude then that the procedure for implementing these fuzzy techniques to control systems consists of two very different stages:


Control Application Using Fuzzy Logic: Design of a Fuzzy Temperature Controller 385

Once the fuzzy controller's inputs and outputs are selected, the next step is to determine the

The fuzzy control system, then, with its inputs and outputs, would be as shown in Figure 5.

Assume that the human expert provides a description in his own words of the best way to control the plant. We will have to use this linguistic description to design the fuzzy

An expert uses linguistic variables to describe the time-varying inputs and outputs of the

We used the quotes to emphasize how certain words or phrases. Though there are many possible ways to describe the variables linguistically, choosing one or another has no effect on how the fuzzy controller works, it only simplifies the task of constructing the controller

Just as e(t) takes on a value, for example, 0.1 at t=2 (e(2)=0.1), so do linguistic variables take on "linguistic values", that is, the values of the linguistic variables change over time. For example, to control the temperature, we can have the "error", "error-variation" and

reference input desired, which in our case will be r=60 (step input of sixty).

Fig. 4. Human control of a temperature system.

Fig. 5. Fuzzy controller for a temperature system.

controller.

**5.1 Linguistic description** 

1. "error" to describe e(t)

using fuzzy logic.

2. "error variation" to describe de(t)/dt

3. "increase-energy-supplied" to describe u(t)

"increase-energy-supplied" take on the following values:

**5. Inclusion of control knowledge in the rule base** 

fuzzy controller. Thus, for our temperature system, we might have:


This scheme is applied to classical feedback control techniques, as shown in Figure 3. The classical controller is replaced by a fuzzy controller, which performs the same function. The variables in lower case indicate precise values ('r' for the setpoint, 'e' for the error, 'u' for the command and 'y' for the output), while upper case letters indicate the corresponding fuzzy variables.

Fig. 3. Fuzzy controller in the feedback loop.

#### **4. Fuzzy controller inputs and outputs**

If we assume the presence of an expert in the feedback loop that controls the temperature system, as shown in Figure 4, then a fuzzy controller must be designed that automates the way in which the human expert carries out this control task. To do this, the expert must indicate (to the designer of the fuzzy controller) what information he receives as the input to his decision-making process. Assume that in the temperature control process, the expert observes the error and the variation in this error to carry out his control function; that is, he makes his decision based on the result obtained from Equation 4:

$$e(t) = r(t) - y(t) \tag{4}$$

Though there are many other variables that can be used as the input (e.g., the integral of the error), we will adopt this one since it is the one used by the expert.

We must next identify the variables to be controlled. For the temperature control case proposed, we can only control the amount of energy (q) supplied by the heating element.

Fig. 4. Human control of a temperature system.

c. Inference: Applying the rule base and calculating the output fuzzy sets inferred from

d. Defuzzification: Calculating the precise output values from the inferred fuzzy sets. These precise values will be the controller's outputs (commands) and be applied to the

This scheme is applied to classical feedback control techniques, as shown in Figure 3. The classical controller is replaced by a fuzzy controller, which performs the same function. The variables in lower case indicate precise values ('r' for the setpoint, 'e' for the error, 'u' for the command and 'y' for the output), while upper case letters indicate the corresponding fuzzy

If we assume the presence of an expert in the feedback loop that controls the temperature system, as shown in Figure 4, then a fuzzy controller must be designed that automates the way in which the human expert carries out this control task. To do this, the expert must indicate (to the designer of the fuzzy controller) what information he receives as the input to his decision-making process. Assume that in the temperature control process, the expert observes the error and the variation in this error to carry out his control function; that is, he

Though there are many other variables that can be used as the input (e.g., the integral of the

We must next identify the variables to be controlled. For the temperature control case proposed, we can only control the amount of energy (q) supplied by the heating element.

*et rt yt* () () () (4)

the input sets.

variables.

system to be controlled.

Fig. 3. Fuzzy controller in the feedback loop.

**4. Fuzzy controller inputs and outputs** 

makes his decision based on the result obtained from Equation 4:

error), we will adopt this one since it is the one used by the expert.

Once the fuzzy controller's inputs and outputs are selected, the next step is to determine the reference input desired, which in our case will be r=60 (step input of sixty).

The fuzzy control system, then, with its inputs and outputs, would be as shown in Figure 5.

Fig. 5. Fuzzy controller for a temperature system.
