Optimal Adjustment of Evolutionary Algorithm-Based Fuzzy Controller for Driving Electric Motor with Computer Interface

This study focused on the development of a fuzzy system based on evolutionary algorithms (EA) to obtain the optimum parameters of the fuzzy controller and increase the convergence speed and accuracy of the controller. The aim of the study is to design a fuzzy controller without expert knowledge by using evolutionary genetic algorithms, and apply it in a DC motor. The design is based on the optimization of rule bases of the fuzzy controller. In the learning stage, the obtained rule base fitness values are measured by working the rule base on the controller. The learning stage is repeated with the termination criteria. The proposed fuzzy controller is applied on the DC motor from a PC program using an interface circuit. Simulated and experimental results have shown that the designed fuzzy controller provides system responses with high performance, low steady-state error for DC motor control, and low settling time


I. INTRODUCTION
Control systems have become widespread in all areas of life, and methods for their optimization are needed to increase sensitivity and performance. The DC motor is widely used in many applications. Brushless DC motors are widely used in high performance control systems due to advances in power electronics and control technology. Position control without oscillation is also desirable in these motors that are fed from a switched source. Fuzzy controllers are used in the industry as an optimization tool, especially in the control of DC motors, because uncertainty can be defined in the input variables of fuzzy systems and they also provide ease of application. Various methods are proposed in the literature to improve the performance of fuzzy controls. Sun et al. investigated the problem of fuzzy adaptive control of unknown nonlinear fractional order systems with external interference and unknown control directions [1]. When the bound functions of the uncertainties were not available, the adaptive fuzzy logic system was used to approach the uncertain function and the corresponding output feedback controller was designed [2]. In the study of Boulkroune and M'Saad, an observer-based fuzzy adaptive controller was examined for nonlinear systems with an unknown control gain mark, and a tracking error observer was created because the system states were not available for measurement. In this controller, the adaptive fuzzy system was used to approximate unknown nonlinear states [3]. The design of a fuzzy controller is often done by simulation or by performing input-output experiments on a prototype of the existing system [4,5].
The most important part in applications using fuzzy controls is the creation of the rule base of the system. The rule base, where acceptable results can be obtained from a fuzzy-controlled system, can only be defined by an expert who knows the system and has experience about the system. This can only be achieved after a long time and many trials in creating the necessary control structure for the system. In recent years, due to these and other similar problems, the necessary rule base for the control system has been automatically learned, or exploratory methods have been used to extract the examples. Evolutionary algorithms (EA) are considered as an alternative that lead to faster results than traditional tuning strategies, to improve proportional integrated (PI)-fuzzy controller parameters for DC motor speed control [6][7][8][9]. Bulut et al., [10] in their study, seek impact of the generation number to find the rule base of a PI-fuzzy controller using genetic algortihms (GAs).
Song et al. [11] developed an approach using a combination of random particle swarm optimization (PSO) and gravitational search algorithm to design the optimal fuzzy PI controller for a brushless DC motor (BLDCM). As studies in which GAs and fuzzy logic methods are used together in the literature show, the integrated fuzzy GA-based unidirectional floating mode control [12] gains the setting of a fuzzy controller with GAs [13], closed loop speed control of the BLDCM driver using conventional controllers [14], and the brushless DC motor's speed with GA [15] using a modified GA-tuned fuzzy controller [16]. Castillo et al., [17] in their comparative study, have shown that the optimal fuzzy harmony search is better in comparison to the optimal fuzzy differential evaluation. Hannan et al., [18] in designing an accurate and robust controller for three-phase induction motor control systems using the fuzzy logic controller (FLC), have presented a quantum-inspired lightning search algorithm to avoid exhaustive conventional heuristic procedures when obtaining fuzzy membership functions.
In this study, an evolutionary algorithm (EA) was used to eliminate dependency on expert knowledge and to automatically determine the parameters of fuzzy rule sets such as membership functions. The purpose of this article is to show that fuzzy controls based on the genetic algorithms (GA), compared to traditional methods, find better adjustment techniques and optimum results such as peak time, rise time, settling time in the transient response. In order to design a robust controller using the fuzzy PI logic controller (FLC) of a DC motor, EA were used to avoid traditional heuristic procedures while obtaining fuzzy membership functions, and for this, the optimum rule base search was made using a membership function pool in the GA.
The organization of this article is as follows: Firstly, the structure of an FLC and an evolutionary-based algorithm are introduced. Secondly, material and methods are illustrated, and the experimental tool setup and hardware structure are introduced. Finally, a description of methods used to obtain fuzzy rules by EA and the results of the proposed evolutionary fuzzy PI system are presented. This article provides a solution on how to obtain the required rule bases without the need for expert knowledge to calculate the check mark using GAs. The results show that the GA-based fuzzy controller has a better performance in DC motor control than the traditional controller.

