CNC car processing program structure and commonly used code

The CNC car program can be divided into three parts: the beginning of the program, the contents of the program, and the end of the program.

Part 1 The beginning of the program

Mainly define the program number, call out the parts processing coordinate system, machining tools, start the spindle, open the coolant and so on.

The maximum spindle speed limit defines the G50 S2000, which sets the maximum spindle speed to 2000 RPM. This is a very important command for CNC lathes.

Definition of coordinate system Unless otherwise specified, the CNC defaults to the G54 coordinate system.

To return to the reference point command G28 U0, in order to avoid collision and/or interference between the tool holder and the workpiece or fixture during tool change, an effective method is to return the machine tool to the machine reference point in the X-axis direction and leave the spindle. A safe distance.

Tool definition G0 T0808 M8, automatic adjustment No. 8 left-side offset No. 8 tool compensation, open the coolant.

Spindle speed definition G96 S150 M4, constant line speed S function definition, S function makes CNC lathe spindle speed instruction function, there are two expressions, one is based on r/min or rpm as a unit of measurement. The other is in units of m/min. The S code of the CNC lathe must be used with G96 or G97 to set the spindle speed or cutting speed.

G97: Speed ​​command, defines and sets the speed per minute.

G96: The constant speed command makes the cutting speed at any position on the workpiece the same.

The second part of the program content part

Program content is the main part of the entire program and consists of several program sections. Each program segment consists of several words, each of which consists of an address code and several numbers. Commonly used are the G and M instructions and the program sections that are composed of the coordinate points of each axis, and the function definition of the feed amount has been added.

F function refers to the function of feed speed, CNC lathe feed speed has two expressions, one is the feed per revolution, that is expressed in mm/r units, mainly used for feed processing. The other uses the same amount of feed per minute as the CNC milling machine, which is expressed in mm/min units. It is mainly used for milling in milling and machining centers.

Part 3 The end of the program

At the end of the program, it is necessary to return the tool holder to the reference point or machine tool reference point. This is the safe position for the next tool change. At the same time, the spindle is stopped, the coolant is turned off, and the program selects to stop or end the program.

Reference point reference G28U0 is the reference point of the machine tool in the direction of the return X axis, and G0 Z300.0 is the reference point in the direction of the return Z axis.

The stop command M01 is the selection stop command. It is valid only when the device selection stop switch is turned on; M30 is the program end command. When it is executed, the coolant, feed, and spindle stop all. The NC program and the numerical control device are reset and returned to the original state before processing to prepare for the resumption of the next program operation and numerical control processing.