Approximation Possibilities of Fuzzy Control Surfaces for Purpose of Implementation into Microcontrollers

: The main contribution of the paper is the simpliﬁcation of the computational process of fuzzy control of a mobile robot controlled by a microcontroller. We present a way to implement this control method with a reduced computation time of control actions and memory demand. Our way to accomplish this, was to replace the fuzzy controller with the approximation of its resulting control surfaces. In the paper, we use the previously presented approximation by the table and describe other methods of approximation of the control area through polynomial and exponential function. We tested all approximation methods in simulations and with a real mobile robot. Based on the measured trajectory of the EN20 mobile robot, we found that approximation through the table is the most accurate in terms of the fuzzy surface but delivers noticeable oscillations of mobile robot control in real conditions. Polynomial and exponential functions fuzzy surface approximations were less accurate than the table, but provide smoother control based on robot trajectories and are much more appropriate in terms of microcontroller implementation due to lower demand on memory.


Introduction
The potential for using autonomous mobile robotics in practice is constantly increasing and demand for autonomous systems continues. Complex systems require intelligent control algorithms to perform precisely. One of such algorithms is fuzzy control [1]. The theory of fuzzy sets has revolutionized many applications unsolvable by traditional control theory [2]. This is one of the reasons for adopting fuzzy control in the field of unstructured, dynamically changing environments [3]. Fuzzy sets theory was practically applied in the field of control by Mamdani and Takagi-Sugeno and later further developed by Karnik-Mendel and Wu-Mendel. However, these approaches are due to calculation complexity very demanding on hardware, in particular for control problems [4]. The first advantage of the fuzzy controller is the ability to control simultaneously multiple variables as was demonstrated in the design of omnidirectional mobile robot navigation [5]. The second advantage, specific to fuzzy control, is that it is not required to know the mathematical model of the controlled system [6,7]. This can be problematic with most of the linearizationbased and algebraic control algorithms when the dynamic system cannot be described for some reason. Therefore, in those cases, an appropriate choice is to use control methods capable of dealing with uncertainties, such as fuzzy logic [1].
In mobile robotics, the most desired control tasks are trajectory tracking, path following, or moving to a specific position. Many authors developed trajectory tracking algorithms based on the dynamic properties of controlled systems [8,9]. Some of them also consider control action constraints for the actuators [10,11]. But from the implementation point of view, these algorithms are very dependent on the exact mathematical description of the system. Therefore, it is more appropriate to explore and improve the possibilities of fuzzy control for wider use. Numerous researchers used fuzzy logic to investigate its behavior and usability in the field of controlling autonomous mobile robots. Based on the results of [12], fuzzy logic controllers showed an ability to process data from multiple inputs and to lead robots to their destination. Authors Faisal et al. [13] used a synthesis of two fuzzy controllers for mobile robot navigation in the warehouse. A recent paper by Štefek et al. [14] showed the usage of genetic algorithms for fuzzy controller optimization. The optimized controller outperformed all compared controllers. The control quality is mainly influenced by the number of fuzzy membership functions and fuzzy inference rules [15]. Furthermore, with an appropriate selection of fuzzy membership functions shapes and rules formulation, better control results can be obtained [16]. On the other hand, with an increasing number of rules, memory allocation becomes the most limiting factor and execution time is also increased [17]. Given that, computers, programmable logic controllers, or digital signal processors are used to providing fast sampling periods. Their disadvantage is mainly high price and higher power consumption. Therefore, it is suitable to use a microcontroller as a central control unit of a system like a mobile robot when these factors need to be considered.
In numerous presented applications fuzzy control is used with microcontrollers. Work [18] presented temperature and humidity control, in work [19] fuzzy control was used for pressure control, and also for electric motor control in [20]. Papers by [21,22] presented control of small mobile robots. In all referred papers, results showed that microcontrollers are suitable for implementation purposes of fuzzy logic techniques when the fuzzy controller has not too many fuzzy inference rules and sample times in milliseconds are not required. This is supported by [18]. The main limitations of microcontrollers are limited computing power, memory, and still limited possibilities for direct fuzzy control implementation for commercially available microcontrollers. This means that the possibilities of implementing fuzzy control into microcontrollers are still limited due to high requirements on computing power required by fuzzy logic algorithms [23]. For this reason, our work is devoted to additional possibilities of approximation of fuzzy control surfaces into the control system of the mobile robot. Another presented approach by Sekaj [24] has proposed a method for defuzzification approximation, similar to fuzzy logic but without explicitly using fuzzy logic. The most recent paper on this topic presented a new type of fuzzy membership function that provides a computationally efficient defuzzification process [25]. Work [26] showed an interesting solution to cope with the slow execution time of the controller. An approximation of fuzzy control surfaces through lookup tables was used.
Inspired by this approach to directly implement fuzzy control surfaces, in this paper we present a way to use polynomial and exponential functions for fuzzy control surface approximation. Moreover, we compare these two methods to the table approximation. The control accuracy of the approximations will be analyzed using both simulations of a mathematical model of a mobile robot and the real mobile robot EN20. This paper is organized as follows. In Section 2 materials and methods are presented. A comparison of the proposed fuzzy controller along with created approximation is addressed in Section 3. The discussion and conclusions are given in Sections 4 and 5.

