You are on page 1of 28

Temperature control based on traditional PID versus fuzzy controllers

Industrial temperature-control applications demand speed and precision. Improved temperature controllers can meet these demands by adding features not found in traditional PID controllers but increase system complexity. Fuzzy temperature controllers give you another option.
By Peter Galan, Control Software Designer, Nortel Networks

Common perception holds that temperature control is a mature and largely static area of technology. Some industrial applications—for example, injection-molding processes—still desire not only precise temperature control but also a faster warm-up phase and a quicker response to disturbances with minimal overshoot and undershoot when the set point changes. Traditional PID (proportional-integral-derivative) control techniques cannot meet these extra challenges. Figure 1 shows a continuous-time (analog) PID controller, typical for most closedloop control systems. Its output, the actuating value y(t), is a function of the regulation error e(t):

y (t ) = K P e(t ) + K I ∫ e(t )dt + K D

de(t ) . dt

The use of a standard PID controller is fully adequate for some applications. Such applications commonly feature low to moderate control-quality (timing, precision) constraints and well-defined and stable dynamic system behavior. Precision industrialtemperature control, however, does not belong among these standard applications. For example, injection-molding processes require fast changing—readjusting of controlled temperatures with minimal overshoot. In addition, heating processes do not exhibit stable dynamic behavior, because heating and cooling rates are different at each temperature set point. In addition, coupling between the zones of a multizone heating system makes dynamic behavior very unpredictable.

Heat-transfer-specific problems
Figure 2's simplified thermal model of a typical heating system ignores heattransport delays. Assume that when you switch on a constant power source, W, it powers an electrical heating element with a heat capacity, Ce. The temperature of the heating element, Te(t), rises with time, t. The heat continuously propagates, by direct conduction, to the heated system. Res represents a thermal resistance between the electrical element and the heated system, and Cs represents the heated system’s thermal capacity. The system temperature, Ts(t), also rises with time. Rsa thus represents a thermal resistance between the heated system and surrounding environment (with ambient temperature Ta(t)), which tends to cool the system. Ideally, without any cooling from the outside (that is, Rsa ), both temperatures, Te(t) and Ts(t), would rise forever. In practice, however, natural cooling prevents this occurrence. So, after a certain time period, both temperatures stabilize at certain constant values. Figure 2's model represents a second-order system with the following transfer function:

G p (s ) =

K . 1 + sT1 + s 2T2

The PID controller would be an ideal controller, because its transfer function with two nulls could, at least theoretically, cancel both poles of Gp. Figure 2 demonstrates that two cascaded first-order systems can replace this second-order system. Therefore, in practice, system response to a step function will always be aperiodical, and if Res is relatively small, the output temperature will follow a simple exponential curve when rising or falling. For such systems, even PI controllers (without the derivative member) are fully adequate. An interesting feature of a typical heated system, which represents the first difficulty for any temperature controller, is that increasing the temperature a couple of degrees from the surrounding temperature takes substantially less time than does cooling down to the surrounding temperature. In contrast, increasing the temperature of the same system by a couple of degrees when it is close to its maximum temperature takes substantially longer than does bringing the temperature back down by a couple of degrees. At one temperature set point, the heating rate (the speed of heating up) and the cooling rate (the speed of cooling down) are equal. This set point is at the temperature that requires the application of exactly 50% of the maximum applicable power to the heater. What is that “balanced” temperature? Theoretically, from Figure 2's thermal model, the dependence between power (W) and temperature (Ts) should be linear. That is, the stabilized temperature corresponding to 50% of maximum power should be exactly in the middle between the minimum and maximum temperature. The assumption here is that the maximum reachable temperature requires 100% power, and the minimum (ambient) temperature requires you to apply 0% power to the heating element for an unlimited time. Figure 3 shows the above-described feature for three set points: One is close to the ambient temperature, one is at the balanced temperature, and one is close to the maximum temperature. Temperatures are rising and decreasing exponentially with different rates (time constants) for heating and cooling. The ratio of the rate of heating and cooling processes at any stage depends only on the value of the set point.

Enhancing the traditional PID controller
The PID constants basically depend on the gain and time constant of the controlled system. If you select them properly, they will cancel poles of the controlled systemtransfer function. Different rates of the heating and cooling processes affect the optimal values of the PID constants, making their estimation very difficult. If you want to use autotuning, be aware that all autotuning methods provide only one set of PID constants, which will at best suit only the set points close to the balanced temperature. A different situation exists when the temperature set point is different from the balanced temperature. The farther the set point is from the balanced temperature, the farther the PID constants will be from their optimal values. Just how far depends on how far the set point is from the balanced temperature and whether the current temperature is below or above the set point. To make the PID controller suitable for temperature control at any set point, you need some automatic adaptation of the PID constants. Generally, all three PID constants, K P , K I , and K D , are inversely proportional to the rate of temperature change. Autotuning algorithms (known in control theory as the Ziegler-Nichols rules) also adhere to this rule. The rate of temperature change is not a linear function of the temperature set point (the derivative of exponential is also exponential), but a straight line is a rea-

