1 Introduction

DC motors are one of useful electrical machines in industry. The relevant controllability and precise controlling and wide range of final speed of these machine are some factors which have introduced them popular electrical machine in industry. Given to the abundant uses of such machines, controller systems with high accuracy and application have to be developed. To control speed of electrical machine many controller systems have been proposed such as fuzzy controller systems [1], PID controller systems [2], adaptable PID controller systems [3], optimized systems by meta-heuristic algorithms [4], evolutionary algorithms [5,6,7], and neural network [8]. The training of neural network substantially has effect on performance precision [9,10,11,12]. One of the noticeable disadvantages of electrical DC machine is its non-linear characterizes which cause unsuitable performance and drop in precision.

Fuzzy controllers are one of the systems which provide suitable performance in DC machines. Because of having proximate nature and less sensitivity to input variables precision, system is considered as black box and it can be noted that have their easy implementation in comparison with other DC controller systems. Hence, these controller systems become one of the well-known DC machine controller systems. Thus, given to the disadvantages of DC machines in fuzzy controller systems, the non-linear characterizes of electrical DC machine do not have influence on these controller systems’ performances and no disorder is caused in their performance. Fuzzy controllers have problems that motivate the researchers to use optimization methods in real time systems such as speed controlling of DC motors [13]. In the following, some disadvantages of fuzzy controller systems are expressed.

  • The fuzzy controllers require complicated mathematical computations.

  • The critical information provided by experts are not optimum or precise.

  • Calculating the best values for input and output gains is difficult

Due to large number of multiplication and addition function in fuzzy computation, these systems intrinsically require too many wide bit; hence, it needs many hardware and will bring low computation speed.

In this paper, it is considered that some strategies to reducing the impacts of presented disadvantages be provided. In following it, the suggested method is being evaluated with other aforementioned methods so that its advantages are exposed. Firstly, a new Genetic Algorithm (GA) is introduced which applies the developed crossover to appropriately regulate fuzzy controller parameters. In this method, the parameters are imported to per chromosome like genes. Then, the operators of GA and special improved crossover operator approach the fuzzy controller’s performance to its optimum maximum. By using pipeline implementation method, the optimized controller in previous step are implemented in FPGA workplace; so that prepare it for real time applications.

In Sect. 2 of this paper, optimization methods by use of improved GA is provided to enhance intrinsic characterizes of fuzzy controllers and the obtained results are compared with different types of introduced fuzzy controllers in other papers. In Sect. 3, specific strategies are introduced in optimal implementation of fuzzy controller upon FGPA and also according to their disadvantages, some strategies are propounded to reduce the effects of these disadvantages on implemented fuzzy controller’s performance upon FPGA. In final, there are comparisons among achieved results and results of previous papers.

2 Proposed method

2.1 Review of speed controlling in DC motors

In majority of DC motors applications, use of speed controller always is recommended. The most important reasons of speed controller using in DC motors can be described:

  • DC motors protection

  • Precise speed control of DC motors

  • Torque control

  • Economizing of energy consumption

Nowadays, due to large number usages of electrical machines and being complicated of structural equations, electrical machines require controllers which simple implementation and structure with adequate precision. It can be noted that PID controller is one of the most popular electrical controller machines [14]. Simple structure and implementation are the most critical advantage of this controller. Although, the parameters regulating is essential part of PID controller, it also can be its most complex and weakness in non-linear and complicated systems [15]. The effectiveness of outside conditions and disorders on system structure is another weakness of PID controllers which bring out more complication. Given to these disadvantages of PID controllers, fuzzy controller is suggested as another controller for speed controlling in DC motors. PID controller needs a mathematical model of system; however, fuzzy controller considers systems as a black box that is a remarkable prominence of fuzzy controller in comparison with other traditional electrical DC machines. Electrical DC machines have complex and non-linear mathematical equations. Hence, traditional controller systems are not able to achieve acceptable precision and performance. Fuzzy controllers perform based on practical experiences and experts’ knowledge; although, the implementation of these controllers is more complicated than PID controllers. But, because of having no need to mathematical equation and non-linear features of electrical DC machines. Fuzzy controller is suitable for DC machines controlling. According to the Eq. (1), electrical circuit of DC machines for their speed control are proposed in three ways. This paper focuses on controlling DC machines speed using voltage controlling in two terminators of armature.