Differential Drive Kinematics
Differential drive chassis is characterized by two independently driven wheels located on the common axis and often the third supportive wheel. Distance between the driven wheels is called track width, L as shown in Figure 1. The movement can be described as a movement along the arcs around the instant center of rotation (ICR) with the radius of R. From Figure 1, the simplest will be to calculate the position of the chassis relative to the P point, which lies in the center of the wheel axis. Angular velocity of the robot ωP is calculated from the difference in the speeds of the left and right wheel from (1) [27]: where L is track width, VP and VL is peripheral velocity of right VP and left VL wheels are given in (2) [27]: where R is radius to the instant center of rotation. To determine tangential speed VTP of the chassis at the point P from the peripheral velocities of wheels we simply calculate their mean value (3) [27]: From the VP and VL it is possible to determine the position of differential drive chassis in the Cartesian coordinate system based on the previous values as the system of difference equations to be used in discrete system (4): where x(k), y(k) is current sample of the x and y mobile robot coordinates, x(k-1) and y(k-1) is the previous sample of the x and y mobile robot coordinates, Θ(k) is current angle of the robot, Θ(k-1) is the previous angle of the robot, VP(k) and VL(k) is current sample of the right and left wheel peripheral velocity and T is the sampling period [27].

Control Task
Based on the distance of the mobile robot from the target position D and the angle of deflection of the mobile robot from the target position of the mobile robot δ, the task of a fuzzy controller is to control the speed of the right and left wheel of the EN20 mobile robot Angular velocity of the robot ω P is calculated from the difference in the speeds of the left and right wheel from (1) [27]: where L is track width, V P and V L is peripheral velocity of right V P and left V L wheels are given in (2) [27]: where R is radius to the instant center of rotation. To determine tangential speed V TP of the chassis at the point P from the peripheral velocities of wheels we simply calculate their mean value (3) [27]: From the V P and V L it is possible to determine the position of differential drive chassis in the Cartesian coordinate system based on the previous values as the system of difference equations to be used in discrete system (4): where x(k), y(k) is current sample of the x and y mobile robot coordinates, x(k − 1) and y(k − 1) is the previous sample of the x and y mobile robot coordinates, Θ(k) is current angle of the robot, Θ(k − 1) is the previous angle of the robot, V P (k) and V L (k) is current sample of the right and left wheel peripheral velocity and T is the sampling period [27].

Control Task
Based on the distance of the mobile robot from the target position D and the angle of deflection of the mobile robot from the target position of the mobile robot δ, the task of a fuzzy controller is to control the speed of the right and left wheel of the EN20 mobile robot Processes 2021, 9, 1602 4 of 20 so that the mobile robot reaches its target position in the shortest possible time and with as little deviation from the direct direction as possible. The calculation of the distance of mobile robot from the target position D is given by (5) [27]: where x TARGET , y TARGET is position of target point, x and y are current coordinates of the mobile robot. Deflection angle is derived from the difference between robot's angle and the desired angle to the target point in (6) [27]: where Θ TARGET is desired angle to the target point and δ is deflection angle of mobile robot from the target. These input quantities of our fuzzy controller are for better understanding shown in Figure 2.
Processes 2021, 9, x FOR PEER REVIEW 4 of 20 so that the mobile robot reaches its target position in the shortest possible time and with as little deviation from the direct direction as possible. The calculation of the distance of mobile robot from the target position D is given by (5) [27]: where xTARGET, yTARGET is position of target point, x and y are current coordinates of the mobile robot. Deflection angle is derived from the difference between robot's angle and the desired angle to the target point in (6) [27]: where ΘTARGET is desired angle to the target point and δ is deflection angle of mobile robot from the target. These input quantities of our fuzzy controller are for better understanding shown in Figure 2. Furthermore, if we in (5,6) replace the constant coordinate yTARGET by function yTARGET = f(x), where f(x) represents trajectory function, then the robot can move along the defined trajectory by this function. This solution is limited to trajectories, where for each x-coordinate is only one y-coordinate.

