- HomePage /
- Sector News /
- CNC /
- G AND M CODES IN CNC LATHE MACHINES
G AND M CODES IN CNC LATHE MACHINES
G AND M CODES IN CNC LATHE MACHINES
G Codes
G codes are used in CNC programming to control machining movements and operations. The range of G-code numbers is G00 – G99.
Basic G Codes
· G00 – Rapid movement (non-cutting motion)
· G01 – Linear interpolation (cutting motion)
· G02 – Clockwise (CW) circular interpolation
· G03 – Counterclockwise (CCW) circular interpolation
· G04 – Dwell (pause)
· G20 – Inch measurement system
· G21 – Metric measurement system
· G28 – Return to reference point
· G31 – Skip function
· G32 – Thread cutting
· G34 – Variable pitch threading
Tool Compensation & Speed Control
· G40 – Tool radius compensation cancel
· G41 – Tool radius compensation (left)
· G42 – Tool radius compensation (right)
· G50 – Maximum spindle speed limitation
· G54 - G59 – Workpiece coordinate system
Machining Cycles
· G70 – Finishing turning cycle
· G71 – Rough turning cycle (longitudinal)
· G72 – Face turning cycle
· G73 – Profile rough turning cycle
· G74 – Peck drilling cycle in Z-axis
· G75 – Peck drilling cycle in X-axis
· G76 – Multi-pass threading cycle
· G80 – Canned cycle cancel
· G83 – Deep hole drilling cycle
· G84 – Tapping cycle
Advanced Machining Functions
· G90 – Outer/inner cylindrical turning cycle (single pass)
· G92 – Threading cycle
· G94 – Face turning cycle
· G96 – Constant surface speed
· G97 – Fixed spindle speed
· G98 – Feed rate in mm/min
· G99 – Feed rate in mm/rev
M Codes (Mnn)
M codes are auxiliary functions in CNC programming that assist machining operations. They are represented as M + two-digit number (e.g., M00, M03, M08).
Basic M Codes
· M00 – Program stop (halts execution regardless of optional stop switch status)
· M01 – Optional stop (stops if optional stop switch is active)
· M02 – Program end (used for single-part machining)
· M03 – Spindle on (clockwise)
· M04 – Spindle on (counterclockwise)
· M05 – Spindle stop
· M06 – Tool change
Coolant & Auxiliary Functions
· M08 – Coolant on
· M09 – Coolant off
· M19 – Spindle orientation
· M30 – Program end and return to the beginning
· M98 – Subprogram call
· M99 – Subprogram end
Optional Formatting Rules in CNC Programming
In CNC programs, leading zeros (0) before numbers in G and M codes are optional. Whether they are included or omitted does not affect the functionality of the program.
For example:
· M0 (without a leading zero) is equivalent to M00
· G1 is the same as G01
Usage of M Codes in CNC Programming
· M0 › The machine stops and waits for operator intervention. It resumes only when the Cycle Start button is pressed. This is useful for inspection or reorientation of a workpiece before continuing.
· M1 › Optional stop. If the Optional Stop switch is ON, the machine stops when it encounters M1. Otherwise, it continues executing the program.
· M30 › Ends the program and automatically returns to the beginning.
Practical Applications of M0 & M1
- M0 for Workpiece Repositioning
· If both ends of a workpiece need machining, M0 stops the machine after the first side is finished.
· The operator flips the part and presses Cycle Start to continue machining the second side.
- M0 for Deep Hole Drilling
· When drilling soft materials, chips can clog the drill.
· The machine stops at M0, allowing the operator to clean the drill before resuming the process.
- M1 for Selective Stopping
· Unlike M0, which always stops the machine, M1 stops only if the Optional Stop switch is ON.
· If the switch is OFF, the program continues uninterrupted.