$$E_{a} \left( t \right) = R_{a} *I_{a} + L_{a} *\frac{{di_{a} }}{dt} + e_{b}$$
(1)

In fuzzy controller systems, different types of Fuzzy Inference Systems (FISs) are suggested. Considering to their complexity and general usage, Sugeno and Mamdani are two useful inductive systems. The main difference between these systems is in a way that they calculate output. In Mamdani inference, it is necessary to find centroid of two-dimensional shape, while, in Sugeno inference, a fuzzy set with certain membership function is utilized which its value in some points is the maximum value of membership function while is zero in other points.

In the next section, these two FISs are compared in DC machines controlling and the best system with best results is selected finally.

2.2 Fuzzy motor selection

In this section, the performance of fuzzy controllers is examined using Sugeno and Mamdani inference motors. To compare the performance of these controllers, both fuzzy controller systems are simulated in Matlab software for controlling DC electrical machine. As well, fuzzy controller systems are provided by applying Mamdani and Sugeno fuzzy motors based on expert’s knowledge and without any optimization [16].

As shown in Fig. 1, both controller inference motors present approximately same performance to applied bridging function in DC motors. Table 1 displays the details of both controllers.

Fig. 1
figure 1

Step response of system using different FIS

Table 1 Initial characteristics of different FIS type

2.3 Proposed method and its simulation results

In this section, the manner of improved GA and also the parameters of fuzzy controller using proposed method is presented [17]. GA is a special type of meta-heuristic algorithm which utilizes evolutionary biology such as heredity, biology and Darwinian selective principles to find the optimum formulae for prediction and pattern matching. The prominent feature of GA as an optimizer is searching less number of solutions in comparison with total number of solutions. GA determines the efficiency of solutions using cost function and wrong solution with less cost are eliminated. As a result, the number of examinable solutions diminish dramatically [18, 19]. This feature of GA is a great help in optimizing the fuzzy controller parameters, which due to the large number of states, these parameters cannot be verified by humans [20].

This paper has concentration on optimizing the expressed parameters in following:

  • Input gains

  • Parameters value of membership function

  • Rules

  • Output gains

Crossover operator is one of the most crucial operators in GA which has noticeable influence on algorithm’s performance [21, 22]. In this operator, parent chromosomes which have certain value of cost, produce new child by transforming their features. It is expected that these children are better chromosome than their own parents. Therefore, by iteration of each generation, it is expected that fuzzy controller parameters will be updated to improve controller’s performance. The presented paper makes a plan to improve the convergence speed and precision of GA by providing new crossover operators and eventually enhance the fuzzy controller performance.

Hereby, instead of utilizing two parent chromosomes, the proposed method uses one father chromosome, one mother chromosome, one elite chromosome, and one random chromosome in per crossover as can be seen in Algorithm 1. Elite chromosome selection rises the exploitation of GA in producing new child that climbs the convergence speed of algorithm. Also, it is possible that algorithm is trapped in local minimums. Hence, using random chromosome in new child production solve this difficulty and the algorithm can comprehensively can search problem space. In result, the proposed algorithm simultaneously rises the exploitation and exploration rates of algorithm. The following pseudocode demonstrates the trend of proposed crossover operator. Figure 2 shows a flowchart of the entire proposed system.

figure e
Fig. 2
figure 2

Flowchart of the entire proposed system

The gains applied in pre-processor and post-processor steps have remarkable impact on the stability of a fuzzy controller system. Hence, optimum value selection of these parameters have considerable criticality. Since, these parameters have real values, finding the best and optimum values for them cannot be done by human. In this step of proposed GA, it is tried to find optimum value for parameters of input membership functions obtained from DC motor.

To decrease the computations done by GA, it is supposed that membership ranges are considered each other’s symmetric.

