Abstract:The error caused by thermal deformation of NC machine tools usually accounts for 40% ~ 70% of the total errors. A horizontal CNC lathe manufactured by some company was taken as the research object,the thermal error of the spindle and the thermal error of the Xfeed axis were detected,and the thermal error models of the spindle X,Y,Zand X feed axes of the lathe were established respectively based on the least square method. Considering the factor of the elongation of the ball screw when the measured ambient temperature was 20 ℃ relative to the reference temperature,the measured thermal error of the spindle was corrected. The X-axis comprehensive thermal error model was established according to the X-axis corrected thermal error model and the X-feed axis thermal error model. The Siemens 840D system was used for thermal error compensation test.The thermal error was reduced by 54.5%,and the CP value was increased from 1.34 to 1.88. It is proved that this method of modeling and compensation is effective and feasible.