Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Case Study: Design of A Fuzzy Controller Using MATLAB

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Appendix A

Case Study: Design of a Fuzzy Controller using MATLAB


This Appendix considers a case study for the design of a generic fuzzy controller for the control of a simple, yet representative process. The dynamic process exhibits nonlinear behavior and response asymmetry, for which it is desired to compensate. The objective is to show the reader the step-by-step procedure that must be followed and the ease with which it is possible to examine the performance of the resultant fuzzy controller using MATLAB and its Simulink and Fuzzy Toolboxes. The steps in the design procedure are explained in sufficient detail so that the advantages and disadvantages of fuzzy control over conventional three-term control can be evaluated. The case study includes a comprehensive study of the effects of the choice of fuzzy sets on the performance of the closed system. The case study is based on the example given in the book by Gulley and Roger Jang (1995) on the use of the MATLAB Fuzzy Toolbox.
259

260

Appendix A

A.1 The Controlled Process


The controlled process comprises a single storage tank shown in Figure A.1. Inflow is controlled by a flow control valve while outflow is through a fixed opening at the bottom of the tank. Outflow depends on the pressure in the tank and consequently on the level of the fluid in the storage tank. The control objective is to maintain the level of the fluid in the storage tank h(t) constant so that the outflow rate remains constant despite perturbations in the inflow rate. In order to maintain the storage tank level constant, it is necessary to know the level of the fluid in the tank at all times. This can be achieved by using an inductive, capacitive or ultrasonic sensor, for instance. Even a floating ball connected to a potentiometer will do if the variations in the fluid level are relatively small. The controller has the error e(t)= hd - h(t) where hd and h(t) are the desired and actual levels of the fluid in the tank respectively as input and the rate u(t) with which the valve is opened or closed as output.
u(t)

Inflow

Level sensor

Desired fluid level hd Actual level h(t) Outflow rate y(t)

Figure A.1 The controlled process

Design of a Fuzzy Controller Using MATLAB

261

A.2 Basic Linguistic Control Rules


Without knowing anything about the controlled process characteristics and using only basic qualitative knowledge, it is possible to control the level of fluid in the storage tank by following the three intuitive rules: R1: IF the error_in_the_fluid_level is ZEro (i.e., the actual level is equal to the desired level) THEN the control_valve_rate must be ZEro (i.e., do nothing), R2: IF the error_in_the_fluid_level is LOw (i.e., the actual level is less than the desired level) THEN the control_valve_rate must be POsitive_large (so that the tank will fill as quickly as possible), R3: IF the error_in_the_fluid_level is HIgh (i.e., the actual level is higher than the desired level) THEN the control_valve_rate must be NEgative_large (so that the tank will empty as fast as possible), Since the controller must send a quantitative action to the control valve, then the following additional information is required: the maximum permissible change (also termed the deadzone) in the nominal value of the fluid level and the maximum rate of change of the fluid level (which can be computed from the dimensions of the storage tank and the maximum inflow rate or by experimental measurements).

A.3 A Simple Linguistic Controller


A very simple linguistic controller can be implemented very easily using the three rules presented above. Thus, for example, let the linguistic variable NORmal be assigned a tolerable discrepancy from the desired level of meters. If the level is greater than meters below the desired level then the valve must open at its highest rate POsitive_Large. By contrast if the level of fluid in the tank exceeds the desired level by then the rate of valve closure must be NEgative_Large. It is noted that this simple

262

Appendix A

principle is used in simple on-off controllers using relays in building thermostats for which no knowledge of the room dynamics or characteristics is required! Unfortunately, this simple controller leads to undamped oscillations in the level of fluid in the tank with a peak to peak amplitude of 2 meters, as seen in Figures A.2(a) and A.2(b). Furthermore the step response, i.e., the fluid level as a function of time in response to a sudden change in the desired level, is asymmetric. As seen, an increase in the desired fluid level leads to a different response than a decrease in the desired level. This is characteristic of fluid systems since fluid pressure and level are nonlinearly related. There is no way of estimating the frequency of oscillation since there it is assumed that there is no knowledge of the dynamics of the controlled process. It is observed, however, that reducing the dead-zone 2 reduces the amplitude and increases the frequency of the oscillation. This is observed in Figures A.2(a) and A.2(b). Reducing the dead-zone to zero will, in theory, lead to an infinite frequency of oscillation. In practice this is unlikely because of the inherent delays in the relay. In any case this continuous chattering is undesirable since it shortens relay life.