The most evident feature of fuzzy controller is experimental use of expert’s knowledge. Along with this advantage, it has a big problem. These rules and amounts might not be optimized or be completely wrong. Figure 3 represents a fuzzy controller with its required gains. As a result, GA is utilized in order to determine optimum fuzzy rules. In this section like last section, given to symmetry of rules, these rules will be optimized. Figure 4(a), (b) and Table 2 show inputs membership functions and rules of fuzzy controller in DC motor based on expert’s knowledge, respectively.

Fig. 3
figure 3

Fuzzy logic controller

Fig. 4
figure 4

Initial distribution of the a error input membership function and b change error input membership function

Table 2 5*5 FLC rule-base in tabular form

In Fig. 5, fuzzy controller rules are visually displayed by three-dimensional diagram. The most critical point obtained from Fig. 5 is that these rules create a surface with moderate slope. Few number of rules to more rules is continuously corresponding to light slope to sharp slope. The great feature of this representation is displaying how changes created by applying GA in fuzzy controller.

Fig. 5
figure 5

Rule surface of fuzzy controller

Given to mentioned assumptions including symmetry of membership functions as well as the parallel rules regulated by GA, we will optimize fuzzy controller using Sugeno inference function.

Figure 6(a), (b) illustrates the changes of inputs membership functions applied by GA. As can be seen, the first point is that GA tries to localize membership function centers around the center of input ranges. The second point is the relationship between compression rates of membership function and range of membership function. In other words, the compression rate of the error membership function is much greater than the differences error membership function, and the GA attempts to establish a balance between the two inputs of the fuzzy controller.

Fig. 6
figure 6

Optimized distribution of the a error input membership function and b change error input membership function

As shown in Fig. 7, fuzzy controller rules lose their previous shape; although, being symmetric as an initial assumption is still kept after optimizing even. Figure 8 displays comparison between fuzzy controller optimized by proposed GA and fuzzy controller without optimization.

Fig. 7
figure 7

Rule surface of optimized fuzzy controller

Fig. 8
figure 8

Step response of system using different fuzzy controller

The main objective of this paper is use of GA to reduce overshoot phenomena, signal fluctuation as well as reaching to convergence. As presented in Fig. 8(a), the performance of fuzzy controller optimized by GA has noticeably less overshoot amount than not optimized controller. Moreover, according to the Fig. 8(b), the optimized fuzzy controller has substantially less signal fluctuation, however, not optimized fuzzy controller creates semi-wave and non-convergent signals. Both controllers simultaneously reach to same relative stability approximately and also overshoot measure and the distortion of output signal diminish remarkably. It means that the proposed fuzzy controller has noticeable prominence in comparison with other fuzzy controllers. In Table 3, the difference between these two controllers has been presented.

Table 3 Characteristics of different FIS type

3 Optimal hardware implementation of the proposed method

Section 3 focuses on implementing optimized fuzzy controller which was described in Sect. 2. It also provides techniques for optimal implementation of this controller on the FPGA by reducing the computations performed in the fuzzy controller and increasing the clock speed of the control system. The required hardware for a digital circuit is the most important point in implementing a digital circuit on FPGA [23]. In Fig. 9, a general schematic of implemented fuzzy controller on FPGA for controlling speed of outputs in DC electrical motor is shown. The provided techniques in this section include bit width reduction technique for fuzzy controller and pipeline technique. Both techniques focus on avoiding extra and unnecessary computations; so that rise speed of fuzzy controller’s performance and reduce hardware sources consumption for controller on FPGA; however, no disorder and precision reduction are caused for fuzzy controller.

Fig. 9
figure 9

Schematic diagram of DC motor fuzzy controller

3.1 Effective width reduction technique

This section provides a technique to reduce required bit width in fuzzy controller. High complexity in computation is one of the main disadvantages of fuzzy controller. In this section, the objective is to finding optimum value for bit width of input signals to fuzzy controller. To begin with, the input signals of fuzzy controller which is obtained from an electrical DC motor, are examined and keep optimizing for middle signals and finally the desired output value with suitable width of bit is delivered to electrical DC motor.

Figure 10 represents the bit width of fuzzy controller of DC electrical motor without bit width optimization and optimized bit width in different parts of fuzzy controller.