Control Quality Criterions
For determining the deviation of the robot from straight path to the target position we use general control quality criterions-absolute and quadratic error control area. Absolute error control area IAE in (7) In our case the control error e(t) is the actual deviation of the mobile robot from the line connecting the starting and target point. The aim is to achieve the smallest error control areas IAE and ISE. The closer they are to zero, the more the ideal trajectory is tracked. Error area is area bordered by measured trajectory of the robot and line between start and Furthermore, if we in (5,6) replace the constant coordinate y TARGET by function y TARGET = f (x), where f (x) represents trajectory function, then the robot can move along the defined trajectory by this function. This solution is limited to trajectories, where for each x-coordinate is only one y-coordinate.

Control Quality Criterions
For determining the deviation of the robot from straight path to the target position we use general control quality criterions-absolute and quadratic error control area. Absolute error control area I AE in (7) is suitable for oscillating process variable error values and property of squared error control area I SE in (8) is accentuation of large error values and neglecting small error values.
In our case the control error e(t) is the actual deviation of the mobile robot from the line connecting the starting and target point. The aim is to achieve the smallest error control areas I AE and I SE . The closer they are to zero, the more the ideal trajectory is tracked. Error Processes 2021, 9,1602 5 of 20 area is area bordered by measured trajectory of the robot and line between start and the target points. Another important criterion is control time t reg defined as time interval from the first change of control variable to the setpoint reached within a defined tolerance [23]. In this work it represents time during the mobile robot reaches its target position.

Approximation of Surfaces
The standard way to describe an area is through a table or through an equation. When the area is approximated through a table, certain values are selected from the area and arranged in a table. This method is simple but ineffective in terms of implementation into the microcontroller due to its limited memory. Therefore, it is much more effective to describe the area with an equation. We can describe the area with an equation in an implicit and explicit shape. An equation in the form F(x, y, z) = 0 is called implicit equation of area if two assumptions are met: the coordinates x, y, z from each point Q = [x, y, z] which lies on the area, conform to the equation, 2.
each Q point on the x, y, z of which Q = [x, y, z] from which the coordinates conform to the equation, represents a point of area [28].
A special case of the equation is an equation in the form z = f (x, y). If this equation is an equation of a specific area, we call it the explicit equation of the area [28]. Equation (9) describes the general form of the explicit equation of surface in polynomial form where x, y is the independent variable area, z is the dependent area variable, p ij are the coefficients of the polynomial, m is the highest power of x, n is the highest power of y.
If we replace variable x with D, y with δ and create multiples of the maximum speed of the right engine k wR and left engine k wL , we get (10).
The largest influence on control quality of mathematical model has powers m, n, coefficients p ij and p i , q i which are introduced in exponential function approximation method.

EN20 Mobile Robot
EN20 mobile robot is based on differential steering chassis and can be operated wirelessly. The principal scheme of this robot is shown in Figure 3. Communication with the drive modules, incremental sensors, power monitor with control module runs according to the SPI communication standard in a four-wire connection with a data flow rate of 1 Mbps. Data received through SPI. The control unit is based on C8051F340 microcontroller which also secures communication with PC for data transfer. The microcontroller features an on-board USB 2.0 function controller with an integrated transceiver and on-chip clock recovery. It includes a core with 50 MHz performance along with 64 kB Flash, 4.25 kB RAM. On-chip analog features include a 10-bit, 20ch A-D converter, voltage reference, an internal oscillator, two comparators, and a temperature sensor.
The controller receives information required by fuzzy controller and subsequently calculates control actions for each driving wheel. The mentioned microcontroller combines the communication standards UART and SPI. UART is a device exclusively designated for communication with the control computer via the full-duplex wireless protocol ZigBee. The second type of communication is SPI, where the module is set as "MASTER" in a 4-wire connection with the possibility of connecting eight SPI "SLAVE" modules [29]. Communication with PC is solved through a virtual serial port via USB (controller CP2102). BLY171S 24V-4000 BLDC motors are controlled by dedicated drivers designed specifically for this robot to drive the mobile robot considering effects described in [30]. Velocity measurement of drive wheels of the robot is provided by optical incremental sensors TP 6.35 1024 BZ TTL with a resolution of 1024 pulses per revolution.

