# Design and Implementation of a Novel Intelligent Strategy for the Permanent Magnet Synchronous Motor Emulation

Authors: Hamed Zeinoddini-Meymand; Salah Kamel; Baseem Khan
Journal: Complexity
 (2022)

---

## Abstract

In this paper, an intelligent neural network-based controller is designed and implemented to control the speed of a permanent magnet synchronous motor (PMSM). First, the exact mathematical model of PMSM is presented, and then, by designing a controller, we apply the wind turbine emulation challenges. The designed controller for the first time is implemented on a Arm Cortex-M microcontroller and tested on a laboratory PMSM. Since online learning neural network on a chip requires a strong processor, high memory, and convergence guarantee, this article uses the offline method. In this method, first, for different work points, the neural network is trained by local controllers, and then, the trained network is implemented on the chip and used. Uncertainty in the parameters and the effect of load torque as challenges of control systems are applied in the proposed method, and a comparison with other methods is performed in the implementation results section.


---

## Body

## 1. Introduction

In recent decades, fuzzy logic has grown dramatically in many sciences. One of the reasons for the growth of fuzzy logic is that it does not require strong mathematics, and also, in applying fuzzy logic to different systems, a precise dynamic model of the system is not needed [1]. One of the most important reasons for the rapid growth of the use of fuzzy logic is the implementation of human thinking and reasoning as if-then rules. One application of fuzzy logic is fuzzy modeling. Fuzzy modeling involves obtaining “if-then” fuzzy rules from system input-output data, creating the basic model structure (structural identification), and model training (parametric identification) [1]. One way to obtain if-then rules and identify fuzzy model parameters is to combine fuzzy logic and neural networks. This combination can be used as an intelligent controller in various systems. In this paper, the purpose of neuro-fuzzy control is synchronous motor; so first, a brief review of recent work is presented. In [2], the permanent magnet synchronous motor dynamics is first identified by a neural network with postpropagation error training, and then, it is used to adjust the fuzzy control parameters. Using the simulation in this reference, the fuzzy neural network is compared with the PID controller, which shows that the fuzzy neural networks are able to track the reference model with acceptable accuracy as well as the metamutation problem of the PID controller. There is no neuro-fuzzy controller. In [3], TSK fuzzy control with reduction gradient training and error propagation method is used to control the six-phase permanent magnet synchronous motor.Nowadays, combined fuzzy neural methods with sliding mode control [4, 5], inverse control [6], robust control [7], H∞ [8], adaptive estimator [9], etc. to control the speed and position of the permanent magnet synchronous motor are widely used. An adaptive neural network distributed control algorithm for a group of high-order non-linear agents with nonidentical unknown control directions under signed time-varying topologies is presented in [10]. An adaptive cooperative control problem with guaranteed convergence for a class of nonlinear multiagent systems with unknown control directions and time-varying topologies is presented in [11]. In [12], the problem of neural network-based adaptive dynamic surface control for permanent magnet synchronous motors is presented. A decoupling scheme for a bearingless permanent magnet synchronous motor to achieve fast-response is presented in [13].However, implementing fuzzy neural control hardware with online training is very difficult. Although more than 20 years have passed since the hardware implementation of computational intelligence systems with online training [14], they are still used in the PID industry and fixed structure controllers because they include derivatives and it is an instantaneous update of the parameters, and despite the noise and disturbance in the physical systems, this work has not yet taken place and requires changes in the training system of neural networks and fuzzy neural networks as well as changes in the chips [15]. The combination training method of least-squares and decreasing gradient was introduced in [16]. This method has a high speed in network training and has the least hardware problems and noise cancellation in terms of implementation and has been widely used in recent years [17–22].In the present paper, the combined least-squares method and descending gradient algorithm and the error propagation method are used to train the adaptive neuro-fuzzy inference system (ANFIS). In the hybrid method, the least-squares method is used to adjust the linear parameters of the output layer, and the descending gradient algorithm is used to adjust the nonlinear parameters of the input layer, including the parameters of the input membership functions. In this paper, a new method based on the fuzzy neural adaptive network is presented offline. In this method, first, the fuzzy neural adaptive network detects changes in motor dynamics at different operating points and with different load torques (with random variable parameters) and is trained by the combined training method of least-squares and decreasing gradients. The identification method is such that for each working point, any amount of turbulence and load torque, as well as random changes of parameters, a precise local controller such as PID, LQR, and LQG is locally designed, and then, the input and output of this controller set is applied to an adaptive fuzzy neural network with combined training and the network covers all controllers. In this case, the trained network has the ability to cope with various situations and the motor speed can be controlled with high accuracy. In the following, first, the dynamic equations of the permanent magnetic synchronous motor will be expressed, and then, the structure of the fuzzy neural adaptive network and its relations will be presented, and finally, the combination of controller and motor, and simulation results will be presented.


