# Sensorless HSPMSM Control of an Improved SMC and EKF Based on Immune PSO
## 4 Case Study
### Simulation Experiment II  
In the second experiment, the flywheel motor speed is set to n* = 8000 rpm with a no-load startup. The total simulation duration is 1 s, and the disturbance load T\({}_{\text{m}}\) = 10 is suddenly added at 0.4 s. Figure 9 shows the speed comparison diagram, speed error diagram, rotor position angle diagram, and electromagnetic torque diagram of the motor using the EKF matrix parameter control strategy optimized by the immune PSO algorithm under the PI controller. Figure 10 shows the speed comparison diagram, speed error diagram, rotor position angle diagram, and electromagnetic torque diagram of the motor under the EKF matrix parameter control strategy optimized by the immune PSO algorithm using the improved SMC controller.  
Figure 9: _Cont._  
Comparing the speed tracking and speed error graphs in Figures 9 and 10 shows that the PI controller's system response time under the immune PSO optimization algorithm is within 0.3 s. Under the improved PSO optimization algorithm, EKF matrices R and Q obviously perform poorly. Speed is not completely tracked after it reaches 8000 rpm, and the speed error fluctuates greatly. The fluctuation of electromagnetic torque is also relatively large. However, although the system response time of the improved SMC controller under the immune PSO optimization algorithm is slow, reaching 8000 rpm when it is close to 0.7 s, the tracking effect under load is still very favorable. Basically, the motor speed observed using the EKF algorithm can fully track the actual measured value of the HSPMSM, and the control effect is relatively favorable. Under both control strategies, the load starts at 0.4 s and does not have a large impact on the system. The accuracy of motor speed estimation is greatly improved by the improved control system, and the error between the estimated and actual values of motor speed is greatly reduced.  
According to the rotational speed curves in Figures 9a and 10a, Table 6 lists the dynamic performance indexes from 0 to 8000 rpm, the static performance indexes when stabilized at 8000 rpm, and the comparison of the dynamic and static indexes with the load applied after 0.4 s.  
Figure 9: Comparison diagram after optimizing the EKF using the immune PSO algorithm under the PI controller. (**a**) Speed comparison diagram; (**b**) speed error diagram; (**c**) rotor position angle diagram; (**d**) electromagnetic torque diagram of the motor.  
Figure 10: Comparison diagram after optimizing the EKF using the immune PSO algorithm under the SMC controller. (**a**) Speed comparison diagram; (**b**) speed error diagram; (**c**) rotor position angle diagram; (**d**) electromagnetic torque diagram of the motor.  
Table 6 shows that the rotational speed under the PI controller fluctuates within a range of 7817-8242 and 7932-8107 for both the actual measured value and the estimated value of EKF optimized using IPSO, and the measured and estimated values cannot be kept at a fixed value. The sudden loading of the system causes poor system stability performance and poor tracking ability. The improved SMC controller speed measurement is fixed at 8120, and the estimated value is between 8109 and 8126, with a speed difference of \(-11\) to 6 rpm. After improvements to the controller, the accuracy of the system's estimation of the motor speed is greatly improved, and the error between the estimated and actual values of the motor speed is greatly reduced.  
In summary, the improved control system has a small drop in speed during sudden load addition and can quickly recover to the original state, which proves that this control system has favorable robustness and anti-load disturbance capability.