Sei sulla pagina 1di 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 applicationsfor example, injection-molding processesstill 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 changingreadjusting 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 systems 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-

sonable approximation (Figure 4). As Figure 4 shows, the rate (speed) of heating at the balanced temperature is 1/2, where is a time constant of the exponential (shown previously in Figure 3). At the ambient temperature, 1/ is the rate of heating. The rate of cooling at the ambient temperature is infinitesimally low. The opposite situation exists at the other end of the exponential curve, close to the maximum temperature. Here, the rate of heating is infinitesimally low, and the rate of cooling is very high. To compensate for varying heating and cooling rates, the PID constants, K P , K I ,

and K D , must also vary, requiring modification of the basic PID controller. Figure 5 shows the addition of two new blocks: an adapter and a heater model. The heater model must at first determine a value of the balanced temperature. For most applications, applying 50% of the maximum output power to the heating element and waiting until the temperature settles down is infeasible. Therefore, 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). You can determine a more precise value of the balanced temperature during the control process. The adapter block (knowing the balanced and set-point temperatures) then calculates two correction coefficients for the modification of the PID constants. This calculation is based on a linear dependence of the temperature-change rate as shown in Figure 4. You apply the first correction coefficient, kh, (it multiplies the PID constants) during the heating and the other coefficient, kc, during cooling: kh TMAX/2(TMAX TSP), [1] and kc TMAX/2TSP, [2] where TMAX is the maximum controllable and TSP is the set point temperature.

Introducing a feedforward member


Once you have created the heater model (which is actually an inverse static characteristic of the heating process), you can use its output variable power level as a feedforward contribution to the actuating variable. Because the heating process is linear (the output temperature is proportional to the applied power), a simple line with the slope km can approximate the heating model characteristic. You can then calculate an initial value of km as: km MAX_POWER / MAX_TEMPERATURE. 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. If you knew in advance what power value youd need for the set-point temperature, you could immediately replace the contribution of the controller's integral member with the output of the feedforward member. However, at the beginning of the control process, you would not have the correct heater model (the correct km value). Fortunately, the integral member can provide this information to the adapter block. So, this approach provides the adapter block with a new task. Once the temperature stabilizes at the set-point value, the adapter block can easily calculate the required output power to maintain this temperature. It is a sum of the integral member and the feedforward member outputs. Because the temperature is stabilized at the set point, the regulation error is zero, and the contributions of the proportional and derivative members are zeros. The last step required from the adapter is to recalculate the slope km of the power-temperature characteristic, so that the feedforward member will generate the

overall required output power by itself. At the same time, you must clear the content of the integral member to retain the current actuating variable unchanged. Now the heater model knows the precise, necessary power value to maintain the set-point temperature; when you change the set point, the feedforward member can predict and more precisely provide the required output power. It also more precisely determines the balanced temperature. Modifying the PID controller can substantially improve its control performance, especially in maintaining the temperature set point. However, do not expect any miracles during the warm-up phase, which should bring the heated system from the ambient temperature to the temperature set point as quickly as possible. This phase can last a long time (minutes or even hours), and the integral member will likely be the first one to cause the problems. During such a long warm-up period, the integrator-accumulated regulation error will very likely hit its maximum. Therefore, you must take measures to prevent the wind-up of the integral member. The accumulated value of the integral member (clamped to its maximum) will continue to drive the heaters with very high power, even after the current temperature reaches the set point. The result will be a huge overshoot usually followed by a series of temperature oscillations. Addressing this problem requires the introduction of some nonlinearity.