## 2. Dynamic Model of Permanent Magnet Synchronous Motor

The dynamic model of the permanent magnet synchronous motor can be shown as follows [23]:(1)dIddt=UdL−RIdL+ωr⋅Iq,dIqdt=UqL−RIqL−ωr⋅Id−φfL⋅ωr,(2)dωrdt=1JmTe−TL−Bm⋅ωr,dθrdt=ωr,where Id and Ud are the currents and voltages of the Iq, Iq, and Uq are the currents and voltages of the q-axis, ωr is the rotor angular velocity, θr is the rotor angular position, L is inductance, R is the stator resistance, and φf is the magnetic flux of the motor. TL is the load torque, Bm is the coefficient of friction, and Jm is the inertia. The electric torque is obtained from the following equation:(3)Te=32Pφf⋅iq,where P is the number of motor poles. According to (3), by keeping the current of the d-axis constant, the torque can be controlled with the current of the q-axis. In this regard, (3) can be written as follows:(4)Te=Kt⋅iq,Kt=32P⋅φf,where Kt is a constant value, so by controlling the current iq, the torque can be controlled.


## 3. Fuzzy Neural Network

Despite the widespread growth of fuzzy logic, there is still no cinematic process for designing a fuzzy controller [1]. However, a neural network has the ability to see from the training environment (input-output pairs), to arrange its structure and adapt its interaction in some way. Therefore, this problem can be overcome by combining fuzzy logic and neural network. Fuzzy neural networks have the ability to train and extract fuzzy rules and adjust the parameters of membership functions. Figure 1 shows the structure of an adaptive fuzzy neural network with two inputs y and x and one output f.Figure 1
TSK model fuzzy neural network.For the structure of Figure1, two fuzzy rules are defined:(1)
Ifx is equal to A1 and y is equal to B1, then, f1 = p1.x + q1.y + r1(2)
Ifx is equal to A2 and y is equal to B2, then, f2 = p2.x + q2.y + r2In Figure1, the first layer is the fuzzy layer and two membership functions are provided for each of the inputs. The numeric input in this layer is converted to a fuzzy number. For example, if the membership functions are Gaussian, the output of the first layer is calculated as follows:(5)Oi1=μAikxi=exp−xi−mikσik2,i=1.2…n;k=1.2…l,where μAik is the membership function of the linguistic variable Aik related to the ith input and the kth rule, mik is the center of the Gaussian function and σik is the deviation from the Gaussian function criterion. In the second layer, fuzzy rules are created. If the AND operator is used in the second layer node, the output of the second layer is as follows:(6)Oi2=wi=μAi×μBi.In the third layer, the normalization operation is performed, so that the output of each node from the second layer is divided by the sum of all the outputs of the second layer.(7)Oi3=w¯i=wiw1+w2.In the fourth layer, the output of the third layer is multiplied by a function that is a linear combination of inputs.(8)Oi4=w¯i⋅fi=w¯ipix+qiy+ri.In a single fifth layer node, the output of all fourth layer nodes is added together.(9)Oi5=f=∑iw¯i⋅fi.To train the fuzzy neural network, a combination of the least-squares method is used to update the parameters of the fourth layer (pi, qi, ri), and the error propagation method is used to update the parameters of the Gaussian membership function (σik, mik). In the least-squares method, it is assumed that the network output is obtained as follows [6]:(10)y=θ1⋅f1U+θ2⋅f2U+…+θn⋅fnU,where U = [u1,…,un] is the input vector of the network, f1,…,fn are the specific functions of the input vector, and θ1,…,θn are also output parameters that must be updated during network training. It is assumed that for input training, the input-output pair is considered as {(ui,yi), i = 1,…,m}. (10) can be written as follows:(11)Aθ=Y,where A is a matrix m×n s as follows:(12)A=f1u1⋯fnu1⋮⋱⋮f1um⋯fnum.Also,θ is the vector parameters of the output as follows:(13)θ=θ1⋮θn.The output is a vectorm×1 as follows:(14)Y=y1⋮ym.Since there is alwaysm > n as well as the modeling error e, (11) could be written as follows:(15)Aθ+e=Y.The goal of findingθ^ is to minimize the cost function.(16)Eθ=∑i=1myi−aiT⋅θ2=eT⋅e,where ai is the ith row of the matrix A.If the cost function is minimized, then,θ=θ^ is obtained.(17)ATAθ^=ATY.If the matrixATA is not singular, θ^ is obtained by solving the following equation.(18)θ^=ATA−1⋅ATY.In equations (10)–(18), if new data is applied to the network, all of the above calculations are repeated. For this reason, it is better to use the least-squares return algorithm. The recursive least-squares algorithm is presented as follows:(19)Pk+1=Pk−Pk⋅ak+1⋅ak+1T⋅Pk1+ak+1T⋅Pk⋅ak+1,θk+1=θk+Pk+1⋅ak+1yk+1−ak+1T⋅θk,where Pk is the error variance matrix and ak+1 is the coefficient vector. For example, to estimate the parameters of the output layer of the fuzzy neural network in Figure 1, the values of vectors A and θ are as follows:(20)f=w1⋅xp1+w1⋅yq1+w1⋅r1+w2⋅xp2+w2⋅yq2+w2⋅r2,A=w1⋅xw1⋅yw1w2⋅xw2⋅yw2,θ=p1q1r1p2q2r2T.This section defines the error propagation method with a descending gradient algorithm. It is assumed that the fuzzy neural network hasL layers and the lth layer has N(l) neurons. The output of neuron i from layer l is denoted by the symbol xl.i, and the function of neuron i from layer l is denoted by the symbol fl.i.(21)xl.i=fl.ixl−1.1…xl−1.Nl−1.α.β.γ…,where α.β.γ.… are the parameters of the neurons that must be updated at each stage of training. The total number of data used to train a multiinput-multioutput network is assumed to be equal to P. Now if the pth input-output pair (1≤p≤P) is applied to the network, the sum of the error squares of all outputs related to this data is obtained as follows:(22)Ep=∑k=1NLdk−xL.k2,where dk is the optimal kth output of the network and xL,k is the actual network output of the kth neuron. Also, N(L) is the number of the network outputs. In network training with P data, the goal is to minimize the error associated with all training data, i.e., E=∑p=1PEp. This requires minimizing the error of each training data. The basis of the descending gradient algorithm and the error propagation method is based on the derivative, so that in each step the error derivative is calculated to the unknown parameter to obtain the optimal value of the unknown parameter. This starts from the output layer, and the parameters are updated to reach the input layer. The error of the ith neuron is calculated from the output layer (L) as follows:(23)∈L.i=∂Ep∂xL.i.Similarly, for theith neuron from the lth layer, the error is obtained as follows:(24)∈l.i=∂Ep∂xl.i=∑m=1Nl+1∂Ep∂xl+1.m×∂fl+1.m∂xl.i=∑m=1Nl+1∈L.i×∂fl+1.m∂xl.i.For example, ifα is the nth parameter of the lth layer, the error is obtained as follows:(25)∂Ep∂α=∂Ep∂xl.i×∂fl.i∂α=∈l.i∂fl.i∂α,∂E∂α=∑p=1P∂Ep∂α.Therefore, the following equation is used to update the parameter during the training:(26)αnew=αold+Δα,where(27)Δα=−η⋅∂E∂α.To apply the error propagation method, first consider the fuzzy neural network of Figure2 with two inputs Δe and e and the output Iq∗, with the Gaussian membership function. In this network, the number of membership functions for the input e is equal to j and for the input Δe is equal to k. Network input parameters that are updated with network training include m1.j (Gaussian membership function center for input e), m2.k (Gaussian membership function center for Δe input), σ1.j (deviation from the Gaussian membership function criterion for input e), and σ2.k (deviation from the Gaussian membership function criterion for input Δe).Figure 2
Fuzzy neural network used as controller.First, the cost function is defined as follows:(28)Ek=12Wrefk−Wak2=12e2k,where Wref is the reference speed and Wa is the actual motor speed. The fifth layer error is calculated as follows:(29)δ05=−∂E∂O05=e.The fourth layer error is obtained as follows:(30)δj.k4=−∂E∂Oj.k4=∂E∂O05⋅∂O05∂Oj.k4=1bδ04.The third layer error is obtained as follows:(31)δj.k3=−∂E∂Oj.k3=−∂E∂Oj.k4⋅∂Oj.k4∂Oj.k3=δj.k4⋅fj.k.The second layer error is calculated for each of the inputs from the following equation:(32)δ1.j2=−∂E∂Oj.k2=∑kδj.k3⋅wj.k,δ2.k2=−∂E∂Oj.k2=∑jδj.k3⋅wj.k.In equations (33)–(38), the update of the parameters of the front part and the sequence of fuzzy rules are stated, which includes the update of the parameters of the center and the width of the Gaussian function for each of the inputs [2].(33)Δm1.jk=−∂E∂m1.j=−∂E∂μ1.j⋅∂μ1.j∂m1.j=δ1.j2⋅2x1.j−m1.jσ1.j2,(34)Δm2.kk=−∂E∂m2.k=−∂E∂μ2.k⋅∂μ2.k∂m2.k=δ2.k2⋅2x2.k−m2.kσ2.k2,(35)Δσ1.jk=−∂E∂σ1.j=−∂E∂μ2.k⋅∂μ2.k∂σ1.j=δ2.k2⋅2x1.j−m1.j2σ1.j3,(36)Δσ2.kk=−∂E∂σ2.k=−∂E∂μ2.k⋅∂μ2.k∂σ2.k=δ2.k2⋅2x2.k−m2.k2σ2.k3,(37)m1.jk=m1.jk−1+μm⋅Δm1.jk,m2.kk=m2.kk−1+μm⋅Δm2.kk,(38)σ1.jk=σ1.jk−1+μσ⋅Δσ1.jk,σ2.kk=σ2.kk−1+μσ⋅Δσ2.kk.It should be noted that in the combined training method, first the parameters of the first part are considered with initial values and in a fixed form, and then, all the data are applied to the network. Finally, after calculating the parameters of the output layer, the data are applied to the network in a pattern-by-pattern manner and the nonlinear parameters of the fuzzy layer are calculated from the descending gradient algorithm by the error backpropagation method.


