To overcome the shortcoming of large torque and flux ripples in the traditional direct torque control(DTC)of permanent magnet synchronous motor(PMSM),a super-twisting sliding mode variable structure is utilized in torque and flux control and an improved particle swarm optimization(PSO)algorithm based on Levy flight is used to optimize its adjustable parameters.For the purpose of speeding up the dynamic response of the system,a speed sliding mode controller is utilized to replace PI regulator.The DTC system with sliding mode variable structure is simulated by MATLAB/Simulink.The speed,torque and flux waveforms under no-load and load conditions are analyzed respectively.The results demonstrate that the introduction of sliding mode variable structure can effectively suppress the torque and flux ripples.In addition,the speed overshoot is reduced and the transition time is shortened.This simulation study helps students better understand and apply sliding mode theory,and enhances their awareness of theoretical integration and independent innovation.