Applied Mathematics for Engineering Problems in Biomechanics and Robotics 2020
View this Special IssueResearch Article  Open Access
Nguyen Vu Quynh, "The Fuzzy PI Controller for PMSM’s Speed to Track the Standard Model", Mathematical Problems in Engineering, vol. 2020, Article ID 1698213, 20 pages, 2020. https://doi.org/10.1155/2020/1698213
The Fuzzy PI Controller for PMSM’s Speed to Track the Standard Model
Abstract
This paper proposes a fuzzy PI controller to control the speed of a permanent magnet synchronous motor (PMSM). The structure of the system includes the speed loop controller (SLC) and the current loop controller (CLC). The speed loop controller is the fuzzy PI and standard model (SM). The CLC includes vector control and the space vector pulse width modulation (SVPWM). It compiles two closedloop control systems for the PMSM. This research uses a very highspeed integrated circuit hardware description language (VHDL) to implement the proposed algorithm and embed it into Matlab/Simulink for simulation. Based on the PMSM parameter, this article tests the controller’s correctness with some of the load cases by changing the combined inertia and viscous friction of rotor and load. After success in simulation, the system is tested again by experiment on the FPGA kit. The simulation and experiment results show that when the load changes, the PMSM speed is still stable. The novelty of this research is that it compares two kinds of controllers between simulation and experiment results.
1. Introduction
The PMSMs are commonly used in systems requiring high precision such as the robot and mechanical processing. However, there are many uncertainties, for example, noise, external load, and friction force. They affect the performance quality of the system. Many intelligent control techniques such as fuzzy, neural network, and genetic algorithm have been developed to cope with those problems [1–4]. They helped to control precisely the speed and position of the motor. The FPGA supplied a solution for the implementation of the algorithm. Especially, FPGA has a programmable hardwired feature, fast calculation ability, low power consumption, and higher density. There were many types of research on intelligent controllers such as fuzzy control, sliding fuzzy control, artificial intelligence, and adaptive control based on the FPGA platform to control multiaxis robots for improving precision in machining and assembly [5–9]. The fuzzy control method is an intelligent control system, with an inference mechanism from experts’ control experience. However, obtaining fuzzy sets and optimal membership functions are not easy. To resolve this problem, the fuzzy knowledge base values were adjusted appropriately based on the feedback system parameter [10, 11]. This research proposes a drive system to overcome the slow response and tuning problems of the conventional PI speed controllers without any mathematical calculations [12, 13]. However, the aforementioned research studies do not check with the massive change of load. This research applied a fuzzy PI controller, current controller, and SVPWM for PMSM drive. The contents of the article include, firstly, the mathematical model of PMSM, SVPWM algorithm, vector control method, and fuzzy PI controller. Secondly, VHDL is used to program all systems. Finally, the article presents a simulation on Matlab/Simulink and experiment on FPGA kit results.
Figure 1 shows the block diagram of the proposed algorithm. The speed of the motor () is fed back to the speed loop controller to compare with the output of the standard model (SM). The fuzzy PI controller generates the signal to minimize the error between rotor speed and SM. The adjustment mechanism keeps the motor speed stable when the load changes. The threephase stator currents (i_{a}, i_{b}, i_{c}) and rotor flux angle () are fed back to the current controller to calculate the generated voltage vector for SVPWM. The SVPWM generated the electric current to control threephase inverter for providing power to the motor.
2. The Vector Controller Design for PMSM
2.1. The PMSM Mathematical Model
in which L_{q} and L_{d} are the inductances on qaxis and daxis; R is the resistance of the stator windings; i_{q} and i_{d} are the currents on qaxis and daxis; and are the voltages on qaxis and daxis; is the permanent magnet flux linkage; p is the number of pole pairs; and is the rotational speed of the rotor.
2.2. The Vector Controller
The current controller of the PMSM drive in Figure 1 is based on a vector control approach. The current controller structure includes Clark, Park, inverse Park, and inverse Clark transformation, two PID controllers, and sine/cosine of flux angle. Threephase current is fed back through vector control, enabling controlling current , which helps control the threephase motor similar to a DC motor. The torque of the PMSM is controlled via current on the qaxis (i_{q}). The vector control is described below.
The Clark transformation converts the stationary abc frame (i_{a}, i_{b}, i_{c}) to stationary αβ frame (i_{α}, i_{β}).
The Park transformation converts the stationary αβ frame (i_{α}, i_{β}) to synchronously rotating dq frame (i_{d}, i_{q}).
The inverse Park transformation converts a rotating reference dq frame (, to stationary αβ frame (, ).
The inverse Clark transformation converts a stationary αβ frame (, ) to stationary abc frame (, , ).
Electromagnetic moment of the motor could be calculated using the following formula:
The mathematical equation of the motor under the loadbearing condition iswhere T_{e} is the motor torque; J_{m} and F are the inertia and viscous friction of rotor and load; T_{m} is the shaft mechanical torque; and K_{t} is the torque constant.
3. The SVPWM Algorithm Design
The SVPWM is a control technique widely used in power electronic equipment control. The idea of the method is to create a continuous shift of the space vector equivalent of the voltage vector of the inverter on the circle orbit (Figure 2). With the steady shift of the space vector on a circular orbit, the higher harmonics are removed, and the relationship between the control signal and output voltage amplitude became linear. In this article, the SVPWM technique is used to create a vector to control the inverter using IGBT power switches.
(a)
(b)
The phasetophase voltage and the phasetoneutral voltage of the motor:in which a, b, and c are switching vectors of IGBT power electronic switches.
There are six power IGBTs in the voltagesource inverter. When the upper switch is active, the corresponding lower switches must be turned off. Theremust be coordinated delay time (dead band) between the opening and closing of two switches on the same phase.
The eight primary space vectors () are shown in Figure 2(a). The output voltage () is located at one of the six sectors (S_{1}, S_{2}, S_{3}, S_{4}, S_{5}, S_{6}) at any given time.where x ≠ 0, 7 and T is half of the PWM period, T_{0} = T − T_{1} − T_{2}. For example, in the S_{3} sector, the output voltage can be calculated with and vectors (Figure 2(a)).
From equations (9)–(11), the output voltage and the value of T_{1} and T_{2} can be obtained:
Similarly, the values of T_{1} and T_{2} at the other sectors shown in Table 1 with T_{x}, T_{y}, and T_{z} arewith the condition T_{1} + T_{2} > T; T_{1} and T_{2} are modified as follows:

The duty cycles (Ta_{on}, Tb_{on}, Tc_{on}) in Figure 2(b) can calculated as follows:
PWM1, PWM2, and PWM3 with the duty time at and and zero vector ( and ) are T_{1}, T_{2}, and T_{0}, respectively. The values of CMP_{1}, CMP_{2}, and CMP_{3} at each sector are shown in Table 2. For quickly determining the sector, (5) (inverse Clark transformation) is modified as follows:

We can determine the sectors S_{1}–S_{6} (Figure 3) according to the rule below:
The sector of SVPWM is defined by this equation: sector = a + 2b + 4c. From equations (13)–(15) and (21), we have
The implementation of SVPWM by VHDL can be summarized below:(i)From the value of , , and , we determined the sector as (22).(ii)Calculate the value of T_{x}, T_{y}, and T_{z} from (23).(iii)Select T_{1} and T_{2,} in Table 1.(iv)Calculate the duty cycle (Ta_{on}, Tb_{on}, and Tc_{on}) from equations (18)–(20).(v)Select comparative value (CMP_{1}, CMP_{2}, and CMP_{3}) at the duty cycles from Table 2.
4. Standard Model (SM)
The SM is the standard speed for PMSM. The output of the SM is increase and tangent to the set value at the input. To build the SM to meet the above requirements, we used the typical secondorder system:where are the natural frequency and damping ratio, respectively. Using the bilinear transformation, we obtained the discrete function in Z domain and difference equation:with coefficients: a_{0} = 0.0077, a_{1} = 0.0153, a_{2} = 0.0077, b_{1} = −1.6496, and b_{2} = 0.6803.
The error between the output of SM and the rotor speed is supplied to the fuzzification and the fuzzy adjustment mechanism function of the fuzzy PI controller. Figure 4 shows the SM; it does not change the rising time, zero steadystate value, and overshoot when the system is running. Figures 5 and 6 show a finite state machine (FSM) and the VHDL code to describe the SM, respectively.
5. Structure of Fuzzy PI Controller
The structure of the fuzzy PI controller includes fuzzification, fuzzy inference mechanism, defuzzification, fuzzy knowledge base, fuzzy adjusting mechanism, and the PI controller (Figure 1).
The rotor speed () is fed back to SLC for comparison with the output of SM and an error signal (e) is generated, and the signal changes over time (de). Based on the e and de signal, the fuzzy PI controller generates the signal to control the motor's speed. This signal is defuzzified and then amplified by the PID controller. When the motor had a heavy load or light load, the difference between rotor speed and output of SM increased, the fuzzy adjustment mechanism (figure 1) changes the knowledge base of the fuzzy PI controller. With this method, the motor speed is still in the balance.
Fuzzy PI controller used singleton fuzzy rule, and the method of the average center solution with input linguist value includes
In Figure 7, the values e, de, and u_{f} are the input and output of fuzzy controller. Their linguist values E and dE are (A_{1}, A_{2}, A_{3}, A_{4}, A_{5}, A_{6}, A_{7}) and (B_{1}, B_{2}, B_{3}, B_{4}, B_{5}, B_{6}, B_{7}), respectively. During each cycle, there are only two E and dE values that are supplied to the fuzzy PI controller (Figure 7). From the values of E and dE, based on membership functions, we can calculate the values of with the formula below:
Membership function has the shape of the symmetrical triangle, and control rules have the form
Crisp value in the output of the fuzzy controller:where and are adjustable parameters in the adaptation mechanism. Also, it can be obtained by the equations (28)–(31). Therefore, it is straightforward to obtain in (33).
The purpose of the fuzzy adjustment mechanism is to create the signal to adjust the fuzzy knowledge base of the fuzzy PI controller so that the error between the speed of the rotor and the output of the SM is the smallest. We use the method of gradient descent to determine the adaptive control law for the system.
Definition of instantaneous value function:
Parameter C_{m,n} is determined by the variation of the instantaneous value function.in which α shows the learning rate of the system.
By taking Laplace and bilinear transform of (7), we obtained a discrete function in the Z domain of PMSM.in which T is a sampling cycle and z^{−1} is a stage of delay time. The equation describes the relationship between and u_{f}:in which K_{p} and K_{i} are the coefficients of the PI controller and u_{f} is the output function of the fuzzy PI controller.
From (36) and (37), we get the function between ω_{r} and u_{f}:in which ,.
Variation of the instantaneous value function J (k + 1) from (34) is
From (35), (38), and (39), the parameters of the fuzzy PI controller in (33) could be adjusted through the function.
6. Implementation on FPGA
The proposed algorithm has been embedded in one FPGA chip. The architecture of FPGA is shown in Figure 8. The FSM sequential programming technique was used to describe control algorithms. The internal circuit of the proposed algorithm includes one circuit of the SLC and one circuit of the CLC.
Figure 8(a) shows the implementation of FPGA for the PMSM speed controller. CLK and CLK_40ns are the input clocks (50 MHz and 25 MHz) to supply all modules. The command speed and rotor speed (, ) with 16 bit length are the input of the SLC. The threephase currents (i_{a}, i_{b}, i_{c}) and rotor flux angle (θ_{e}) with 12 bit length are the input of the CLC. The 6 PWMs are the output of SVPWM.
In Figure 8(b), there are 33 steps to carry out the fuzzy PI controller. The steps s_{0}–s_{5} compute SM, and the steps s_{6}s_{7} calculate the rotor speed error with SM and error change. The steps s_{8}–s_{11} compute the fuzzification. The step s_{12} looks up the fuzzy table to select four values of c_{m,n} based on i, j obtained from s_{11}. The steps s_{13}–s_{21} compute the defuzzification function. The steps s_{22}–s_{32} turn the PI and turn the fuzzy rule parameters.
Figure 8(c) shows the design of SVPWM with 12 kHz frequency and 1.2 μs dead band. The input of SVPWM is , , and with 12 bit length.
Figure 8(d) computes the current vector controller, and it takes 24 steps. The steps s_{0}s_{1} look up the table to take the value of sine and cosine functions. The steps s_{2}–s_{8} calculate the Clark and Park transformations. The PID controller turns the current on d and qaxis from step s_{9}–s_{14}. The steps s_{15}–s_{23} calculate the inverse Park and modified inverse Clark transformations.
The data type in vector control and SVPWM for PMSM is 12 bits. The data type is designed with 16 bit length for the fuzzy PI controller and SM. Each clock pulse in the FPGA is 40 ns to complete a command. There are 33 steps (1.32 μs) and 24 steps (0.96 μs) to implement the SLC and the current vector controller, respectively. It does not lose any performance because the operation time of fuzzy PI with 1.32 μs is much less than the sampling time of the speed controller (2 kHz).
Although the control algorithm of this research by using the fuzzy PI controller is quite complicated, using the FSM description in stepbystep order reduced the execution time of coding. The simulation was performed on Matlab/Simulink/ModelSim for adjusting and verifying the controller’s parameters and checking the accuracy of the proposed algorithm. The ModelSim software was embedded in Matlab/Simulink for simulating the whole system. The feedback signals, PMSM model, and inverter are designed on Simulink. After success in simulation, the whole VHDL code is downloaded to the FPGA board for testing again by experiment.
7. Simulation Work
The simulation is demonstrated in this section to confirm the effectiveness of the proposed architecture. In simulation work, five steps are used to confirm the effectiveness of the system. In the first step (Figure 9), the generation of SVPWM function is firstly tested, and its block diagram includes inverse Clarke and inverse Park coordinate transformation, sin/cosine function, and SVPWM (Figure 9(a)). In Figure 9(b), the EDA simulator link for ModelSim executes the cosimulation using VHDL code, which describes the function of the block diagram in Figure 9(a). The switching frequency and dead band in SVPWM are designed with 16 kHz and 1.2 μs, respectively. The input signal i_{q} is set to a value varying from 0.1 to 0.4, i_{d} is chosen to be zero, and the address () is generated from 0 to 360° with increment by one. The PWM1–PWM6 outputs can be generated through the computation in ModelSim. Further, PWM1, PWM3, and PWM5 are serially connected to the RC circuit (R = 10 Ω, C = 47). The saddle waveform of PWMs is shown in Figure 9(c).
(a)
(b)
(c)
In step 2, the inverter and PMSM are added to step 1. A real rotor flux angle replaces the address. The block diagram of this step is shown in Figure 10(a), and the Simulink model is shown in Figure 10(c). This step confirms the correctness of SVPWM on PMSM again. The rotor speed is shown in Figure 10(b), and it follows the value of i_{q} at the input.
(a)
(b)
(c)
In step 3, the PI speed controller is applied to the system, and the real rotor speed is fed back to the speed controller. The block diagram of this step is shown in Figure 11(a), and the Simulink model is shown in Figure 11(c). In this step, we can check the speed response of PMSM. The rotor speed can follow well the step response at the input (Figure 11(b)).
(a)
(b)
(c)
In step 4, the threephase stator currents are fed back and applied through Clack and Pack transformation. The results of that transformation are compared with i_{d} and i_{q} obtained from the motor. Then, i_{d} and i_{q} are fed back to the PI controller in the current loop to create the completed system. The block diagram of this step is shown in Figure 12(a), and the Simulink model is shown in Figure 12(b). In this step, the rotor speed also tracks the step response perfectly (Figure 12(c)). Figure 12(d) also validates the effectiveness of current vector control in Figure 1 (). The threephase stator current is balanced (Figure 12(e)).
(a)
(b)
(c)
(d)
(e)
In step 5, the PI and fuzzy PI controllers are applied to check the overall system with three load cases. The Simulink model is shown in Figure 13. The VHDL code of the SLC is embedded in the ModelSim_1 block; the VHDL code of the CLC is embedded in the ModelSim_2 block; the inverter based on IGBT and PMSM is designed on Matlab/Simulink. The fuzzy PI rule table is designed in Figure 7, and its parameters are shown in Figure 14. The learning rate is set to 0.5. The load of motor is in lightload (J = 0.000036, F = 0.00043) and heavyload (J = 0.000324, F = 0.0039) conditions. The heavyload condition is nine times heavier than lightload condition.
The sampling frequency of the CLC and SLC is designed with 16 kHz and 2 kHz, respectively. The clocks of 50 MHz and 12.5 MHz supply to all modules of ModelSim. The FPGA resource usage of SLC and CLC blocks is 4915 LEs (logic elements) (0 RAM bits) and 1742 LEs (196,608 RAM bits), respectively. The designed PMSM parameters are listed in Table 3.

The article also analyzes the case that just uses the PI controller. k_{i} and k_{p} are designed at a normal load; the rotor speed tracks the output of SM perfectly (Figure 15(b)). The setting value of PI speed controller and PID on daxis and qaxis is shown in Table 4. After that, the PMSM is changed to lightload and heavyload conditions for testing. At the lightload condition, the response of rotor speed is overshot to 43 rpm and the rotor runs faster than the normalload condition (Figure 15(a)). At the heavyload condition, the response of rotor speed is overshot to 47 rpm and the rotor runs slower than the normalload condition (Figure 15(c)). The error between SM and rotor speed is maximum with 393 rpm (lightload condition) and 177 rpm (heavyload condition).
(a)
(b)
(c)

The simulation results show that when using the fuzzy PI controller, the responding speed of the motor is obtained in the case of the lightload, normalload, and heavyload condition, and heavyload (Figures 16–18). Although the load changed very largely, the rotor speed still tracked the output of the SM very well.
(a)
(b)
(a)
(b)
(a)
(b)
Also, from 0–0.1 s in Figure 19(a), the PI controller is used to control the speed of the motor in the lightload condition. The speed response has lag and overshoot. After 0.1 seconds, the fuzzy PI controller is applied, and the rotor speed tracks the SM perfectly, without overshoot. Similar to the heavyload condition shown in Figure 19(b), from 0–0.15 s, the PI controller is used, and from 0.15 s–0.35 s, the fuzzy PI controller is used. The simulation result shows that with the proposed algorithm, the rotor speed can track the reference model well.
(a)
(b)
8. Experiment Work
After the successful simulation, we realize this code on the FPGA kit. The experimental system is shown in Figure 20, and the experimental results are shown in Figure 21–23.
(a)
(b)
(a)
(b)
(a)
(b)
The experimental system includes an FPGA (Cyclone IV EP4CE115F29C7N), a drive board, an encoder board, an ADC board, and a PMSM. The specifications of the motor are shown in Table 3. An encoder with a resolution of 2500 pps is attached to the motor as the rotor position sensor. The inverter has three sets of IGBT power transistors, and its specifications are shown in Table 5. The Toshiba IC (TLP250) is used in the gate driving circuit of IGBT. The PWM signals from the FPGA board are the inputs of the drive board. A Nios II embedded processor is set up in FPGA to construct a SOPC environment.

Figures 21–23 show the speed step response of the motor under an external load of 0 kg or 10 kg using the PI and fuzzy PI controller. The the speed command is square waves with period of 0.5 s and magnitude variation from 0 => 400 rpm => 1000 rpm => 1400 rpm => 1000 rpm => 1400 rpm => 1000 rpm => 1400 rpm => 1000 rpm.
In Figure 21(a), at the lightload condition (0 kg), the speed controller is PI; the step response shows an excellent dynamic response with a rising time of 0.1 s, without overshoot, and a zero steady state. However, when heavyload condition (10 kg) is added and the same PI controller is used, the speed dynamic response worsens and exhibits a 48 rpm overshoot in Figure 22(a). In Figure 23(a), a fuzzy PI controller is applied to solve this problem. The speed responses are highly improved without overshoot. Due to the EMI effect, the measured current in Figures 21(b), 22(b), and 23(b) have a little ripple.
Nevertheless, the experiment result still shows that the measured current could track the current command well. Furthermore, it not only validates the function of the vector control but also could make the PMSM decouple. Therefore, the simulation and experiment results demonstrate the effectiveness and correctness of the proposed algorithm for PMSM.
9. Conclusion
The fuzzy PI controller has been studied to control the speed of PMSM. The adjustment mechanism produces a compensation signal by using (40), which is added to the fuzzy controller’s knowledge base to force the system to track the SM. The simulation and experiment results confirmed the efficiency of the proposed fuzzy PI and SVPWM for PMSM.
Data Availability
The data used to support the findings of this study are available from the corresponding author upon request.
Conflicts of Interest
The author declares that there are no conflicts of interest.
References
 Y. S. Kung, N. Vu Quynh, C. C. Huang, and L. C. Huang, “Simulink/ModelSim cosimulation of sensorless PMSM speed controller,” in Proceedings of the 2011 IEEE Symposium on Industrial Electronics and Applications (ISIEA 2011), pp. 24–29, Langkawi, Malaysia, September 2011. View at: Publisher Site  Google Scholar
 C. Tseng, R. Jan, and J. Liaw, “Adaptive control design for permanent magnet synchronous motor with uncertain parameters: an LMI approach,” in Proceedings of the 2006 IEEE International Conference on Systems, Man and Cybernetics, pp. 3647–3652, Taipei, Taiwan, October 2006. View at: Publisher Site  Google Scholar
 J. Liu, S. Cao, Y. Yi, and Y. Fang, “Adaptive control for permanent magnet synchronous motor based on disturbance observer,” in Proceedings of the 2017 36th Chinese Control Conference (CCC), pp. 3533–3537, Dalian, China, July 2017. View at: Publisher Site  Google Scholar
 A. Iqbal, H. AbuRub, and H. Nounou, “Adaptive fuzzy logiccontrolled surface mount permanent magnet synchronous motor drive,” Systems Science & Control Engineering, vol. 2, no. 1, pp. 465–475, 2014. View at: Publisher Site  Google Scholar
 N. V. Quynh and Y. Kung, “FPGArealization of fuzzy speed controller for PMSM drives without position sensor,” in Proceedings of the 2013 International Conference on Control, Automation and Information Sciences (ICCAIS), pp. 278–282, Nha Trang, Vietnam, November 2013. View at: Publisher Site  Google Scholar
 C.K. Lai, Y.T. Tsao, and C.C. Tsai, “Modeling, analysis, and realization of permanent magnet synchronous motor current vector control by MATLAB/Simulink and FPGA,” Machines, vol. 5, no. 4, p. 26, 2017. View at: Publisher Site  Google Scholar
 S. Jung and S. s. Kim, “Hardware implementation of a realtime neural network controller with a DSP and an FPGA for nonlinear systems,” IEEE Transactions on Industrial Electronics, vol. 54, no. 1, pp. 265–271, 2007. View at: Publisher Site  Google Scholar
 S. T. Brassai, L. Bako, G. Pana, and S. Dan, “Neural control based on RBF network implemented on FPGA,” in Proceedings of the 11th International Conference on Opimization of Electrical and Electronic Equipment, pp. 41–46, Brasov, Romania, May 2008. View at: Publisher Site  Google Scholar
 Y. Kung, J. Lin, and N. V. Quynh, “ModelSim/Simulink cosimulation of sensorless PMSM speed control system with EKF estimator and adaptive fuzzy controller,” in Proceedings of the 2014 International Conference on Information Science, Electronics and Electrical Engineering, pp. 1488–1492, Sapporo, Japan, April 2014. View at: Publisher Site  Google Scholar
 J. S. Kim and S. Jung, “Implementation of the RBF neural chip with the backpropagation algorithm for online learning,” Applied Soft Computing, vol. 29, pp. 233–244, 2015. View at: Publisher Site  Google Scholar
 J. Yu, J. Gao, Y. Ma, H. Yu, and S. Pan, “Robust adaptive fuzzy control of chaos in the permanent magnet synchronous motor,” Discrete Dynamics in Nature and Society, vol. 2010, Article ID 269283, 13 pages, 2010. View at: Publisher Site  Google Scholar
 Y. M. Alsayed, A. Maamoun, and A. Shaltout, “High performance control of PMSM drive system implementation based on DSP realtime controller,” in Proceedings of the 2019 International Conference on Innovative Trends in Computer Engineering (ITCE), pp. 225–230, Aswan, Egypt, Febraury 2019. View at: Publisher Site  Google Scholar
 A. Maamoun, Y. M. Alsayed, and A. Shaltout, “Fuzzy logic based speed controller for permanentmagnet synchronous motor drive,” in Proceedings of the 2013 IEEE International Conference on Mechatronics and Automation, pp. 1518–1522, Takamatsu, Japan, August 2013. View at: Publisher Site  Google Scholar
Copyright
Copyright © 2020 Nguyen Vu Quynh. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.