[1] and kc TMAX/2TSP. The heater model must at first determine a value of the balanced temperature. To compensate for varying heating and cooling rates. The adapter block (knowing the balanced and set-point temperatures) then calculates two correction coefficients for the modification of the PID constants. The opposite situation exists at the other end of the exponential curve. the adapter block can easily calculate the required output power to maintain this temperature. the control system can first assume that the balanced temperature equals one half of the maximum temperature (a value for which the controller has been designed). this approach provides the adapter block with a new task. requiring modification of the basic PID controller. Introducing a feedforward member Once you have created the heater model (which is actually an inverse static characteristic of the heating process). kh. Therefore. and the rate of cooling is very high. during cooling: kh TMAX/2(TMAX TSP). at the beginning of the control process. kc. At the ambient temperature. applying 50% of the maximum output power to the heating element and waiting until the temperature settles down is infeasible. you could immediately replace the contribution of the controller's integral member with the output of the feedforward member. Because the heating process is linear (the output temperature is proportional to the applied power). For most applications. K I .sonable approximation (Figure 4). you would not have the correct heater model (the correct km value). [2] where TMAX is the maximum controllable and TSP is the set point temperature. close to the maximum temperature. The rate of cooling at the ambient temperature is infinitesimally low. The last step required from the adapter is to recalculate the slope km of the power-temperature characteristic. You can express the MAX_POWER value in the percentage of the output pulse width if you use the PWM method to drive the heater elements. you can use its output variable power level as a feedforward contribution to the actuating variable. If you knew in advance what power value you’d need for the set-point temperature. the PID constants. You apply the first correction coefficient. 1/τ is the rate of heating. the rate (speed) of heating at the balanced temperature is 1/2τ. Here. It is a sum of the integral member and the feedforward member outputs. As Figure 4 shows. so that the feedforward member will generate the . (it multiplies the PID constants) during the heating and the other coefficient. and K D . a simple line with the slope km can approximate the heating model characteristic. the rate of heating is infinitesimally low. K P . So. and the contributions of the proportional and derivative members are zeros. Once the temperature stabilizes at the set-point value. You can determine a more precise value of the balanced temperature during the control process. where τ is a time constant of the exponential (shown previously in Figure 3). You can then calculate an initial value of km as: km MAX_POWER / MAX_TEMPERATURE. However. Figure 5 shows the addition of two new blocks: an adapter and a heater model. the integral member can provide this information to the adapter block. the regulation error is zero. Because the temperature is stabilized at the set point. must also vary. Fortunately. This calculation is based on a linear dependence of the temperature-change rate as shown in Figure 4.

In the middle range. the integrator-accumulated regulation error will very likely hit its maximum. . At the same time. The range ends up somewhere above the set-point value. You can describe this control as follows: The controller initially applies maximum actuating value (power) to the heating elements. you may remember a time-optimal control or “bang-bang” control. which starts at the ambient temperature and ends somewhere below the set point. which should bring the heated system from the ambient temperature to the temperature set point as quickly as possible. and the integral member will likely be the first one to cause the problems. The accumulated value of the integral member (clamped to its maximum) will continue to drive the heaters with very high power. do not expect any miracles during the warm-up phase. During such a long warm-up period. If the controlled variable (temperature) and its derivative reach the so-called switching curve (in a phase diagram). and it provides results that are almost as good as those that the bang-bang control provides. the heating process ends. It sounds simple. the temperature controller applies the PID compensation. especially in maintaining the temperature set point.overall required output power by itself. the controller will drive on the heater elements with the full power. From control theory. the system eventually reaches the set-point temperature without any overshoot. In the first range. The LCZ approach offers two essential differences from the bang-bang approach: First. you must clear the content of the integral member to retain the current actuating variable unchanged. The LCZ method is an approximation of the bang-bang control. It also more precisely determines the balanced temperature. to avoid overshoot. call the entire threerange control process an LCZ method. when you change the set point. Modifying the PID controller can substantially improve its control performance. you must take measures to prevent the “wind-up” of the integral member. Introducing nonlinearity With the introduction of nonlinearity. For simplicity. Therefore. the power applied to the heating element drops to 0%. The third range represents the cooling process when you apply a zero power to the heating elements. It is simple to apply. At that moment. the LCZ band must begin at a lower temperature than would correspond to the switching curve. Addressing this problem requires the introduction of some nonlinearity. and the content of the integral member stays at a zero value. but applying it is not easy. You can call this range the LCZ (linear control zone). the heating element receives only the power necessary to maintain the set-point temperature. Second. Now the heater model knows the precise. In unforced cooling. In an optimally calculated switching curve. even after the current temperature reaches the set point. However. and the integral member content is frozen. again. because the PID control inside the LCZ band takes care of reaching and maintaining the set-point temperature. Here. the feedforward member can predict and more precisely provide the required output power. because a nonzero power will be applied to the heater inside the LCZ band (Figure 6). The result will be a huge overshoot usually followed by a series of temperature oscillations. precise definition of the LCZ band is unnecessary. and the cooling process starts. This phase can last a long time (minutes or even hours). necessary power value to maintain the set-point temperature. the entire range of temperature control splits into three basic ranges with a different control mechanism acting in each one. The PID compensation is disabled. including the PID constants adaptation and the feedforward contribution as it is shown in Figure 5. The bang-bang control method yields the fastest possible system response. the PID compensation is disabled.