## 4. Use of Fuzzy Neural Network as Speed Controller of the PMSM

The structure of the drive used with the fuzzy neural controller to control the motor speed is shown in Figure3. Fuzzy neural network is first trained offline by combining two methods of least-squares and descending gradient with the error propagation method and after training the network and placing it as a controller in the block diagram of Figure 3, the motor speed can be controlled. The input signals of the controller are e and Δe, and the output signal of the controller is Iq∗.Figure 3
The structure of the used drive.In Figure3, the control inputs are obtained from the following equations:(39)ek=Wrefk−Wak,ck=ek−ek−1.In Figure3, the two PI controllers act as a flow control loop. If the id current is controlled by a zero reference current, the PMSM can be coupled and controlled by the iq current like a DC motor [24]. Figure 3 uses IGBT modules in the inverter.


## 5. Hardware Implementation

The structure of Figure3 has been used to evaluate the proposed method. Figure 4 shows the Arm Cortex-M board, and also, the laboratory setup of the PMSM control system is shown in Figure 5.Figure 4
Arm Cortex-M board.Figure 5
The setup of the PMSM control system.Specifications of the 4-pole permanent magnet synchronous motor used are described in Table1 [24].Table 1
Parameters and nominal values of the PMSM.
ParameterSymbolsValueNominal powerPn2 kWRated voltageVL-L380 VNominal streamI5 aNominal speedωr380 rad/sNominal torqueTe3.5 NmStator resistanceRq = Rd = R1.6ΩInductionLq = Ld = L0.5 mHMagnetic fluxφf0.12 WbInertiaJm0.000552 Nm/s2Friction coefficientBm0.00035 Nms/radIn the used fuzzy neural network, five membership functions are designed for each input. The membership functions used are of the Gaussian type. In Figures6 and 7, the membership functions of each of the inputs are shown.Figure 6
Membership functions for inpute.Figure 7
Membership functions for inputc.In Figure6, the input space e is divided into five parts: very small, small, medium, large, and very large. Also, in Figure 7, the input space c is divided into five parts: large negative, medium negative, small negative, negative, and zero. Table 2 shows 25 fuzzy rules. As mentioned earlier, the output of the first-order Sugeno neural-fuzzy network is a linear combination of inputs and is a nonfuzzy number. In Table 2, the linear parameters of the control signal Iq, i.e., p, q, and r are expressed for each rule, respectively.Table 2
Fuzzy rules.
e cVSSMBVBNB4 × 10−5−8×10−82 × 10−70.375−8×10−40.001910.48−0.0210.051511.01−0.0170.03759.698−0.0130.0284NM0.277−0.0010.006610.25−0.0220.083410.09−0.0250.04098.571−0.0150.03399.598−0.0090.026NS10.03−0.0460.306910.04−0.0380.09389.761−0.0220.08060.536−2×10−40.00110.9−0.0080.0285N9.981−0.220.128610.02−0.041−0.5919.585−0.0020.09100.0053000.002700Z104.0214 × 10−4103.77−0.00810−0.232−0.08310.01−1×10−4−0.02810.0100.0331Figure8 shows the speed of a permanent magnet synchronous motor using a neural-fuzzy controller.Figure 8
Reference speed and motor speed using an adaptive neural-fuzzy controller.Figure9 shows the performance of three types of controllers ANFIS, Fuzzy, and PID.Figure 9
The result of three types of controllers ANFIS, Fuzzy, and PID.In Figure10, in order to show the ability of the proposed structure to deal with uncertainty, the motor parameters R and L are halved.Figure 10
Reference speed and motor speed using ANFIS, Fuzzy, and PID by halving the (R) and (L) (motor parameters).Figures11–13 show the motor torque (Te) for normal mode, halving the parameters and doubling the parameters, respectively.Figure 11
Normal PMSM torque (parameters constant).Figure 12
PMSM torque when the parameters are halved.Figure 13
PMSM torque in the mode of doubling the parameters.Figure14 shows the performance of the three controllers ANFIS, Fuzzy, and PID for reference speed as a “step.”Figure 14
Reference speed and PMSM speed using ANFIS, Fuzzy, and PID.Figure15 is a magnification of the transient part of Figure 14.Figure 15
A magnification of the transient part of Figure14.Figure16 shows the q-axis current of all three ANFIS, Fuzzy. and PID controllers in the “step” reference input mode.Figure 16
q-axis current of all three ANFIS, Fuzzy. and PID controllers, in “step” reference input mode.Figure17 shows the d-axis current of all three controllers ANFIS, Fuzzy, and PID, in the “step” reference input mode. As can be seen, the current on the d-axis is in the mA range.Figure 17
d-axis current of all three ANFIS, Fuzzy, and PID controllers, in “step” reference input mode.Figure18 shows the PWM signal of all three ANFIS controllers, Fuzzy, and PID, in the “step” reference input mode.Figure 18
PWM signal of all three ANFIS controllers, Fuzzy, and PID, in “step” reference input mode.In Figure19, part of Figure 18 is magnified.Figure 19
Zoom part of Figure18.In the following, our proposed method is compared with the method of [15]. In Figure 20, the PMSM speed is compared exactly with the method of [15] with its frame.Figure 20
PMSM speed control with our proposed method and reference method [15].In order to better compare our proposed method in this paper with the reference method [15], it is assumed that at the moment t = 125 s, it is applied to the motor once as Tl = 2 Nm, and then, at the moment t = 175 s, it is separated from the motor. Figure 21 shows the state of motor speed following the “step” reference speed (applied from zero to 500 rpm at t = 50 s) with the above load conditions.Figure 21
Comparison of our proposed method and reference [15] in the case of load apply at t = 125 s and its removal at t = 175 s.In Figure22, Figure 21 is zoomed at t = 125 s.Figure 22
Magnification of Figure21 at t = 125 s.In Figure23, Figure 21 is zoomed at t = 175 s.Figure 23
Magnification of Figure21 at t = 175 s.As expected and shown in Figures21 to 23, the response speed of our proposed method is much faster than the reference method [15]. In general, it can be stated that in Figure 6, the neural-fuzzy controller has been able to follow the reference speed well. It should be noted that in order to train the fuzzy neural network, the input-output information of Fuzzy and PID controllers has been used. So, to put it simply, the adaptive fuzzy neural network uses the Fuzzy and PID controllers in its heart. As can be seen, the performance of the proposed method in the adaptive fuzzy neural network is better than fuzzy alone. Figures 8 and 9 showed the proper performance of the proposed method by considering the uncertainty in the parameters of the permanent magnet synchronous motor. In Figure 10, a load torque of one Nm was applied at the moment t = 100 s, which again proved the proper performance of our proposed method. In Figures 11–13, the motor torque was depicted, and finally, in Figure 14, the performance of the controllers was measured by considering the reference speed as a “step.” The simulation results showed that the performance of the control system presented in this paper is very suitable with the reference results [15], especially in the case of load application and parameter changes. Also, in reference [15], 36 fuzzy rules were used, while in our method, a total of 25 rules were defined, and in each training, the number of rules used was less than 10 fuzzy rules.


## 6. Conclusion

In this paper, a new method for using adaptive fuzzy neural network with combined training method was introduced as a speed controller for permanent magnetic synchronous motor. In this method, the adaptive fuzzy neural network, by identifying and approximating a set of several local controllers, has the ability to control the permanent magnet synchronous motor in a wide operating range and despite the uncertainty and load torque. Each of these local controllers performs well for a particular operating point. The experimental results show that despite the high ability and acceptability of PID control in indeterminate systems, the proposed method performs better because the proposed fuzzy neural network covers not only fuzzy control but also a number of other local controllers. Then, the proposed method was compared with two controllers, Fuzzy and PID, and the results show better performance of the proposed method than the two controllers. In future work, a structure based on type-2 fuzzy systems can be proposed that covers a wider range of uncertainty.



---

*Source: 4936167-2022-03-10.xml*