# A Low Torque Ripple Direct Torque Control Method for Interior Permanent Magnet Motor
## 4 Hardware-in-the-Loop Test  
The hardware-in-the-loop (HIL) toolkit shown in Figure 21 is designed as a real-time emulator for evaluation of the performance of electric motor drives and controllers. Therefore, the HIL was used to verify the effectiveness of the proposed method. Potential problems can be identified and resolved in the early developmental stage of motor drives by using HIL. In the HIL test, the control performance can be tested in a safe test environment offered to researchers [20]. Electrical motors are often tested using a dynamometer. However, for measuring torque ripples, a torque sensor with high bandwidth and a suitable mechanical coupling linking the motor shaft and the test-bench would be required. These are not available in the laboratory and therefore the HIL, which is considered to be sufficiently reliable [20; 21], was employed to test the control performance of the proposed method. In the HIL, various types of built-in electric motor models can be selected, and the parameters of these motors can be easily set up by users through a provided user interface. The HIL offers physical terminals for six gate driving signals, three-phase current feedback and rotor position feedback (by \"virtual\" optical encoders, resolvers or others). A DC link voltage can also be set up as required. In this paper, the target motor was a PMSM whose parameters are listed in Table 1. These parameters can then be input into the HIL as the controlled target, i.e., the \"virtual\" PMSM with its model. The detailed function and configuration of the HIL can be found in [22; 23]. In this study, a digital signal processor (DSP), TMS320F28377S was used to implement the proposed algorithm, which was coded in C language. The setup used for the HIL tests is illustrated in Figure 21. Based on the test platform, the torque ripple and response for different control methods could then be compared. Figure 22 shows the connections between the DSP and the HIL toolkit. As can be seen, the six PWM signals are produced by the DSP after calculating the voltage command. The three-phase currents, rotor speed and rotor position can also be fed back to the DSP through \begin{table}
\begin{tabular}{c c c c} \hline \hline  & **cSVM-DTCI** & **cSVM-DTC2** & **Proposed rSVM-DTC** \\ \hline Load torque & 40 Nm & 40 Nm & 40 Nm \\ Switching frequency & 10 kHz & 11 kHz & 10 kHz \\ Torque variation range due to 3 rd term & 4.5-21.1 Nm & 11.47–14.41 Nm & 10.6–15.3 Nm \\ Torque variation range due to 4 th term & \(-\)0.124 to \(-\)0.135 Nm & \(-\)0.126 to \(-\)0.132 Nm & \(-\)0.126 to \(-\)0.133 Nm \\ Magnitude range of voltage command & 45–280 V & 160–193 V & 138–218 V \\ Torque ripple & 27.50\% & 14.8\% & 17.32\% \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Comparison of the simulation results for different methods. Figure 21: Hardware-in-the-loop (HIL) test setup and microcontroller. The Model is called MR2 [22; 23]the wire connections. Therefore, in this HIL test system, the DSP, the control algorithm written into program and loaded to the DSP and the command/feedback signals were \"real\", while the motor and inverter were models built into the HIL toolkit and were \"virtual\". The motor model was established according to the parameters listed in Table 1, as previously mentioned. In the HIL toolkit, the load torque is allowed to be programmed such that the load can be applied to the motor model. The motor model would then react to the load condition with the voltage controlled by the DSP. As observed in Figures 23 and 24, the torque ripple in cSVM-DTC1 was 35 Nm (87.5%), and that for the proposed rSVM-DTC was 15 Nm (37.5%). Note that the switching frequency was 10 kHz. The improvement was significant by employing the proposed method. Additionally, it can be noted that the magnitude of torque ripple obtained by the HIL tests was generally greater than that in the simulation.