Line P in the figure shows the contribution of the PID compensator's proportional member. even rather high values of the PID constants cause little danger of large overshoots. is useful for providing initial PID constants for a control system. K I . the system is stable at an initial temperature (previous set-point value) with the applied initial power. It dynamically adapts the PID constants according to the value of the temperature set point. point 1 (Figure 6). as anyone who has tried it well knows. the system still needs the integral member. Only when the current temperature is very close to the set-point value will the clamping fail to affect the regulation error. can be significantly smaller than in a PID compensation working without the feedforward member. the bold dotted curve. with slight modifications. can provide reasonable initial values for not only PID coefficients but also the additional control blocks implemented in Figure 7's enhanced controller. The integral member causes these oscillations. The setting of a new set point results in the application of full power to the heater (points 1 to 2).At the beginning. In an optimally tuned system. The implementation of an additional nonlinearity and the REL (regulation error limit) can further reduce these overshoots. it approximates the optimal (bang-bang) control method using the LCZ and REL nonlinearities. because the current temperature is below the beginning of LCZ. which tracks a moving set-point value. C. Manually tuning a PID controller is a painful process. In real systems. The regulation error limit clamps the otherwise varying value of the regulation error to a small constant value throughout almost the entire LCZ. Relay-feedback method The first autotuning method is derived from the relay-feedback method for identifica- . because there is no guarantee that the feedforward member will provide the precise output power required for the temperature set point. The derivative member contribution (not shown in Figure 6’s diagram) can help dramatically reduce the overshoot and temperature oscillations. which shows oscillation (overshoots and undershoots) around the set point. the trajectory usually follows the dotted spiral. Implementation of autotuning Autotuning. referred to earlier. The regulation error clamping creates the equivalent of a tracking-control system. Unfortunately. Following a recommended tuning procedure is helpful. Because the set-point value is only marginally ahead of the actual temperature. The temperature rises during application of the full power (points 2 to 3). Two widely used tuning methods for heating processes. however. and the power level jumps below 100%. Figure 6's diagram would follow the straight bold full line until it reached the set-point temperature and power (point 5). the PID compensator takes over (points 3 to 4). When the temperature reaches the beginning of LCZ (point 3). The actual PID output depends upon the values of the PID constants and may have various shapes—such as. the curve I is the contribution of the integral member. and it uses a learning feedforward member capable of predicting and generating the power output required to maintain any set-point temperature. Figure 7 shows a final block diagram of the enhanced PID temperature controller. but using a built-in autotuning procedure is even more helpful. The figure omits a contribution of the derivative member for clarity. At least the integral constant. Final design of the temperature controller Now the temperature controller has all the possible improvements.

KD. As the temperature approaches the set-point value. but after a while. PWMPeriod. Clearly. Tpeak go into calculating all the PID parameters. which is running in open loop. you add a thermometer with an analog display to continuously measure the temperature inside the oven. When the temperature is even closer the set-point value. especially for the smallest microcontrollers. Practical applications started to appear later. Tmax. which include KP. Will you keep the full power until the temperature reaches the set-point value (200°C)? Very unlikely. when the world market became flooded with inexpensive microcontrollers. Imagine that you have to manually control the temperature of an electric oven. which initially helps to set up the heater model (the feedforward block). Tmin. So. Tmax. Fuzzy control (fuzzy logic in the role of a control system) becomes attractive. Fuzzy logic acquired its name from the Fuzzy Set Theory developed by LA Zadeh at the University of California—Berkeley in 1965. ∆t. called the step-response method. tmax. you will further re- . Fuzzy-control applications are especially prevalent among consumer products such as digital cameras. KI. or vice versa. Let’s say that you are going to bring the temperature of the oven from the ambient temperature to 200°C. Fuzzy logic—another approach to temperature control Engineers have known the principles of fuzzy logic for more than 35 years. In addition.tion of the dynamic behavior of a controlled process. LCZ and the heater model characteristic. The series of pulses forces the process variable (temperature) to oscillate around the set-point value. comes from the step response of an open-loop system (Figure 9). Your task is not only to maintain the set-point value but to reach this value as quickly as possible and with minimum oscillations. because it more thoroughly “exercises” the tuned system. relay-feedback autotuning is unusable in multiple-zone systems. The zones affect each other to such an extent that temperature oscillations become completely distorted. you will intuitively reduce the applied power to some lower level. km. it can find the gain of the system. the relay-feedback method should provide more reliable results. such as an injection-molding-machine barrel. nothing could prevent you from applying fuzzy control to industrial temperature control. On the other hand. Generally. you will first try to apply full power to the heating element. Tmin. REL. which typically has eight heating zones. so each method must have certain pros and cons. The temperature will start to rise. whenever the actual temperature crosses it. t1. At the end of the step-response autotuning process. At the end of process. From the beginning. because it requires less computational power and demands less operational memory than conventional. when the current temperature is far from the set-point value. the output (actuating value) changes from 0 to 100%. In this type of situation. PID compensation. Which autotuning method is better? Both get wide use. which turns in one direction to increase power and in the opposite direction to decrease power to the heating element. t2. The set-point value acts as a switching temperature. This method applies a sequence of power pulses (Figure 8) to the heater. However. and Tpeak go into calculating the same set of PID constants that the relay-feedback method calculates (except the km value). you will notice that the rate of the temperature change is increasing. it will be rising slowly. ∆T. Your control element is only one knob. only the stepresponse method can provide usable results. you also need to know the current value of the controlled temperature. the measured values of t0. one beside the other. Step-response method The second autotuning method. How will you proceed? From the very beginning. the measured values of t0.

