Numerical control (10, 10A) which controls a five-axis
machine tool using three linear axes and two rotary axes, which machines a workpiece mounted on a table, wherein the
numerical control (10, 10A) comprises: a workpiece
installation error compensation unit (13, 13A) that compensates for an
installation error during the installation of the workpiece, wherein the workpiece
installation error compensation unit (13, 13A) comprises: a tool position and direction calculation unit (131) that calculates a position and direction in a command coordinate
system of a tool based on command values for the three linear axes and the two rotational axes; and An error compensation unit (132), which, using an error size preset to correspond to the installation error during workpiece installation, performs such error compensation with respect to the three linear axes and the two rotary axes that the position and direction calculated by the tool position and direction calculation unit (131) in the command coordinate
system of the tool on the workpiece with the installation error are maintained, wherein the error compensation unit (132) selects the positions of the two rotary axes to be compensated, if multiple solutions of a trigonometric calculation exist, according to a first procedure for selecting a solution close to a previous solution, or either a second procedure for selecting a solution close to the command value in the command coordinate
system.or a third method for switching to a different solution at a time when a movement of the two rotation axes is minimized while selecting a solution that is close to a previous solution, , wherein the
numerical control (10, 10A) drives each axis according to the coordinate values of the three linear axes and the two rotary axes calculated by the workpiece installation error compensation unit (13, 13A), wherein the
numerical control (10, 10A) further comprises: a read-ahead unit (11) that anticipates in a program, wherein The workpiece installation error compensation unit (13, 13A) performs error compensation according to the first method on the previously retrieved instruction value to determine a compensated command value, and The workpiece installation error compensation unit (13, 13A) sets the error compensation based on the first method when the compensated command value is within a
range of motion of the five-axis
machine tool, and sets either the error compensation based on the second method or the error compensation based on the third method when the compensated command value is outside the
range of motion of the five-axis
machine tool.