Optimal Adjustment of Fuzzy Controller Based Evolutionary Algorithms For Driving Electric Motor with Computer Interface

This study focused on the development of a system based on evolutionary Algorithms to obtain the optimum parameters of the fuzzy controller to increase the convergence speed and accuracy of the controller. The aim of the study is to design fuzzy controller without expert’s knowledge by using evolutionary genetic algorithms and carry out on a DC motor. The design is based on optimization of rule bases of 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 the termination criteria. The proposed fuzzy controller is performed on the dc motor from a PC program using a 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, low settling time.


Introduction
Control systems have become widespread in all areas of life. For this reason, optimization methods are needed to increase sensitivity and performance in control systems. The DC motor provides good dynamics and its reliable behavior is important, providing excellent speed tracking with the lowest overshoot, higher performance and higher strength than those achieved using other controller. DC motor is widely used in steel mills, electric trains, cranes and many more 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 at the same time they provide ease of application. To providing performance improvement, they require high speed mathematical computation in real-time applications, so they are costly in terms of hardware resources. Various methods are proposed in literature to improve the performance of fuzzy controls. Beyhan aims to apply adaptive expanded fuzzy function observer based controller, proposed for the control of nonlinear unknown and uncertain systems, and adaptive extended fuzzy function observer based controller to real-time system and provide control in the direction of the unknown control signal [1]. In the studies of Gencer et al., A proportional-derivative (PD) controller was designed and digital signal processor based position control of Brushless Direct Current Motors (BDCM) was realized [2]. Zeydan, ai their study developed fuzzy modeling of the Fluid Bed Catalytic Cracking (FCC) unit in the refinery system, which is the most important part of the petrochemical industry, has been made. Since the mathematical models describe this system incompletely, they have found properties that can be the subject of fuzzy logic and the fuzzy model of the system has been created [3]. The design of a fuzzy controller is often done by simulation or by performing inputoutput experiments on a prototype of the existing system [4], [5]. As fuzzy controller applications, they used the interactive inverter in the controlled network [6], the speed control of the permanent magnet synchronous motor [7] in their studies of Real Time Control of an Automated Guided Vehicle with Fuzzy Logic [8].
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 trials in creating the necessary control structure for the system. In recent years, due to these and 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 leads to faster results than traditional tuning strategies to improve PI-Fuzzy controller parameters for DC motor speed control [9]- [12]. Bulut in their study, seek impact of the generation number to find rule base of a Fuzzy-PI Controller using genetic algorithms [13]. Baoye S. et al., developed the approach using a combination of a random swam optimization (PSO) and gravitational search algorithm (GSA) for to design the optimal fuzzy proportional integrated (PI) controller for brushless DC motor (BLDCM) [14]. As studies in which genetic algorithms and fuzzy logic methods are used together in the literature; integrated fuzzy ga based unidirectional floating mode control [15], gains the setting of a fuzzy controller with genetic algorithms [16], closed loop speed control of the bldc motor driver using conventional controllers [17], the brushless dc motor's speed with genetic algorithm [18] and using a modified genetic algorithm tuned fuzzy controller [19].
In this study, a 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 genetic algorithm, compared to traditional methods, find better adjustment techniques and optimum results such as peak time, transient and transient response. Organization of this article as follows: Firstly, structure a fuzzy logic controller and an evolutionary based algorithm are introduced. Secondly, material and methods are illustrated and experimental tool setup, hardware structure introduced. Then finally, described that how is obtained fuzzy rules by EA and results of proposed evolutionary Fuzzy-PI System are presented.

Evolutionary algorithm based Fuzzy system
Fuzzy systems uses parameters which are based on linguistically defined logic statements. These linguistic statements are represented by fuzzy sets. In fuzzy logic, the membership of a parameter in a fuzzy set is not necessarily a full member, but may also be partial membership.
In the application, fuzzy logic system has net numerical values for the input and output parameters. For this reason, the fuzzy systems includes a fuzzifier section for inputs and a defuzzifier section for outputs. The schematic structure of the commonly used fuzzy controller system consists of five parts as shown in Figure 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 [20]. Fuzzy logic is a powerful method used in the control of systems that are not well defined, not fully mathematical. However, in classical applications of fuzzy logic, it is dependent on an appropriate expert knowledge that needs to know the system and set out the rules of the system.
There is a physical relationship between the fuzzy PI controller and the classical PI controller. One of the main problems of the fuzzy controller is that it has too many parameters to adjust. Well-tuned fuzzy controller is more stable and more durable for systems that change over time.
In order to design a fuzzy controller, problems are encountered when setting the logical expressions that make up the rule base that will represent the operation of the system with IF-THEN rules. One of the important of them, nobody is sure that the rules defines truly and cause of misunderstanding in some cases. Evolutionary Algorithms are used in computer science as a sub-topic of artificial intelligence studies in the literatüre [21], [22]. 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 evolutionary algorithms are based is the tendency to choose this best result [23].
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 genetic algorithms.
The results show that the genetic algorithm based fuzzy controller has a better performance in dc motor control than the traditional controller.