Figure A.2(a) Step response of linguistic controller with =0,1

Design of a Fuzzy Controller Using MATLAB

263

Figure A.2(b) Step response of linguistic controller with =0,025

The system can be modeled using MATLAB/Simulink/Fuzzy Toolbox simply typing the instruction sltank at which the flow diagram shown in Figure A.3 appears. In this file we are given the opportunity to compare the step responses of the fuzzy and fuzzy controllers for the same conditions. The fuzzy sets in this simple case have the Boolean form shown in Figure 5.1. As a consequence the output of the controller can only take one of three possible values, i.e., POL, ZER or NEL. The qualitative controller is equivalent to a threshold logic unit with dead-zone, as shown in Figure A.4. If the fluid level error is within the dead-zone then the controller gives no output and the process coasts freely. However, when the absolute error exceeds the dead-zone then the controller gives a command of sgn(e).

264

Appendix A

Figure A.3 Simulink flow diagram using sltank


u 1 - -1 e

Figure A.4 Input-output relationship of qualitative controller

A.4 The Design Procedure


With the simple linguistic controller, the oscillations (or more precisely, limit cycles) of the fluid in the storage tank about its desired value are not acceptable except only where coarse control suffices. The constant chattering of the controller relay inevitably leads to wear of the control valve, which is in a state of continuous motion. We must find a suitable control strategy that will dampen these oscillations and ultimately elimi-

Design of a Fuzzy Controller Using MATLAB

265

nate them. It is also desirable to find some technique to compensate for the response asymmetry. We could, of course, follow the road of conventional control, identifying the process dynamics by applying step disturbances to it, determining a simple approximant and using the cookbook techniques of Ziegler and Nichols, or more sophisticated methods in order to establish the parameters of the required three-term controller. This procedure is quite tedious and time-consuming and it is doubtful that all objectives can be satisfied simultaneously. It is certain, however, that a conventional three-term controller cannot compensate for the observed asymmetric response. If we could change the control strategy by adding some additional stabilizing rules and some advanced inference mechanism so that the control action changes smoothly, instead of abruptly as in the case of the simple controller, then we could achieve stabilization and significant improvement in the closed system response. The solution is to turn to unconventional control techniques and design a fuzzy controller with one of the available computer aided design packages. This case study uses MATLAB Simulink and the Fuzzy Toolbox. In the following, we present the procedure that must be followed in the design of a simple generic fuzzy controller. Our objective is a robust fuzzy controller which can be described by simple linguistic rules but which will not exhibit the problems that were encountered with the simple linguistic controller described earlier. The next step in the design procedure following encoding of the control rules, is to decide on the number of fuzzy sets for every input and output variable of the controller. We must also specify the shape of the corresponding fuzzy sets, some of the available choices being shown in Figure 11.5. In this study we experiment with a number of shapes in an attempt to find acceptable overall performance. The FIS Editor in the Fuzzy_Toolbox shown in Figure A.5. is a simple and effective tool that makes designing fuzzy controllers simple. As was noted in earlier chapters of this book, it is not necessary to specify many fuzzy sets for the inputs to the controller in order to obtain acceptable accuracy. Most industrial applications use 3 to 5 fuzzy sets. Where fine control is essential then many more fuzzy sets are required. In the F. L. Smidth kiln controller, for instance, more than a dozen fuzzy sets are used. In the fuzzy controller proposed here, only

266

Appendix A

three fuzzy sets LOw, OK and HIgh are used for the input variables for simplicity.

A.5 System Stabilization Rules


The oscillations in the fluid level in the storage tank which were observed with the simple qualitative controller resulting from the use of only three rules, can be damped by adding two more rules which involve the derivative of the level error de(t)/dt. This is a classical procedure even in conventional control. However, in order to avoid any problem through using derivatives of the set point, we prefer to use the derivative of the measured fluid level in the tank dh(t)/dt as the second input to the controller in addition to the level error e(t)=hd-h(t). In practice the derivative is replaced by the first backwards difference of the level hk=hkhk-1.

