You are on page 1of 12

Fuzzy Logic Temperature Controller

by Yunseop Kim

Physics 344 Project December 14, 2001

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

FUZZY LOGIC TEMPERATURE CONTROLLER


PURPOSE
The purpose of the project is to design a fuzzy logic controller (FLC) for temperature control. Performance of the FLC was evaluated and compared with a conventional PID controller. Specific objectives of the project are listed as follows: 1. Hardware circuit design. - Construct an input sensor to measure temperature using a thermocouple. - Design an amplifier to magnify input signal from the thermocouple. - Construct an output actuator to provide a heating source - Design an amplifier to magnify output signal from the computer. 2. Temperature sensor calibration. 3. Software design in LabView. 4. Tuning for both Fuzzy and PID controllers. 5. Performance evaluation with several set points & disturbance.

BACKGOUNDS
A fuzzy logic was used to perform the temperature control. The idea behind the use of the fuzzy logic was from the fact that temperature is not explicitly defined. For example, considering of it is warm, is this true, given that a measured temperature is 70 oF? One would hesitate to answer true or false; rather prefer to say sort of. This is not a question of uncertainty about the external world, because we are sure of the degree of temperature. Rather, it is a case of vagueness or uncertainty about the meaning of the linguistic term warm. Fuzzy logic treats the true value of warmness is a number between 0 and 1, rather than being just true or false. Thus, a fuzzy set F in a universe of discourse X is characterized by a membership function F that takes values within [0, 1] as follows:

F : X [0,1] .
While conventional controllers are analytically described by a set of equations, the FLC is described by a knowledge-based algorithm. The FLC incorporates human knowledge into their Knowledge Base (KB) through fuzzy rules and fuzzy membership functions. It is also suitable for nonlinear multi-input and multi-output systems. A block diagram of fuzzy logic system for temperature control is illustrated in Figure 1. In this project, the temperature (state variable) was determined by a heater in a form of output voltage (control variable). Membership functions transform crisp inputs (temperature) into fuzzy sets in the process of fuzzification and fuzzy sets back into crisp outputs (voltage) in the process of defuzzification.

Page 2/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

Knowledge Base
Data Base
Membership Functions Crisp data Fuzzy sets

Rule Base
Control Rules Fuzzy sets Crisp data

Fuzzification

Inference

Defuzzification

Process State (Temperature)

Controlled System Environment

Control Action (Voltage)

Figure 1 Block diagram of fuzzy logic system for temperature control.

MATERIALS AND METHODS


A temperature control system consisted of a sensor, actuator, and computer (Fig. 2). The signal from the sensor was amplified to increase measurement resolutions and fed back to A/D computer interface board. LabView software was used to acquire the input signal and send output signal to an actuator. The output signal was determined by control algorithm. Fuzzy logic controller was designed in the LabView and compared with conventional PID controller.

Page 3/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

Actuator Sensor

Amplifier Amplifier

A/D Computer D/A

Figure 2 Schematic diagram of a temperature control system. 1. Hardware Circuit Design. Apparatus of a temperature control system is shown in Figure 3 (a). Temperature was measured by using a thermocouple. Thermocouple was connected to an on-amp to amplify the measurement signal with a gain of 1,000 so as to increase resolution of input signal to the computer from 0 ~ 5V. Input signal detected from the thermocouple was read by a computer through A/D conversion of a DAQ interface board. Upon the software design of control algorithm in LabView, output signal was sent to an actuator from the computer though D/A conversion of the DAQ board. A power ceramic resistor was used as an actuator to generate heat.

(a)

(b)

Figure 3 Hardware design for a temperature control system. Left (a): Overall picture of the system, Right (b): Two identical temperature control circuits.

Page 4/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

Figure 4 Circuit diagram of a temperature control system. In order for effective comparison, two identical circuits were made (Figure 3 (b)). Thus, there were two analog input signals from the thermocouples and two analog output signals to actuate the resistors. Since the input signal measured by the thermocouple had only a few millivoltage, it was amplified with a gain of 1,000 using an on-amp so as to increase resolution of input signal to the computer from 0 ~ 5V. The output from the DAQ can source only 2 mA. In order to drive the heater, the output signal was connected to an op-amp and a transistor current booster in a feedback arrangement. Since a 100 power resistor provided heat source with maximum 1 W or 10 V and the maximum DAQ output was 5 V, a gain of 2 was added. Circuit diagram of the temperature control system is illustrated in Figure 4. 2. Temperature Sensor Calibration. Thermocouple was calibrated to convert voltage signal to temperature. Two heat sources were used to provide reference temperature reading: one is ice water (4oC) and the other is boiling water (100oC). Amplified voltage readings were 0V and 3,75V with the thermocouple for FLC and 0.15V and 4.09V with that for PID for ice and boiling water, respectively. Accordingly, regression equations were derived as following: 100 4 Temperature = (voltage reading 0.0) + 4 for FLC, and 3.75 0.0 Temperature = (voltage reading 0.15) 100 4 + 4 for PID. 4.09 0.15

