1 Introduction

Recently, the use of the permanent magnet synchronous motor (PMSM) in various electrical applications has increased exponentially compared to the induction motor (IM) and the direct current (DC) motor [1], that’s got to do with its robust and simple model compared to the IM, and its advantageous viability and low-cost maintenance compared to the DC motor; moreover, the diversity of controlling techniques of the PMSM makes it the more preferable choice for most systems [2, 3]. Each control technique is designed for a specific objective; however, when it comes to the overall performance, whether its speed and position tracking, or traction and transportation, field oriented control (FOC) with a non-classical speed controller is mostly the best choice [4].

FOC can be executed using three main controllers [5], two for the direct and quadratic axis currents regulation, which are usually a classical proportional–integral (PI) controllers, and one for the mechanical speed regulation, the speed controller definitely got the most impact on the performance of FOC [6], non-classical controllers such as sliding mode controller [6], fuzzy-PI controller [7], and standard fuzzy logic controller (FC) [8] are very recommended over classical controllers such as PI and proportional–integral–derivative (PID) controllers, especially for speed regulation of PMSM.

It is no doubt that the fuzzy logic controller (FC) has become one of the most promising and effectual controllers in the field of electronic and electrical engineering [9,10,11,12], due to its adaptive functioning and flexible model, the FC does not require thorough tuning to deliver an acceptable outcome; however, when tuned properly by optimizing its membership functions (MFS), and its inputs and outputs factors using an optimization algorithm [13], it can significantly surpass its standard performance.

In the past few years, optimization algorithms capability of solving complicated mathematical problems of nonlinear systems has been validated repeatedly, Yousri D, Allam D, and Eteiba M performed parameters identification of fractional order models of PMSM using a set of chaotic meta-heuristic algorithms [14]. In [15], Aguilar-Mejia O, Minor-Popocatl H, and Tapia-Olvera R published a comparison and ranking of a wide range of meta-heuristic algorithms, for tuning of PI controllers in a machine drive systems. Optimization algorithms performance varies based on the task whether its gains tuning, or parameters identification, etc., and the number of system parameters that needs solving. Particle swarm optimization (PSO), for example, is one of the most used meta-heuristic algorithms [16], it offers fast optimization with good solutions, but it struggles with systems that have too many knobs to adjust, where some algorithms like symbiotic organisms search(SOS) can provide better results [5, 17]. In the case of complicated systems, algorithms with intense exploration and fast convergence like sewing trainee-based optimization (STBO) [18] are way more competent than PSO. In [18], STBO managed to outperform many capable algorithms such as gray wolf optimizer (GWO) [19], whale optimization algorithm (WOA) [20], and genetic algorithm (GA) [21].

Many researchers have implemented meta-heuristic algorithms for the tuning of FC factors and MFS.

Quantum-behaved lightning search algorithm has been implemented for the tuning of a fuzzy-PI controller for indirect FOC of induction motor [22]. In [7], a hybrid fuzzy-PI controller with tuned MFS was used for advanced control of PMSM.

FC forms and implementation methods are very diverse [23,24,25]. In [23], a fractional order adaptive fuzzy back-stepping controller was used for speed control of PMSM. In [24], fuzzy-based and multivariable optimization approach robust control of PMSM was performed. However, the simplest and most common fuzzy speed controllers of PMSM are the standard FC with a single direct output, and the hybrid fuzzy-PI controller where the fuzzy part provides two outputs consisting of adaptive proportional and integral gains that are supplied to the PI part, which provides the controller’s output. Since the fuzzy part of fuzzy-PI controller has more outputs, its inference system, tuning difficulty, and level of complexity are way higher than the standard FC with one output.

In the literature, many papers have used the standard FC for speed control of PMSM [8, 26,27,28,29].

In [26,27,28], authors of these papers performed similar research comparing the standard FC against the conventional PI controller. In [29], a comparison of the dynamic response under load disturbances of PMSM using the standard FC and the conventional PI and PID controllers was simulated. In these research papers, the standard FC provided faster response time with better robustness; however, none of them provided an approach to design and tune the FC inputs and output scaling factors.

In [8], AliSkan I and Unsal S tested the speed control performances of the standard FC having different membership functions and inference methods.