Figure A.5. The FIS Editor in the fuzzy design tool

Adding two rules can, indeed, stabilize the closed system:

Design of a Fuzzy Controller Using MATLAB

267

R4: IF error_in_the_fluid_level is ZEro AND the rate_of_change_of_level is NEgative_Small THEN the control valve must be closed slowly, i.e., the control_valve_rate must be NEgative_Small R5: IF error_in_the_fluid_level is ZEro AND the rate_of_change_of_ level is POsitive_Small THEN the control valve must be opened slowly, i.e., the control_valve_rate must be POsitive_Small These 5 control rules may be specified in many ways, the most convenient of which is linguistic, as shown in Figure A.6.
1. If (level is OK) then (valve is no_change) 2. If (level is low) then (valve is open_fast) 3. If (level is high) then (valve is close_fast) 4. If (level is OK) and (rate_of_change_of level is positive) then (valve is close_slow) 5. If (level is OK) and (rate_of_change_of level is negative) then (valve is open_slow) Figure A.6. The control rules in linguistic form

A.6 On the Universe of Discourse of the Fuzzy Sets


The universe of discourse of every input to the controller depends on the permissible range of that variable. Errors are confined to e[-, ] and the change of errors to dh(t)/dt|max[-, ]. The two parameters and thus uniquely specify the universes of discourse of the two controller inputs. The output of the controller is the rate with which the flow control valve is opened or closed . Here we specify 5 fuzzy variables, i.e.,

268

Appendix A

NEg_Large, NEgative_Small, ZEro, POsitive_Small and POsitive_Large for finer control. The universe of discourse in this Case is normalized to [-1,1] where +1 indicates that the valve is entirely open (i.e., 100% open) and 1 that it is closed (i.e., 0% open). The median 0.5 implies that the valve is at the center of its range.

A.7 On the Choice of Fuzzy Sets


The fuzzy sets of the controller inputs and outputs can be given any of the most common shapes offered in the Fuzzy Toolbox, such as triangular, trapezoidal, Gaussian, etc. (see Figure 5.12). Various combinations are tried and the resultant control surface and corresponding dynamic behavior of the closed system are compared. The control surface is a graphical interpretation of the control actions in input space, i.e., how the outputs of the controller vary as functions of the controller inputs. For a given set of control rules the control surface depends on the shape of the fuzzy sets of both the inputs and the outputs of the controller but this does not greatly affect the dynamic performance of the closed system. The control surface of a generic controller with two inputs gives us an immediate indication of the magnitude of the control action in control space but clearly when the controller has more than two inputs, the control surface becomes a manifold which is impossible to visualize. Should the performance of the closed system prove unsatisfactory, the control surface can be examined to see how the rules must be modified or what new rules must be added to bring about the desired behavior. In the design example, the control surfaces were computed using an inference engine based on Mamdanis compositional inference rule while COG (Center Of Gravity) was used to de-fuzzify the fuzzy set of the controller output. The Fuzzy Toolbox provides alternative forms for both the inference engine and de-fuzzification.. The following five cases were considered in the design study: 1. Case - Figure A.7: Inputs with 3 triangular fuzzy sets and outputs with 5 symmetric triangular fuzzy sets with large support (50%) and no overlap.

Design of a Fuzzy Controller Using MATLAB

269

2. Case - Figure A.8: Inputs with 3 triangular fuzzy sets and outputs with 5 symmetric triangular fuzzy sets with small support and no overlap. 3. Case C - Figure A.9: Inputs with 3 Gaussian fuzzy sets and outputs with 5 symmetric triangular fuzzy sets with small support and no overlap. 4. Case D - Figure A.10: Inputs with 3 Gaussian fuzzy sets and outputs with 5 asymmetric triangular fuzzy sets with small support and no overlap. 5. Case E - Figure A.11 : Inputs with 3 Gaussian fuzzy sets and outputs with 5 asymmetric triangular fuzzy sets with small support and some overlap. It is noted that triangular fuzzy sets with small support, i.e., , 0 approximate singletons (see chapter 5) that have been used in industrial fuzzy controllers. The advantage of using singletons is the simplicity and speed of the computations for de-fuzzification. A number of vendors use singletons in their products, e.g., S5-Profuzzy, S7Fuzzy_Control by Siemens and FuzzyTech by Allen Bradley. For every one of the five cases we present the control surface and the corresponding step response. Figure A.12 shows the computer screen from the Fuzzy Toolbox which shows which rules are fired for a given controller input values and the corresponding controller output for the Case E.

