G-Code and M-Code List for CNC Turning Machine | TSRCNC

G-Code and M-Code List for CNC Turning Machine

πŸ”§ Introduction

CNC turning machines use a unique programming language known as G-Code and M-Code to control every movement and function of the machine.
These codes are the backbone of CNC machining β€” they tell the machine when to move, how fast to cut, when to start or stop the spindle, and much more.
In this article, you’ll find the complete list of G-Codes and M-Codes used in CNC turning, along with explanations and examples that help you master CNC programming easily.

βš™οΈ What is a G-Code?

G-Codes are also called preparatory functions.
They control how the machine tool moves β€” including straight cuts, circular movements, coordinate modes, and speed settings.

Common G-Codes in CNC Turning

G-CodeFunctionDescription
G00Rapid TraverseMoves the tool at maximum speed (non-cutting movement).
G01Linear InterpolationMoves the tool in a straight line at feed rate (used for cutting).
G02Circular Interpolation CWCircular cutting in a clockwise direction.
G03Circular Interpolation CCWCircular cutting in a counter-clockwise direction.
G04DwellPauses tool movement for a set time.
G20Inch ProgrammingPrograms and dimensions in inches.
G21Metric ProgrammingPrograms and dimensions in millimeters.
G28Return to Home PositionSends tool back to reference or home position.
G32Thread CuttingUsed for single-pass threading operations.
G40Cancel Cutter CompensationDisables any cutter compensation.
G41Cutter Compensation LeftEnables tool compensation to the left.
G42Cutter Compensation RightEnables tool compensation to the right.
G50Spindle Speed LimitSets maximum spindle speed.
G96Constant Surface Speed (CSS)Maintains constant cutting surface speed automatically.
G97Cancel CSSSwitches back to fixed RPM mode.
G98Feed per MinuteFeedrate measured in mm/min or inch/min.
G99Feed per RevolutionFeedrate measured per spindle revolution.

βš™οΈ What is an M-Code?

M-Codes are called miscellaneous functions.
They control the machine’s auxiliary actions β€” like spindle start/stop, coolant control, program stop, and tool change

Common M-Codes in CNC Turning

M-CodeFunctionDescription
M00Program StopStops program until manually restarted.
M01Optional StopStops only if optional stop is enabled on control panel.
M02Program EndEnds the program without rewind.
M03Spindle ON (Clockwise)Turns spindle on in clockwise direction.
M04Spindle ON (Counter-Clockwise)Turns spindle on in counter-clockwise direction.
M05Spindle StopStops spindle rotation.
M06Tool ChangeChanges to specified tool number.
M08Coolant ONTurns coolant ON.
M09Coolant OFFTurns coolant OFF.
M30Program End & RewindEnds program and returns to start.
M98Subprogram CallCalls subprogram.
M99Subprogram ReturnReturns from subprogram.

πŸ’‘ Example CNC Turning Program

O1000;
G21 G40 G99;
G50 S2000;
G96 S180 M03;
G00 X50.0 Z2.0;
G01 Z0.0 F0.25;
G01 X0.0 F0.15;
G00 X100.0 Z100.0;
M05;
M30;

Program Explanation

🎯 Why It’s Important to Learn G & M Codes

Understanding G and M codes gives you complete control of the CNC machine.
Even if you use advanced CAM software, having manual knowledge helps you:

πŸ“š Learn CNC Programming with TSRCNC

If you want to learn CNC Programming from basic to advanced, the TSRCNC E-Learning App is designed just for you.

You can explore:

πŸŽ“ Download the TSRCNC App on Google Play and start your CNC learning journey today. TSRCNC – Learn Without Limits.

Download now

🏁 Conclusion

G-Codes and M-Codes form the language of CNC turning.
By mastering them, you can confidently create, read, and modify CNC programs for any turning operation.
Keep practicing and refer to this list whenever you write new programs β€” it’s the foundation for every CNC machinist.

Our Course Syllabus

Mastercam Turning Syllabus Mastercam Milling Syllabus CNC Turning Programming Syllabus