COMMON G CODE, M CODE USED ON CNC MACHINING PROGRAM
1. Programming instructions
1.Preparation function (G function)
The preparation function G code is used to specify the relative motion trajectory of the tool and the workpiece, the machine coordinate system, the coordinate plane, the tool compensation, the coordinate offset and other processing operations. Below is a list of G function codes commonly used in CNC machining.
G code | Group | Function | Remark |
G00 | 01 | Positioning (Fast travel) | Modal |
G01 | Linear interpolation | Modal | |
G02 | Clockwise circular interpolation | Modal | |
G03 | Counterclockwise circular interpolation | Modal | |
G04 | 00 | Tool stop, accurate stop | Non-modal |
G17 | 02 | XY plane selection | Modal |
G18 | XZ plane selection | Modal | |
G19 | YZ plane selection | Modal | |
G28 | 00 | Machine return to reference point | Non-modal |
G40 | 07 | Tool radius compensation cancellation | Modal |
G41 | Tool radius left compensation | Modal | |
G42 | Tool radius right compensation | Modal | |
G43 | 08 | Tool length positive compensation | Modal |
G44 | Tool length negative compensation | Modal | |
G49 | Tool length compensation cancellation | Modal | |
G50 | 11 | Scaling cancellation | Modal |
G51 | Scaling valid | Modal | |
G50.1 | 22 | Programmable mirror cancellation | Modal |
G51.1 | Programmable mirror valid | Modal | |
G52 | 00 | Local coordinate system setting | Non-modal |
G53 | 00 | Coordinate system selection | Non-modal |
G54 | 14 | Workpiece coordinate system 1 selection | Modal |
G55 | Workpiece coordinate system 2 selection | Modal | |
G56 | Workpiece coordinate system 3 selection | Modal | |
G57 | Workpiece coordinate system 4 selection | Modal | |
G58 | Workpiece coordinate system 5 selection | Modal | |
G59 | Workpiece coordinate system 6 selection | Modal | |
G65 | 00 | Macro program invoking | Non-modal |
G66 | 12 | Macro program modal invoking | Modal |
G67 | Macro program invoking cancellation | Modal | |
G68 | 16 | Coordinate rotation | Modal |
G69 | Coordinate rotation cancellation | Modal | |
G73 | 09 | Chip removal drilling cycle | Modal |
G74 | Left-hand tapping thread cycle | Modal | |
G76 | Fine boring cycle | Modal | |
G80 | Canned cycle cancellation | Modal | |
G81 | Drilling cycle | Modal | |
G82 | Back boring cycle | Modal | |
G83 | Deep hole drilling cycle | Modal | |
G84 | Tapping cycle | Modal | |
G85 | Boring cycle | Modal | |
G86 | Boring cycle | Modal | |
G87 | Back boring cycle | Modal | |
G88 | Boring cycle | Modal | |
G89 | Boring cycle | Modal | |
G90 | 03 | Absolute value programming | Modal |
G91 | Incremental value programming | Modal | |
G92 | 00 | Workpiece coordinate system setting | Non-modal |
G94 | 05 | Feed per minute | Modal |
G95 | Feed per revolution | Modal | |
G98 | 10 | Canned cycle return to the initial point | Modal |
G99 | Canned cycle return to point R | Modal |
2. Auxiliary function (M code for Fanuc)
Auxiliary function codes are used to instruct the connection and shutdown of auxiliary devices of CNC machine tools, such as spindle rotation/stop, cutting fluid opening/closing, chuck clamping/releasing, tool replacement, etc. Below is the list of M codes widely used in CNC machining:
Code | Function | Description |
M00 | Program pause | When the block with M00 instruction is executed, the spindle rotation and cutting fluid will stop. Press the (Cycle Start) key again to continue executing the following block |
M01 | Program selection stop | The function is the same as M00, but only when the (select stop) key on the machine operation panel is in the "ON" state, M01 will be executed, otherwise it be executed after skipping |
M02 | End of program | In the last section of the program, after executing this instruction, the spindle stops, the cutting fluid is closed, and the automatic operation stops, and the machine is in the reset state |
M30 | End of program | Also placed in the last section of the program, in addition to executing the content of M02, it also returns to the first section of the program to prepare for the next workpiece processing |
M03 | Spindle positive rotation | Spindle rotates in the clockwise direction |
M04 | Spindle negative rotation | Spindle rotates on the counter clock wise direction |
M05 | Spindle stop | Spindle stops rotating |
M06 | Tool changing | On automatic tool changing |
M08 | Cutting liquid on |
|
M09 | Cutting liquid off |
|
M98 | Subroutine invoking | For subroutine |
M99 | End of subroutine | End of subroutine and return to the main program |