A. Evolutionary Algorithm-Based Fuzzy Systems
In the application, the fuzzy logic system has net numerical values for the input and output parameters. The schematic structure of the commonly used fuzzy controller system consists of five parts, as shown in Fig. 1. The input parameters of the fuzzy controller are processed by the inference engine using a rule-based fuzzy set. Fuzzy systems were first put forward by Mamdani as a suggestion for solving complex problems [19]. Fuzzy logic is a powerful method used in the control of systems that are not well defined, and are not fully mathematical. However, the classical applications of fuzzy logic is dependent on an appropriate expert's knowledge, one who needs to know the system and set out the rules of the system. In designing a fuzzy controller, problems are encountered when setting the logical expressions that make up the rule base which will represent the operation of the system with IF-THEN rules. One such significant problem is the lack of clarity regarding what the rules truly define, which causes misunderstanding in some cases. EA are used in computer science as a sub-topic of artificial intelligence studies, in the literature [20,21]. In general, it can be considered as the application of the change made to adapt to the environment in nature to computer algorithms. An important basis on which EA are based is the tendency to choose the best result [22].

B. Setup of Experimental Tool
The experimental set consists of fuzzy controls and a personal computer where GA programs are run, the digital analog converter used to generate the motor drive signal, the analog digital converter that receives the motor speed information, the motor drive circuit, the voltage frequency converter, the tacho-generator, the DC motor, and the load. In this study, the GA-based fuzzy PI control system that was developed and implemented is shown as a block diagram in Fig. 2. In the operation of the system, the motor is controlled over the computer's parallel port and using a fuzzy control program. The values of the rule-based matrix used in fuzzy controls are provided by the GA algorithm. The interface circuit and driver circuit designed between the computer and the motor operate with 8-bit data transmission in two directions, with parallel  connection. There is a speed sensor with a photo-diode on the motor to receive information about the speed of the motor. Motor control is realized in real time using the GA-based fuzzy PI controller created on the computer.

C. Hardware Layout
A digital input-output (I/O) interface circuit that enables data transfer over the PC parallel port as 8-bit, and the feedback speed data for the controller are designed. Moreover, a motor driver circuit is included. Thus, the data receiving-sending function is provided between the motor driver circuit and the PC parallel port as 8-bit. The speed control of the DC motor is achieved using the controller which runs on the PC. In order to control the DC motor at the reference speed, the motor speed data as a feedback signal are sent directly to the computer via the interface and processed in the developed algorithm.
The controller with DAC signal output circuit is shown in Fig. 3. The speed data, which act as controller signal, are sent to the motor, using 8-bit data pins (0 × 378) on the PC parallel port by an interface program which was developed with C language. The digital data taken from the program on the PC are converted to the analog data using DAC, and applied to the motor via the driver circuit. As shown in Fig. 4, collector-emitter voltage is adjusted by driving a BC337 transistor. This change of the voltage directly affects the motor speed. The motor driver circuit is illustrated in Fig. 4.
The frequency data are proportionally taken from the motor speed data via a disc with a hole connected to the motor shaft, and a photo-transistor and photo-diode are placed on both sides of the disc. The signal frequency value is directly proportional to the motor shaft speed. The data are used as  a feedback signal for controlling the motor speed. The sensor that generates the square wave signal from the motor shaft is shown in Fig. 5.
Next, the frequency data are converted to voltage data. This process is carried out using the LM 2907 frequency-voltage converter. The data on voltage obtained from the motorspeed are converted to a digital signal via ADC and sent to the PC by using the other pins (that are not used in the motor driving process) of the parallel port. The circuit designed to send the feedback speed data to the PC is shown in Fig. 6.