Introducing nonlinearity
With the introduction of nonlinearity, the entire range of temperature control splits into three basic ranges with a different control mechanism acting in each one. In the first range, which starts at the ambient temperature and ends somewhere below the set point, the controller will drive on the heater elements with the full power. The PID compensation is disabled, and the content of the integral member stays at a zero value. In the middle range, the temperature controller applies the PID compensation, including the PID constants adaptation and the feedforward contribution as it is shown in Figure 5. You can call this range the LCZ (linear control zone). The range ends up somewhere above the set-point value. The third range represents the cooling process when you apply a zero power to the heating elements. Here, again, the PID compensation is disabled, and the integral member content is frozen. For simplicity, call the entire threerange control process an LCZ method. From control theory, you may remember a time-optimal control or bang-bang control. You can describe this control as follows: The controller initially applies maximum actuating value (power) to the heating elements. If the controlled variable (temperature) and its derivative reach the so-called switching curve (in a phase diagram), the heating process ends, and the cooling process starts. In unforced cooling, the power applied to the heating element drops to 0%. In an optimally calculated switching curve, the system eventually reaches the set-point temperature without any overshoot. At that moment, the heating element receives only the power necessary to maintain the set-point temperature. The bang-bang control method yields the fastest possible system response. It sounds simple, but applying it is not easy. The LCZ method is an approximation of the bang-bang control, It is simple to apply, and it provides results that are almost as good as those that the bang-bang control provides. The LCZ approach offers two essential differences from the bang-bang approach: First, to avoid overshoot, the LCZ band must begin at a lower temperature than would correspond to the switching curve, because a nonzero power will be applied to the heater inside the LCZ band (Figure 6). Second, because the PID control inside the LCZ band takes care of reaching and maintaining the set-point temperature, precise definition of the LCZ band is unnecessary.

At the beginning, the system is stable at an initial temperature (previous set-point value) with the applied initial power, point 1 (Figure 6). The setting of a new set point results in the application of full power to the heater (points 1 to 2), because the current temperature is below the beginning of LCZ. The temperature rises during application of the full power (points 2 to 3). When the temperature reaches the beginning of LCZ (point 3), the PID compensator takes over (points 3 to 4), and the power level jumps below 100%. Line P in the figure shows the contribution of the PID compensator's proportional member; the curve I is the contribution of the integral member. The figure omits a contribution of the derivative member for clarity. The actual PID output depends upon the values of the PID constants and may have various shapessuch as, the bold dotted curve, C. In an optimally tuned system, Figure 6's diagram would follow the straight bold full line until it reached the set-point temperature and power (point 5). In real systems, however, the trajectory usually follows the dotted spiral, which shows oscillation (overshoots and undershoots) around the set point. The integral member causes these oscillations. Unfortunately, the system still needs the integral member, because there is no guarantee that the feedforward member will provide the precise output power required for the temperature set point. At least the integral constant, K I , can be significantly smaller than in a PID compensation working without the feedforward member. The derivative member contribution (not shown in Figure 6s diagram) can help dramatically reduce the overshoot and temperature oscillations. The implementation of an additional nonlinearity and the REL (regulation error limit) can further reduce these overshoots. The regulation error limit clamps the otherwise varying value of the regulation error to a small constant value throughout almost the entire LCZ. Only when the current temperature is very close to the set-point value will the clamping fail to affect the regulation error. The regulation error clamping creates the equivalent of a tracking-control system, which tracks a moving set-point value. Because the set-point value is only marginally ahead of the actual temperature, even rather high values of the PID constants cause little danger of large overshoots.

Final design of the temperature controller


Now the temperature controller has all the possible improvements. It dynamically adapts the PID constants according to the value of the temperature set point; it approximates the optimal (bang-bang) control method using the LCZ and REL nonlinearities; 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.

Implementation of autotuning
Autotuning, referred to earlier, is useful for providing initial PID constants for a control system. Manually tuning a PID controller is a painful process, as anyone who has tried it well knows. Following a recommended tuning procedure is helpful, but using a built-in autotuning procedure is even more helpful. Two widely used tuning methods for heating processes, 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.

Relay-feedback method
The first autotuning method is derived from the relay-feedback method for identifica-

tion of the dynamic behavior of a controlled process. This method applies a sequence of power pulses (Figure 8) to the heater, which is running in open loop. The series of pulses forces the process variable (temperature) to oscillate around the set-point value. The set-point value acts as a switching temperature; whenever the actual temperature crosses it, the output (actuating value) changes from 0 to 100%, or vice versa. At the end of process, the measured values of t0, t1, t2, Tmin, Tmax, Tpeak go into calculating all the PID parameters, which include KP, KI, KD, PWMPeriod, REL, LCZ and the heater model characteristic, km.

