**2.1 Fuzzy controller design**

The design of a fuzzy controller of the Mamdani type is carried out, which is made up of the fuzzification, inference, aggregation, and defuzzification stages. On the other hand, a fuzzy controller can use more than one input variable and can determine more than one output variable; however, a fuzzy controller needs at least two input variables and one output variable to function properly. If the number of input and output variables of the fuzzy controller is increased, then the complexity of the fuzzy controller implementation will increase. **Figure 2** shows the structure of a fuzzy controller of the Mamdani type. The design and implementation of a fuzzy controller begins with the definition of the controlled variable of the process, for example,

**Figure 2.** *Structure of a fuzzy controller of the Mamdani type.*

temperature, humidity, pressure, pH, among others. Subsequently, the input and output variables of the controller must be defined. For this, it must be considered that the input variables of the fuzzy controller are used to measure the state or condition of the process, and the output variable of the fuzzy controller is the control action, which will be used to adjust the controlled variable. Also, a universe of discourse must be specified for each of the controller variable, which can be defined as the range of values, where a specific value of the input or output variables can be found or located. In other words, a universe of discourse is made up of the values that are between the minimum and maximum values of a variable. On the other hand, a series of linguistic values (low, high, good, bad, etc.) must be defined, which describe the state or condition of the input and output variables of the controller. Subsequently, within the universes of discourse of the controller variables, fuzzy sets must be defined, which must be labeled with the name of the linguistic values. Also, the type of fuzzy set that will be used to implement the controller must be defined. For this, the computational load and the necessary programming elements must be considered. Finally, these elements should be considered as the initial parameters of the fuzzy controller [20].

The fuzzy controller should be used for a specific situation since this is the correct way to show how to implement the fuzzy controller. Therefore, the fuzzy controller is used to determine the tip of a food establishment, since this application is the simplest to understand the operation of the fuzzy controller. This application will allow to characterize the controller; that is, this application allows defining the input and output variables of the controller, the length of the universes of discourse, type of fuzzy sets, dimensions of fuzzy sets, among other things. In this case, the value of the tip depends on the quality of the food and the service of the food establishment. Therefore, a signal defined as "food" and a signal defined as "service" are used as controller input variables, and a signal defined as "tip" is used as the controller output variable. A universe of discourse from 0 to 100 was used for the input variables since food and service can be evaluated with a score of 0 to 100. A universe of discussion from 0 to 120 was used for the output variable, which represents the amount of money from 0 to \$120. However, the minimum value of the tip will be \$20, and the maximum value of the tip will be \$100.