Fig. 10
figure 10

Bandwidth of optimized fuzzy controller

Tables 4 and 5 display required hardware sources for implementation of fuzzy controller on FPGA. Given to these tables, it is gained that since, fuzzification block applies more multiplication and division operators and because of requirement to wide width of bit for used signals, the noticeable number of hardware sources is consumed in comparison with other blocks.

Table 4 Slice logic utilization of fuzzification block
Table 5 Slice logic utilization of rule and defuzzification block

As can be seen from Figs. 11 and 12, due to the repeated use of multiplication in the computations required by a fuzzy controller, the width of the bit has increased dramatically as a result of the increase in hardware consumption, and also due to increased computations, the fuzzy controller’s performance decreases.

Fig. 11
figure 11

Bandwidth of optimized fuzzifier block

Fig. 12
figure 12

Bandwidth of optimized rule and defuzzification block

To reduce bit width, each part of fuzzy controller are implemented separately in MATLAB software. It should be mentioned that if bit width doesn’t diminish per step and bit width reduction is occurred merely in output block, more required hardware would be consumed on FPGA. Hence, the great advantage of bit width reduction in per block is that less hardware is consumed in comparison with bit width reduction in the last step.

Due to large number of required blocks in fuzzy controller, the number of existing mathematical operators as well as the width of the large bit of input signals, it is difficult to find the best and least value for desirable optimized bit width. MATLAB makes finding the least and optimum value of bit width easier that can be expressed as an advantage of MATLAB utilizing in this paper. Since, numbers in FPGA are considered as fixed-point, the proposed method in this paper makes an effort to reduce bit width of calculated number in decimal part in different parts of proposed fuzzy controller. Hereby, numbers should be implemented as fixed-point in MATLAB. In the next step, the bit width of decimal part decreases gradually to be stopped in desired accuracy. In Tables 4, 5, 6 and 7 the comparison of the hardware consumption in various parts of the fuzzy controller is shown in the scenarios without decreasing bit width bit width reduction mode.

Table 6 Slice logic utilization of pipeline fuzzification block
Table 7 Slice logic utilization of pipeline rule and defuzzification block

The most critical point in this section is the perfect understanding of the rules for implementing the digital circuit on FPGA. Having complete familiarization of rules of multiplication and addition on FPGA and considering to bit width of these mathematical operators are vital points in this section. Since, these rules have not been allotted in MATLAB, the implementation on FPGA might be encountered with some problems.

3.2 Pipeline technique

In this section, the use of pipeline technique in practical implementation of fuzzy controller is described. In following it, the advantages and disadvantages of utilizing pipeline technique in fuzzy controller implementation on FPGA is expressed [24,25,26].

Propagation delay is a matter in digital systems which given to increasing frequency in digital circuit has importance, nowadays [27,28,29]. In general, propagation delay is the amount of time it takes to get the input signal from the beginning of the digital circuit to the circuit output which is so important in sequential logic. There are two strategies to reduce propagation delay. The first way is frequency reduction in circuit which is the most obvious way. If it is possible, we reduce frequency of circuit to prevent errors. The second strategy is pipeline technique.

To optimize required codes for TSK fuzzy controller, it needs to recognize those parts of controller that have maximum delay and maximum volume of computation in order to reduce propagation delay of circuit using pipeline technique. It finally rises the speed of fuzzy controller. The maximum volume of computation and delay belong to final and fuzzy parts of controller.

In Tables 6 and 7, the consumption rate of hardware resources required to implement the fuzzy controller like pipeline is shown.

3.2.1 Fuzzification part

In this part, common fuzzification methods like Mamdani is utilized for this FIS. In this paper, due to need of requiring to rising computation speed and declining complexity of computation, triangular membership function is used for those inputs which have been extracted from DC motor. As can be seen from Eq. (2), this part includes two main subtraction and division operators. As a result, for each part of this equation, we should apply pipeline technique.

$$f\left( {x;a, b, c} \right) = max\left( {\left( {\frac{x - a}{b - a},\frac{c - x}{x - b}} \right) ,0} \right)$$
(2)