Step-response method
The second autotuning method, called the step-response method, comes from the step response of an open-loop system (Figure 9). At the end of the step-response autotuning process, the measured values of t0, Tmin, t, T, tmax, Tmax, and Tpeak go into calculating the same set of PID constants that the relay-feedback method calculates (except the km value). Which autotuning method is better? Both get wide use, so each method must have certain pros and cons. Generally, the relay-feedback method should provide more reliable results, because it more thoroughly exercises the tuned system. In addition, it can find the gain of the system, which initially helps to set up the heater model (the feedforward block). On the other hand, relay-feedback autotuning is unusable in multiple-zone systems, such as an injection-molding-machine barrel, which typically has eight heating zones, one beside the other. The zones affect each other to such an extent that temperature oscillations become completely distorted. In this type of situation, only the stepresponse method can provide usable results.

Fuzzy logicanother approach to temperature control


Engineers have known the principles of fuzzy logic for more than 35 years. Fuzzy logic acquired its name from the Fuzzy Set Theory developed by LA Zadeh at the University of CaliforniaBerkeley in 1965. Practical applications started to appear later, when the world market became flooded with inexpensive microcontrollers. Fuzzy control (fuzzy logic in the role of a control system) becomes attractive, especially for the smallest microcontrollers, because it requires less computational power and demands less operational memory than conventional, PID compensation. Fuzzy-control applications are especially prevalent among consumer products such as digital cameras. However, nothing could prevent you from applying fuzzy control to industrial temperature control. Imagine that you have to manually control the temperature of an electric oven. Your control element is only one knob, which turns in one direction to increase power and in the opposite direction to decrease power to the heating element. Clearly, you also need to know the current value of the controlled temperature. So, you add a thermometer with an analog display to continuously measure the temperature inside the oven. Lets say that you are going to bring the temperature of the oven from the ambient temperature to 200C. Your task is not only to maintain the set-point value but to reach this value as quickly as possible and with minimum oscillations. How will you proceed? From the very beginning, when the current temperature is far from the set-point value, you will first try to apply full power to the heating element. The temperature will start to rise. From the beginning, it will be rising slowly, but after a while, you will notice that the rate of the temperature change is increasing. Will you keep the full power until the temperature reaches the set-point value (200C)? Very unlikely. As the temperature approaches the set-point value, you will intuitively reduce the applied power to some lower level. When the temperature is even closer the set-point value, you will further re-

duce the power, and maybe switch it off completely. Your first attempt to manually control temperature will probably be a disaster. But when you try it again and again, you will acquire a better sense of when and how to manipulate the power level. As the input information, 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. Figure 10 represents a state diagram showing how the temperature deviation from the set-point value (a regulation error, err) and the rate of the temperature change (a derivative of the regulation error, derr) might change during your first attempt to control the oven temperature. FP, HP, LP, and ZP are the approximate power levels you apply to the heating element. A dotted curve in Figure 10 represents the switching curve well known from the bang-bang control. If you knew the trajectory of this switching curve, you would at first apply full power to the heating element until the trajectory of the rising temperature crossed the switching curve. At that moment, you would turn off the power. The trajectory of the regulation error and its derivative would then follow the switching curve to the set point. When it reached the set point (center of the state diagram), you would apply some reasonable power level, which would maintain the set-point value. 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. Consider one approach to using fuzzy logic in a role of the temperature controller.

Designing a fuzzy controller


