A Simple Tuning Algorithm of Augmented Fuzzy Membership Functions

The successful application of fuzzy control depends to a large extent on the parameters of some subjective decisions, such as fuzzy membership function (MF). Fuzzy logic controller (FLC) implementing augmented output MFs as compare to input MFs is presented to improve the accuracy, robustness, and performance of the system. The best possible combination of input and output MFs is introduced to distribute the uniform input MFs and augmented output MFs in the treatise. The simulation of the 2-Inputs 1-Output Fuzzy Control System is performed in many nonlinear processes. Then, the experimental outcomes of the uniformly and augmented distributed output MFs are compared under similar circumstances. The experimental outcomes are in a virtuous covenant with the simulation outcomes. The experimental outcomes show that the root mean square error (RMSE) is reduced around 75.3% and bringing down the relative error to the acceptable range (≤±10%). The control accuracy is improved and the robustness is boosted by reducing the RMSE through the FLC with augmented-distributed output MFs. Moreover, the cost and energy efficiency in any fuzzy system will be improved by implementing the augmented-distributed output MFs using the best possible combination of input and output MFs.


I. INTRODUCTION
Fuzzy control systems (FCS) enable humans to make decisions and control real-time applications based on inaccurate linguistic information. Zadeh [1] introduced the concept of fuzzy sets as a means of expressing uncertainty and ambiguity. Since then, the fuzzy set theory has become a hot topic in different disciplines. In a FCS, membership functions (MFs) and fuzzy rules have a major impact on the control system performance [2]. Consequently, tuning of the MFs has been a crucial task for fuzzy system design.
Nowadays, the focus of fuzzy related research is on the continuous development of innovative prediction and optimization techniques to maximize user comfort and minimize energy consumption. However, control accuracy is the most critical part which contributes to system performance but has largely been ignored by researchers. In most studies, the Mamdani model has been used because of its simplicity and effectiveness. The Mamdani model relies on MFs with The associate editor coordinating the review of this manuscript and approving it for publication was Ding Zhai. fixed boundaries which affect the performance of the FLC because, for particular input values, variation in MFs and their granularity provide different results [3].
The FLC characteristics play a significant part in achieving better performance in the nonlinear control system. The nonlinear recital of the FLC is very much sensitive to the position and length of the fuzzy set MF. The base length of the MF and the position of its peak affect the triggering level of the fuzzy rule. The heftiness of the FLC to parameter changes can exist in the appropriate settings of the MF. However, despite its significant role, the number of studies on MFs design is limited. Triangular MFs are widely used in FCS because they are simple and easy to compute. Triangular MFs perform better concerning the steady-state behavior specifically with cumulative preferred location. The augmented output MFs approach, on the other hand, enhances the compactness of the logical scenario and ultimately increases the control accuracy [4].
In the literature, different optimization methods have been reported for MF optimization. These optimization techniques include artificial neural networks [5], particle swarm optimization (PSO) [6], ant colony algorithm (ACO) [7] and genetic algorithm (GA) [8]. However, these algorithms are very time consuming since complex computation is required for convergence [8]- [10]. The time consumption is due to the fact that these methods need either prior extensive training of networks (e.g. ANN) [11] or require updating of many particles as in PSO and ACO methods. GA also needs to calculate the suitability and to discard the least suitable candidate solution members after every generation. It is, therefore, not feasible to practically implement these methods using commercially available microcontrollers [12].
Based on machine learning algorithms and fuzzy logic, multiple techniques have been utilized in various fields for different purposes, but there is no accurate way to determine the span, the granularity or the shape of appropriate MFs [13]. The MFs and fuzzy rules are designed to rely heavily on the expert's knowledge in the relevant application areas. Therefore, it is not an easy task to analyze how MFs affect the system's response in the event of a change in the MFs standard. Consequently, augmented output MFs using specific length and position remains uninvestigated due to the lack of auxiliary experimental statistics [14], which is the key motive of this research.
It has already been reported that the performance linearity of the fuzzy system enhances with the increase in output MFs [15]. However, the requirement of tuning an increased number of MFs only worsens the convergence issues.
In this work, we have presented a new and simple algorithm for the tuning of MFs. It is shown that, for a given monotonic system, by determining the effects of relative variation in the positions of output MFs peaks and incorporating the results in the de-fuzzification process, accurate results can easily be achieved. It is also shown that for higher number of output MFs, the tuning of only the first and the last MFs using the proposed algorithm eliminates the need for optimization algorithm, that require large computational sources, at least for small data scenario especially where targeted system behavior is already known. The simulated and experimental results are provided for the uniformly-distributed output membership functions (UOMFs), and augmenteddistributed output membership functions (AOMFs) for 2-Inputs 1-Output FCS.
Section 2 presents the simplified overview of the complete architecture of the proposed model. Section 3 explains the algorithm design in detail. The simulation setup is described in section 4. Section 5 defines the experimental setup utilized for the implementation of proposed model. Section 6 provides the comparison and analysis of simulation and experimental results. The conclusion and future work is presented in section 7.

