A method of controlling a machine tool, configured to control a synchronized operation of a spindle axis and a feed axis, the method comprising the steps, executed by a controller, of:
- obtaining, from a tapping program, a total rotation amount and a maximum rotation speed of the spindle axis during a period when the spindle axis operates from a starting position to a target position;
- making the spindle axis perform an accelerated rotation at maximum capacity using a maximum permissible current of a drive source from the starting position, by a velocity, control in which the maximum rotation speed is set as a target value;
- detecting a maximum acceleration of the spindle axis during the accelerated rotation at the maximum capacity, based on a rotational position feedback of the spindle axis;
- detecting a residual rotation amount of the spindle axis during a period when the spindle axis operates from a current position to the target position, based on the total rotation amount and the rotational position feedback;
- detecting a current speed of the spindle axis based on the rotational position feedback;
- executing the velocity control for making the spindle axis perform a decelerated rotation so as to reach a predetermined intermediate speed, based on the residual rotation amount and the current speed, after the accelerated rotation is performed at the maximum capacity;
- and
- executing a position control for making the spindle axis perform the decelerated rotation so as to reach the target position at a maximum deceleration corresponding to the maximum acceleration, the residual rotation amount and the current speed, after the spindle axis reaches the intermediate speed,
- wherein the step to reach the predetermined intermediate speed includes successively updating a velocity command for the velocity control with use of the residual rotation amount and the current speed, and making the spindle axis perform the decelerated rotation by the successively updated velocity command so that the residual rotation amount at an instant when the spindle axis reaches the intermediate speed becomes equal to a positioning rotation amount of the spindle axis required for the spindle axis to reach the target position under the position control, and
- wherein the step to reach the target position includes
- calculating a first velocity command for the position control, the first velocity command making the spindle axis perform the decelerated rotation at the maximum deceleration corresponding to the maximum acceleration, during a time except for a predetermined acceleration-varying time just after the spindle axis reaches the intermediate speed or just before the spindle axis reaches the target position, and making the spindle axis perform the decelerated rotation at a variable deceleration lower than the maximum deceleration and varying at a predetermined rate, during the acceleration-varying time;
- calculating a second velocity command for the position control, the second velocity command making the spindle axis perform the decelerated rotation at a constant deceleration lower than the maximum deceleration after the spindle axis reaches the intermediate speed;
- and
- choosing a velocity command achieving a lower speed, which is either one of the first velocity command and the second velocity command, during a period when the spindle axis operates from the intermediate speed to reach the target position, and
- wherein the method further comprises the step, executed by the controller, of controlling a feed motion of the feed axis in accordance with a feed axis command and based on the rotational position feedback of the spindle axis.