In reality, any implementation of fuzzy logic or fuzzy control is based on classical numerical processing. So, the hardware design of a fuzzy temperature controller can be based on any suitable microprocessor (microcontroller). Much more important is the software design, which generally comprises three steps: fuzzification, applying the fuzzy rules, and defuzzification. Fuzzification aims to convert a single (crisp) input value into corresponding fuzzy-set values. Applying the fuzzy rules, or second step, entails processing the fuzzy information. The third step, defuzzification, converts the internal fuzzy results back to a crisp output value. In the case of a temperature controller, the input variables are the variables that Figure 10s state diagram uses: the regulation error, err, and its derivative, derr. You must calculate these two input variables on basis of the known set-point value and the periodically measured controlled temperature. Their difference will yield the regulation error, and the difference between two consecutive measured temperatures (or regulation errors) will yield the derivative of the regulation error. Lets say that you measure both input variables in degrees Celsius and their range is 500 units (degrees). The purpose of the first step, fuzzification, is to convert a crisp input value to corresponding fuzzy-set values. This step requires creation of the membership functions. The membership functions divide the entire range (500) of the input variables into a few subranges represented by the fuzzy states. For example, Table 1 shows how you can define the following five (partially overlapping) subranges and their corresponding fuzzy states. Having defined five fuzzy states, you must define five membership functions. The most widely used are the lambda-type functions, which will appear as shown in Figure 11. Each membership function reaches a maximum value, MAXV, at the input value stated above in Table 1s second column (in bold). This maximum value can be any value that is not too high and still allows a good resolution (for example, 1000). Further, you can notice that for any input value, two membership functions overlap (they have nonzero values), except at the peaks of the membership functions. At these input values

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

keep the constant output power required to maintain the temperature set point once the control process has stabilized. The other variable is the actual output of the fuzzy controller, corrOut. Its purpose is to correct the FFOut value during the warm-up phase. In addition, corrOut is responsible for eliminating the stabilized temperature variation due to possible disturbances. Once the crisp input values are fuzzified, the fuzzy controller processes the fuzzy input variables to produce the fuzzy output variable, 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, MedNegOut, SmallOut, MedPosOut, FullPosOut } CorrQt; The next is a definition of the fuzzy output variable, CorrVal, including its initialization. You use the values MAXV, MAXV/2, 0, MAXV/2 and MAXV ( 1000, 500, 0, 500, and 1000) for the mapping of the fuzzy output variable to the crisp output variable: int CorrVal[MEMB] = {-MAXV, -MAXV/2, 0, MAXV/2, MAXV}; To access the individual (MEMB) values of the fuzzy output variable, use the abovedefined quantificator, CorrQt. Output of the feedforward member, FFOut, and the crisp correction output variable, corrOut, are defined as simple integer variables: int FFOut, corrOut; /* Output of Feed-Forward & Correction blocks */ Now, that you have defined all the major data structures and variables, you can continue your design with the fuzzy procedures.

Fuzzification
Fuzzification aims to convert crisp input values into corresponding fuzzy set values. As you already know, this process uses the set of membership functions. If you had such a set (as shown in Figure 11) in the form of look-up tables, fuzzification would be very simple. You would apply the input value as the offset to a look-up table and pick up a corresponding value of each membership function. 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, representing the set. This is a lot of memory. A better approach is to generate the set of the membership functions during the fuzzification process itself. Actually, you need to generate only one value for each of the membership functions, which correspond to the current input value. These five generated values are the weighting coefficients determining how strongly the input value is tied to the individual membership function. This is the entire purpose of the fuzzification. You can verify whether the fuzzification and the membership-function generation are correct by looking at the fuzzified variable. Table 2 shows a few selected values of the input variable, err, and the corresponding values of errFv.Funct[MEMB] variable (for clarity, shown as Funct[x] values). The sum of weighting coefficients for any input value is always a constant of MAXV (1000), and a maximum of two membership functions can acquire nonzero values. Implementation of the fuzzification procedure is left to you. First, find out to which interval (given by the values of Point[MEMB])the input value belongs. For example, an

input value of 125 lies in the interval between Point[2] and Point[3]. It is immediately clear that only the membership function[2] and the membership function[3] will have nonzero values in this interval; all the other membership functions will have zero values. In this interval, membership function[2] has the falling edge and membership function[3] has the rising edge. Using a simple linear interpolation, you can calculate exact values of both functions.

Applying fuzzy rules


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