II. SYSTEM MODEL OVERVIEW
The fuzzy model is designed for a general control system that takes inputs from two sensors i.e. Sensor One (SN-1) and Sensor Two (SN-2) and provides a pulse width modulated (PWM) output signal as shown in Fig.1 Since most of  the modern sensors provide transistor-transistor logic (TTL) compatible output voltage levels (i.e. 0 -5 V), therefore these two sensors (SN-1 and SN-2) can be assumed to measure any physical parameter e.g. temperature, pressure, humidity etc. The system output in the form of a Pulse Width Modulated (PWM) signal is chosen due to its higher efficiency and lesser power loss during the driving of various loads e.g. motors. The PWM output signal is presented in terms of percentage (%).
Isosceles-triangles are used to define MFs for these fuzzy sets. Each MF has two parameters to characterize. In order to keep simplicity, the current fuzzy model is designed for a system exhibiting monotonic behavior only. Fig. 2 shows the simplified architecture of the fuzzy model. The proposed model takes inputs from two sensors i.e. SN-1, and SN-2. The output of each sensor is proportional to its corresponding sensing parameter. The generated signals are provided to two fuzzifiers each of which generates two fuzzy variables after necessary signal conditioning. An inference engine received these fuzzy variables. A rule-block containing pre-defined rules is also connected to the inference engine. Based on the four fuzzy inputs and the pre-defined rules, the inference engine provides four outputs using the min-AND operation to a de-fuzzifier. The de-fuzzifier then provides a crisp value at its output.

III. ALGORITHM DESIGN
The input values from sensors are described in the fuzzy model in terms of percentage i.e. from 0% to 100%. In this work, 0 V and 5 V are considered as 0% and 100% respectively. But the model can equally be applied on systems where   Fig. 2, translates the signals from sensors (0 -5 V) into different ranges, defined in the model for each input sensor.

A. FUZZIFIER
The fuzzifier interprets the fuzzy inputs as linguistic values and produces output in the form of a fuzzy set of the linguistic variable. Five triangular MFs are defined which are further categorized into four sections for the whole range of each input variable. the distribution of names of the MFs along with their associated sections and ranges is summarized in Table 1. Fig. 3, shows the graphical view of the above mentioned categorization of four sections and five MFs for each input variable.
A design of the fuzzifier unit, shown in Fig.4, is taken from [16] and employed in the model to generate fuzzy outputs for a single sensor. For each input variable, one fuzzifier unit is needed in this model. Fig. 4 shows that the input signal in the range of 0-5 V is first multiplied by a factor of 25 in order to emulate the complete range defined for each variable in the model. The output of the multiplier (x) is provided directly to a four-channel subtractor as well as a sectioncomparator. The four-channel subtractor identifies the input value by subtracting range boundary values from it i.e. 25, 50, 75, 100. Section comparator compares the input (x) with the range boundaries to determine the section occupied by the input value. The output of the four-channel subtractor serves as input data of a multiplexer whereas the output from section comparator is connected to the selection lines of the multiplexer. A divider module connected at the output of multiplexer divides the outcome of multiplexer by 25. The output of the divider generates f 1 , f 3 output values of fuzzifier whereas a further subtraction from '1' generated either of f 2 , f 4 output values.