The analog voltage was digitized by a DAQ interface board with 12-bit resolution which produces a range of digital count 0~4095 for uni-polar analog input of 0~+5V. Thus, input range

Page 5/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

from 0V to about 4.0V from the sensor corresponded to digital value from 0~3277 with resolution of 4.0V/3277=1.22 [mV/count]. The corresponding temperature resolution was 100oC/3277=0.023 [oC/count]. This resolution was high enough for the temperature control system, because acceptable control tolerance was assumed to be around 0.3oC. 3. Software Design in LabView. The system is aimed to control the temperature of the power resistor at a set point. Once reading the signal from the temperature sensor, current temperature (Tcurrent)can be calculated through a calibration equation. If a desired set point is Tset, then the error temperature (E) was defined as E=TsetTcurrent. For example, E<0 means hot, while E>0 indicates cold. Fuzzy Logic Controller A fuzzy rule-based system was characterized by a set of rules that were defined by antecedents and consequents. Inference rules were made by a simple logic to implement basic concept of the Fuzzy Logic as follows: If temperature is hot, change the heater to large decrease. If temperature is warm, change the heater to small decrease. If temperature is moderate, dont change the heater. If temperature is cool, change the heater to small increase. If temperature is cold, change the heater to large increase. The linguistic rules can be presented in terms of fuzzy sets as follows: If the error (x) is negative large (A1), then the control (y) is negative large (B1). If the error (x) is negative small (A2), then the control (y) is negative small (B2). If the error (x) is nil (A3), then the output (y) is nil (B3). If the error (x) is positive small (A4), then the control (y) is positive small (B4). If the error (x) is positive large (A5), then the control (y) is positive large (B5). where x is an input state variable representing difference between a set point and current temperature reading, Ai are fuzzy input sets, y is an output control variable representing output voltage to the heater, and Bi are fuzzy output sets. For simplification, the triangular membership function was chosen for both input and output. A 50% overlap in the membership functions of all fuzzy sets was used so that only two fuzzy sets have non-zero degree-of-membership functions at any point of the universe of discourse. The fuzzification of two degree-of-membership functions for input variable (x) was defined as:

F1 =
and

x InputDomain1 InputDomain2 InputDomain1

F 2 = 1 F1

Page 6/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

Among many methods applied to the defuzzification stage, the defuzzified output value that was applied to control variables was defined by:

y = OutputDomain2 F 1 + OutputDomain1 F 2

PID Controller As a conventional way, PID control was used and its output was defined as follows:

Output = offset + K P E + K I

dE + K D Edt , dt

where KP, KI, and KD are the control parameters for proportional, integral, and derivative controls, respectively. The integration of the errors was calculated by Simpsons one-third rule as follows:

Edt = 3 ( E

+ 4 E 2 + E3 ) ,

where h is elapsed time and E1, E2, and E3 are the three consecutive error values that are reassigned as each sample is taken. LabView Design Algorithms of Fuzzy Logic and PID control were implemented by using LabView software. Figures 5 and 6 illustrate circuit diagram and front panel of the temperature control system.

Page 7/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

Figure 5 Circuit diagram of LabView for Fuzzy and PID controllers.

Figure 6 Front panel of LabView consisting of tuning parameters for Fuzzy and PID controllers.
Page 8/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

Upper multiple case-loops were to generate the set points as a ramp function. Following consisted of two parts: one for FLC on upper half screen and the other for PID on lower half screen. The temperature was monitored by showing set points, Fuzzy response, and PID response in real-time mode. All data points including elapsed time were recorded to an output file for further analysis. A case-loop after a while-loop was needed to nullify the output signal with termination, otherwise the last output values after while loop were continuously sent to two analog output ports and thus may burn up the resistors.