output power would have been very likely changing its levels according a following sequence: MNO SO MPO SO MNO forever. In addition, the fuzzy rules themselves as they are listed above, would yield ambiguous results. Either of the two fuzzified input variables will be in most cases decomposed into two input levels (though with different weighting coefficients), so conditions of as many as four fuzzy rules will be fulfilled at the same time. (Be aware: In the set of fuzzy rules, none of the if statements are followed by else statements.) 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 entire process of calculating this multilevel contribution and converting it into a single (crisp) value is called defuzzification.

Defuzzification
Defuzzification is the opposite of fuzzification. It aims to convert a value (actually several values) of the fuzzy output variable to a single crisp value. There are many ways to perform defuzzification, just as there are many ways to perform fuzzification. The most common method is called Min-Max method, which selects only the maximum or minimum values from each fuzzy rule for further processing. Procedurally, the most convenient way to implement defuzzification using this method is to combine it with fuzzy rules processing. For fuzzy rules (if statements) comprising two or more conditions ANDed together, you select a minimal weighting coefficient (a fuzzified input variable with the minimal value) as a combined truth value for further processing. In a fuzzy rule comprising two or more conditions ORed together, you select a maximum weighting coefficient for further processing. These rules are consistent with the theory of sets. In this control application, you use only ANDed conditions, but different applications may use ORed conditions as well. For example, if in Figure 12 an entire raw (column) used the same output level, conditions would be ORed, and you would select maximum weighting coefficient for further processing. 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.Funct[MedPosDev] && derFv.Funct[SmallDev]) { minVal = min(errFv.Funct[MedPosDev], derFv.Funct[SmallDev]); num += minVal * CorrVal[MedPosOut]; denom += minVal; } If the expression of the if statement yields the truth value (both ANDed weighting coefficients are nonzero), the minimum value of the weighting coefficients of both fuzzified input variables is assigned to an auxiliary variable minVal. The minVal value is added to the variable denom (denominator), and after multiplication with the mapping value corresponding to the produced output level, CorrVal[MedPosOut], the product is added to another variable, num (numerator). You repeat these actions for each true if statementin this case, for as many as four out of 25 statements. The num and denom variables must be cleared before they enter fuzzy rules processing. After the whole set of fuzzy rules is processed, the ratio num/denom will yield a crisp value of the output variable, which is assigned to the corrOut variable. You describe this process as singleton defuzzification. It is a simplified centroid

method, which got its name because it resembles the calculation of the center of the mass of a complex object. The simplification ignores the fact that any two adjacent (output) membership functions overlap. The error caused by this simplification is negligible as is shown in the following example (Figure 13). 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. Calculations based on the centroid method would find the center of the mass at the distance of 828. The singleton defuzzification would yield a value of 833 (for clarity, negative power levels were used). Figure 14 shows a 3-D graph of the defuzzified (crisp) output variable corrOut. Its content (vertical axis) changes from the MAXV value to the MAXV value as the input variables, err and derr, change from the extreme values of 500 and 500 to the other extreme values 500 and 500, respectively. The surface of the defuzzified output variable is often called the control surface, because it determines the value of the controlled (actuating) variable for any given input values. In this case, the surface represents a nice, linear cut through a cube, led almost symmetrically from one corner to the other. You would expect this situation, because the process has used for the fuzzification a set of linear and equally spaced membership functions (Figure 11). The fuzzy rules exhibit no irregularities (Figure 12) but yield constant output levels diagonally placed from the lowest to the highest. The linearly arranged numbers govern the mapping of the fuzzy to crisp output variable. The shape of the control surface is extremely important. The quality of the control process entirely depends on it. However, the actuating variable is a combination of the corrOut value with a constant value, FFOut, which is an output of the feedforward member. If the value of FFOut provides the output power, which does not correspond to the temperature set point, the temperature will settle down at a value other than the set point. You must correct for this deviation.

Correction of the feedforward output


