The Fuzzy PI Controller for PMSM’s Speed to Track the Standard Model

)is paper proposes a fuzzy PI controller to control the speed of a permanent magnet synchronous motor (PMSM).)e structure of the system includes the speed loop controller (SLC) and the current loop controller (CLC).)e speed loop controller is the fuzzy PI and standard model (SM). )e CLC includes vector control and the space vector pulse width modulation (SVPWM). It compiles two closed-loop control systems for the PMSM. )is research uses a very high-speed 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. )e simulation and experiment results show that when the load changes, the PMSM speed is still stable. )e novelty of this research is that it compares two kinds of controllers between simulation and experiment results.


Introduction
e 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. ey 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][2][3][4]. ey helped to control precisely the speed and position of the motor. e FPGA supplied a solution for the implementation of the algorithm. Especially, FPGA has a programmable hard-wired feature, fast calculation ability, low power consumption, and higher density. ere 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][6][7][8][9]. e 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]. is 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. is research applied a fuzzy PI controller, current controller, and SVPWM for PMSM drive. e 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. e speed of the motor (ω r ) is fed back to the speed loop controller to compare with the output of the standard model (SM). e fuzzy PI controller generates the signal to minimize the error between rotor speed and SM. e adjustment mechanism keeps the motor speed stable when the load changes. e three-phase stator currents (i a , i b , i c ) and rotor flux angle (θ e ) are fed back to the current controller to calculate the generated voltage vector for SVPWM. e SVPWM generated the electric current to control threephase inverter for providing power to the motor.

The Vector Controller Design for PMSM
in which L q and L d are the inductances on q-axis and d-axis; R is the resistance of the stator windings; i q and i d are the currents on q-axis and d-axis; V q and V d are the voltages on q-axis and d-axis; λ is the permanent magnet flux linkage; p is the number of pole pairs; and ω r is the rotational speed of the rotor.

e Vector Controller.
e current controller of the PMSM drive in Figure 1 is based on a vector control approach. e current controller structure includes Clark, Park, inverse Park, and inverse Clark transformation, two PID controllers, and sine/cosine of flux angle. ree-phase current is fed back through vector control, enabling controlling current i d ≈ 0, which helps control the three-phase motor similar to a DC motor. e torque of the PMSM is controlled via current on the q-axis (i q ). e vector control is described below.
e Clark transformation converts the stationary a-b-c frame (i a , i b , i c ) to stationary α-β frame (i α , i β ).

The SVPWM Algorithm Design
e SVPWM is a control technique widely used in power electronic equipment control. e 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 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. e phase-to-phase voltage and the phase-to-neutral voltage of the motor: in which a, b, and c are switching vectors of IGBT power electronic switches. ere are six power IGBTs in the voltage-source inverter. When the upper switch is active, the corresponding lower switches must be turned off. eremust be coordinated delay time (dead band) between the opening and closing of two switches on the same phase. e eight primary space vectors Figure 2(a). e output voltage (V ref ) 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, For example, in the S 3 sector, the output voltage can be calculated with V 1 and V 2 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 are Mathematical Problems in Engineering with the condition T 1 + T 2 > T; T 1 and T 2 are modified as follows: e 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 V 1 and V 2 and zero vector (V 0 and V 7 ) are T 1 , T 2 , and T 0 , respectively. e 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: e sector of SVPWM is defined by this equation: sector � a + 2b + 4c. From equations (13)-(15) and (21), we have

Standard Model (SM)
e SM is the standard speed for PMSM. e 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 second-order system: where ω n and η 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. e 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 steady-state 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.

