fuzzy logic temperature controller by yunseopkimfall2001

12
Fuzzy Logic Temperature Controller by Yunseop Kim Physics 344 Project December 14, 2001

Upload: deconstys-kadjely

Post on 27-Oct-2014

49 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Fuzzy Logic Temperature Controller

byYunseop Kim

Physics 344 ProjectDecember 14, 2001

Page 2: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 2/12

FUZZY LOGIC TEMPERATURE CONTROLLER

PURPOSE

The purpose of the project is to design a fuzzy logic controller (FLC) for temperaturecontrol. Performance of the FLC was evaluated and compared with a conventional PIDcontroller. 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 ofthe 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 wouldhesitate to answer “true” or “false”; rather prefer to say “sort of”. This is not a question ofuncertainty 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”. Fuzzylogic 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 membershipfunction µµµµF that takes values within [0, 1] as follows:

]1,0[: →XFµ .

While conventional controllers are analytically described by a set of equations, the FLCis described by a knowledge-based algorithm. The FLC incorporates human knowledge intotheir Knowledge Base (KB) through fuzzy rules and fuzzy membership functions. It is alsosuitable for nonlinear multi-input and multi-output systems. A block diagram of fuzzy logicsystem for temperature control is illustrated in Figure 1. In this project, the temperature (statevariable) was determined by a heater in a form of output voltage (control variable). Membershipfunctions transform crisp inputs (temperature) into fuzzy sets in the process of fuzzification andfuzzy sets back into crisp outputs (voltage) in the process of defuzzification.

Page 3: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 3/12

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). Thesignal from the sensor was amplified to increase measurement resolutions and fed back to A/Dcomputer interface board. LabView software was used to acquire the input signal and sendoutput signal to an actuator. The output signal was determined by control algorithm. Fuzzylogic controller was designed in the LabView and compared with conventional PID controller.

InferenceFuzzification Defuzzification

Knowledge Base

ControlledSystem

Control Action(Voltage)

Process State(Temperature)

Environment

Crispdata

CrispdataFuzzy sets Fuzzy sets

MembershipFunctions

Data Base

ControlRules

Rule Base

InferenceFuzzification Defuzzification

Knowledge Base

ControlledSystem

Control Action(Voltage)

Process State(Temperature)

Environment

Crispdata

CrispdataFuzzy sets Fuzzy sets

MembershipFunctions

Data Base

MembershipFunctions

Data Base

ControlRules

Rule Base

ControlRules

Rule Base

Page 4: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 4/12

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 wasmeasured by using a thermocouple. Thermocouple was connected to an on-amp to amplify themeasurement signal with a gain of 1,000 so as to increase resolution of input signal to thecomputer from 0 ~ 5V. Input signal detected from the thermocouple was read by a computerthrough A/D conversion of a DAQ interface board. Upon the software design of controlalgorithm in LabView, output signal was sent to an actuator from the computer though D/Aconversion of the DAQ board. A power ceramic resistor was used as an actuator to generateheat.

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

Sensor Amplifier A/D

D/AComputer

Actuator Amplifier

Page 5: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 5/12

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 toactuate the resistors. Since the input signal measured by the thermocouple had only a few milli-voltage, it was amplified with a gain of 1,000 using an on-amp so as to increase resolution ofinput signal to the computer from 0 ~ 5V. The output from the DAQ can source only 2 mA. Inorder to drive the heater, the output signal was connected to an op-amp and a transistor currentbooster in a feedback arrangement. Since a 100 Ω power resistor provided heat source withmaximum 1 W or 10 V and the maximum DAQ output was 5 V, a gain of 2 was added. Circuitdiagram 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 sourceswere used to provide reference temperature reading: one is ice water (4oC) and the other isboiling water (100oC). Amplified voltage readings were 0V and 3,75V with the thermocouplefor FLC and 0.15V and 4.09V with that for PID for ice and boiling water, respectively.Accordingly, regression equations were derived as following:

40.075.3