The major drawbacks of these studies are the untested robustness against internal disturbances such as motor parameters changes, and the lack of MFS tuning since the full potential of the standard FC can only be achieved with deformed and precisely tuned MFS [13, 22, 30].

Fig. 1
figure 1

FOC MATLAB/SIMULINK representation

In [31], a hybrid algorithm was proposed for the tuning of the output MFS of the standard FC, the main focus of this paper was the proposed algorithm and not the performance of the FC since the output of the controller was saturated using MATLAB/SIMULINK saturation block, which limits the controller’s output, and does not showcase its real performance; moreover, the speed tracking was so poor because it delivered a very high steady-state error despite the absence of high external disturbances, tracking of a speed reference higher than the rated speed, or any parameters changes, which could be a result of poorly tuned output MFS, or the untuned inputs MFS.

Thus, this paper main contribution is the design and development of a robust and a very efficient standard FC with thoroughly tuned inputs and output membership functions (FC-TMFS) for speed control of PMSM. In order to determine the best possible parameters for the aforementioned controller, a hybrid algorithm called (ST-PS-SO) was proposed, to investigate the efficiency of the proposed algorithm, when simulating FOC of PMSM, ST-PS-SO-based FC-TMFS (SPS-FC-TMFS) was compared to PSO-based FC-TMFS (PSO-FC-TMFS), STBO-based FC-TMFS (STBO-FC-TMFS), and SOS-based FC-TMFS (SOS-FC-TMFS), with the task if minimizing a specific objective function(OBJ). Finally, running a MATLAB/SIMULINK simulation of FOC of PMSM, FC-TMFS with the best-obtained parameters was compared to the conventional FC, PI, and PID controllers, the simulation included a wide range of speed and load charge references, as well as a massive change in the system parameters to examine the robustness of the designed controller. Processor-in-loop (PIL) simulation was also applied to confirm the integrity of the designed controller.

2 Modeling of the PMSM

Using the dq0 frame reference, equations of PMSM model can be written as in [(1),(2),(3),(4)].

$$\begin{aligned} v_d= & {} Ri_d-L_d\frac{\hbox {d}i_d}{\hbox {d}t}-\omega L_qI_q \end{aligned}$$
(1)
$$\begin{aligned} v_q= & {} Ri_q-L_q\frac{\hbox {d}i_q}{\hbox {d}t}-\omega L_dI_d+\omega \phi \end{aligned}$$
(2)
$$\begin{aligned} T_e= & {} \frac{3}{2}P_{\textrm{n}}[(L_d-L_q)i_di_q+\phi i_q] \end{aligned}$$
(3)
$$\begin{aligned} j\frac{\hbox {d}\omega _r}{\hbox {d}t}= & {} T_e-T_l-B\omega _r \end{aligned}$$
(4)

where \(v_d\) and \(v_q\) represent the voltages, \(T_e\) and \(i_q\) represent the currents. \(L_q\) and \(L_d\) are the stator inductances, \(\omega \) is the electrical velocity, \(\omega _r\) is the mechanical velocity, \(P_{\textrm{n}}\) is the number of pair of poles, \(\phi \) is the flux induced by the permanent magnet, \(T_e\) is the electromagnetic torque, \(T_l\) is the load torque, B is the motor viscous friction, and J is the motor inertia. The output of the FC is the electromagnetic torque \(T_e'\) required to deliver the targeted speed, after multiplying it by \(Kt=\frac{2}{3(P_{\textrm{n}}\times \phi ))}\). As in (5) and Fig. 1, we get the quadratic axis current reference \(i_q'\).

$$\begin{aligned} i_q'=T_e'\times Kt \end{aligned}$$
(5)

Figures 1 and 2 present FOC and PMSM MATLAB/SIMULINK models, respectively.

Fig. 2
figure 2

PMSM SIMULINK model

3 Field oriented control of PMSM

FOC is a vector control technique used to command and drive AC motors, compared to DTC, FOC is more complicated because of its extra two controllers, but it compensates that by delivering a better and more precise current control, and way less electromagnetic torque ripples; moreover, with the introduction of optimization algorithms, the complexity of FOC became less of a concern since the tuning of its controllers parameters became way easier. The goal of FOC is to simplify the control of PMSM by severing the link between the direct and quadratic axis voltages, in order to do that, a decoupling block is used as in Fig. 1 and [32], along with a closed loop control of \(i_d\) to drive it into a value very close to zero, hence making the induced electromagnetic torque linear with \(i_q\), and easier to control. With \(i_d\backsimeq 0\), (3) could potentially be reduced to (6):