Similar to the PID control, the feedforward output is an output of the heater model block, which is an inverse static characteristic of the heating process. The heating process is linear (the output temperature is proportional to the applied power), so a simple line with the slope km represents the heating-model characteristic. As previously described, the initial value of km can be: km = MAX_POWER / MAX_TEMPERATURE. (If MAX_TEMPERATURE is not at least a couple of hundreds degrees, you should subtract from it the ambient temperature.) The MAX_POWER value in this case should be MAXV, which represents 100% of the output pulse width, if you use the PWM method to drive the heater elements. The feedforward output value for a particular set point temperature will be: FFOut = km * SET_POINT_TEMPERATURE. In this case, the MAX_TEMPERATURE value is 500 C and the MAX_POWER value is 1000. Now, if a desired set point temperature is, for example, 200 C, the FFOut value required to maintain this set point value will be 400 (40% PWM). This actuating value might be suitable in an ideal situation when using a properly sized heater. In practice, you might prefer an oversized heater, which requires less power to maintain the same temperature. This option is especially important when the set-point value is in the high end of the temperature range. You would not want to wait hours for the temperature to reach the set point value. In certain applications, you may encounter the opposite situation, in which the heating elements are undersized. In any case, the probability that the

FFOut value will maintain exactly the set point temperature without any additional corrections is extremely low. When FFOut is higher than is needed, the temperature will stabilize somewhere above the set-point value. A steady nonzero (in this case, negative) regulation error will cause the corrOut value to become negative, which will reduce the overall power applied to the heating element. Finally, the temperature will stabilize somewhere between the set point value and the temperature corresponding to the FFOut value. You can eliminate this control error by either adding an integral member identical with what the PID correction uses, or implementing the following adaptation routine: if(abs(derr) < SOME_SMALL_NUMBER) { km = (FFOut + corrOut)/(currentTemperature ambientTemperature); FFOut = km * setPoint; } If the current temperature settles down, the derivative of the regulation error will be close to zero. The current temperature is maintained by the output power from the combined contribution of the FFOut and corrOut values. So, the calculation of a corrected characteristic, km, is very simple. You take the combined output power and divide it by the current temperature decreased by the ambient temperature; km is actually a ratio of P/T, where P is a difference between the powers applied to the heating element at the current and at the ambient temperatures, T. Of course, at the ambient (surrounding) temperature, there was no power applied to the heating element. After modifying the heater-model characteristic, do not forget to calculate a new feedforward output value. And, you can go a step further in this adaptation process. If your controller can remember the latest value of km, it can use it from the very beginning of the next control process. However, this routine has one fault. The derivative of the regulation error can acquire a zero value even though the current temperature is far from the stabilized value. Figure 10 shows that this situation will occur every time the spiral crosses the horizontal line, even at the very beginning of the control process, when the current temperature equals the ambient temperature. The calculation would fail even here, because of the division by zero. So, you need to provide some additional mechanisms to prevent premature km modifications.

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. In the center of the state diagram (when both, err and derr acquire zero values), the FFOut value should be applied to the heating element to hold the desired temperature. The transition from one level to the other would be abrupt and be led along the switching curve. It sounds simple in theory. The problem is determining the trajectory of the switching curve. For a second-order controlled system, you can approximate the switching curve by a parabolic curve (second-order polynomial). If you do not know precisely parameters of the curve, youll never get to the target (the center of the state diagram). Therefore, you need to allow the traditional control system to apply linear controlling in a certain band around the set-point value. PID control uses the LCZ for exactly this reason. The control surface in Figure 14 resembles the LCZ used in the PID control, but they are not identical. They would be identical if the layers of the constant power were

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

Similarly, as the PID controlling has been enhanced by introducing an adapter block for the modifications of the PID constants, you can use the same idea to automatically modify the power profile of the fuzzy controller by modifying those distribution points. Your system must compare the set-point value with the balanced temperature, and a simple linear equation (Figure 4 and equations 1 and 2) can calculate the new distribution points for the optimized power profile. Even such a simple process as temperature control can become complex if you want additional features, such as a fast warm-up phase. Implementing the enhanced, traditional PID controller can be a challenge, especially if you want to have autotuning capabilities. However, the theory of PID controlling is very well known and widely used in many other control applications. If you are a traditionalist, it might be your preferred choice of control method. On the other side, lesser known fuzzy control seems to accomplish the same control quality with less complexity. Better approximation of the switching curve makes it a better candidate for time-optimal applications for temperature control. As a relatively new control method, it still provides space for further improvements. If you are an innovator, you will prefer fuzzy control as a modern, elegant control method. You can contact author Peter Galan at petergalan@rogers.com.