applying the fuzzy rules. A dotted curve in Figure 10 represents the switching curve well known from the bang-bang control. and ZP are the approximate power levels you apply to the heating element. For example. you would at first apply full power to the heating element until the trajectory of the rising temperature crossed the switching curve. MAXV. the input variables are the variables that Figure 10’s state diagram uses: the regulation error. Applying the fuzzy rules. Your first attempt to manually control temperature will probably be a disaster. If you knew the trajectory of this switching curve. But when you try it again and again. As the input information. and the difference between two consecutive measured temperatures (or regulation errors) will yield the derivative of the regulation error. The most widely used are the “lambda-type” functions. two membership functions overlap (they have nonzero values). Each membership function reaches a maximum value. FP. Fuzzification aims to convert a single (crisp) input value into corresponding fuzzy-set values. entails processing the “fuzzy” information. err. The purpose of the first step. Consider one approach to using fuzzy logic in a role of the temperature controller. Let’s say that you measure both input variables in degrees Celsius and their range is ±500 units (degrees). In the case of a temperature controller. Their difference will yield the regulation error. and defuzzification. fuzzification. Further. err) and the rate of the temperature change (a derivative of the regulation error. you would turn off the power. defuzzification. which generally comprises three steps: fuzzification. at the input value stated above in Table 1’s second column (in bold). At that moment. LP. is to convert a crisp input value to corresponding fuzzy-set values. The membership functions divide the entire range (±500) of the input variables into a few subranges represented by the fuzzy states. you would apply some “reasonable” power level. Designing a fuzzy controller In reality. The third step. HP. any implementation of fuzzy logic or fuzzy control is based on classical numerical processing. Table 1 shows how you can define the following five (partially overlapping) subranges and their corresponding fuzzy states. and its derivative. you must define five membership functions. When it reached the set point (center of the state diagram). This maximum value can be any value that is not too high and still allows a good resolution (for example. you can notice that for any input value. At these input values . Having defined five fuzzy states. the hardware design of a fuzzy temperature controller can be based on any suitable microprocessor (microcontroller). or second step. Terms such as “far away” and “too close” to the set point and “high” and “low power level” are measures or states that fuzzy logic uses. you will acquire a better sense of when and how to manipulate the power level. you will use not only the difference (deviation) of the current temperature from the set point but also the speed (rate) of the temperature change. So. The trajectory of the regulation error and its derivative would then follow the switching curve to the set point. which will appear as shown in Figure 11.duce the power. 1000). converts the internal fuzzy results back to a crisp output value. derr. Much more important is the software design. and maybe switch it off completely. except at the peaks of the membership functions. This step requires creation of the “membership” functions. Figure 10 represents a state diagram showing how the temperature deviation from the set-point value (a regulation error. You must calculate these two input variables on basis of the known set-point value and the periodically measured controlled temperature. derr) might change during your first attempt to control the oven temperature. which would maintain the set-point value.

Relationship between control surface and control process. derr. 250. LargePosDev } InputQt. 250. SmallDev. 250. FFOut.) The two fuzzified input variables.( 500. 0. int Funct[MEMB]. At the least. 375}.) The input variables themselves (a current regulation error and its derivative) are declared as simple integer variables: int err. 500}. } MFset. 0. and 500. MedPosDev. The proposed fuzzy controller uses two output variables. If you are designing the fuzzy controller in C. Before you start writing even the first fuzzy control procedure. is an array of MEMB (5) integer values. -250. which show at which input values the membership functions acquire their maximum values. As you will see later. You might also find useful the following definitions. which are divided into five subranges. 0. -200. 200. which will later combine into one output (actuating) variable. variable definitions. 250 and 500). which are suitable for representing the membership functions: #define MAXV 1000 #define RANGE 1001 #define MEMB 5 typedef struct _MFset { int Point[MEMB]. describes why. (The following section explains fuzzification. (The last section of this article. Point[]. 250. Funct[MEMB]. Its first item. will . Now you have to deal with the definitions of the output variables of the fuzzy controller. which is its maximum. the Point[] arrays are initialized with values other than 500. this not the only possible division of the input range. which will be an essential definition throughout the entire process: typedef enum { /* Input value quantificator */ LargeNegDev. which the fuzzification procedure will periodically calculate each time the input variable is measured. only a single membership function acquires a nonzero value. 250. This variable. is an array of MEMB (5) “weighting” coefficients. As described above. Introducing a feedforward member). and 500. 0. are defined as of the MFset type. You can connect their definition with the initialization of the Point[] arrays: MFset errFv {-500. The MFset structure represents one fuzzified variable. these five values can be 500. MedNegDev. it is always reasonable to start with data representation. you can conveniently define the following enum type. and declarations. InputQt is a quantificator providing names of the fuzzy states of the input values. 0. MFset derFv {-325. 250. The first output variable is similar to the output of the feedforward member (see the section. As you can see. errFv and derFv. such an approach will simplify the entire design process. The second item.

