Vector control is the current mainstream control method for permanent magnet synchronous motors (PMSM). Aiming at its disadvantages such as complex calculations and dependence on motor parameters identification, a formal method of signal temporal logic (STL) is proposed to identify the running states of the motor, so that the maximum torque per ampere (MTPA) can be realized by controlling the pulse width modulation (PWM) of the motor drive circuit. The voltage data of the shunt resistance in series with the DC bus of the driving circuit under the same working condition and different running states of the motor were collected. The 5-fold cross validation is adopted, and the STL formula is learned based on the decision tree. Finally, the STL formula is used to determine whether the motor is running normal, under modulation or over modulation. The first-level and second-level primitives are defined as the nodes of the decision tree respectively. Particle swarm optimization (PSO) is used in the learning process, and different impurity measures are used as the loss functions. The experimental results show that the accuracy of motor states recognition by STL with first-level primitives can reach 98.78%, and the program takes 0.1509s. The recognition accuracy with second-level primitives can reach 95.06% and the program takes 2.3979s. It is of great significance to the implementation of motor control algorithms based on STL.