Table 1Subranges 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 2Selected values of the input variable, err, 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

KP
+ e(t)

SET POINT

KI KDd/dt

ACTUATING VALUE

ACTUAL VALUE

Figure 1A PID controller calculates an actuating value from proportional, integral, and derivative components.

Te Res

Ts

Ce

Cs

Rsa

Ta

Figure 2A simple heating-system model has thermal resistances and capacitances.

MAXIMUM REACHABLE TEMPERATURE TEMP (T) HEATING

BALANCED TEMPERATURE

COOLING

AMBIENT TEMPERATURE

TIME (t)

Figure 3Heating rates and cooling rates vary with temperature.

1/ TEMPERATURE CHANGE RATE 1/2 COOLING RATE

HEATING RATE AMBIENT BALANCED MAXIMAL TEMPERATURE

Figure 4The rate of temperature change is not linear, but a straight line is a reasonable approximation.

HEATER MODEL ADAPTER

Set Point

+ -

ACTUATING VALUE

D
ACTUAL TEMPERATURE

Figure 5The addition of a heater model and an adapter to a PID controller provides adaptive modification of PID constants and feed-forward output.

100%

POWER (%) 4 SET-POINT POWER POWERTEMPERATURE CHARACTERISTIC INITIAL POWER 0% 1

C
5

INITIAL (AMBIENT) TEMPERATURE

BEGINNING OF LCZ TEMPERATURE

SET-POINT TEMPERATURE

Figure 6A nonlinear control process with the LCZ (linear control zone), as seen in this diagram, approximates the bang-bang control.

HEATER MODEL ADAPTER

P
+ REL Set Point

+ -

e
- REL

ACTUATING VALUE

D
Linear Control Zone Hold & Full Power ACTUAL TEMPERATURE

Figure 7An enhanced temperature controller incorporates PID control, adaptive PID constants, approximation of bang-bang control, and a learning feedforward member capable of predicting and generating required output power.

100% PWM

0% PWM
Tpeak Tmax Set Point Temperature Tmin

t0

t1

t2

time (t)

Figure 8The 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 9Step-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 10A state diagram shows how the regulation error, err, and its derivative, derr, 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

250

500

Figure 11The fuzzification of the input variables uses a set of five membership functions.

500 FNO FNO FNO MNO SO

250

FNO

FNO

MNO

SO

MPO

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 12This graphical representation of the Fuzzy Control knowledge base is suitable for the controlling of a generic heating system.

FNO

MNO

SO

MPO

FPO

500

x
-1000 -833 (SINGLETON) -500

250 0 500

x
1000 828 (CENTROID)

Figure 13Difference between the centroid and much simpler singleton defuzzification is negligible.

POWER PROFILE LINE

+corrOut

-corrOut

+err

-err

+derr

-derr

Figure 14A three-dimensional schematic represents the defuzzified output variable.

375 250

-250 -375

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

(FullPosOut) +1000 (MedPosOut) (SmallOut) (MedNegOut) +500 0 -500

+corrOut

-corrOut -err, +derr +err, -derr

(FullNegOut) -1000

(FullPosOut) +1000 (MedPosOut) (SmallOut) 0 0

+corrOut

(MedNegOut) -1000 (FullNegOut) -1000 -err, +derr +err, -derr

-corrOut

(FullPosOut)

+1000

(MedPosOut) +1000 (SmallOut) (MedNegOut) (FullNegOut) 0 0 -1000 -err, +derr +err, -derr

+corrOut

-corrOut

Figure 16The power profile depends on the mapping function of the fuzzy output variable to the crisp output variable.

Potrebbero piacerti anche