Structure of Fuzzy PI Controller
e structure of the fuzzy PI controller includes fuzzification, fuzzy inference mechanism, defuzzification, fuzzy knowledge base, fuzzy adjusting mechanism, and the PI controller ( Figure 1). e rotor speed (ω r ) 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. is 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. eir linguist values E and dE are ( , 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 μ A i (e) and μ B i (de) with the formula below: Membership function has the shape of the symmetrical triangle, and control rules have the form if e is A m and de is B n , then u f is C m,n .
Crisp value in the output of the fuzzy controller:  Mathematical Problems in Engineering and c m,n are adjustable parameters in the adaptation mechanism. Also, it can be obtained by the equations (28)-(31). erefore, it is straightforward to obtain i+1 n�i j+1 m�j d n,m � 1 in (33). e 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. e equation describes the relationship between i * q 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 :  Mathematical Problems in Engineering From (35), (38), and (39), the parameters of the fuzzy PI controller C m,n in (33) could be adjusted through the function. (40)

Implementation on FPGA
e proposed algorithm has been embedded in one FPGA chip. e architecture of FPGA is shown in Figure 8. e FSM sequential programming technique was used to describe control algorithms. e internal circuit of the proposed algorithm includes one circuit of the SLC and one circuit of the CLC.   e data type in vector control and SVPWM for PMSM is 12 bits. e 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. ere 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 step-by-step order reduced the execution time of coding. e simulation was performed on Matlab/ Simulink/ModelSim for adjusting and verifying the controller's parameters and checking the accuracy of the Fuzzy knowledge base    proposed algorithm. e ModelSim software was embedded in Matlab/Simulink for simulating the whole system. e 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.

Simulation Work
e 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 co-simulation using VHDL code, which describes the function of the block diagram in Figure 9  circuit (R � 10 Ω, C � 47). e saddle waveform of PWMs is shown in Figure 9(c).
In step 2, the inverter and PMSM are added to step 1. A real rotor flux angle replaces the address. e block diagram of this step is shown in Figure 10(a), and the Simulink model is shown in Figure 10(c). is step confirms the correctness of SVPWM on PMSM again. e rotor speed is shown in Figure 10(b), and it follows the value of i q at the input.
In step 3, the PI speed controller is applied to the system, and the real rotor speed is fed back to the speed controller.
e 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. e rotor speed can follow well the step response at the input (Figure 11(b)).
In step 4, the three-phase stator currents are fed back and applied through Clack and Pack transformation. e results of that transformation are compared with i d and i q obtained from the motor. en, i d and i q are fed back to the PI controller in the current loop to create the completed system. e 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 (i d ≈ 0). e three-phase stator current is balanced (Figure 12(e)).
In step 5, the PI and fuzzy PI controllers are applied to check the overall system with three load cases. e Simulink model is shown in Figure 13. e 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. e fuzzy PI rule table is designed in Figure 7, and its parameters are shown in Figure 14.
e learning rate is set to 0.5. e load of motor is in light-load (J � 0.000036, F � 0.00043) and heavy-load (J � 0.000324, F � 0.0039) conditions. e heavy-load condition is nine times heavier than light-load condition. e sampling frequency of the CLC and SLC is designed with 16 kHz and 2 kHz, respectively. e clocks of 50 MHz and 12.     (logic elements) (0 RAM bits) and 1742 LEs (196,608 RAM bits), respectively. e designed PMSM parameters are listed in Table 3. e 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)). e setting value of PI speed controller and PID on d-axis and qaxis is shown in Table 4. After that, the PMSM is changed to light-load and heavy-load conditions for testing. At the light-load condition, the response of rotor speed is overshot to 43 rpm and the rotor runs faster than the normal-load condition (Figure 15(a)). At the heavy-load condition, the response of rotor speed is overshot to 47 rpm and the rotor runs slower than the normal-load condition (Figure 15(c)). e error between SM and rotor speed is maximum with 393 rpm (light-load condition) and 177 rpm (heavy-load condition). e simulation results show that when using the fuzzy PI controller, the responding speed of the motor is obtained in the case of the light-load, normal-load, and heavy-load condition, and heavy-load (Figures 16-18). Although the load changed very largely, the rotor speed still tracked the output of the SM very well.
Also, from 0-0.1 s in Figure 19(a), the PI controller is used to control the speed of the motor in the light-load condition. e 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 heavy-load 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. e simulation result shows that with the proposed algorithm, the rotor speed can track the reference model well.

Experiment Work
After the successful simulation, we realize this code on the FPGA kit. e experimental system is shown in Figure 20, and the experimental results are shown in Figure 21-23.    EP4CE115F29C7N), a drive board, an encoder board, an ADC board, and a PMSM. e 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. e inverter has three sets of IGBT power transistors, and its specifications are shown in Table 5. e Toshiba IC (TLP250) is used in the gate driving circuit of IGBT. e 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. e 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 light-load 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. e 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. erefore, the simulation and experiment results demonstrate the effectiveness and correctness of the proposed algorithm for PMSM. compensation signal by using (40), which is added to the fuzzy controller's knowledge base to force the system to track the SM. e simulation and experiment results confirmed the efficiency of the proposed fuzzy PI and SVPWM for PMSM.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e author declares that there are no conflicts of interest.