The rest of paper is organized to subtraction and division part optimization of two inputs. Pipeline technique is provided to replace implemented subtraction and division operators with traditional ones. Since, division operator cannot be generally done in FPGA and also because of requirement to complex algorithm such as Cordic algorithm in FPGA, this part needs pipeline technique. In this paper, division operator is performed by Cordic algorithm [30].

3.2.2 Difuzzification part

In this part, the value of TSK fuzzy system output is calculated by weighted mean which includes addition, multiplication and division, according to the Eq. (4). Since, error and change error are two inputs of DC motor to fuzzy controller, Eq. (4) reformulated to simple Eq. (5):

$$W_{i} = AndMethod\left( {F_{1} \left( x \right), \, F_{2} \left( y \right)} \right)$$
(3)
$$Final\;Output = \frac{{\sum\nolimits_{i = 0}^{n} {w_{i} z_{i} } }}{{\sum\nolimits_{i = 0}^{n} {w_{i} } }}$$
(4)
$$simple\;equation = \frac{{w_{1} z_{1} + w_{2} z_{2} + w_{3} z_{3} + w_{4} z_{4} }}{{w_{1} + w_{2} + w_{3} + w_{4} }}$$
(5)

In this part, pipeline technique will be suggested in four parts of Eq. (5):

  • W calculation

  • Calculation of fraction numerator

  • Calculation of fraction denominator

  • Final result of fraction calculation

In the following essay, comparison between hardware sources consumption and growth of speed is provided in each part.

As can be seen from tables, pipeline has a basic drawback. This technique requires more hardware sources which is a result of using various registers. According to this drawback of pipeline technique, bit width reduction technique will take high importance because of reducing hardware source consumption. By rising number of required hardware sources in pipeline digital circuit, replacing these hardware resources on the FPGA surface becomes an important point.

Replacing hardware resources centrally will increase the digital circuit clock. Due to number of existing scenarios for placing hardware resources and the high number of these resources, it is impossible to manually place them. Hence, an auxiliary tool should be utilized. In this paper, by using FPGAs of Xilinx Company, fuzzy controller is implemented. Xilinx project manager is a collection of tools in Xilinx company whereby the required hardware resources to implement the proposed digital circuit can be fully optimized at FPGA surface. Finally, in Table 8, the pipeline mode and non-pipeline cases of each constructor blocks of this controller are compared. According to this table, due to width of bit and less use of mathematical operators, pipeline technique is more sufficient in rules section and output calculation. Figure 13 shows the experimental setup of the proposed scheme.

Table 8 Comparison of pipeline blocks and non-pipeline blocks
Fig. 13
figure 13

Experimental setup of the proposed scheme

4 Conclusions

This paper concentrates on applying practical techniques in DC electrical machine fuzzy controller in order to find optimum amounts of controller’s features. Also, finding logical relationship between fuzzy controller parameters and desired plans such as overshoot, rise time, settling time and convergence speed of outputs is another objective of this paper. Hereby, in the first step, comparison and examination among FISs have been done. Moreover, according to the advantages of Sugeno inference system such as lower complexity than Mamdani inference system and better features including rising time setting time and overshoot, Sugeno inference system is selected. In the next step, by use of GA, we tried to optimize the required values of the fuzzy controller to control the output speed of an electrical DC motor. Hence, a GA has been proposed which suggest strategies to rise exploitation and exploration rates, convergence rate of GA and prevent the algorithm to be trapped in local minimum. In result, these advantages of propounded GA help us to profoundly optimize the parameters of fuzzy controller. In final step, the techniques have been considered for optimally implementation of DC electrical machine fuzzy controller on FPGAs and also the relationship between required hardware sources and desirable clock for optimal implementation has been examined. The obvious feature o suggested techniques in this paper is that each of them separately has disadvantages, but, by simultaneous using these two techniques, their disadvantages will be covered. In following it, hardware sources consumption and desired clock in case without using these techniques have been compared. Eventually, the reasonable growth of hardware sources rises the performance of clock in parts of fuzzy controller.