$$\begin{aligned} T_e\backsimeq \frac{3}{2}P_{\textrm{n}}(\phi i_q) \end{aligned}$$
(6)

Figure 1 illustrates in detail the implementation of FOC of PMSM in MATLAB/SIMULINK software.

4 Hybrid ST-PS-SO optimization algorithm

Optimization algorithms are tools designed to solve mathematical and physical problems, either by minimizing or maximizing a certain OBJ, with the aim of finding an optimal solution, through exploring and exploiting a bounded interval of possible solutions. Since each algorithm has its distinctive approach of exploiting and exploring, their performance varies a lot based on the problem structure, for example, PSO is a heavy exploiting algorithm, SOS is a heavy exploring algorithm, and STBO is somewhere in between. ST-PS-SO is a hybrid three-phase algorithm specifically built for the tuning of FC-TMFS, for speed control of PMSM, each phase operates based on one of the three parent algorithms, STBO, PSO, and SOS. Any optimization algorithm can only be initiated by generating a specific number of search agents denoted by \(X_{i....N_{\textrm{s}}}\), where i is the current search agent, and \(N_{\textrm{s}}\) is the amount of search agents, each search agent begins with a random matrix of a possible solution, which is updated every iteration through mathematical equations, the algorithm keeps updating solutions until a certain criteria is met, or until it completes the allowed number of iterations. Finally, a global optimum is deduced from the search agent with the best fitness; in the case of FOC of PMSM, the smaller the OBJ is the better is the fitness.

4.1 ST-PS-SO phases

This section presents the phases of ST-PS-SO in detail.

4.1.1 Phase I

Phase one of ST-PS-SO is a guided exploration that utilizes the first phase of STBO [18], which is called the training phase. In this phase, the current search agent \(X_i\) is called a trainee, a set of search agents with better fitness than \(X_i\) is established and named S, each agent from S represents a possible instructor for \(X_i\), then a random instructor \(X_j\) from S is chosen to help \(X_i\) improve its fitness using (7).

$$\begin{aligned} X_i^P=X_i+r_i\times (X_j-I_i\times X_i) \end{aligned}$$
(7)

where \(I_i\) is either 1 or 2, \(r_i\) is a random number equals or between 0 and 1, \(X_i^P\) is the potential new solution for \(X_i\) depending on:

