- HomePage /
- Sector News /
- CNC /
- G AND M CODES IN CNC LATHE MACHINES
G AND M CODES IN CNC LATHE MACHINES

G00 – G0: Rapid tool movement without cutting
G01 – G1: Tool movement with chip removal, in contact with the workpiece
G02 – G2: Clockwise circular motion (CW)
G03 – G3: Counterclockwise circular motion (CCW)
G04 – G4: Dwell
G20: Inch measurement system
G21: Metric measurement system
G28: Return to reference point command
G31: Skip command
G32: Thread cutting command
G34: Variable lead thread cutting command
G40: Tool nose radius compensation cancel
G41: Tool nose radius compensation (left)
G42: Tool nose radius compensation (right)
G50: Maximum spindle speed limit command
G54: Workpiece zero
G55 – G59: Selection of different reference points
G70: Finish turning cycle
G71: Longitudinal rough outer diameter turning cycle
G72: Face turning cycle
G73: External diameter turning cycle according to profile
G74: Hole drilling cycle on the Z-axis
G75: Channel grooving and cutting cycle on the X-axis
G76: Multi-pass threading cycle
G80: Cancel drilling cycles
G83: Hole drilling cycle
G84: Tapping cycle
G90: Cylindrical outer diameter/inner diameter turning cycle (Single pass)
G92: Threading cycle
G94: Face turning cycle
G96: Constant surface speed
G97: Constant RPM
G98: Feed rate (mm/min)
G99: Feed rate (mm/rev)
M Codes (Mnn)
M codes are auxiliary function codes used in CNC program writing. These codes facilitate cutting operations. They consist of the letter M followed by two digits. Below are some of the main M codes:
M00 - M0: Program stop (When this command is encountered, the machine stops regardless of the Optional Stop Switch position).
M01 - M1: Optional stop (Program stops if the Optional Stop Switch is active).
M02 - M2: End of program (for single-part production).
M03 - M3: Rotate the spindle clockwise (CW).
M04 - M4: Rotate the spindle counterclockwise (CCW).
M05 - M5: Stop the spindle.
M06 - M6: Tool change.
M08 - M8: Activate coolant.
M09 - M9: Deactivate coolant.
M19: Deactivate coolant.
M30: End of program and return to the beginning of the program.
M98: Call a subprogram.
M99: End of subprogram.
In CNC program writing, there is no requirement to include the leading zero (0) before the G and M codes. The presence or absence of these leading zero digits does not constitute a formatting error. When the M00 command is encountered, the machine stops and waits regardless of the position of the Optional Stop Switch. The wait time continues until the Cycle Start button is pressed. Pressing the Cycle Start button allows the program to resume from where it left off.
The M00 command is particularly useful for tasks like dimension checking or machining workpieces from both ends with the same program. After machining one end of the workpiece, when the M00 command is encountered, the machine stops. The workpiece is unclamped, rotated, and re-clamped. Pressing the Cycle Start button again allows machining of the previously unprocessed end of the workpiece. It's important to ensure that the clamping diameters are close to each other to avoid recalibrating the jaws.
M00 is sometimes used for deep hole drilling, especially in soft materials where chips can clog the drill flutes. In such cases, the drill bit is retracted from the workpiece, and the M00 command is used to stop the machine. After cleaning the drill bit, pressing the Cycle Start button allows the drilling operation to continue.
M01 is an optional stop command. During program execution, when the machine reaches an M01 line and the Optional Stop switch is in the ON position, the machine stops. To continue from where it left off, the operator must press the Cycle Start button. Even if the M01 command is present in the CNC program, the machine will not stop unless the Optional Stop switch on the control unit is in the ON position. If the switch is in the OFF position, the machine will continue to operate without stopping.