D. Obtained Fuzzy rules of the Fuzzy Controller
In the fuzzy logic-based feedback controller system used for a DC motor, the input signal applied to the motor is defined as u kT and the output DC motor speed signal as y kT , where T is defined as the sampling period. In the system, the reference input for the desired motor speed is y kT r and the system output as the resulting DC motor speed is y kT The structure of the fuzzy PI controller and the defined scale factor for input and output variables using fuzzy controllers are given in Fig. 7.
In fuzzy control theory, the range of values that the input and output of the controller can take is called the parameter "definition range." To realize a more flexible controller, each process input is normalized by shifting it to the domain [−1,1] using fixed scaling coefficients. In fuzzy control system design, ge, gd, and gu scaling coefficients are used for e(kT) error value, d(kT) integral of error, and u(kT) normalization of the controller output to the operating range (Fig. 7). For the integral of the error, the gd coefficient is determined experimentally by giving different entries to the system to determine the normal values d(kT) will take. These values are then adjusted again to move to the range of [−1-1]. The fuzzy PI controller  rule is combined using fuzzy sets (Figures 8 and 9) with the nth system input generated from the control rule are described in Table I, in whiche i and d i are linguistic values which describe the fuzzy controller inputs ( Fig. 8 and Fig. 9), U n is the linguistic variable which describes the controller output, and E i k and D i k are linguistic variables related with e i and d i , respectively. For example, a fuzzy control rule can be written as provided in Table II. where e 1 = "error" and E 1 4 = "positive large", etc. The rule set obtained in this way forms the rule base that characterizes how a dynamic system can be controlled. A fuzzy inference form can be formed from the control rule in Table III by using the fuzzy set theory, in which E j , D 1 and U j..k, l..m are "e is E j ", "d is D 1 " and "u is U j..k, l..m ", respectively. They show fuzzy sets that describe their linguistic states. Output membership functions for fuzzy controller output u(t) on the definition universe are automatically determined by using the EA. Thus, a fuzzy controller that controls the system is to be learned. Initially, the first rule base that belongs to the fuzzy controller is randomly generated at the beginning of the learning algorithm. There are two inputs and one output of the system. Thus, all of the fuzzy controller rule bases can be formed, as shown below: where E 1 j and D 1 l are triangle-type input membership functions. In the same way, U n j.,l is a triangle-type input membership function whose center value is randomly generated at the beginning of the algorithm and base width is 0.4, as shown in Figures 8 and 9.
The membership grade of the input and output values is calculated by using the membership function in (4):     1 11 (4) where c E i is the triangle type E i (or D i ) membership function center. w is half of the membership function base width. U n j… 1 represents information of the control rules, which are directly designed for conventional fuzzy controller, and described as prior information that an expert who knows the process will suggest. This information, which shows output membership functions, is learned by the EA. Here, the center of gravity is used in the defuzzification process.

E. Optimization of the Rule Base by GA
In the GA-based evolutionary learning algorithm, the chromosomes in the pool, each representing the rule base of a fuzzy controller, are obtained after cross-over and mutation processes. After that, a mathematical model is first applied to the DC motor and the responses obtained are stored. Then, by applying these data as input to the fitness function defined for GA, the performances of each chromosome as a rule base are measured and the fitness values are calculated. Thus, in the evolutionary learning algorithm for each generation, the chromosome which has the highest fitness value as a rule base is determined. These rule bases are used to run the inference engine of the fuzzy PI controller. The fitness function used in the system of the fuzzy PI controller is defined to determine the rule base that will give the highest performance with high accuracy. The fitness function f (x) used in GAs is defined according to the problem to be solved, the structure of the system, and the application type. In (5), the fitness function is defined to obtain a fuzzy controller that can overcome small steadystate errors, short rise time, low oscillations, and overshoots: where T, applied time to DC motor mathematical model; a, a positive number used to set the upper and lower bases of fitness value; t, the time index; e, the error signal between the measured DC motor output speed signal and reference input speed signal at time t, and Δe , the error change at time t.
The output value of the fitness function varies between zero and one. Rule bases with higher fitness values correspond to better fuzzy controller performance. At the same time, defining a system's fitness function always needs to be done according to a specific application. The rule base obtained by GA at the end of the evolutionary learning process is applied to the fuzzy controller structure and used in the application to control a real DC motor.
The time to learn the desired system model of the evolutionary learning algorithm varies from application to application and depends on different factors. If the chromosome number at a pool of GA, the defined convergency criteria for the EA, and the maximum number of reproductions increases, the learning time increases. In addition, the application time to the DC motor by the fuzzy controller which has the rule base is much more effective. In this study, the number of chromosomes in the genetic pool containing the rule bases necessary for the fuzzy control of the DC motor was selected as 20 and the number of evolutionary generations between 10 and 30.