$$\begin{aligned} X_i= {\left\{ \begin{array}{ll} X_i^P,&{} \text {if } F_i^P< F_i\\ X_i, &{} \text {otherwise} \end{array}\right. } \end{aligned}$$

where \(F_i^P\) is the new candidate fitness value and \(F_i\) is \(X_i\) fitness value.

4.1.2 Phase II

Phase two of ST-PS-SO is a partial exploration that imitates the third phase of SOS [5] which is called parasitism phase. Instead of updating the whole matrix of the search agent \(X_i\), parasitism phase replaces the value of one of the dimensions of \(X_i\) randomly, by a new random value from the allowed interval; however, in this system, parasitism phase is set to only update the parameter of the output gain factor denoted by \(X_{i_{\textrm{OUT}}}\) since it is the hardest parameter to tune due to its wide interval of possible values. \(X_{i_{\textrm{OUT}}}\) updates based on:

$$\begin{aligned} X_{i_{\textrm{OUT}}}= {\left\{ \begin{array}{ll} X_{i_{\textrm{OUT}}}^P,&{} \text {if } F_{i_{\textrm{OUT}}}^P< F_{i_{\textrm{OUT}}}\\ X_{i_{\textrm{OUT}}}, &{} \text {otherwise} \end{array}\right. } \end{aligned}$$

4.1.3 Phase III

Phase three of ST-PS-SO is a fast exploit phase mimics the whole algorithm of PSO [16], PSO uses the memory of each search agent to perform a fast and efficient convergence toward a global optimum using (8), (9), and (10)

$$\begin{aligned} V_i^P= & {} r_1\times V_i\times \omega + c_1\times r_2\times (X_i^{\textrm{Pbest}}-X_i)\nonumber \\{} & {} + c_2\times r_3\times (X_i^{\textrm{Gbest}}-X_i) \end{aligned}$$
(8)
$$\begin{aligned} \omega= & {} \omega \hbox {Max} - t \times ((\omega \hbox {Max}-\omega \hbox {Min})/\hbox {Maxiter}) \end{aligned}$$
(9)
$$\begin{aligned} X_i^P= & {} X_i + V_i^P \end{aligned}$$
(10)

where \(r_1\), \(r_2\), and \(r_3\) are random numbers from [0–1], t is the current iteration, \(\hbox {Maxiter}\) is the maximum number of iterations, \(\omega \hbox {Max}=0.9\), \(\omega \hbox {Min}=0.4\), and \(c_1=c_2=2\). \(X_i^{\textrm{Pbest}}\) represents the parameters of the best fitness achieved by \(X_i\), and \(X_i^{\textrm{Gbest}}\) represents the best fitness achieved by the whole population of search agents so far, \(V_i\) is the previous iteration velocity of the current search agent, and \(V_i^P\) and \(X_i^P\) are the new velocity and position of \(X_i\), respectively.

4.2 ST-PS-SO algorithm

This section describes the workflow of ST-PS-SO in the following pseudo-code (1).

Algorithm 1
figure a

ST-PSO-SOS pseudo-code

5 ST-PS-SO-based FC-TMFS

The special thing about the standard FC is its simplicity compared to other types of fuzzy controllers, and its robustness and capability of handling linear and nonlinear systems, without the need of an exact identification of the system parameters [33]. Fuzzy controllers can determine their outputs based on the assigned inputs and inference system, and a set of linguistic rules that are inspired from humans way of thinking [34].

5.1 Design of SPS-FC-TMFS for speed control of PMSM

For speed control of PMSM, SPS-FC-TMFS was based on MAMDANI inference system. SPS-FC-TMFS has two inputs and one output, each has their own shape of deformed and tuned MFS. The MFS of the inputs and outputs of SPS -FC-TMFS are depicted in Figs. 3, 4 and 5.

Fig. 3
figure 3

First input of SPS-FC-TMFS: speed error

Fig. 4
figure 4

Second input of SPS-FC-TMFS: derivative of speed error

Fig. 5
figure 5

Output of SPS-FC-TMFS: \(T_e\) reference

From here on the standard conventional fuzzy controller will be addressed by FC, and the standard fuzzy controller with tuned membership functions will be addressed by FC-TMFS.

The linguistic rules of SPS-FC-TMFS are presented in Table 1. Figure 6 depicts MATLAB/SIMULINK representation of the standard fuzzy speed controller.

5.2 Process of tuning SPS-FC-TMFS for speed control of PMSM

In this section, the performances of SP-PS-SO, STBO, PSO, and SOS, when tuning FC-TMFS for speed control of PMSM were compared, the selected OBJ is represented in (11), based on [5]. The amount of search agents is 50, and iterations count is 200.

$$\begin{aligned} \hbox {OBJ}= & {} \int 2\times \mid (\hbox {error}_{\textrm{speed}})\mid + \int t\times \mid (\hbox {error}_{i_d})\mid \nonumber \\{} & {} + \int t\times \mid (\hbox {error}_{i_q})\mid \end{aligned}$$
(11)

Note that the inputs of the FC-TMFS were normalized using MATLAB/SIMULINK saturation blocks, where input one and input two are limited within the intervals [-120; 120] and [-0.292; 0.292], respectively, the output was not saturated. PI controllers of the direct and quadratic axis currents were pre-tuned. The parameters of the tested PMSM are presented in Table 2.

Table 1 The rules set of SPS-FC-TMFS

The computational complexities of the update processes of SP-PS-SO, STBO, PSO, and SOS are O(3NmT), O(3NmT), O(NmT), and O(4NmT), respectively, where N is \(N_{\textrm{s}}\), m is the number of the variables, and T is the iterations count. In order to balance the scales, PSO was run with three times the search agents count of other algorithms, which makes O(3NmT) its new computational complexity.

The progress of minimizing OBJ is depicted in Fig. 5, where we can clearly see that SP-PS-SO is the most successful when tuning FC-TMFS.

Table 3 shows \(N_s\) and the global optimum OBJ of each controller.

5.3 Performance of SPS-FC-TMFS compared to other algorithms-based controllers

In order to inspect and evaluate the performance of FC-TMFS obtained optimal parameters of each algorithm, 4 s of MATLAB simulation of FOC of PMSM was run with a sudden increase in the load charge, and multiple changes applied to the speed reference point. Table 4 presents the speed and load charge values during the simulation.

Fig. 6
figure 6

MATLAB/SIMULINK fuzzy speed controller

Table 2 Parameters of the motor
Fig. 7
figure 7

Progress of tuning of each algorithm

Table 3 Tuning performance and the size of \(N_s\) of each algorithm
Table 4 Speed and load charge references during the simulation

Figure 8 depicts the speed curves achieved in the simulation, where we can see that SPS-FC-TMFS have executed a very precise speed tracking with 0% overshoot. In Fig. 8a, d, and e, STBO-FC-TMFS and SOS-FC-TMFS performed similarly with fast response time but with a slight 0.5% overshoot after every sudden change in speed reference, whereas PSO-FC-TMFS performed poorly and could not handle the sudden changes in the speed setpoint, resulting in a very significant steady-state error, especially after the increase in the load torque, which is highlighted in Fig. 8b.

In Fig. 9, after analyzing the induced \(T_e\) of each controller, we can see a clear win for SPS-FC-TMFS, since it delivered the most accurate load charge tracking and overshoot suppression, STBO-FC-TMF and SOS-FC-TMFS came second with relatively similar results, and PSO-FC-TMFS could not provide a satisfactory and decent results due to its slow response time.

Fig. 8
figure 8

Speed tracking performance of each controller

Fig. 9
figure 9

Induced torque during the change of load charge and speed reference

5.4 Performance of FC-TMFS compared to conventional FC, and the classical PID and PI controllers

This section presents a very comprehensive and intense simulated comparison between FC-TMFS, the conventional FC, and the classical PID and PI controllers. The conventional FC was tuned using ST-PS-SO algorithm, FC inputs scaling is identical to FC-TMFS; however, its output factor and the shape of its MFS are completely different than the ones of FC-TMFS. Tables 5 and 6 present the parameters of each speed controller, along with the parameters of the used currents controllers.

Note that all controllers were tuned with the aim to minimize the response and settling time, and suppress the overshoot of speed tracking as much as possible.

Table 5 Parameters of FC-TMFS and the conventional FC
Table 6 Parameters of the classical PID and PI controllers

5.4.1 Variable speed reference with no load torque

After applying a variety of speed references, we got the results of response time and overshoot percentage of each controller in Tables 7 and 8.

Table 7 Settling time
Table 8 Overshoot percentage
Fig. 10
figure 10

Speed tracking performance with a fixed load charge and a variable speed reference

Table 9 Speed tracking steady-state error under variable charge load
Fig. 11
figure 11

Speed tracking performance with a variable load charge and a fixed speed reference

In Fig. 10, as expected, after every sudden change of the speed reference, the classical PI controller responded poorly with a massive overshoot and undershoot [35], the classical PID managed to lessen the overshoot but at the cost of a very critical kick-back effect [36].

Although the conventional FC managed to partially suppress the overshoot, it still had some flaws in terms of settling time. FC-TMFS, however, delivered a flawless speed tracking performance, outmatching all other controllers with faster settling time, and way better overshoot rejection, which is highlighted in Fig. 10a–d, and in Tables 7 and 8.

5.4.2 Fixed speed reference with a variable load torque

Table 9 presents the steady-state error of speed tracking in accordance with every increase in the load charge.

Figure 11 presents the speed tracking achieved with every controller under various load charges. Based on Fig. 11a, b and c, FC-TMFS managed to deliver the best overall results, which is due to its fine-tuned MFS and output gain. The conventional FC could not keep a tight steady state error, mainly because of its symmetric and un-optimized MFS. The classical PID performance was close to FC-TMFS; however, it still showed a significant kick-back effect but only in the case of small load charges. Similarly to the conventional FC, the classical PI also could not effectively handle the increasing value of the load charge, which is mainly because it was tuned to suppress the overshoot, and respond as fast as possible, but because it lacks a derivative component, it cannot deliver a precise speed tracking, and simultaneously handle the introduced load charges.

Fig. 12
figure 12

Speed tracking performance after significantly increasing the values of \(L_q\), \(L_d\), and R

Fig. 13
figure 13

The produced torque after significantly increasing the values of \(L_q\), \(L_d\), and R. a FC-TMFS produced \(T_e\). b The conventional FC produced \(T_e\). c PID produced \(T_e\). d PI produced \(T_e\)

5.4.3 Fixed speed reference and load charge with a significant increase in the motor parameters

In order to further verify the robustness of the designed controller, an analysis of speed control of PMSM with a fixed speed reference point of 100rad/s, fixed load torque of 0.5N, and a massive increase in the motor internal parameters was simulated using FC-TMFS, the conventional FC, PI, and PID individually.

By increasing the values of the quadratic and direct axis inductances, and the stator resistance, we can determine if these controllers can handle high internal disturbances. The new values of \(L_q\), \(L_d\), and R are 0.022H, 0.013H, and 3.5\(\varOmega \), respectively.

Figure 12 presents the speed tracking performance of each controller after introducing a significant amount of internal disturbances; obviously, despite the drastic increase in the motor parameters, FC-TMFS still managed to deliver the targeted speed with extreme precision and minimum overshoot and steady-state error, whereas all the other controllers struggled and settled at around 20% of the targeted speed.

The induced electromagnetic torque is presented in Fig. 13. In Fig. 13b, c, and d, the conventional FC, PID, and PI speed controllers produced a very unreliable \(T_e\), since it kept on oscillating with a very dangerous frequency and amplitude, whereas in Fig. 13a, FC-TMFS managed to produce an ideal and compact electromagnetic torque.

5.5 Processor-in-loop simulation of FC-TMFS

In order to confirm the applicability of the designed FC-TMFS, TMS320F28379D board was used to replicate and replace: (FC-TMFS speed controller, PI currents controllers, decoupling block, and SVPWM block), to perform a full PIL control of the simulated PMSM and the three levels inverter. Figure 14 presents and highlights the main components of PIL simulation.

Fig. 14
figure 14

Processor-in-loop FOC of PMSM

Figure 15 compares the performance of PIL with the standard full MATLAB simulation which is called software-in-loop (SIL) simulation, the comparison was based on 0.4s of FOC of PMSM with a fixed speed reference, and an increase in the load torque at 0.2s. At startup, based on Fig. 15a, b, and c, SIL produced speed settled faster than PIL by 0.001 s; however, PIL startup current and electromagnetic torque were 30% less than SIL, at steady state both methods delivered similar results, which strengthens the validity of the proposed controller.

Fig. 15
figure 15

PIL and SIL FOC of PMSM. a Produced mechanical speed. b Induced id current. c Produced electromagnetic torque

6 Conclusion

In this paper, a hybrid meta-heuristic algorithm called ST-PS-SO was proposed for the tuning of the output gain, and the MFS of FC-TMFS for speed control of PMSM. With the help of MATLAB/SIMULINK simulation, the superiority of the proposed algorithm when tuning FC-TMFS was validated against STBO, PSO, and SOS, which is due to ST-PS-SO combination of guided and efficient exploration, and fast convergence. Then, ST-PS-SO-based FC-TMFS (SPS-FC-TMFS) was thoroughly compared to the conventional FC, and the classical PID and PI controllers. The proposed SPS-FC-TMFS managed to utterly outperform every controller with way more durable speed control of PMSM, no overshoot/undershoot problems, and way less steady-state error with or without a charge load. Then after applying an enormous increase to the parameters of the motor, SPS-FC-TMFS still managed to start and track the setpoint of speed reference, while the conventional FC, PI, and PID destabilized and caused the system to malfunction and fail to deliver a reliable mechanical speed, which again proves the significance of the proposed algorithm, and the necessity of tuning the MFS of the standard FC. Finally, results of processor-in-loop (PIL) simulation of the designed controller were presented and analyzed to further enhance the credibility and practical suitability of speed control of PMSM with the proposed SPS-FC-TMFS. Although the performance of FC-TMFS is very satisfactory, it can still be further improved by using a Type-2 standard FC or tuned using newer optimization algorithms.