Case Study: Design of A Fuzzy Controller Using MATLAB
Case Study: Design of A Fuzzy Controller Using MATLAB
Case Study: Design of A Fuzzy Controller Using MATLAB
260
Appendix A
Inflow
Level sensor
261
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.
263
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
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.
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
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.
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.
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.
271
272
Appendix A CASE B
273
274
Appendix A CASE D
275
CASE E
276
Appendix A
277
278
Appendix A