This is a lot of memory. You use the values MAXV. 500. the fuzzy controller processes the fuzzy input variables to produce the fuzzy output variable. The other variable is the actual output of the fuzzy controller. FullPosOut } CorrQt. These five generated values are the weighting coefficients determining how strongly the input value is tied to the individual membership function. MAXV}. corrOut. MedNegOut. CorrQt. 0. SmallOut. Its purpose is to correct the FFOut value during the warm-up phase. and the “crisp” correction output variable. You would apply the input value as the offset to a look-up table and pick up a corresponding value of each membership function. use the abovedefined quantificator. Having the set of membership functions ready for use in the form of look-up tables would mean sacrificing RANGE (1001) words (integers) for each of MEMB (5) arrays. MAXV/2 and MAXV ( 1000. Fuzzification Fuzzification aims to convert crisp input values into corresponding fuzzy set values. and 1000) for the mapping of the fuzzy output variable to the crisp output variable: int CorrVal[MEMB] = {-MAXV. The next is a definition of the fuzzy output variable. you need to generate only one value for each of the membership functions. and the corresponding values of errFv. corrOut. In addition. 0. Implementation of the fuzzification procedure is left to you. -MAXV/2. err. which correspond to the current input value. For example.Funct[MEMB] variable (for clarity. MAXV/2. 0. are defined as simple integer variables: int FFOut. A better approach is to generate the set of the membership functions during the fuzzification process itself. Once the crisp input values are fuzzified. 500. and a maximum of two membership functions can acquire nonzero values. including its initialization. This is the entire purpose of the fuzzification. FFOut. As you already know. To access the individual (MEMB) values of the fuzzy output variable. that you have defined all the major data structures and variables. You can verify whether the fuzzification and the membership-function generation are correct by looking at the fuzzified variable. MAXV/2.keep the constant output power required to maintain the temperature set point once the control process has stabilized. you can continue your design with the “fuzzy” procedures. corrOut. corrOut is responsible for eliminating the stabilized temperature variation due to possible disturbances. find out to which interval (given by the values of Point[MEMB])the input value belongs. Actually. The sum of weighting coefficients for any input value is always a constant of MAXV (1000). If you had such a set (as shown in Figure 11) in the form of look-up tables. corrVal. Table 2 shows a few selected values of the input variable. an . this process uses the set of membership functions. representing the set. MedPosOut. /* Output of Feed-Forward & Correction blocks */ Now. First. CorrVal. You can represent this value with a similar set of MEMB (5) membership functions with the following states: typedef enum{ /* Output variable quantificator */ FullNegOut. Output of the feedforward member. fuzzification would be very simple. shown as Funct[x] values).

and each one is decomposed into five states. This process lies under the supervision of the “fuzzy rules.” These rules are the typical production rules “ if…then … ” used in expert systems. though the fuzzification and defuzzification steps are also integral parts of this knowledge base. The fuzzy rules represent the “knowledge base” of the fuzzy control system. Actually. They both describe how the regulation error and its derivative depend on the output power applied to the heating elements. all the other membership functions will have zero values. Therefore. you are interested in the dependence of the output power on the regulation error and its derivative. 25 combinations of input states exist. In this interval. the fuzzy rules (written in a pseudo-code) are: if err is LargeNegDev and derr is LargePosDev then set FullNegOut. If the output power could acquire only one of those five levels shown in Figure 12. and vice versa. because they are the input (independent) variables to the control system. Starting from the top left corner of Figure 12 through the underlined MPO field and ending at the bottom right corner. This knowledge is identical to the knowledge necessary for manual temperature control. if err is LargePosDev and derr is LargePosDev then set SmallOut. the . “if err is LargePosDev and derr is MedNegDev then set MedPosOut. FNO. Because there are two input variables. MNO. The criteria for this action are minimum time and minimum temperature oscillation. It is based on rational feelings rather than on the knowledge of the time constants. Figures 12 and 10 are very similar. you can calculate exact values of both functions. and other physical attributes of the controlled system. gains. To maintain the set-point temperature. the fuzzy rules will have a specific form. In this case. and only if all fuzzified input variables contain nonzero weighting coefficients does the fuzzified output variable acquire a prescribed output level. MPO. Applying fuzzy rules Once the current values of the input variables are fuzzified. the output power is the dependent variable.” therefore.” The “if” statement evaluates the sets of the fuzzified input variables. … if err is LargePosDev and derr is LargeNegDev then set FullPosOut. SO.input value of 125 lies in the interval between Point[2] and Point[3]. if err is MedNegDev and derr is LargePosDev then set FullNegOut. you need 25 fuzzy rules. Figure 12 shows a graphical representation of a knowledge base (the fuzzy rules) suitable for the controlling of a generic heating system. if err is SmallDev and derr is LargePosDev then set FullNegOut. if err is MedPosDev and derr is LargePosDev then set MedNegOut. CorrQt. Using a simple linear interpolation. membership function[2] has the falling edge and membership function[3] has the rising edge. the fuzzy controller continues with the phase of “making decisions. and FPO are the short forms of the output variable quantificator.” or deciding what actions to take to bring the temperature to its set-point value. It is immediately clear that only the membership function[2] and the membership function[3] will have nonzero values in this interval. Creating them requires the designer to have adequate “knowledge” of the control-system behavior. it is usually called “applying the fuzzy rules. such as. the control process would be very coarse. … if err is MedPosDev and derr is ZeroDev then set MedPosOut.

and after multiplication with the mapping value corresponding to the produced output level. so conditions of as many as four fuzzy rules will be fulfilled at the same time. You describe this process as “singleton” defuzzification.Funct[MedPosDev]. would yield ambiguous results. The following C-code explains how the weighting coefficients and output levels are processed in one fuzzy rule evaluation (in Figure 12 with underlined MPO): if(errFv. Either of the two fuzzified input variables will be in most cases decomposed into two input levels (though with different weighting coefficients). the ratio num/denom will yield a crisp value of the output variable. you use only ANDed conditions. Defuzzification Defuzzification is the opposite of fuzzification. none of the “if” statements are followed by “else” statements. which is assigned to the corrOut variable. denom += minVal. the product is added to another variable. It is a simplified “centroid” .output power would have been very likely changing its levels according a following sequence: … → MNO → SO → MPO → SO → MNO → … forever. In a fuzzy rule comprising two or more conditions “ORed” together.Funct[MedPosDev] && derFv. if in Figure 12 an entire raw (column) used the same output level. num (numerator). CorrVal[MedPosOut]. The minVal value is added to the variable denom (denominator). and you would select maximum weighting coefficient for further processing. } If the expression of the “if” statement yields the truth value (both ANDed weighting coefficients are nonzero).) Which level then will be assigned to the output variable? The output level produced by each fulfilled fuzzy rule should contribute to the actuating variable. the fuzzy rules themselves as they are listed above. After the whole set of fuzzy rules is processed. num += minVal * CorrVal[MedPosOut]. (Be aware: In the set of fuzzy rules. There are many ways to perform defuzzification. For example. you select a maximum weighting coefficient for further processing. derFv. In addition. For fuzzy rules (“if” statements) comprising two or more conditions “ANDed” together. conditions would be ORed. just as there are many ways to perform fuzzification. In this control application. the most convenient way to implement defuzzification using this method is to combine it with fuzzy rules processing. You repeat these actions for each true “if” statement—in this case. for as many as four out of 25 statements. The most common method is called “Min-Max” method. the minimum value of the weighting coefficients of both fuzzified input variables is assigned to an auxiliary variable minVal. Procedurally. but different applications may use ORed conditions as well. which selects only the maximum or minimum values from each fuzzy rule for further processing.Funct[SmallDev]) { minVal = min(errFv. The num and denom variables must be cleared before they enter fuzzy rules processing.Funct[SmallDev]). It aims to convert a value (actually several values) of the fuzzy output variable to a single crisp value. you select a minimal weighting coefficient (a fuzzified input variable with the minimal value) as a combined truth value for further processing. These rules are consistent with the theory of sets. The entire process of calculating this multilevel contribution and converting it into a single (crisp) value is called defuzzification.

In this case. (If MAX_TEMPERATURE is not at least a couple of hundreds degrees. the initial value of km can be: km = MAX_POWER / MAX_TEMPERATURE. You would not want to wait hours for the temperature to reach the set point value. Now. Figure 14 shows a 3-D graph of the defuzzified (crisp) output variable corrOut. the FFOut value required to maintain this set point value will be 400 (40% PWM). which is an output of the feedforward member. The quality of the control process entirely depends on it. linear cut through a cube. However. Calculations based on the “centroid” method would find the center of the mass at the distance of 828. Say that the fuzzy rule processing yields two truth rules (“if” statements)—one with the minimal coefficient value of 250 and the MedPosOut output power level and the other with the minimal coefficient value of 500 and the FullPosOut output power level. which represents 100% of the output pulse width. negative power levels were used). because the process has used for the fuzzification a set of linear and equally spaced membership functions (Figure 11). In any case. err and derr. you should subtract from it the ambient temperature. which is an inverse static characteristic of the heating process. Correction of the feedforward output Similar to the PID control. If the value of FFOut provides the output power.” because it determines the value of the controlled (actuating) variable for any given input values. so a simple line with the slope km represents the heating-model characteristic. in which the heating elements are undersized. if a desired set point temperature is. if you use the PWM method to drive the heater elements. The error caused by this simplification is negligible as is shown in the following example (Figure 13). In practice. The heating process is linear (the output temperature is proportional to the applied power). This actuating value might be suitable in an ideal situation when using a properly sized heater. In certain applications. for example. You would expect this situation. change from the extreme values of 500 and 500 to the other extreme values 500 and 500. the actuating variable is a combination of the corrOut value with a constant value. The shape of the control surface is extremely important. respectively. As previously described. In this case. The linearly arranged numbers govern the mapping of the fuzzy to crisp output variable. the surface represents a nice. The surface of the defuzzified output variable is often called the “control surface.) The MAX_POWER value in this case should be MAXV. 200 C. you may encounter the opposite situation. You must correct for this deviation. The feedforward output value for a particular set point temperature will be: FFOut = km * SET_POINT_TEMPERATURE. you might prefer an oversized heater. The simplification ignores the fact that any two adjacent (output) membership functions overlap. led almost symmetrically from one corner to the other. FFOut.method. which requires less power to maintain the same temperature. the temperature will settle down at a value other than the set point. the feedforward output is an output of the heater model block. The “singleton” defuzzification would yield a value of 833 (for clarity. The fuzzy rules exhibit no “irregularities” (Figure 12) but yield constant output levels diagonally placed from the lowest to the highest. the MAX_TEMPERATURE value is 500 C and the MAX_POWER value is 1000. the probability that the . This option is especially important when the set-point value is in the high end of the temperature range. which does not correspond to the temperature set point. which got its name because it resembles the calculation of the center of the mass of a complex object. Its content (vertical axis) changes from the MAXV value to the MAXV value as the input variables.

you can go a step further in this adaptation process. Relationship between control surface and control process The ideal (bang-bang) control surface would have only two levels: a maximum output and a minimum output level. Therefore. And. the derivative of the regulation error will be close to zero. when the current temperature equals the ambient temperature. but they are not identical. do not forget to calculate a new feedforward output value. the temperature will stabilize somewhere between the set point value and the temperature corresponding to the FFOut value. km. If you do not know precisely parameters of the curve. even at the very beginning of the control process. You take the combined output power and divide it by the current temperature decreased by the ambient temperature. at the ambient (surrounding) temperature. Of course. this routine has one fault. there was no power applied to the heating element. negative) regulation error will cause the corrOut value to become negative. you can approximate the switching curve by a parabolic curve (second-order polynomial). the FFOut value should be applied to the heating element to hold the desired temperature. The problem is determining the trajectory of the switching curve. it can use it from the very beginning of the next control process. When FFOut is higher than is needed. They would be identical if the layers of the constant power were . It sounds simple in theory. If your controller can remember the latest value of km. A steady nonzero (in this case. FFOut = km * setPoint. err and derr acquire zero values). PID control uses the LCZ for exactly this reason. where ∆P is a difference between the powers applied to the heating element at the current and at the ambient temperatures. Finally. because of the division by zero. After modifying the heater-model characteristic. you need to provide some additional mechanisms to prevent premature km modifications. The control surface in Figure 14 resembles the LCZ used in the PID control. which will reduce the overall power applied to the heating element. The derivative of the regulation error can acquire a zero value even though the current temperature is far from the stabilized value. } If the current temperature settles down. you need to allow the traditional control system to apply linear controlling in a certain band around the set-point value. In the center of the state diagram (when both. ∆T. So. The transition from one level to the other would be abrupt and be led along the switching curve. The current temperature is maintained by the output power from the combined contribution of the FFOut and corrOut values. Figure 10 shows that this situation will occur every time the spiral crosses the horizontal line. km is actually a ratio of ∆P/∆T. However. The calculation would fail even here. the calculation of a corrected characteristic.FFOut value will maintain exactly the set point temperature without any additional corrections is extremely low. or implementing the following “adaptation” routine: if(abs(derr) < SOME_SMALL_NUMBER) { km = (FFOut + corrOut)/(currentTemperature – ambientTemperature). For a second-order controlled system. So. you’ll never get to the target (the center of the state diagram). the temperature will stabilize somewhere above the set-point value. is very simple. You can eliminate this control error by either adding an integral member identical with what the PID correction uses.

you use membership functions with a nonequidistant distribution of membership functions as shown in Figure 15. A simpler way is to modify the scaling of the input variables. neither too high nor too low. Exceptions are the corners. For the set points close to the maximum temperature. In either case. multiplying the derr variable by a constant greater than 1 will have the same effect as pressing the switching curve toward the horizontal line. The power profile A in Figure 16 is suitable for the set points close to the balanced temperature. You would not want to modify the extreme values 1000 and the value of 0 in the middle of the mapping function. How can be “tweaking” the mapping function useful? Do you remember how different rates of the heating and cooling processes affected required values of the PID constants? The same principle applies to the power profile. One variable. If you do not know this slope (the precise parameters of the polynomial that approximates it). The LCZ method approximates the switching curve (represented by a second-order polynomial) with a zero-order polynomial. because you can replace the original mapping-point values 500 with any value from 0 to ±1000. the control surface from Figure 14 approximates it by a first-order polynomial. You do have other “freedom” degrees left in your fuzzy controller. Figure 16 shows how changing those values affects the power profile. they are laid under 45%. 0. You can try to modify the slope of the switching curve by further changing the dividing points for the membership-function distribution. of course. You can take this approximation even further. making a better approximation. by changing the mapping function. but you can play with the values 500. respectively. Heating and cooling effects are in this area equivalent. The slope of the switching curve. because you will never get the derr values as high as 500 C unless the sampling rate is extremely low. CorrVal[MEMB]. Remember that the power profiles B and C represent an extreme “distortion” of the mapping function. you can obtain any power profile between the extreme profiles B and C. providing exactly the opposite heating and cooling effects of profile B. system-response time will be less than optimal. for the fuzzification. you should scale both input variables so that only their extreme values (the maximum regulation error and maximum change of the regulation error) would be represented by values close to 500. but you have limited possibilities. Actually. These linearly growing values cause the vertical cut diagonally from the bottom left corner to the top right corner through the cube in Figure 14 (a power “profile”) to be linear. The high sampling rate will bring a lot of noise to the system. You would get the same result if you replaced the MPO and MNO states (in the diagonals) in Figure 12’s knowledge database with the SO and FNO (profile B) or the FPO and SO (profile C) states. so they more closely follow the switching curve. if. and the low sampling rate can cause the temperature oscillations. but its negative output power changes much more dramatically with the changing negative regulation error (when the current temperature is above the set-point value). which has been initialized with the values 1000. where the power is clamped to its maximum and minimum levels. The rate of the temperature sampling must be reasonable. .laid in parallel with the vertical axis. a power profile close to C is the best choice. 500. However. For example. A modified power profile approaching the B shape best suits the set points close to the ambient temperature. plays a role in the controlling. It generates only a moderate positive output power for the positive regulation errors (when the current temperature is bellow the set point value). you need to multiply derr by a constant of 10 or even higher. and 1000 for the mapping of the fuzzy output variable to the crisp output variable. has so far been untouched: the fuzzy output variable. 500. However.

such as a fast warm-up phase. and the corresponding values of errFv.Funct[MEMB] variable Err Funct[0] Funct[1] Funct[2] Funct[3] Funct[4] 0 0 0 0 500 1000 996 4 0 0 0 499 500 0 0 0 375 500 0 0 0 1000 0 0 125 0 0 500 500 0 490 0 0 0 40 960 . If you are an innovator. As a relatively new control method. Even such a simple process as temperature control can become complex if you want additional features. err. it might be your preferred choice of control method. the theory of PID controlling is very well known and widely used in many other control applications. You can contact author Peter Galan at petergalan@rogers. especially if you want to have autotuning capabilities. lesser known fuzzy control seems to accomplish the same control quality with less complexity. Table 1—Subranges and their corresponding fuzzy states 250 Large negative deviation 500 0 Medium negative deviation 500 250 250 0 250 Small deviation 0 250 500 Medium positive deviation Large positive deviation 250 500 Table 2—Selected values of the input variable. you will prefer fuzzy control as a modern. as the PID controlling has been “enhanced” by introducing an adapter block for the modifications of the PID constants. Better approximation of the switching curve makes it a better candidate for time-optimal applications for temperature control.com. traditional PID controller can be a challenge. Implementing the enhanced. However. On the other side. you can use the same idea to automatically modify the power profile of the fuzzy controller by modifying those distribution points.Similarly. it still provides space for further improvements. and a simple linear equation (Figure 4 and equations 1 and 2) can calculate the new distribution points for the optimized power profile. Your system must compare the set-point value with the balanced temperature. elegant control method. If you are a traditionalist.

integral. . Te Res Ts W Ce Cs Rsa Ta Figure 2—A simple heating-system model has thermal resistances and capacitances. and derivative components.KP + e(t) SET POINT KI ∫ KDd/dt ACTUATING VALUE + ACTUAL VALUE Figure 1—A PID controller calculates an actuating value from proportional.

. but a straight line is a reasonable approximation.MAXIMUM REACHABLE TEMPERATURE TEMP (T) HEATING BALANCED TEMPERATURE COOLING AMBIENT TEMPERATURE τ TIME (t) Figure 3—Heating rates and cooling rates vary with temperature. 1/τ TEMPERATURE CHANGE RATE 1/2τ COOLING RATE HEATING RATE AMBIENT BALANCED MAXIMAL TEMPERATURE Figure 4—The rate of temperature change is not linear.

HEATER MODEL ADAPTER P Set Point + - e I + ACTUATING VALUE D ACTUAL TEMPERATURE Figure 5—The addition of a heater model and an adapter to a PID controller provides adaptive modification of PID constants and feed-forward output. . .

as seen in this diagram. . approximates the bang-bang control.100% 2 3 POWER (%) 4 SET-POINT POWER POWERTEMPERATURE CHARACTERISTIC INITIAL POWER 0% 1 C 5 P I INITIAL (AMBIENT) TEMPERATURE BEGINNING OF LCZ TEMPERATURE SET-POINT TEMPERATURE Figure 6—A nonlinear control process with the LCZ (linear control zone).

and a learning feedforward member capable of predicting and generating required output power.HEATER MODEL ADAPTER P + REL Set Point + - e . approximation of bang-bang control.REL I + ACTUATING VALUE D Linear Control Zone Hold & Full Power ACTUAL TEMPERATURE Figure 7—An enhanced temperature controller incorporates PID control. . adaptive PID constants.

.100% PWM 0% PWM Tpeak Tmax Set Point Temperature Tmin t0 t1 t2 time (t) Figure 8—The relay-feedback method creates power pulses that cause a process variable (such as temperature) to oscillate around a set-point value.

Tpeak T [°C] Set Point Temperature Tmax ∆T Tmin t0 tL ∆t tmax time Figure 9—Step-response autotuning derives from the step-response of an openloop system. .

derr Switching curve ZP ZP ZP ZP LP ZP LP HP LP LP LP LP FP … Full Power HP … High Power LP … Low Power ZP … Zero Power FP err Figure 10—A state diagram shows how the regulation error. and its derivative. derr. . err. change upon applying different power levels.

5-th membership function 4-th membership function 3-rd membership function 2-nd membership function 1-st membership function 1000 0 -500 -250 0 250 500 Figure 11—The fuzzification of the input variables uses a set of five membership functions. .

.500 FNO FNO FNO MNO SO 250 FNO FNO MNO SO MPO 0 FNO MNO SO MPO FPO -250 MNO SO MPO FPO FPO SO -500 -derr MPO FPO FPO FPO -250 -500 LargeNegDev MedNegDev 0 SmallDev 500 250 MedPosDev LargePosDev err Figure 12—This graphical representation of the Fuzzy Control knowledge base is suitable for the controlling of a generic heating system.

POWER PROFILE LINE +corrOut -corrOut +err -err +derr -derr Figure 14—A three-dimensional schematic represents the defuzzified output variable. .FNO MNO SO MPO FPO 500 x -1000 -833 (SINGLETON) -500 250 0 500 x 1000 828 (CENTROID) Figure 13—Difference between the “centroid” and much simpler “singleton” defuzzification is negligible.

375 250 0 -250 -375 -derr -500 err 0 200 -200 500 Figure 15—Membership functions with a nonequidistant distribution. help to approximate the switching curve. used for the fuzzification of the input variables. .

-derr -corrOut (FullPosOut) +1000 C (MedPosOut) +1000 (SmallOut) (MedNegOut) (FullNegOut) 0 0 -1000 -err. . +derr +err.(FullPosOut) +1000 (MedPosOut) (SmallOut) (MedNegOut) +500 0 -500 A +corrOut -corrOut -err. +derr +err. +derr +err. -derr (FullNegOut) -1000 (FullPosOut) +1000 (MedPosOut) (SmallOut) 0 0 B +corrOut (MedNegOut) -1000 (FullNegOut) -1000 -err. -derr +corrOut -corrOut Figure 16—The power “profile” depends on the mapping function of the fuzzy output variable to the crisp output variable.