What Are G and M Codes? Beginner’s Guide to CNC Lathe Programming

Mar 18 2026

G-code (Geometric Code) and M-code (Machine Code) are the foundational languages of CNC machines. They tell the machine where and how to move, and what auxiliary actions to perform. Even on conversational control interfaces, G/M codes are generated and executed behind the scenes.

Common G-Codes and Their Functions

G-Code Function Description
G00 Rapid Positioning Moves tool quickly without cutting
G01 Linear Interpolation Straight cutting move with feedrate
G02/G03 Arc Cutting (CW/CCW) Used for circular paths
G28 Return to Home Used for retracting tools after machining
G90 Absolute Positioning Coordinates are based on work origin
G91 Incremental Positioning Moves based on current position
G96/G97 Spindle Speed Modes G96 for constant surface speed; G97 for fixed RPM

Common M-Codes and Their Functions

M-Code Description
M00 Program Stop
M03/M04 Spindle Start CW/CCW
M05 Spindle Stop
M08/M09 Coolant On/Off
M30 End of Program and Reset
M06 Tool Change (mainly in milling)

Basic Program Structure

A typical CNC program is made up of lines of instructions (blocks). Each line performs one specific action. Example:
N001 G00 X100 Z100 ; Rapid move to start
N002 G01 X50 Z0 F0.2 ; Linear cutting motion
N003 G28 U0 W0 ; Return axes to home
N004 M30 ; End of program


Controller Support and Training at Force One

Force One CNC lathes equipped with FANUC, Siemens, and other user-specified controllers support ISO-standard G/M codes. They also provide:

  • Conversational programming (e.g., FANUC Manual Guide i)
  • Machining simulation interface
  • Siemens also offers advanced conversational systems like ShopMill / ShopTurn
  • Other systems such as FAGOR, Syntec, LNC, Delta also support user-friendly programming tools

For beginners, we recommend reviewing the manufacturer’s manuals and practicing with simple sample workpieces in simulation mode. This helps build programming logic and confidence.

Force One encourages operators to develop strong programming discipline, stay curious about new controller features, and continuously refine program quality to improve overall productivity and stability.


Summary

Mastering G/M codes is like learning the language of CNC machining. Whether using manual programming or relying on conversational tools, understanding this foundation gives you full control of your machine’s potential.

Send inquiry