4100)0.0( +−−×−= readingvoltageeTemperatur for FLC, and

415.009.4

4100)15.0( +−−×−= readingvoltageeTemperatur for PID.

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

Page 6: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 6/12

from 0V to about 4.0V from the sensor corresponded to digital value from 0~3277 withresolution of 4.0V/3277=1.22 [mV/count]. The corresponding temperature resolution was100oC/3277=0.023 [oC/count]. This resolution was high enough for the temperature controlsystem, 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. Oncereading the signal from the temperature sensor, current temperature (Tcurrent)can be calculatedthrough a calibration equation. If a desired set point is Tset, then the error temperature (E) wasdefined as E=Tset–Tcurrent. 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 byantecedents and consequents. Inference rules were made by a simple logic to implement basicconcept 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, don’t 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 currenttemperature reading, Ai are fuzzy input sets, y is an output control variable representing outputvoltage to the heater, and Bi are fuzzy output sets.

For simplification, the triangular membership function was chosen for both input andoutput. A 50% overlap in the membership functions of all fuzzy sets was used so that only twofuzzy sets have non-zero degree-of-membership functions at any point of the universe ofdiscourse. The fuzzification of two degree-of-membership functions for input variable (∆x) wasdefined as:

12

11 nInputDomainInputDomai

nInputDomaixF −

−=µ

and

12 1 FF µµ −=

Page 7: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 7/12

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

2112 FF inOutputDomainOutputDomay µµ ×+×=

PID Controller

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

dtEKdtdEKEKoffsetOutput DIP ∫⋅+⋅+⋅+= ,

where KP, KI, and KD are the control parameters for proportional, integral, and derivativecontrols, respectively. The integration of the errors was calculated by Simpson’s one-third ruleas follows:

)4(3 321 EEEhEdt +×+=∫ ,

where h is elapsed time and E1, E2, and E3 are the three consecutive error values that arereassigned as each sample is taken.

LabView DesignAlgorithms 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 controlsystem.

Page 8: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 8/12

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 9: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 9/12

Upper multiple case-loops were to generate the set points as a ramp function. Followingconsisted of two parts: one for FLC on upper half screen and the other for PID on lower halfscreen. The temperature was monitored by showing set points, Fuzzy response, and PIDresponse in real-time mode. All data points including elapsed time were recorded to an outputfile for further analysis. A case-loop after a while-loop was needed to nullify the output signalwith termination, otherwise the last output values after while loop were continuously sent to twoanalog 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 wereobtained by tuning process. Optimal values for the parameters were selected based on minimumof overshooting, oscillation, and steady state error. The tuning process was illustrated in Figures7 and 8. A selected Once a control parameter was selected (marked in bold), it remained infurther 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 overshootand oscillation in steady state (Figure 7 (b)). PI-controller reduced the overshoot sinceaccumulated errors were compensated by the integral control parameter (Figure 8 (a)). But, thesteady state error remained. PID-controller improved the steady state response with smalleroscillation (Figure 8 (b)) due to predicting the slop of the response curve.

Page 10: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 10/12

(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 fuzzyinput domain was empirically assigned to -5.0, –0.5, 0.0, 0.5, 5.0, because temperature to bemeasured in this project ranged within 30±7oC. With the fixed fuzzy input domain, fuzzy outputdomain was tuned for half elements of the set (third, fourth, and fifth elements) since the fuzzysets for input and output were symmetrical on the middle value 0 (third element). The fifthelement 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 responsesshown 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 11: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 11/12

Tuned fuzzy membership functions were illustrated in Figure 10. The fuzzy sets of inputand output were partitioned into five membership functions corresponding to five linguisticvariables (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 fasterresponse in transient state than PID and settled down without overshoot and oscillation in steadystate, 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): withdisturbance (additional heat and blowing).

One of the most important factors in control is robustness of the system response againstpossible disturbances. The evaluation was continued to observe the robustness against somedisturbance (Figure 11 (b)). The disturbance was made manually on both temperature sensors atthe same time so as to produce same effect of disturbance. Over peaks and under peaks in figure11 (b) represent the disturbance by applying an additional heat source (solder) and coolingsource (blowing), respectively. The FLC was more robust for both disturbances than the PID.

Page 12: Fuzzy Logic Temperature Controller by YunseopKimFall2001

Physics 344 Fall 2001 Project Report Physics Department, University of Illinois at Urbana-ChampaignFuzzy Logic Temperature Controller By Yunseop Kim Instructor: Professor Ian Robinson

Page 12/12

Further evaluations were made with varying set points: step function (Figure 12 (a)) andramp function (Figure 12 (b)). The FLC followed the step function faster than the PID and lessovershoot and oscillation, but had some steady state errors as seen before. The steady state errorincreased 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, theresponses were not effectively evaluated.

(a) (b)

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

CONCLUSIONS

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