B. INFERENCE ENGINE
The inference engine is comprised of 4 AND operators. The fuzzifier provides four inputs to the inference engine which uses the min-AND configuration to acquire the R output.
The total number of rules required for all the defined ranges of a fuzzy system is determined by factor m n , where n = number of inputs and m = maximum number of overlapping fuzzy sets. For this fuzzy model, n = 2 and m = 5, therefore the total number of rules are (5 × 5) 25. Fuzzy rules with singleton values of UOMFs (5 input and 5 output MFs) and AOMFs (5 input and 9 output MFs) are shown in Table 2 and  Table 3.

C. RULE BLOCK
Two crisp values of SN-1 and SN-2 are accepted by the rule block. It elastically outputs singleton values (S 1 , S 2 , S 3 , and S 4 ) under the algorithm rules defined in the fuzzy system. Four rules are needed to obtain the individual singleton values for two input variables. After receiving the two crisp input values, the rule block divides the treatise into the sections. Each section contains 2 fuzzy variables and is responsible to trigger the rules and generates the resulting output.

D. DE-FUZZIFIER
The de-fuzzifier section controls the output of the system and thus has a significant impact on the accuracy of the control system. Usually, equal numbers of input MFs and output MFs are considered for designing a fuzzy control system. However, in our proposed aomfs approach, the accuracy is enhanced by (i) setting the output MFs to a higher number than input MFs and (ii) applying the proposed tuning algorithm on the first and last output MFs only. Fig. 5 shows the isosceles-triangles used to design the Mfs. The base of triangle is defined by the line y-z whereas point 'X' shows the original position of triangle peak. For aomfs case, the algorithm for tuning of the first and last isosceles-triangle is mentioned below VOLUME 8, 2020   Here  Table 4 where Fig. 6, 7, and 8 show that the graphical representation of the MFs distributions 5, 7, and 9 output MFs system respectively.
Graphical representation of our proposed nine distributed fuzzy MFs using the tuning algorithm associated with the output are shown in Fig. 9. Fig. 10 shows the results of 9 AOMFs after tuning with different values of ''b''.
The process of defuzzification provides a crisp value output after evaluating its inputs [17], [18]. In this scenario,   eight inputs are assigned to the de-fuzzifier. The inference engine generated four output values R 1 , R 2 , R 3 , and R 4 and rule block generated four output values S 1 , S 2 , S 3 , and S 4 . De-fuzzifier evaluates crisp standard output using center of average (COA) process as shown in Equation (1), here i = 1 to 4.
The MF of the output variable design contains five/seven/nine functions through a similar range of interpretation criteria. The de-fuzzifier consists of 4 multipliers for S i * R i , in which 2 adders are used, one for R i and the other for S i * R i , and only divider for equation (1). In the end, the defuzzifier generates an evaluation of crisp output [16].
For the performance evaluation of the proposed model, we used mean absolute error (MAE), mean absolute percentage error (MAPE), and root mean square error (RMSE) which are represented in Equations (2), (3), and (4): where 'K' indicates the No. of observations, 'M' is the MATLAB Simulated value, and 'D' is the Measured value.