Experimental tool setup
The experiment set consists of a fuzzy controls and a personal computer where genetic algorithm 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, voltage frequency converter, tacho-generator, dc motor and load. In this study, developed and implemented GA based fuzzy-PI control system block diagram is shown in Figure 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-base matrix used in fuzzy controls are provided by the GA algorithm. The interface circuit and driver circuit designed between the computer and the motor operates 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 was realized in real time using the GA based fuzzy PI controller created on the computer.

Hardware layout
A digital input-output (I/O) interface circuit that provides possibility the data transfer over the PC parallel port as 8-bit and the feed-back speed data for the controller was designed. Moreover, there is a motor driver circuit on it. Thus, data receiving-sending is provided between the motor driver circuit and the PC parallel port as 8-bit. The speed control of the dc motor was done 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 is sent directly to the computer via the interface and processed in the developed algorithm. The controller with DAC signal output circuit is shown in Figure 3.
8-bit data pins (0x378) on the PC parallel port were used to send the speed data which is a controller signal to the motor by a interface program which developed with C language. The digital data taken from the program on the PC are converted to the analog data by using DAC and applied to the motor via driver circuit. As shown in Fig. 4, collector-emitter voltage is adjusted by driving BC337 transistor. This changing of the voltage affects to the motor-speed directly. The motor driver circuit is illustrated in Figaure 4. The frequency data is proportionally taken from the motor speed data via a disc with a hole connected to the motor shaft, and there is a foto-transistor and foto-diode on two side of the disc. The signal frequency value is direct proportional to the motor shaft speed. This data was used for controlling the motor speed as feed-back signal. The sensor that generates square wave signal from the motor shaft is shown in Fig. 5. Then, the frequency data was converted to the voltage data. This process was carried out by using LM 2907 frequencyvoltage converter. The voltage obtained from the motor-speed was data was 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 parallel port. The designed circuit sending the feed-back speed data to the PC is shown in Figure 6. Figure 6. The circuit scheme sending speed sensor data to the PC via parallel port.

Obtained fuzzrules of fuzzy controller
Fuzzy rules were obtained by using the EA program written in Turbo C language. The rule base of a system fuzzy controller. When determined by an expert using IF THEN rules, problems may arise from not being able to fully define the system. However, it is not possible to be sure that the proposed and preferred rule base can provide the optimum solution for the system to be controlled. This can only be understood by applying the fuzzy controller using this rule base on the system. This can lead to situations that can damage the system and carry risks. In this study, this problem caused by human knowledge while defining the fuzzy system rule base was solved by using EA's.
In the fuzzy based feedback controller system used for a DC motor, the input signal applied to the motor is defined as ( ) and the output dc motor speed signal ( )In here, T is defined as the sampling period. In the system, the reference input for the desired motor speed is ( ) and the system output as the resulting dc motor speed is ( ) As the inputs of the fuzzy logic controller, the error signal ( ) showing the difference between ( ) and ( )and the integral of error signal is ( ). The equations defining in the system are expressed as belowe; The structure of the fuzzy-PI controller and defined scale factor for input and output variables using fuzzy controllers are given in Figure 7. Figure 7. The fuzzy-PI controller structure for dc motor process.
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

Bulut, M.
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 ( Figure 7).
For the integral of the error, gd coefficient is determined experimentally by giving different entries to the system to determine the normal values d(kT) will take. Then these values are 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 sistem input generated from the control rule as follows: IF e1 is E1 j AND ...AND es is Es k AND....AND d1 is D1 l AND .... AND ds is Ds m THEN un is Un j..k,l..m Where ei and di are linguistic values which describe the fuzzy controller inputs (Figures 10 and 11). Un is linguistic variable which describes the controller output. Ei k and Di k are linguistic variables related with ei and di, respectively. For example, a fuzzy control rule can be written as below: IF error(e) IS positive large AND error integral is negative small THEN process input is positive big (4) Where e1 = "error" and E1 4 = "positive large", etc. This rule set abtained in this way occurs the rule base that characterize how to control a dynamic system. A fuzzy inference form can be occurred from the control rule in Equation (4) Where 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 defination universe is automatically determined by using the EA.
Thus, fuzzy controller that controls the system is to be learned. At the beginnig, the first rule base that belongs to fuzzy controller is randomly generated at the beginning of the learning algorithm. There are two inputs and one output of the system. So, all of the fuzzy controller rule bases is to be form as below: IF E1 j AND D1 l THEN Un j.,l Where E1 j and D1 l are triangle type input membership functions. In the same way, Un j.,l is triangle type input membership function that its centre 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 membership function in Equation (7).
Where is triangle type Ei (or Di) membership fuction centre. is half of the membership function base width. Un j… 1 information at the control rules, which is directly designed for conventional fuzzy controller, is described as priorinformation that an expert knowing process suggests it. This information that shows output membership functions is learned by the EA. Here, centre of gravity (COG) is used at defuzzification process.