Identification of EN20 Robot Dynamics
The dynamic model of the robot was obtained from the transfer function of robot's response on step input signal. The obtained dynamics is compared to the real measurement in Figure 4. The transfer function of EN20 robot (11) we used in all simulations. Communication with the drive modules, incremental sensors, power monitor with control module runs according to the SPI communication standard in a four-wire connection with a data flow rate of 1 Mbps. Data received through SPI. The control unit is based on C8051F340 microcontroller which also secures communication with PC for data transfer. The microcontroller features an on-board USB 2.0 function controller with an integrated transceiver and on-chip clock recovery. It includes a core with 50 MHz performance along with 64 kB Flash, 4.25 kB RAM. On-chip analog features include a 10-bit, 20-ch A-D converter, voltage reference, an internal oscillator, two comparators, and a temperature sensor.
The controller receives information required by fuzzy controller and subsequently calculates control actions for each driving wheel. The mentioned microcontroller combines the communication standards UART and SPI. UART is a device exclusively designated for communication with the control computer via the full-duplex wireless protocol ZigBee. The second type of communication is SPI, where the module is set as "MASTER" in a 4-wire connection with the possibility of connecting eight SPI "SLAVE" modules [29]. Communication with PC is solved through a virtual serial port via USB (controller CP2102). BLY171S 24V-4000 BLDC motors are controlled by dedicated drivers designed specifically for this robot to drive the mobile robot considering effects described in [30]. Velocity measurement of drive wheels of the robot is provided by optical incremental sensors TP 6.35 1024 BZ TTL with a resolution of 1024 pulses per revolution.

Identification of EN20 Robot Dynamics
The dynamic model of the robot was obtained from the transfer function of robot's response on step input signal. The obtained dynamics is compared to the real measurement in Figure 4. The transfer function of EN20 robot (11) we used in all simulations.

Fuzzy Controller
As the basis for all approximation methods, we used the control surfaces of the fuzzy controller with 49 inference rules with triangular functions of the respective different linguistic values, as seen in Table 1 and their membership functions in Figure 5 with the centroid defuzzification method. This fuzzy controller controls the mobile robot. Inputs to the controller are distance to the target position D and deviation from the target position δ. These output values are calculated based on measurements from the EN20′s right and left incremental sensors. From them, we calculate distances travelled by each wheel since the start. Using the differential chassis kinematics model, we transform these distances to actual robot x, y coordinates and the robot's angle Θ, and subsequently the inputs to the fuzzy controller from (5), (6) are calculated. Outputs represent multiples (0 to 1) of maximum speed of right kwR and left motor kwL. By using 12 V supply voltage, the maximum speed is approximately 2000 rpm.

Fuzzy Controller
As the basis for all approximation methods, we used the control surfaces of the fuzzy controller with 49 inference rules with triangular functions of the respective different linguistic values, as seen in Table 1 and their membership functions in Figure 5 with the centroid defuzzification method. This fuzzy controller controls the mobile robot. Inputs to the controller are distance to the target position D and deviation from the target position δ. These output values are calculated based on measurements from the EN20 s right and left incremental sensors. From them, we calculate distances travelled by each wheel since the start. Using the differential chassis kinematics model, we transform these distances to actual robot x, y coordinates and the robot's angle Θ, and subsequently the inputs to the fuzzy controller from (5), (6) are calculated. Outputs represent multiples (0 to 1) of maximum speed of right k wR and left motor k wL . By using 12 V supply voltage, the maximum speed is approximately 2000 rpm. Table 1. Input and output linguistic values for D, δ, k wR , and k wL of fuzzy controller with 49 inference rules.

Distance to Target Position D (m)
Deflection Angle from the Target Position δ ( • )

