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 closed-loop control systems for the PMSM. This 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. 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 [14]. 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 hard-wired 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 [59]. 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 three-phase stator currents (ia, ib, ic) 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 three-phase inverter for providing power to the motor.

2. The Vector Controller Design for PMSM

2.1. The PMSM Mathematical Model

in which Lq and Ld are the inductances on q-axis and d-axis; R is the resistance of the stator windings; iq and id are the currents on q-axis and d-axis; and are the voltages on q-axis and d-axis; 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. Three-phase current is fed back through vector control, enabling controlling current , which helps control the three-phase motor similar to a DC motor. The torque of the PMSM is controlled via current on the q-axis (iq). The vector control is described below.

The Clark transformation converts the stationary a-b-c frame (ia, ib, ic) to stationary α-β frame (iα, iβ).

The Park transformation converts the stationary α-β frame (iα, iβ) to synchronously rotating d-q frame (id, iq).

The inverse Park transformation converts a rotating reference d-q frame (, to stationary α-β frame (, ).

The inverse Clark transformation converts a stationary α-β frame (, ) to stationary a-b-c frame (, , ).

Electromagnetic moment of the motor could be calculated using the following formula:

The mathematical equation of the motor under the load-bearing condition iswhere Te is the motor torque; Jm and F are the inertia and viscous friction of rotor and load; Tm is the shaft mechanical torque; and Kt 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.

The 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.

There are six power IGBTs in the voltage-source 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 (S1, S2, S3, S4, S5, S6) at any given time.where x ≠ 0, 7 and T is half of the PWM period, T0 = T − T1 − T2. For example, in the S3 sector, the output voltage can be calculated with and vectors (Figure 2(a)).

From equations (9)–(11), the output voltage and the value of T1 and T2 can be obtained:

Similarly, the values of T1 and T2 at the other sectors shown in Table 1 with Tx, Ty, and Tz arewith the condition T1 + T2 > T; T1 and T2 are modified as follows:

The duty cycles (Taon, Tbon, Tcon) in Figure 2(b) can calculated as follows:

PWM1, PWM2, and PWM3 with the duty time at and and zero vector ( and ) are T1, T2, and T0, respectively. The values of CMP1, CMP2, and CMP3 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 S1S6 (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 Tx, Ty, and Tz from (23).(iii)Select T1 and T2, in Table 1.(iv)Calculate the duty cycle (Taon, Tbon, and Tcon) from equations (18)–(20).(v)Select comparative value (CMP1, CMP2, and CMP3) 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 second-order 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: a0 = 0.0077, a1 = 0.0153, a2 = 0.0077, b1 = −1.6496, and b2 = 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 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.

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 uf are the input and output of fuzzy controller. Their linguist values E and dE are (A1, A2, A3, A4, A5, A6, A7) and (B1, B2, B3, B4, B5, B6, B7), 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 Cm,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 uf:in which Kp and Ki are the coefficients of the PI controller and uf is the output function of the fuzzy PI controller.

From (36) and (37), we get the function between ωr and uf: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 three-phase currents (ia, ib, ic) 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 s0–s5 compute SM, and the steps s6-s7 calculate the rotor speed error with SM and error change. The steps s8–s11 compute the fuzzification. The step s12 looks up the fuzzy table to select four values of cm,n based on i, j obtained from s11. The steps s13–s21 compute the defuzzification function. The steps s22–s32 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 s0-s1 look up the table to take the value of sine and cosine functions. The steps s2–s8 calculate the Clark and Park transformations. The PID controller turns the current on d and q-axis from step s9–s14. The steps s15–s23 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 step-by-step 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 co-simulation 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 iq is set to a value varying from 0.1 to 0.4, id 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).

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 iq 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. 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)).

In step 4, the three-phase stator currents are fed back and applied through Clack and Pack transformation. The results of that transformation are compared with id and iq obtained from the motor. Then, id and iq 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 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. 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 light-load (J = 0.000036, F = 0.00043) and heavy-load (J = 0.000324, F = 0.0039) conditions. The heavy-load condition is nine times heavier than light-load 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. ki and kp 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 d-axis and q-axis 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)). The error between SM and rotor speed is maximum with 393 rpm (light-load condition) and 177 rpm (heavy-load condition).

The 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 1618). 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. 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 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. The simulation result shows that with the proposed algorithm, the rotor speed can track the reference model well.

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 2123.

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 2123 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 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 heavy-load 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.