PURPOSE: To automatically calculate an averaged tapping pitch and to optimize a main shaft feeding for the tool rotation by providing a memory storing the data expressing the tapping pitch of respective tool as a data group on each main shaft head.
CONSTITUTION: Tapping tools 161-164 are held on a main shaft head 31a, tapping tools 165-169 are held on the main head 31b exchangeable with the head 31a, and discrimination numbers T1, T2 are attached to the respective tool group. The respective tool pitch of T1, T2 is stored individually as data group in a data group memory 12. The averaged tapping pitch calculated from the data group is also stored on each main shaft head 31a, 31b in an averaged tapping pitch data memory 13. When a tool number is designated, the optimum change of the main heads 31a, 31b and the rotation of the main shaft motor 27 and the feeding speed of a feeding shaft motor 7 are controlled by a control part 2 so as to become optimum.