Multiples of Maximum Right and Left
Motor Speeds k wR , k wL Z-zero distance Z-zero angle Z-zero multiple VS-very small distance PS-positive small angle VS-very small multiple S-small distance PM-positive middle angle S-small multiple M-middle distance PL-positive large angle M-middle multiple L-large distance NS-negative small angle L-large multiple VL-very large distance NM-negative middle angle VL-very large multiple C-colossal distance NL-negative large angle C-colossal multiple Values of these controlled variables are fuzzified by triangular functions. When the deflection angle is beyond the range of ±90 • , then the fuzzy controller is overridden, and the robot rotates clockwise to get back within the range. The range of ±90 • was chosen to reduce number of membership functions for δ to focus more on controller's precision at smaller angles. If the distance of the robot from the target position is larger than 2 m, the input value is reduced to 2 m. The decision rules are defined as a set of function pertinences for individual terms of the output linguistic variables that must be assigned to a sharp value of the control action within the allowed range [14,31].
The choice of mentioned fuzzy controller parameters was first tested in simulations. The effect of improvement of fuzzy controller control quality decreased with an increasing number of rules as was presented by [15]. The same trend with the increasing number of rules had inference type. With fewer rules, the resulting control surfaces differed more. In terms of membership function types, we compared the four most common shapes. Best results were achieved with triangular shapes, as shown in Figure 6. input value is reduced to 2 m. The decision rules are defined as a set of function pertinences for individual terms of the output linguistic variables that must be assigned to a sharp value of the control action within the allowed range [14,31]. The choice of mentioned fuzzy controller parameters was first tested in simulations. The effect of improvement of fuzzy controller control quality decreased with an increasing number of rules as was presented by [15]. The same trend with the increasing number of rules had inference type. With fewer rules, the resulting control surfaces differed more. In terms of membership function types, we compared the four most common shapes. Best results were achieved with triangular shapes, as shown in Figure 6.   The choice of mentioned fuzzy controller parameters was first tested in simulations. The effect of improvement of fuzzy controller control quality decreased with an increasing number of rules as was presented by [15]. The same trend with the increasing number of rules had inference type. With fewer rules, the resulting control surfaces differed more. In terms of membership function types, we compared the four most common shapes. Best results were achieved with triangular shapes, as shown in Figure 6.  Resulting control surfaces of created controller, which are the subject of following approximations, as illustrated in in Figure 7. Resulting control surfaces of created controller, which are the subject of following approximations, as illustrated in in Figure 7.

Approximation of Fuzzy Control Surfaces Using a Table
The most important step in this approximation method is to create custom tables with multiples of kwR and kwL based on the proposed fuzzy controller. For both tables it is most important to define the step of incrementing the distance of the mobile robot from the target position kD and the step of incrementing the angle of deflection of the mobile robot from the target position kδ.
Step values affect the number of rows and columns in the table and thus the amount of data that needs to be stored. The number of rows nr and columns ns in a table can be calculated using (12) where

Approximation of Fuzzy Control Surfaces Using a Table
The most important step in this approximation method is to create custom tables with multiples of k wR and k wL based on the proposed fuzzy controller. For both tables it is most important to define the step of incrementing the distance of the mobile robot from the target position k D and the step of incrementing the angle of deflection of the mobile robot from the target position k δ .
Step values affect the number of rows and columns in the table and thus the amount of data that needs to be stored. The number of rows n r and columns n s in a table can be calculated using (12): where D max is the upper bound of mobile robot's distance from the target position, D min is the lower bound of mobile robot's distance from the target position, δ max is the upper bound of mobile robot's deflection angle from the target position, and δ min is the lower bound of mobile robot's deflection angle from the target position. Another important step is to determine the corresponding table cell through row i and column j of the table where the value of multiples of the maximum motor speed from fuzzy control surfaces is stored using (13), based on the mobile robot's D and δ values. The function round rounds decimal value of i or j to the nearest integer.
For our purpose we chose Dmax = 2, Dmin = 0, δmax = 90, δmin = −90. From evaluating multiple combinations of kD and kδ we picked, based on both control quality and memory occupancy of tables for each motor, values kD = 0.5 m and kδ = 1°. The resulting surfaces of multiples of the maximum speed of the right and the left motor which approximate the fuzzy control surfaces from Figure 7 are shown in Figure 8.

Approximation of Fuzzy Control Surfaces through a Polynomial
When approximating fuzzy control surfaces via polynomial, we proceed from (10). Polynomials were obtained using surface fitting function in Matlab software. From testing multiple combinations of m and n values, we found that the best average control time is achieved by approximating the fuzzy control surfaces by polynomial with power of m = 1 and n = 5. However, in terms of average absolute and quadratic error area, the optimal approximation is by polynomial with power of m = 5 and n = 5. We inclined to approximate the control surfaces by means of a polynomial with powers m = 1 and n = 5 in (14) because of the smaller average control time, which will ensure that the mathematical model of the mobile robot reaches its destination earlier.

Approximation of Fuzzy Control Surfaces through a Polynomial
When approximating fuzzy control surfaces via polynomial, we proceed from (10). Polynomials were obtained using surface fitting function in Matlab software. From testing multiple combinations of m and n values, we found that the best average control time is achieved by approximating the fuzzy control surfaces by polynomial with power of m = 1 and n = 5. However, in terms of average absolute and quadratic error area, the optimal approximation is by polynomial with power of m = 5 and n = 5. We inclined to approximate the control surfaces by means of a polynomial with powers m = 1 and n = 5 in (14) because of the smaller average control time, which will ensure that the mathematical model of the mobile robot reaches its destination earlier.
Graphical representation of the polynomials from (14) is shown in Figure 9.