IV. SIMULATION SETUP
MATLAB Simulink R2016b was used to develop the system, and MATLAB simulations were carried out to verify the cogency of the designed MFs. Different models of 2-Inputs 1-Output FCS for the linear system keeping five uniformly distributed input MFs fixed with different output MFs (5,7,9) had been simulated as given in Table 5. To find the best possible solution for error reduction and accuracy improvement VOLUME 8, 2020  for a fuzzy system, numerous scenarios were simulated using similar input values of both sensors in the complete range. Similarly, simulation of different models of 2-Inputs 1-Output FCS using different combinations of input and output MFs had been performed as given in Table 6. Uniformly distributed input and output MFs had been used in 2-Inputs 1-Output FCS and these adjacent MFs overlap each other by 50%. To determine the maximum error, similar inputs from the two sensors were used to simulate different scenarios over the entire range of all models. After that, using the proposed AOMFs approach, different models using the tuning algorithm had been simulated and the error had been reduced significantly.
To test the better accuracy of the proposed AOMFs approach, different models of 2-Inputs 1-Output FCS for the nonlinear system were simulated. Using identical input values to the full extent for all models, simulation of various cases was conducted. A comparison of these models with the proposed AOMFs approach is given in Table 7.
The same number of fuzzy rules and best suitable singleton values had been used for all the 2-Inputs 1-Output FCS using

input MFs & different output
MFs. The pattern should be the same for fuzzy rules and singleton values, after increasing or decreasing the input or output MFs.

V. IMPLEMENTATION
The proposed tuning algorithm is implemented through Atmel ATmega 328P microcontroller. The particular microcontroller is chosen due to its low price, availability on commercial basis and provision of built-in analog-to-digital conversion system.
Voltages in the range of 0 to 5 V are applied at the two analog input pins of the microcontroller to represent the 0% to 100% variation of input signals from TTL compatible outputs of sensors. The computed results of the proposed models are used to generate corresponding Pulse Width Modulated (PWM) signal at the output pin of the microcontroller. The generated PWM can then be used to control the actuation  rates (e.g. fan speed, motor speed etc.) in any control system. The authentic disparity of the output pulses in terms of their duty cycle is measured through a digital oscilloscope (Model: GDS-810C).
A fuzzy model with the proposed tuning algorithm has been implemented using the Arduino platform. This system strictly describes a fuzzy logic technique. Every class has the following functions: selection of section, identification of membership functions, fuzzification, generation of inference engine, defuzzification. Exception handling and conditional statements are also incorporated in the system.

VI. OUTCOMES AND DISCUSSION
In literature, usually, the FLC designs are based on uniformly distributed the equal number of input and output MFs (e.g. 3/3, 4/4, 5/5, and 7/7 input/output MFs) [12]. [14]. [19]- [22]. The experimental results, Fig. 12, show that such FLC designs are prone to large errors even if applied for the linear system. It is evident the relative error values of more than 10 % are produced in many instances which ultimately leads to higher values of RMSE, MAE, and MAPE as these FLC designs.
The relative errors can be reduced significantly by employing higher number of output MFs as compared to input MFs in FLC design. The experimental results of relative error for a 2-Inputs 1-Output FCS having uniformly distributed MFs are shown in Fig. 13. While keeping the 5 input MFs fixed, the output MFs are varied from 5 to 9. It can be seen that, in comparison to 5 output MFs, the relative errors in 9 output MFs case stays well below 10% throughout the input range except for the very low input values. The results for 5 output MFs case, however, produces relative errors of more than 10% in many instances throughout the range of input values. This indicates that using higher number of output MFs as compared to input MFs in FLC design, tuning of only first and/or last MFs is required. This is in contrast to the case of the same number of input/output MFs where the tuning of almost all MFs is needed to achieve better accuracy.
From Fig. 13, it can be seen that increasing the number of output MFs to 7 worsens the relative errors in comparison with 5/5 input/output MFs case in the first half of the input range. Analysis of a number of simulation results on different FLC designs reveals that the best results can be obtained if the number of output MFs are set according to the following criteria.
No. of Output MFs = 2 * (No. of Input MFs) − 1 (5) The authenticity of this relation is determined through simulations for 2-Inputs 1-Output models using up to 5 inputs MFs and up to 9 output MFs.
In order to further reduce the relative errors in the very low region, the AOMF approach is used for the case 5 input and 9 output MFs. The results, Fig. 14, show that even the AOMF approach alone is not able to reduce the errors. However, it can be seen that after applying the tuning algorithm, the relative errors are significantly reduced down to 10%.
A comparison of RMSE, MAE, and MAPE values of 2-Inputs 1-Output models of the linear system is given in Table 5. It can be seen that our proposed approach using AOMFs (with tuning) provides the most accurate results determined either in terms of maximum relative error (%), RMSE, MAE, and MAPE.
The proposed approach of FLC design using AOMFs along with the tuning algorithm is also implemented on designs with 3/5, 4/7 input/output MFs. Fig. 15 shows the experimental results of the two FLC designs. It can be seen that the proposed tuning algorithm can adequately reduce the maximum relative error. The results show not only a significant decrease VOLUME 8, 2020   in the maximum relative error (%) but also an improvement in the values of RMSE, MAE, and MAPE as shown in Table  6. The proposed approach of FLC design, therefore, offers much better system accuracy than approaches.
The efficacy of our proposed approach to design accurate FLC with monotonic and nonlinear output is also determined. Fig. 16 shows the experimental results of 2-Inputs 1-Output FCS with uniformly distributed different numbers of output  MFs while keeping the 5 input MFs fixed. It is evident that, even in this scenario, increment in output MFs reduces relative errors. The best results (<10% maximum relative error) are, however, obtained for the case of 5/9 input/output MFs after applying the tuning algorithm.
Similarly, the maximum relative error in 2-Inputs 1-Output FCS with 3 or 4 input MFs and 5 or 7 output MFs respectively reduces significantly, down to < 10%, after tuning of only first and last output MFs as shown in Fig. 17. The comparative view of errors shown in Table 7 clearly shows the proposed approach of AOMFs (with tuning) shows much better performance even in the case of nonlinear output values.
Furthermore, the proposed system provides better accuracy and stability not available in any FCS model in the literature. Moreover, we did not compare the proposed model with other models available in the literature according to the authors' knowledge, there is no existing FCS model that has successfully implemented AOMFs (with tuning) in existing FCS model and which provides the best possible combination of input and output MFs to improve system's accuracy. Using the best combination of input and output MFs with the tuning of first and last MF can improve the system's accuracy better than other models available in literature using ANN, GA, etc.

