This paper presents the analysis and compensation of cogging torque in the permanent magnet synchronous motor (PMSM). A magnetic circuit is used to derive the mathematical model of the system. This paper considers the following compensation methods: (i) feedforward controller, (ii) disturbance observer-based controller, and (iii) doubly coprime factorization controller, to attenuate the disturbance of cogging torque. These three compensation controllers are studied and compared through experimental works. In experiments, the controllers are implemented through a digital signal processor (TMS320F28335) from Texas Instruments. It is shown experimentally that the feedforward controller has better performance to attentuate the cogging effect among the other two.