During the permanent magnet synchronous motor operation, the inherent back-EMF output voltage harmonics of the permanent magnet synchronous motor shows the high harmonic noise signal, which is not conducive to the high precision control system. The harmonic error compensation method based on feedforward compensation is adopted to solve this problem and improve the system response characteristics and control accuracy. Firstly, in this paper, the torque harmonic error of a 12-pole 18-slot permanent magnet synchronous motor is analyzed and compensated. Then, this paper compensates the lag problem, which caused by the lag phase of the space voltage vector and harmonic lag. Finally, the experimental and observational simulation analysis results show that the method proposed in this paper can effectively suppress the error caused by the signal sampling lag. And the observation accuracy of permanent magnet synchronous motor is significantly improved.