Optimization of rule base using fitness function
In the genetic algorithm-based evolutionary learning algorithm, the chromosomes in the pool, each representing the rule base of a fuzzy controller, obtained after cross-over and mutation processes. After that, firstly applied to the DC motor mathematical model 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 cromozom as rule base which has the highest fitness value is determined. And these rule bases are used to run the inference engine of the fuzzy-PI controller.
The fitness function used in system is defined to determine the rule base of the fuzzy-PI controller that will give the highest performance with high accuracy. The fitness function f (x) used in genetic algorithms is defined according to the problem to be solved, the structure of the system and the application type. In Equation (8), the fitness function is defined to obtain a fuzzy controller that can overcome small steady-state errors, short rise time, low oscillations and overshoots. The output value of the fitness function varies between 0 (zero) and 1 (one). Rule bases with higher fitness values correspond to better fuzzy controller performance. At the same time, defining a system fitness function always needs to be done according to a specific application. Obtained the rule base by GA at the end of the evolutionary learning process is applied to the fuzzy controller structure and used in application of control of s real dc motor.
The time to learning the desired system model of the evolutionary learning algorithm varies from application to application and depending on different factors. If the chromosom number at pool of GA and the defined convergency criteria for evolutionary and the maximum number of reproduction increases, the learning time increases. In addition, the application time to the dc motor by the fuzzy controller which has rule base is much more effectual.
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 20 and the number of evolutionary generations between 10 and 30.

Results of evolutionary fuzzy system
While determining the rule base of the evolutionary algorithm-supported fuzzy control system, the initial pool of GA is randomly created. Therefore, each time we run GA, the generic algorithm produces different rule-base 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, for find the most optimum rule base in the next generation After determining a termination criterion (covergency) or the number of iterations for the genetic algorithm. Then the rule base which has the highest fitness value was selected in each new generation of the genetic algorithm, cross-over with the chromomes of the next generation, providing the criteria within the genetic pool.
The most appropriate rule base (chromosome) is taken as the learned rule base of the system. After running the algorithm, the chromosome as rule base which has the highest fitness value acquired in the 9th generation of the evolutionary algorithm has 0.977 fitness value in 10 generations.
The rule base (chromosome) that produces the most appropriate output for the dc motor model is placed in the fuzzy controls structure. When the termination criterion determined in the genetic algorithm is reached, the fuzzy-PI controller containing the best performing rule base according to the fitness function is 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 experimental. As result, in here was developed fuzzy-PI controller using an offline learning method for rule base acquisition process It is seen that, system outputs of the DC Motor mathematical model gives 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 Figure 10(a) and Figure 10(b). The rule base obtained by using 10 generations in the learning process of the fuzzy rule base with the evolutionary algorithm does not represent a sufficiently defined fuzzy control to control the dc motor under load. In this case, although the dc motor output speed signal reach to the desired reference speed value in a short time, then in steady state occured some oscillations. As shown in Figure 10(c), oscillations at the output increase when high reference values are selected for the motor speed.
Therefore, the process of obtaining the rule base for the fuzzy controller with the learning algorithm with EA has been rerun by increasing the evolutionary generation number.
In the evolutionary fuzzy control system, the number of genetic algorithm generations has been increased to 30. When the results are examined, a successful fuzzy-PI controls rule base has been obtained that can control the dc motor control more successfully even when it is loaded.
The highest fitness values obtained in each generation in the learning process with the evolutionary algorithm are given in Figure 11. Figure 11. At the learning stage, chromosomes with the highest fitness values.
The unit step response for the rule base with the highest fitness value achieved over 30 generations is shown in Figure  12 for dc motor control system.
In the genetic-based fuzzy system, firstly using 30 generation and acquired the rule base with has the highest fitness value was applied in the fuzzy-PI controller to drive the dc motor at different reference input values. When looking at the Fuzzy-PI dc motor control system response shown in Figure 13, It is seen that the rise time for the DC motor speed to settle at the desired reference value is less than 1 second, and the settling time is 1.2 seconds.

Conclusion and Discussion
The biggest disadvantage of fuzzy-based control systems is that the system requires the knowledge of an expert who has already experienced the system and the rules determining the rule base. Artificial intelligence-based algorithms are used to deal with this problem, and many different methods are available in the literature. Many researches are carried out to develop high performance rule base for fuzzy systems without resorting to human experience.The design of the rule base requires human expertise with many years of experience in the system to be controlled. Genetic fuzzy systems is one of the methods that automatically learn the basic information of the fuzzy controller. In this article, using an evolutionary algorithm for DC motor control, a genetic algorithm based fuzzy system that provides automatic rule-base learning has been designed and a good performance has been obtained by applying it to the real system. The optimization of the parameters of a computer based evolutionary fuzzy-PI controller for the speed control of the dc motor was done 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 DC motor for fuzzy-PI controller. The approach designed in this study constitutes a fuzzy controller design that provides system responses with low steady-state error and low settling time in DC motor control.At the end of this study; it has been shown that the performance of the controller, which is designed automatically by means of genetic algorithms, is better compared to that of the human knowledge-based controller. 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, so the processing time increases. 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.