Standard G-Codes and M-Codes For CNC Lathe(Turning)

You can find it here standard and brand-specific G-codes and M-codes. Standard basic turning codes are hugely standardized. However, more complex machines like mill-turns and machines with sub-spindle can have extra and different codes. So always check specific machine code guides.

You can learn about how to read and write g-codes from here.

You can find G-Codes and M-Codes for milling from here.

Standard G-Codes running process

Standard Common G-Codes for Turning

G-CodeDescriptionPossible Parameters
G00Rapid positioningX, Z
G01Linear interpolationX, Z, F
G02Circular interpolation, clockwiseX, Z, I, K, F
G03Circular interpolation, counterclockwiseX, Z, I, K, F
G04DwellP or X
G20Programming in inchesNone
G21Programming in millimetersNone
G28Return to home positionX, Z
G32ThreadingX, Z, F
G40Cutter compensation offNone
G41Cutter compensation leftD
G42Cutter compensation rightD
G70Finishing cycleP, Q
G71Rough turning cycleU, R, K, P, Q
G72Rough facing cycleU, R, K, P, Q
G90Absolute programmingNone
G92Threading cycleX, Z, P, Q, F
G94Feedrate per minuteF
G95Feedrate per revolutionF
Standard Common G-Codes for Turning

Standard Common M-Codes for Turning

M-CodeDescriptionPossible Parameters
M00Program stop, take a bowNone
M01End of the program, the final curtainNone
M02The spindle start, clockwiseNone
M03Call the subprogram, summon the spiritsS (speed)
M04End of the program with reset, a standing ovationS (speed)
M05Spindle stop, rest the wheelNone
M06Tool change, switch the wandT (tool number)
M08Coolant on, quench the thirstNone
M09Coolant off, dry the browNone
M30The spindle starts, counterclockwiseNone
M41Low gear range, tread lightlyNone
M42High gear range, full steam aheadNone
M98End of the subprogram, spirits be goneP (program number), L (number of repeats)
M99End of subprogram, spirits be goneNone
Standard Common M-Codes for Turning

Brand Specific G-Codes, M-Codes for Turning

Mazak G-Codes (Turning)

G-CodeDescription
G12.1Polar coordinate interpolation mode on
G13.1Polar coordinate interpolation mode off
G22Stored stroke limit on
G23Stored stroke limit off
G31Skip function
G35Coordinate system rotation on
G36Coordinate system rotation off
G68Mirror image on
G69Mirror image off
G135Cylindrical interpolation cancel
G136Cylindrical interpolation (X-axis)
Table of Mazak G-Codes (Turning)

Mazak M-Codes (Turning)

M-CodeDescription
M26Spindle gear range change, high gear
M27Spindle gear range change, low gear
M30End of the program with a return to start
M36Automatic door open
M37Automatic door close
M38Chip conveyor forward
M39Chip conveyor reverse
M48Cancel override
M49Enable override
M97Local subprogram call
M98Call external subprogram
M99End of subprogram
Table of Mazak M-Codes (Turning)

Siemens G-Codes (Turning)

G-CodeDescription
G70Finishing cycle
G71Longitudinal turning cycle
G72Face turning cycle
G73Pattern repeating cycle
G74Face grooving or drilling
G75Outer/internal longitudinal grooving
G76Fine boring cycle
G96Constant cutting speed on
G97Constant cutting speed off
Table of Siemens G-Codes (Turning)

Siemens M-Codes (Turning)

M-CodeDescription
M17End of subprogram
M21External M-function
M22Spindle cooling on
M23Spindle cooling off
M25Release clamping device
M26Engage clamping device
M29High-speed spindle mode
M30End of program with reset
M38Chip conveyor on
M39Chip conveyor off
M50Override cancel
M51Feedrate override
M52Rapid traverse override
M53Spindle override
Table of Siemens M-Codes (Turning)

Fanuc G-Codes (Turning)

G-CodeDescription
G20Programming in inches
G21Programming in millimeters
G22Stored stroke check on
G23Stored stroke check off
G40Cutter compensation cancel
G41Cutter compensation left
G42Cutter compensation right
G50Set coordinate system
G70Finishing cycle
G71Turning cycle
G72Facing cycle
G73Pattern repeating cycle
G74End face peck drilling cycle
G75OD/ID grooving
G76Fine boring cycle
G92Threading cycle
G94Feedrate per minute
G95Feedrate per revolution
Table of Fanuc G-Codes (Turning)

Fanuc M-Codes (Turning)

M-CodeDescription
M19Spindle orientation on
M21Mirror image X-axis on
M22Mirror image X-axis off
M26Spindle gear range change
M29High-speed spindle mode
M41Low gear range
M42High gear range
M52Unload the last tool from the spindle
M53Disable override
M61Set constant surface speed
M62Single direction positioning
M64Tailstock forward
M65Tailstock backward
Table of Fanuc M-Codes (Turning)

By Isaac Aloyan

Isaac Aloyan is a talented mechanical engineer with a background in machinery design and manufacturing. He completed his diploma from the Department of Machinery Design and Manufacturing at Kocaeli University and also graduated from Level 7 NZDE Mechanical Engineering at Manukau Institute of Technology (M.I.T). Isaac has developed strong expertise in various areas of mechanical engineering, including CNC programming and machining, vacuum mold design and production, manual machining, CAD and CAM, and thermoforming machine design and production. Also, he has educator experience in the area of CNC machinery and programming and mechanical design. With two decades of experience under his belt, Isaac has established a website called mechutopia.com to share his knowledge and help others who are interested in the field of mechanical engineering. The site is likely to feature a wealth of information, resources, and tips for those looking to learn about CNC machines, machining, mold production, and more. It is a testament to Isaac's dedication to the field and his commitment to helping others excel in sub-domains of mechanical engineering like design and manufacturing.