Introduction
Today, we are immersed in an increasingly digitized society, numerous applications and technological devices have emerged from applications of artificial intelligence. The development of electronics and household appliances that use fuzzy logic as a decision-making method has increased steadily. Numerous technological advances have been benefited from the development of systems based on fuzzy logic [1]-[3] The learning of various branches of artificial intelligence such as fuzzy logic and neural networks, are generally taught in optional specialization courses in careers related to mechatronics. Theorical sessions and laboratory experiments provide a hands-on approach to developing manual skills and abilities. Through laboratory experiments it is possible to verify theoretical results, make comparisons and contrast them, furthermore where is appropriate, make some adjustments to the models based on the experimental results.
Related work
The exploration of the RC circuit has been used to address fundamental concepts of physics related to electric current, resistance and capacitance with various approaches [4]. In this work it has been proposed to model the response of a resistor-capacitor series circuit, when a unit step input of 5 volts of direct current is connected. The use of fuzzy logic is encouraged for this purpose, implemented through low-cost hardware and open software elements such as Arduino [5] and Scilab for system identification. In the current moments of contingency there is a growing need to transfer educational and academic environments to the home, where engineering students take virtual sessions. It is of great importance the development of laboratory practices in the engineering area [6], they can be carried out using available and low-cost hardware elements, as well as the use of free software that facilitates the processing and interpretation of data.
This engineering experiment could be adapted for students to introduce and gain an understanding of the fuzzy logic modeling process, through a real-life experiment using open hardware instrumentation and open source software. This situation could reduce the inconveniences observed during the transfer of face-to-face engineering education into educational centers, to home confined spaces of virtual distance education.
System identification using the Arduino platform
The modeling of response to a 5 volt step input of a circuit formed by a resistor (100 kΩ) and a capacitor (100 µF) using fuzzy logic start with the experimental identification of the system. The objective is to know the behavior and evolution of the voltage at capacitor terminal as a variable output in time. An Arduino Nano based board has been used for the experiment. The microcontroller board has low cost and it is possible to acquire it with some ease in establishments dedicated to the commercialization of electronic components. Through analog pin A0 it is possible to measure the analog voltage of the capacitor over time. The connection diagram for the physical implementation can be observed in Figure 1.
At the beginning of the test, it must be ensured that the capacitor is completely discharged. To ensure that it starts from 0 volts. The capacitor terminals can be connected to the same resistance for a period of 2 minutes without the power source, in order to ensure the initial conditions of the experiment. The data transfer between the Arduino Nano based board and a personal computer is carried out between the Serial monitor enabled by the program, as shown in Figure 2.
The implementation of the program in Arduino language, performs a data sampling for the analog signal using a time delay 1000 ms, that is, an analog voltage reading is made about one second. Considering that the circuit consists of a 100 kΩ resistor and a 100 µF capacitor, it is observed that the constant of the system is reached around 10 seconds, that is, 63% of the expected final value. The circuit presented is simple, the values of the resistance and the capacitor can be modified and adapted for other educational purposes, where it is necessary to increase or decrease the establishment time of the transient response of the circuit.
The use of the board based on Arduino nano has allowed to obtain experimental results that allow to create a model based on fuzzy logic. The main purpose is estimating the response of the circuit over time, using linguistic variables in an approximate decision-making system. The analog voltage between the capacitor terminals is read by the analogRead function through the A0 physical pin of the board with microcontroller. The analog reading and digital conversion, allows to obtain voltages values between 0 and 5 volts. It is noted that the microcontroller board have an analog-to-digital converter with 10 bit resolution. The experimental results obtained from the reading of analog voltages over time, corresponding to the evolution of the voltage across the capacitor terminals over time, are shown in Table 1. The data were obtained directly from the interface of the serial monitor with the that found in the Arduino program.
The data obtained experimentally represent the evolution in time of the capacitor charge, from when the capacitor is totally discharged, until reaching values close to the total charge, that is, 5 volts.
IV. Fuzzy Logic modelling through Scilab
The 11 data points obtained from the identification of the system, were used to create a Mamdani-type fuzzy logic system in Scilab [7], through the fuzzy logic toolbox. The system consists of a single "Time" input and a single "Voltage" output. The input variable consists of 11 triangular membership functions distributed in the interval that represents the range from -0.1 to 55 seconds as shown in Figure 3. This range is known as the universe of the discourse of the variable.
The highest point of each of the triangles represents the highest degree of membership of each function, that is, the core and corresponds to each of the points obtained in the identification of the experimental system through the use of the Arduino Nano board, used as a low cost data acquisition system [8]. The 3 parameters of each proposed triangular functions are: the lower limit, core and upper limit, they can be consulted in Table 2.
For the case of the output variable, 11 triangular membership functions are proposed, which were distributed throughout the universe of the variable's discourse, from -0.1 to 5.01 volts, as can be seen in Figure 4. For the case of selecting the upper limit of each membership function, it was proposed that it must coincide with the core value of the following membership function.
The Figure 2 and Figure 4 were created using Open Office Calc for graphical presentation of the data. It is observed that each core of the outgoing membership functions correspond to the point values obtained experimentally from the identification of the system. The distribution of the lower and upper limits of each of the membership functions, for the output variable was made in such a way that the lower limit of the membership function coincides with the core of the membership function. The individual parameters of each of the membership functions, which correspond to the lower, core and upper limits, can be seen in Table 3.
It is noted that there is a bigger number of membership functions located in the right half of the universe of discourse of the output variable, this situation corresponds to that experimentally, the data obtained for the last time interval are also closer between them, at the end of the time interval. This situation refers to the exponential behavior that first order systems present when a unit step input is applied. Once the input and output variables of the fuzzy system have been defined, a rule base is required for relating each of the inputs with each of the outputs. In this sense, the rule base allows taking a specific action according to a specific input. For this work, 11 rules have been proposed that assign each of the inputs to each of the outputs as can be seen in the Table 4.
With the definition of the membership functions of both the input variable and the output variable, the set of rules that relate each of the inputs to each of the outputs, we proceed to construct the fuzzy system using the Mamdani type Scilab Toolbox. The implication method selected was the Minimum and the aggregation method was the maximum. The defuzzification method was the centroid, which allows obtaining a numerical value as the output of the system.
Results and Discusion
When implementing the fuzzy system in Scilab and using the surface view function of the fuzzy logic toolbox, the output response of the system is computed, that is, the relationships that exist between the input and the output of the system. The fuzzy logic modeling, generated from the experimental identification of the system with the microcontroller board, shows that the results obtained with the fuzzy system implemented in Scilab are approximate; the analytical solution is close to the experimental data obtained by mean of the microcontroller board, and also close to the values obtained with the fuzzy logic approach proposed, as shown in Figure 5.
It is worth highlighting the approximation obtained to model physical systems implementing a fuzzy logic system. Different parameters can be modified to obtain a closer tuning in the modeling, such as membership functions definitions for both, the input and output. The implication and aggregation methods can be used, as well as different defuzzification methods. These characteristics make fuzzy logic a very versatile modeling tool that can be adapted for the analysis of more complex systems with multiple inputs and / or multiple outputs.
Conclusions
The implementation of a Mamdani type fuzzy system has been described, to model the response in time to a unit step of 5 volts in a system composed of a resistor and a capacitor connected in series. Low cost and easily acquired hardware elements are used, as well as free software for its implementation through the Scilab tool. This combination favors the implementation of this type of systems for the analysis of the behavior of physical systems and their evolution in time before different physical conditions. It is intended to promote the understanding of fundamental concepts of fuzzy logic with a practical approach that combines the manipulation of hardware elements as well as free software. The work presented could be adapted as an educational tool that allows engineering students and practitioners to develop skills and abilities for the construction of data acquisition systems. This process is fundamental for the identification of systems and the consequent development of control systems in engineering. An emphasis is placed on the use of accessible and low cost devices and software. This situation can be adapted to circumstances where distance education is transferred to individual virtual environments such as the current situation experienced by virus pandemic.