Approximation of Fuzzy Control Surfaces through Exponential Function
After closer analysis of the fuzzy control surfaces, we noticed that in a cross-section along the δ axis, the dependence of multiples of the maximum motor speed on δ resembles a transfer function of first order system ( Figure 10).

Approximation of Fuzzy Control Surfaces through Exponential Function
After closer analysis of the fuzzy control surfaces, we noticed that in a cross-section along the δ axis, the dependence of multiples of the maximum motor speed on δ resembles a transfer function of first order system ( Figure 10). Graphical representation of the polynomials from (14) is shown in Figure 9.

Approximation of Fuzzy Control Surfaces through Exponential Function
After closer analysis of the fuzzy control surfaces, we noticed that in a cross-section along the δ axis, the dependence of multiples of the maximum motor speed on δ resembles a transfer function of first order system ( Figure 10).  In time domain it is defined by function (15) [32].
where y(t) is function output, K is gain, T is time constant, and D is time delay. The dependence in Figure 10 with use of (15) can be approximated by a derived exponential function (16). Argument of the transfer function is now angle of deflection δ, T is replaced with rise angle δ n , D is replaced with angle of displacement δ 0 , and K is replaced with steady-state value of the cross-section course K P . Since the control surfaces of the fuzzy controller are symmetrical, in determining the exponential equations, we picked the control surface of the left motor.
The imperfection of this approximation is that for various fuzzy control area crosssections along the D axis, we receive different steady-state values K P and the values of δ n as shown in Figure 7. In our case values of K P are values of k wL at the minimum angle with course shown in Figure 11.
In time domain it is defined by function (15) [32].
where y(t) is function output, K is gain, T is time constant, and D is time delay. The dependence in Figure 10 with use of (15) can be approximated by a derived exponential function (16). Argument of the transfer function is now angle of deflection δ, T is replaced with rise angle δn, D is replaced with angle of displacement δ0, and K is replaced with steady-state value of the cross-section course KP. Since the control surfaces of the fuzzy controller are symmetrical, in determining the exponential equations, we picked the control surface of the left motor.
The imperfection of this approximation is that for various fuzzy control area crosssections along the D axis, we receive different steady-state values KP and the values of δn as shown in Figure 7. In our case values of KP are values of kwL at the minimum angle with course shown in Figure 11. Values of δ0 and δn were used as free parameters in fitting procedure carried out by Matlab's curve fitting functions. We fitted the fuzzy control areas cross-section with (16) in 0.1 m steps of D. The course of obtained δn values is shown in Figure 11. Values of δ0 were uneven and difficult to describe with an equation course over D so we simplified their calculation by setting them constant δ0 = −20°. With this value we achieved best correlation between original fuzzy surface and the exponential function approximation.
When the courses of KP ( Figure 11) and δn ( Figure 12) are approximated by a polynomial, we get (17): where pi, qi are the coefficients of polynomials, m is the highest power of the distance of the mobile robot for approximation of KP, n is the highest power of the distance of the mobile robot for approximation of δn. For example, to fit the cross-section of fuzzy control surface in Figure 8 using (16), we got the following values of the parameters: KP = 0.8318, δn = 27.2°, δ0 = −20°. Approximated exponential function together with original fuzzy controller course is shown in Figure 13. Values of δ 0 and δ n were used as free parameters in fitting procedure carried out by Matlab's curve fitting functions. We fitted the fuzzy control areas cross-section with (16) in 0.1 m steps of D. The course of obtained δ n values is shown in Figure 11. Values of δ 0 were uneven and difficult to describe with an equation course over D so we simplified their calculation by setting them constant δ 0 = −20 • . With this value we achieved best correlation between original fuzzy surface and the exponential function approximation.
When the courses of K P ( Figure 11) and δ n ( Figure 12) are approximated by a polynomial, we get (17): where p i , q i are the coefficients of polynomials, m is the highest power of the distance of the mobile robot for approximation of K P , n is the highest power of the distance of the mobile robot for approximation of δ n . For example, to fit the cross-section of fuzzy control surface in Figure 8 using (16), we got the following values of the parameters: K P = 0.8318, δ n = 27.2 • , δ 0 = −20 • . Approximated exponential function together with original fuzzy controller course is shown in Figure 13.    We fitted courses in Figures 11 and 12 in the same way. We tested obtained approximation functions for various combinations of powers m and n and substituted them into (17). Focus was on minimalizing average control areas. In this respect, we chose approximation of the steady-state KP value with a first-order polynomial and approximation of rise angle δn with the sixth order polynomial. Equation (18) represents the final form of exponential function equations for both motors.
.38? 4.699? Figure 14 shows the resulting control surfaces approximation of the fuzzy control surfaces using an exponential function. We fitted courses in Figures 11 and 12 in the same way. We tested obtained approximation functions for various combinations of powers m and n and substituted them into (17). Focus was on minimalizing average control areas. In this respect, we chose approximation of the steady-state K P value with a first-order polynomial and approximation of rise angle δ n with the sixth order polynomial. Equation (18) represents the final form of exponential function equations for both motors. Figure 14 shows the resulting control surfaces approximation of the fuzzy control surfaces using an exponential function. Comparison of the control time, absolute, and quadratic control area values for each fuzzy control area approximation method is shown in Table 2. Differences between fuzzy control surface approximation methods can also be shown on the paths of the mobile robot simulation from the beginning of the coordinate system to the target point, which is at distance of 10 m in Figure 15. Comparison of the control time, absolute, and quadratic control area values for each fuzzy control area approximation method is shown in Table 2.
Differences between fuzzy control surface approximation methods can also be shown on the paths of the mobile robot simulation from the beginning of the coordinate system to the target point, which is at distance of 10 m in Figure 15.