F. Results of the Proposed System
While determining the rule base of the EA-supported fuzzy control system, the initial pool of GA is randomly created. Therefore, each time we run the GA, it produces different rulebased results for each experiment. In genetic fuzzy systems using the fitness function, the rule base with the highest fitness value is crossed with all rule bases (chromosomes) in the pool, to find the most optimum rule base in the next generation. After determining a termination criterion (convergency) or the number of iterations for the GA, the rule base with the highest fitness value is selected in each new generation of the GA, and crossed-over with the chromosomes of the next generation, providing the criteria within the genetic pool.
In this work, the most appropriate rule base (chromosome) was taken as the learned rule base of the system. After running the algorithm, the chromosome as a rule base which had the highest fitness value was acquired in the 9 th generation of the EA, with a fitness value of 0.977 in ten generations. The rule base (chromosome) that produced the most appropriate output  for the DC motor model was placed in the fuzzy control structure. When the termination criterion determined in the GA was reached, the fuzzy PI controller containing the best-performing rule base according to the fitness function was applied to the derived transfer function model of the DC motor to be controlled. While the result was acquired in the desired tolerance, the rule base with the highest compliance value was transferred to the fuzzy controller and applied to the real DC motor as an experiment. As a result, a fuzzy PI controller using an offline learning method for rule-based acquisition process was developed. It is seen that system outputs of the DC motor mathematical model give ideal responses that do not have overshoots and oscillations. For inputs with different speed reference values, the results of the system responses generated are shown in Fig. 10 and Fig. 11. The rule base obtained by using ten generations in the learning process of the fuzzy rule base with the evolutionary algorithm did not represent a sufficiently defined fuzzy control to control the DC motor under load. In this case, although the DC motor output speed signal reached the desired reference speed value in a short time, some oscillations occurred in the steady state. As shown in Fig.12, oscillations at the output increased when high reference values were selected for the motor speed.
Therefore, the process of obtaining the rule base for the fuzzy controller with the learning algorithm with EA was rerun by increasing the evolutionary generation number. In the evolutionary fuzzy control system, the number of GA generations was increased to 30. The results revealed that a successful fuzzy PI controls rule base had been obtained that could control the DC motor more successfully even when it was loaded. The highest fitness values obtained in each generation in the learning process with the evolutionary algorithm are given in Fig. 13, and the fuzzy PI controller unit step response which contained the rule base with the largest fitness value is shown in Fig. 14. The unit step response for the rule base with the highest fitness value achieved over 30 generations is shown in Fig. 15 for the DC motor control system. In the geneticbased fuzzy system, the initial rule base acquired using 30 generations had the highest fitness value and was applied in the fuzzy PI controller to drive the DC motor at different reference input values. Considering the fuzzy PI DC motor control system's response, shown in Fig. 15, it is seen that the rise time for the DC motor speed to settle at the desired   reference value was less than 1 second, and the settling time was 1.2 seconds.

III. CONCLUSION AND DISCUSSION
Genetic fuzzy systems are one of the models that automatically learn the basic information of the fuzzy controller. In this article, using an evolutionary algorithm for DC motor control, a GA-based fuzzy system that provides automatic rule-based learning was designed, and a good performance was obtained by applying it to the real system. The optimization of the parameters of a computer-based evolutionary fuzzy PI controller for speed control of the DC motor was achieved by using the computer interface over an experimental set designed. From the results obtained, the targeted and realized genetic fuzzy system algorithm has revealed a flexible structure with high performance, applicable to the DC motor for fuzzy PI controller.
The approach designed in this study constitutes a fuzzy controller design that provides system responses with low steadystate error and low settling time in DC motor control. At the end of this study, the performance of the controller, which was designed automatically by Gas, was found to be acceptable,.
The number of generations can be increased to achieve better results. With the increase in the number of generations, more solution points will be investigated, and therefore the processing time will increase. Increasing the number of generations too much may turn out to be a disadvantage, since prolongation of the processing time is undesirable. Therefore, when the required criteria are met, there is no need to increase the number of generations.