EXPERIMENTS AND RESULTS


1. Tuning for PID Controller. Output of the PID controller depends on the control parameters (KP, KI, and KD) that were obtained by tuning process. Optimal values for the parameters were selected based on minimum of overshooting, oscillation, and steady state error. The tuning process was illustrated in Figures 7 and 8. A selected Once a control parameter was selected (marked in bold), it remained in further tuning process.

(a)

(b)

Figure 7 Tuning for PID controller. Left (a): Open-loop tuning, Right (b): P-control tuning. Open-loop controller showed slow and unstable response due to no output feedback (Figure 7 (a)). P-controller was much faster than open-loop controller, but had some overshoot and oscillation in steady state (Figure 7 (b)). PI-controller reduced the overshoot since accumulated errors were compensated by the integral control parameter (Figure 8 (a)). But, the steady state error remained. PID-controller improved the steady state response with smaller oscillation (Figure 8 (b)) due to predicting the slop of the response curve.

Page 9/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

(a)

(b)

Figure 8 Tuning for PID controller. Left (a): PI-control tuning, Right (b): PID-control tuning. 2. Tuning for FLC. Fuzzy membership functions were tuned with a ramp function as set points. The fuzzy input domain was empirically assigned to {-5.0, 0.5, 0.0, 0.5, 5.0}, because temperature to be measured in this project ranged within 307oC. With the fixed fuzzy input domain, fuzzy output domain was tuned for half elements of the set (third, fourth, and fifth elements) since the fuzzy sets for input and output were symmetrical on the middle value 0 (third element). The fifth element was fixed to 5, because the maximum output voltage from the DAQ board was 5 V. Thus, the tuning was made to find only the fourth element. From comparison of the responses shown in Figure 9, the optimal values for the fuzzy output domain were selected to {-5.0, -3.0, 0.0, 3.0, 5.0}.

Figure 9 Tuning for FLC with a ramp function as set points.

Page 10/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

Tuned fuzzy membership functions were illustrated in Figure 10. The fuzzy sets of input and output were partitioned into five membership functions corresponding to five linguistic variables (negative large, negative small, nil, positive small, and positive large).

Figure 10 Membership Functions for Fuzzy inputs and outputs. 3. Evaluation of FLC and PID Controllers. The performance of the FLC was evaluated and compared with that of the PID controller. First evaluation was made with a fixed set point of 30oC (Figure 11 (a)). The FLC showed faster response in transient state than PID and settled down without overshoot and oscillation in steady state, but had slight steady state error that was not seen in the PID controller.

(a)

(b)

Figure 11 Responses of FLC and PID controller. Left (a): with a set point (30oC), Right (b): with disturbance (additional heat and blowing). One of the most important factors in control is robustness of the system response against possible disturbances. The evaluation was continued to observe the robustness against some disturbance (Figure 11 (b)). The disturbance was made manually on both temperature sensors at the same time so as to produce same effect of disturbance. Over peaks and under peaks in figure 11 (b) represent the disturbance by applying an additional heat source (solder) and cooling source (blowing), respectively. The FLC was more robust for both disturbances than the PID.

Page 11/12

Physics 344 Fall 2001 Project Report Fuzzy Logic Temperature Controller By Yunseop Kim

Physics Department, University of Illinois at Urbana-Champaign Instructor: Professor Ian Robinson

Further evaluations were made with varying set points: step function (Figure 12 (a)) and ramp function (Figure 12 (b)). The FLC followed the step function faster than the PID and less overshoot and oscillation, but had some steady state errors as seen before. The steady state error increased as the set point increased. Same trend was found with respect to the ramp function. Since the cooling process of the heater took longer and out of controllable response range, the responses were not effectively evaluated.

(a)

(b)

Figure 12 Responses of FLC and PID controller. Left (a): with a step function, Right (b): with a ramp function.

CONCLUSIONS
FLC was designed for temperature control. The performance of the FLC was evaluated and compared with that of PID controller. PID controller was tuned by stepwise determining the control parameters. FLC was tuned with a ramp function to determine the membership function of input and output domains. The FLC performed superior to the PID controller, showing faster transient response and less overshoot and oscillation. It was also more robust against disturbances than the PID controller. But it had some steady state errors. This was caused by the coarse tuning and small size of fuzzy set. Improvement can be achieved by resizing the fuzzy sets and finer tuning for the membership functions.

Page 12/12

You might also like