Real-World Testing
The main parameter influencing the control time is the maximum speed of the right and left engine of the mobile robot. Therefore, when analyzing the impact of the fuzzy control surface method on the control quality of the EN20 mobile robot in real-world conditions, we set the maximum speed of both motors to 60%. The reason for limiting motor speeds to 60% is due to the robot's current limiter activation at acceleration to higher speeds to reduce the current supplied to the motor drives, thus reducing motors speed [6]. Because of this fact, the used identified mathematical model of the robot is relevant only up to 60% of maximum speed. After implementing approximated controllers, we have made several measurements of the travelled paths of the EN20 mobile robot using different methods of approximation of fuzzy control surfaces. Measurements of the EN20 mobile robot path under real conditions for all the proposed control methods were made on a straight track of 10 m in length and with an initial angle of deflection of the mobile robot from the target position of 0°, 90°, and −90°. Sample time for receiving data was chosen 0.1 s. Obtained average control quality parameters for each control method based on 10 measurements are given in Figure 16. For evaluating the control quality, we focused on three quantitative indicators: control time treg, absolute (IAE), and the quadratic (ISE) control error area stated in (7), (8). Calculated control criterions had in all tests of polynomial and exponential approximations deviation of ± 5%. With table approximation in some measurements the robot turned more abruptly, which caused greater deviations of ± 8% from the average.

Real-World Testing
The main parameter influencing the control time is the maximum speed of the right and left engine of the mobile robot. Therefore, when analyzing the impact of the fuzzy control surface method on the control quality of the EN20 mobile robot in real-world conditions, we set the maximum speed of both motors to 60%. The reason for limiting motor speeds to 60% is due to the robot's current limiter activation at acceleration to higher speeds to reduce the current supplied to the motor drives, thus reducing motors speed [6]. Because of this fact, the used identified mathematical model of the robot is relevant only up to 60% of maximum speed. After implementing approximated controllers, we have made several measurements of the travelled paths of the EN20 mobile robot using different methods of approximation of fuzzy control surfaces. Measurements of the EN20 mobile robot path under real conditions for all the proposed control methods were made on a straight track of 10 m in length and with an initial angle of deflection of the mobile robot from the target position of 0 • , 90 • , and −90 • . Sample time for receiving data was chosen 0.1 s. Obtained average control quality parameters for each control method based on 10 measurements are given in Figure 16. For evaluating the control quality, we focused on three quantitative indicators: control time t reg , absolute (I AE ), and the quadratic (I SE ) control error area stated in (7), (8). Calculated control criterions had in all tests of polynomial and exponential approximations deviation of ± 5%. With table approximation in some measurements the robot turned more abruptly, which caused greater deviations of ± 8% from the average. We also compared the measured paths of the mobile robot for each control method and with the initial angle of deflection of the mobile robot from the target position of 0°, 90°, and −90° graphically in Figure 17. We also compared the measured paths of the mobile robot for each control method and with the initial angle of deflection of the mobile robot from the target position of 0 • , 90 • , and −90 • graphically in Figure 17.
In Figure 17 there is the present oscillation in control with all methods. Oscillations during real experiments were negligible but, in the figure, they are accentuated by scaling of the y-axis. The main reason for their presence is slightly different gear ratios of right and left gearboxes and measurement errors of the robot's position. From the real testing comparison, the approximation by the table is the most accurate from all approximations to the original fuzzy controller and the fastest method among all compared. The control time advantage over the original fuzzy controller is due to quicker execution times of the table approximation method and made the table controller better in the real tests. Approximations by polynomial and exponential functions showed different robot trajectory courses than the previous two. This was due to the smoother shape of approximated control surfaces by (14) and (18). After the start robot changed its direction more gradually which led to longer control times and larger control error areas. The benefit of this is that oscillations in trajectory are less distinct for these two methods. In Figure 17 there is the present oscillation in control with all methods. Oscillations during real experiments were negligible but, in the figure, they are accentuated by scaling of the y-axis. The main reason for their presence is slightly different gear ratios of right and left gearboxes and measurement errors of the robot's position. From the real testing comparison, the approximation by the table is the most accurate from all approximations to the original fuzzy controller and the fastest method among all compared. The control time advantage over the original fuzzy controller is due to quicker execution times of the table approximation method and made the table controller better in the real tests. Approximations by polynomial and exponential functions showed different robot trajectory courses than the previous two. This was due to the smoother shape of approximated control surfaces by (14) and (18). After the start robot changed its direction more gradually which led to longer control times and larger control error areas. The benefit of this is that oscillations in trajectory are less distinct for these two methods.
To clearly show the effect of the approximations on reducing computational demand on the processor, we measured the average computation time of fuzzy output for 100 samples during real-world tests. The obtained values along with memory and RAM occupation are in Table 3. To clearly show the effect of the approximations on reducing computational demand on the processor, we measured the average computation time of fuzzy output for 100 samples during real-world tests. The obtained values along with memory and RAM occupation are in Table 3. Table 3. Comparison of computation load of C8051F340 microcontroller with fuzzy controller and approximation methods.