A.8 Compensation of Asymmetry


Asymmetry in the step response of a closed system is not an uncommon phenomenon in practice due to the inherent nonlinearities in the controlled plants. In these cases, the step response for a positive demand differs significantly from the response for a negative demand. A typical example is in the control of pressure, which is related by the square root of the observed height, as shown in the example analyzed in this Appendix. A conventional industrial three-term controller cannot easily compensate for this asymmetry. In contrast, asymmetry can be compensated for relatively easily in soft controllers (both fuzzy and neural) by warping the control surface appropriately. This can be achieved easily by displacing one or more of the fuzzy sets laterally on the universe of discourse. In

270

Appendix A

Figure A.10(c) for instance, the fuzzy set Positive_Small has been shifted to the left with the consequence that the control action for small positive errors in the liquid level is greater than that for small negative errors. Thus for small discrepancies in the liquid level about the nominal level, the rate with which the valve is changed is increased when the tank is filling and decreased when it empties. This leads to compensation of response asymmetry.

A.9 Conclusions
It should have become clear that altering the shape of the fuzzy sets of the controller does not lead to major changes in the control surface. This is evident in Figures A.7(c) to A.11(c). In cases and , the control surfaces shown in Figures A.7(c) and A.8(c) are almost flat in the dead-zone due the triangular nature of the fuzzy sets of both the inputs and the output. The corresponding step responses are shown in Figures A.11(a) and A.11(b) are unsatisfactory because their steady-state error is non-zero and response asymmetry is severe. It is noted, also, that in these two cases, both the triangular fuzzy sets with a large support set and the singletons have comparable step responses. In contrast, in cases C, D and E the control surfaces are smooth because of the smooth (Gaussian) shape of the fuzzy sets of the controller inputs. The corresponding step responses are seen to be superior. In cases D and E (see Figures A.11(d) and B.11(e)) the step responses are almost symmetric. Finally, in the last three cases the steady-state errors are essentially zero and overshoot is negligible. Case E appears to be the best as it demonstrates symmetric response, zero steady-state error and no overshoot. As was seen in all five cases, the closed system step response is influenced significantly by the shape of the fuzzy sets of the inputs and to a lesser extent by the fuzzy sets of the controller output. In general, Gaussian fuzzy sets have smoother control surfaces, implying smoother control actions and improved responses. The best shapes of the fuzzy sets are not generally known and are the subject of ongoing research.

Design of a Fuzzy Controller Using MATLAB CASE A

271

Figure A.7(a) Input fuzzy sets

Figure A.7(b) Output fuzzy sets

Figure A.7(c) Control surface

272

Appendix A CASE B

Figure A.8(a) Input fuzzy sets

Figure A.8(b) Output fuzzy sets

Figure A.8(c) Control surface

Design of a Fuzzy Controller Using MATLAB CASE C

273

Figure A.9(a) Input fuzzy sets

Figure A.9(b) Output fuzzy sets

Figure A.9(c) Control surface

274

Appendix A CASE D

Figure A.10(a) Input fuzzy sets

Figure A.10(b) Output fuzzy sets

Figure A.10(c) Control surface

Design of a Fuzzy Controller Using MATLAB

275

CASE E

Figure A.11(a) Input fuzzy sets

Figure A.11(b) Output fuzzy sets

Figure A.11(c) Control surface

276

Appendix A

Figure A.12(a) Step response for Case A

Figure A.12(b) Step response for Case B

Design of a Fuzzy Controller Using MATLAB

277

Figure A.12(c) Step response for Case C

Figure A.12(d) Step response for Case D

278

Appendix A

Figure A.12(e) Step response for Case E

Figure A.13 Computations for case E

You might also like