A CNC lathe program can be divided into three parts: program start, program content, and program end.
The program start section mainly defines the program number, calls up the workpiece machining coordinate system, machining tools, starts the spindle, and turns on the coolant. The maximum spindle speed limit is defined as G50 S2000, setting the maximum spindle speed to 2000 RPM. This is a very important instruction for CNC lathes.
Unless otherwise specified, the CNC system defaults to the G54 coordinate system.
The return-to-reference-point instruction G28 U0 is used to avoid collisions or interference between the tool holder and the workpiece or fixture during tool changes. An effective method is for the machine tool to first return to the machine reference point in the X-axis direction and move a safe distance away from the spindle.
The tool definition is G0 T0808 M8, which automatically adjusts to tool #8 (left offset tool) and turns on the coolant.
The spindle speed is defined as G96 S150 M4, and the constant linear speed (S) function is defined. The S function enables the spindle speed command on a CNC lathe, and it can be expressed in two ways: one is in r/min or rpm, and the other is in m/min. The S code on a CNC lathe must be used in conjunction with G96 or G97 to set the spindle speed or cutting speed.
G97: Speed command, defines and sets the speed per minute.
G96: Constant linear speed command, ensures the cutting speed is the same at all positions on the workpiece.
Program Content Section: The program content is the main part of the entire program, consisting of multiple program segments. Each program segment consists of several words, and each word consists of an address code and several numbers. Commonly, program segments consist of G and M commands, coordinate points of each axis, and include the definition of feed rate.
The F function refers to the feed rate function. CNC lathe feed rate has two expressions: one is feed per revolution, expressed in mm/r, mainly used for turning feed. Another method, similar to CNC milling machines, uses feed per minute (FPM), expressed in mm/min. This is primarily used for milling feed in turning-milling machining centers.
Program End Section: At the end of the program, the tool turret needs to return to the reference point or machine reference point for a safe position for the next tool change. Simultaneously, the spindle is stopped, the coolant is turned off, and the program is selected to stop or end.
The return-to-reference-point command G28U0 returns to the machine reference point in the X-axis direction, and G0 Z300.0 returns to the reference point in the Z-axis direction.
The stop command M01 is a stop selection command, only effective when the device's stop selection switch is on; M30 is the program end command, which, when executed, stops the coolant, feed, and spindle. The CNC program and CNC equipment are reset and returned to their pre-machining state, preparing for the next program run and the restart of CNC machining.