VII. CONCLUSION AND FUTURE WORK
The main purpose of this research is to find the best possible relationship that exists between the number of input and output MFs and the stability of the controller, i.e. the speed required for the controller to reach a steady state. This helps engineers in the robotics and control fields gain insight into the key factors required to design a stable system. The key points of our research are summarized as 1. Our proposed approach is based on the Mamdani model which is easy to implement with much less computational burden. In literature, most of the authors use ANN and GA to optimize MFs in FCS. In this paper, we reduced RMSE of 2-Inputs 1-Output FCS by almost 75.3% and also, reduced MAPE, and MAE by 73.9%, and 77.3% using simple Mamdani model. 2. In general, the authors simulated some observations and finalized the results. In our proposed approach model, we have simulated at least 51 observations in the complete range of the treatise to find out the best solution. If we reduce the no. of observations (36) then our results will be far better than this (RMSE = 0.78405, MAE = 0.43942, MAPE = 0.87843). 3. Keeping the same number of input MFs will produce the same number of rules and just increasing the output MFs (No. of output MFs = 2 * No. of Input MFs -1) with the tuning of (first and last) MFs provides us much better system's accuracy and reduce the huge amount of errors. 4. Model outcomes show a substantial improvement by studying the effects of the AOMFs and the efficiency of the FCS, it was observed that the proposed AOMFs approach provides the best FCS from the accuracy metrics. Finally, it can be inferred that the use of the AOMFs approach is more effective for the performance metrics of the controller. The simulation results are in good agreement with the measured PWM. Therefore, the analysis of the number of output MFs and its distribution on FLC in this paper can be considered to be effective. In particular, using the proposed AOMFs approach, the control accuracy required in the (≤± 5%) range has been successfully achieved, thus verifying the effectiveness of the designed MFs. Therefore, the proposed approach can be used as a system design tool for FLC applications in any other industrial field.
In future work, we should like to implement our proposed approach on more than one output FCS and we also plan to implement the proposed approach in more than two inputs (3 or 4) and one output FCS to improve the accuracy of the system.