A controller for a motor cleans, as necessary, a hydraulic chamber that
generates hydraulic oil for changing a phase difference between two
rotors so as to restrain sludge from building up in the hydraulic
chamber. A motor has a first rotor and a second rotor that can be
relatively rotated with respect to the first rotor. The controller
includes a phase difference changing driver that changes the phase
difference between the two rotors by controlling the pressure in the
hydraulic chamber filled with hydraulic oil. The controller further
includes a cleaning need determiner that determines the need for cleaning
the hydraulic chamber, and a cleaning phase difference controller that
controls the phase difference changing driver such that the second rotor
is relatively rotated in the forward direction and the reverse direction
alternately with respect to the first rotor if a determination result of
the cleaning need determiner is affirmative.