Parameter
Fuzzy Controller

Discussion
Verification of presented approximation methods was demonstrated on the fuzzy controller with 49 interference rules. The number of rules directly affects the shape of control surfaces. In general, with fewer rules, the created control surface becomes more broken. Given that, approximations by polynomial and exponential function can become less precise due to their continuous shapes. On the other hand, approximation by the table is more adaptive to the fuzzy control surface shape. In cases when fewer rules are sufficient or the control surface is sharper, this method is more universal. We tested all the methods of approximation of fuzzy control surfaces in real conditions with the EN20 mobile robot. Although approximations through polynomial and exponential function are less precise, they are much more appropriate in terms of microcontroller implementation. By comparing these two methods of approximation, we found that polynomial approximation had a shorter control time, while the exponential approximation had smaller control error areas. The robustness of the approximated fuzzy controllers is conditioned by the accuracy of the approximation to the original fuzzy controller in a defined range of input variables. Due to the algebraic form of the functions, preventing the loss of control stability so that the input variables do not get outside their defined range in which the outputs are approximated must be programmatically solved by the conditions: If input < input min then input = input min and vice versa. Another kind of possible loss of robustness could be in extreme cases of the approximation functions when a value of any term of the function would overflow and caused wrong output value.
These approximation methods can easily be implemented into different types of microcontrollers by being represented by algebraic equations. Another advantage of the presented approximation methods is a less demanding source code, which reduces memory requirements, and the execution time of the program is still very fast. The direction of research in this area should focus both on the search for further approximation methods, simplifying the acquisition of approximations and on the investigation of the control response of these methods.

Conclusions
In this paper, we presented the new possibilities of approximation of fuzzy control surfaces into the microcontrollers without high requirements on microcontroller memory. We compared the existing way of approximating control surfaces through a table and two proposed approximations through a polynomial and exponential function with a regular fuzzy controller. Approximation through the table is simple and accurate, but inefficient due to its higher demand on memory for storing all table values. For this reason, the novelty of the paper is in using approximation methods defined by polynomial and exponential functions. The theoretical and practical functionality of the approximations was tested on the task of navigating the EN20 mobile robot to the target position. Real-world test results verified the functionality of simulations and showed usability and suitability of the approximation methods for implementation into a microcontroller. From the comparison of simulated and experimental results, it can be seen that the simulated model of the EN20 mobile robot described the real robot's performance accurately enough.
Compared to previously presented works, the main benefit is the replacement of a complex calculation of fuzzy control by algebraic equations for the direct calculation of corresponding output values of the fuzzy controller. Compared to the table approximation method the memory required to store the controller with polynomial and exponential function is reduced. Another benefit is the simplicity of implementation into microcontrollers. Instead of defining all membership functions and fuzzy rules or assigning all table values, the approximated fuzzy controller is in form of two equations using standard mathematical operations.