Hamiltonian system theory is an important reflearch tool for nonlinear systems, and has been widely used in motor speed regulation and control during reflent years. Aiming at the chaotic phenomenon in permanent magnet synchronous motors, a design method of robust controller based on the Hamiltonian function is preflented for the chaotic systems. The dynamic model of permanent magnet synchronous motor is transformed into a model similar to the Lorenz chaotic equation, and the model is chaotic at certain parameters according to the Lyapunov exponent and the Lyapunov dimension calculated. Let the rotator speed of the motor track a set of values, an error equation is obtained accordingly. Because the error equation does not satisfy the standard form of Hamilton exactly, it can be transformed into the Hamiltonian system containing uncertain disturbance terms. While the uncertain disturbance terms as well as the load term are regarded as a total disturbance term to the system, a kind of robust controller is designed. The controller consists of two parts. One part is based on the method of interconnection and damping assignment, and can make the rotator speed track any value well; The other part is used as a disturbance compensator. Simulation result shows that the controller drives the permanent magnet synchronous motor out of the chaotic state rapidly and the rotator speed tracks the set of values well. It is proven that the controller is feasible and effective. The method mentioned in this paper extends the range of application of Hamiltonian function and has a certain advantage.