G and M Codes List in CNC Machining

Discover the secret language that brings machines to life! In this captivating blog post, we’ll dive into the fascinating world of G-code and M-code, the essential programming commands that power CNC machining. Whether you’re a seasoned engineer or a curious learner, join us as we unravel the mysteries behind these codes and explore how they enable machines to perform complex tasks with unparalleled precision. Get ready to be amazed by the incredible potential of CNC programming!

Table Of Contents

In CNC machining, G-codes and M-codes are two fundamental programming commands used to control the movement and functionality of machine tools.

G-code, also known as “geometric code” or “preparatory code,” is primarily used to define the motion and positioning of the cutting tool. These codes instruct the machine on how to move, such as rapid motion (G00), linear interpolation (G01), and circular interpolation (G02 and G03), among others.

On the other hand, M-code, also known as “miscellaneous code,” controls various functions of the machine tool, such as spindle rotation, coolant flow adjustment, and tool change. Each G and M code is usually followed by a number representing a specific function or command.

The existence of G-codes and M-codes enables CNC machine tools to perform complex machining tasks. By precise programming instructions, they control the actions of the machine tool, resulting in high precision and high-quality machining effects.

Different combinations of G and M codes can complete various machining operations, including but not limited to drilling, milling, and turning. However, it’s important to note that different manufacturers’ CNC systems may have variations in the specific meanings and applications of these codes. Therefore, reference to the specific machine tool’s operating manual or consultation with the manufacturer is necessary to ensure correct application.

In summary, G-codes and M-codes are indispensable parts of CNC machining. Together, they form the programming language of CNC machine tools, making the mechanical machining process more flexible and efficient. Mastery of these codes’ meanings and applications is crucial for CNC programmers.

What is G-code?

G-code (also known as RS-274) is the most widely used numerical control (NC) programming language in computer-aided manufacturing (CAM). It serves as a standardized set of instructions for controlling automated machine tools, including CNC mills, lathes, 3D printers, and other computer-controlled manufacturing equipment.

Developed in the 1950s by the Electronic Industries Alliance (EIA), G-code has evolved through various versions and implementations. Despite its name, G-code encompasses not only “G” commands (preparatory functions) but also “M” codes (miscellaneous functions), coordinate values, and other parameters that collectively form a comprehensive machine control language.

Key features and applications of G-code include:

  1. Motion control: Rapid positioning, linear and circular interpolation, and complex path generation.
  2. Tool management: Selecting tools, controlling spindle speeds, and managing coolant systems.
  3. Coordinate systems: Defining work coordinates and performing coordinate transformations.
  4. Program flow: Implementing loops, subroutines, and conditional statements.
  5. Machine-specific functions: Controlling unique features of different machine tools.

G-code instructions typically follow a structured format, with each line representing a single command or set of parameters. For example:

G01 X100 Y50 F500

This instruction directs the machine to move linearly (G01) to the X-coordinate of 100mm and Y-coordinate of 50mm at a feed rate of 500mm/minute.

While G-code remains the industry standard, modern CAM software often generates G-code automatically from 3D models and toolpath strategies, simplifying the programming process for complex parts. However, understanding G-code fundamentals remains crucial for optimizing machining processes, troubleshooting, and fine-tuning automated manufacturing operations.

What is M-code?

M-code, short for Miscellaneous code, is a crucial component of CNC (Computer Numerical Control) programming, specifically defined as an auxiliary function code in FANUC and other control systems. These codes play a vital role in controlling various non-axis movement functions of the machine tool, complementing G-codes which primarily handle motion and cutting operations.

M-codes are used to command auxiliary operations that are essential for the overall machining process but do not directly involve the movement of cutting tools or workpiece positioning. These functions can include:

  1. Coolant control (e.g., M08 for coolant on, M09 for coolant off)
  2. Spindle operations (e.g., M03 for spindle clockwise, M04 for counterclockwise, M05 for spindle stop)
  3. Tool changes (e.g., M06 for automatic tool change)
  4. Program flow control (e.g., M00 for program stop, M01 for optional stop)
  5. Pallet changes (e.g., M60 in some systems)
  6. Special machine functions (e.g., M21, M22 for custom operations specific to a particular machine)

The implementation and specific functions of M-codes can vary slightly between different machine manufacturers and control systems, although many standard codes are widely recognized across platforms. Proper use of M-codes is essential for efficient and safe operation of CNC machines, allowing for precise control over various machine functions throughout the manufacturing process.

G and M Codes List

1. FANUC lathe G-code

G-codeExplain
G00Positioning (fast moving)
G01Linear cutting
G02Clockwise arc cutting (CW, clockwise)
G03Counterclockwise tangential positioning (fast moving) arc (CCW, counter clock)
G04Pause (dwel1)
G09Stop at the exact position
G20Imperial input
G21Metric input
G22Internal travel effective limit
G23Invalid internal travel limit
G27Check reference point return
G28Reference point return
G29Return from reference point
G30Return to the second reference point
G32Thread cutting
G40Cancel tool tip radius offset
G41Nose radius offset (left)
G42Nose radius offset (right)
G50Modify workpiece coordinates; Sets the maximum rpm of the spindle
G52Set local coordinate system
G53Select machine coordinate system
G70Finishing cycle
G71Internal and external diameter rough cutting cycle
G72Step rough cutting cycle
G73Forming repeat cycle
G74Z-step drilling
G75X-direction grooving
G76Thread cutting cycle
G80Cancel fixed cycle
G83Drilling cycle
G84Tapping cycle
G85Front boring cycle
G87Side drilling cycle
G88Side tapping cycle
G89Side boring cycle
G90(inside and outside diameter) cutting cycle
G92Thread cutting cycle
G94(step) cutting cycle
G96Constant linear speed control
G97Constant linear speed control cancelled
G98Feed rate per minute
G99Feed rate per revolution

2. FANUC milling machine G code

G codeExplain
G00Top position (rapid movement) positioning (rapid movement)
G01Linear cutting
G02Clockwise circular arc
G03Counterclockwise tangent arc
G04Suspend
G15/G16Polar command
G17XY face assignment
G18XZ face assignment
G19YZ face assignment
G28Machine return to origin
G30The machine returns to the 2nd and 3rd origin
*G40Cancel tool diameter offset
G41Tool diameter left offset
G42Tool diameter right offset
*G43Tool length + direction offset
*G44Tool length offset in one direction
G49Cancel tool length offset
*G53Machine coordinate system selection
G54Workpiece coordinate system 1 Selection
G55Workpiece coordinate system 2 selection
G56Workpiece coordinate system 3 selection
G57Workpiece coordinate system 4 selection
G58Workpiece coordinate system 5 Selection
G59Workpiece coordinate system 6 selection
G73High speed deep hole drilling cycle
G74Left spiral cutting cycle
G76Fine boring cycle
*G80Cancel fixed cycle
G81Center drilling cycle reverse boring cycle
G82Reverse boring cycle
G83Deep hole drilling cycle
G84Right spiral cutting cycle
G85Boring cycle
G86Boring cycle
G87Reverse boring cycle
G88Boring cycle
G89Boring cycle
*G90Use absolute value command
G91Use incremental value command
G92Set workpiece coordinate system
*G98Fixed cycle return to starting point

3. FANUC M code

M-codeExplain
M00Program stop
M01Select Stop
M02Program end (reset)
M03Spindle forward rotation (CW)
M04Spindle reversal (CCW)
M05Spindle stop
M06Change knife
M08Cutting fluid on
M09Cutting fluid off
M30Return to the beginning of the program (reset) and end
M48Cancel spindle overload does not work
M49Spindle overload cancellation function
M94Image cancellation
M95X-coordinate mirror image
M96Y-coordinate mirror image
M98Subroutine call
M99End of subroutine

4. Siemens milling machine G code

AddressExplain
DTool complement number
FFeed rate (dwell time can be programmed with G4)
GG function (prepare function word)
GOFast move
G1Linear interpolation
G2Clockwise circular interpolation
G3Counterclockwise circular interpolation
CIPMiddle point arc interpolation
G33Thread cutting with constant pitch
G331Cutting internal thread without compensation fixture
G332Cutting internal thread without compensation fixture. Retract knife
CTTransition arc interpolation with tangent
G4Fast move
G63Fast move
G74Back to the reference point
G75Fixed point
G25Lower limit of spindle speed
G26Upper limit of spindle speed
G110Pole size, relative to the last programmed set position
G110Pole size, relative to the zero point of the current workpiece coordinate system
G120Pole size, relative to the last valid pole
G17*X / Y plane
G18Z / X plane
G19Y / Z plane
G40Cancellation of tool tip radius compensation
G41The tool tip radius compensation is called, and the tool moves on the left side of the contour
G42The tool tip radius compensation is called, and the tool moves on the right side of the contour
G500Cancel settable zero offset
G54First settable zero offset
G55Second, the zero offset can be set
G56Third, the zero offset can be set
G57Fourth, the zero offset can be set
G58Fifth, the zero offset can be set
G59Sixth, the zero offset can be set
G53Cancel by program segment to set zero offset
G60*Accurate positioning
G70Inch size
G71*Metric size
G700Inch size, also used for feed rate F
G710Metric size, also used for feed rate F
G90*Absolute size
G91Incremental size
G94*Feed rate F in mm / min
G95Spindle feed rate F, in mm / revolution
G901Feed compensation “on” in arc segment
G900Feed compensation “off”
G450Arc transition
G451Intersection of equidistant lines
IInterpolation parameters
JInterpolation parameters
KInterpolation parameters
I1Middle point of circular interpolation
J1Middle point of circular interpolation
K1Middle point of circular interpolation
LSubroutine name and subroutine call
MAuxiliary function
MOProgram stop
M1The program stops conditionally
M2Program end
M3The spindle rotates clockwise
M4The spindle rotates counterclockwise
M5Spindle stop
M6Tool change
NSubroutine segment
:Main program segment
PNumber of subroutine calls
RETEnd of subroutine
SSpindle speed, which indicates pause time in G4
TTool number
XCoordinate axis
YCoordinate axis
ZCoordinate axis
CALLLoop call
CHFChamfer, general use
CHRChamfer contour line
CRCircular interpolation radius
GOTOBBackward jump instruction
GOTOFForward jump command
RNDFillet

5. Siemens 802S / CM fixed cycle

CirculateExplain
LCYC82Drilling and counterbore processing
LCYC83Deep hole drilling
LCYC840Thread cutting with compensation fixture
LCYC84Thread cutting without compensation fixture
LCYC85Boring
LCYC60Linear hole arrangement
LCYC61Circular hole arrangement
LCYC75Rectangular groove, keyway, circular groove milling

6. Siemens 802DM / 810 / 840DM fixed cycle

CirculateExplain
CYCLE82Central drilling
CYCLE83Deep hole drilling
CYCLE84Sexual tapping
CYCLE85Reaming
CYCLE86Boring
CYCLE88Boring with stop
CYCLE71End milling
LONG HOLEA rectangular hole in an arc
POCKE T4Annular groove milling
POCKE T3Rectangular groove milling
SLOT1Keyway on an arc
SLOT2Circular groove

7. Siemens lathe G code

AddressExplain
DTool complement number
F
FFeed rate (dwell time can be programmed with G4)
GG function (prepare function word)
GOFast move
G1Linear interpolation
G2Clockwise circular interpolation
G3Counterclockwise circular interpolation
G33Thread cutting with constant pitch
G4Fast move
G63Fast move
G74Back to the reference point
G75Fixed point
G17(required when machining center hole)
G18*Z / X plane
G40Cancellation of tool tip radius compensation
G41The tool tip radius compensation is called, and the tool moves on the left side of the contour
G42The tool tip radius compensation is called, and the tool moves on the right side of the contour
G500Cancel settable zero offset
G54First settable zero offset
G55Second, the zero offset can be set
G56Third, the zero offset can be set
G57Fourth, the zero offset can be set
G58Fifth, the zero offset can be set
G59Sixth, the zero offset can be set
G53Cancel by program segment to set zero offset
G70Inch size
G71*metric size
G90*Absolute size
G91Incremental size
G94*Feed rate f in mm / min
G95Spindle feed rate F, in mm / revolution
IInterpolation parameters
I1Middle point of circular interpolation
K1Middle point of circular interpolation
LSubroutine name and subroutine call
MAuxiliary function
MOProgram stop
M1The program stops conditionally
M2Program end
M30
M17
M3The spindle rotates clockwise
M4The spindle rotates counterclockwise
M5Spindle stop
M6Tool change
NSubroutine segment
:Main program segment
PNumber of subroutine calls
RETEnd of subroutine
SSpindle speed, which indicates pause time in G4
TTool number
XCoordinate axis
YCoordinate axis
ZCoordinate axis
ARCircular interpolation angle
CALLLoop call
CHFChamfer, general use
CHRChamfer contour line
CRCircular interpolation radius
GOTOBBackward jump instruction
GOTOFForward jump command
RNDFillet

8. SIEMENS 801, 802S/CT, 802SeT fixed cycle

CirculateExplain
LCYC82Drilling and counterbore processing
LCYC83Deep hole drilling
LCYC840Thread cutting with compensation fixture
LCYC84Thread cutting without compensation fixture
LCYC85Boring
LCYC93Grooving cycle
LCYC95Blank cutting cycle
LCYC97Thread cutting

9. SIEMENS 802D, 810D/840D fixed cycle

CirculateExplain
CYCLE71Plane milling
CYCLE82Central drilling
YCLE83Deep hole drilling
CYCLE84Rigid tapping
CYCLE85Reaming
CYCLE86Boring
CYCLE88Boring with stop
CYCLE93Grooving
CYCLE94Undercut shape E.F
CYCLE95Blank cutting
CYCLE97Thread cutting

10. HNC lathe G code

G-codeExplain
G00Positioning (fast moving)
G01Linear cutting
G02Clockwise arc cutting (CW, clockwise)
G03Counter clockwise arc cutting (CCW, counter clock)
G04Pause (dwel1)
G09Stop at the exact position
G20Imperial input
G21Metric input
G22The internal travel limit is valid
G23Invalid internal travel limit
G27Check reference point return
G28Reference point return
G29Return from reference point
G30Return to the second reference point
G32Thread cutting
G36Diameter programming
G37Radius programming
G40Cancel tool tip radius offset
G41>Nose radius offset (left)
G42Nose radius offset (right)
G53Direct machine coordinate system programming
G54-G59Coordinate system selection
G71Internal and external diameter rough cutting cycle
G72Step rough cutting cycle
G73Closed loop turning compound cycle
G76Thread cutting cycle
G80Internal and external diameter cutting cycle
G81Fixed cycle of face turning
G82Thread cutting fixed cycle
G90Absolute value programming
G91Incremental value programming
G92Workpiece coordinate system setting
G96Constant linear speed control
G97Constant linear speed control cancelled
G94Feed rate per minute
G95Feed rate per revolution

11. HNC lathe machine G code

G CodeExplain
G00Positioning (fast moving)
G01Linear cutting
G02Clockwise arc cutting (CW, clockwise)
G03Counter clockwise arc cutting (CCW, counter clock)
G04Pause (dwell)
G09Stop at the exact position
G20Imperial input
G21Metric input
G22The internal travel limit is valid
G23Invalid internal travel limit
G27Check reference point return
G28Reference point return
G29Return from reference point
G30Return to the second reference point
G32Thread cutting
G36Diameter programming
G37Radius programming
G40Cancel tool tip radius offset
G41>Nose radius offset (left)
G42Nose radius offset (right)
G53Direct machine coordinate system programming
G54—G59Coordinate system selection
G71Internal and external diameter rough cutting cycle
G72Step rough cutting cycle
G73Closed loop turning compound cycle
G76Thread cutting cycle
G80Internal and external diameter cutting cycle
G81Fixed cycle of face turning
G82Thread cutting fixed cycle
G90Absolute value programming
G91Incremental value programming
G92Workpiece coordinate system setting
G96Constant linear speed control
G97Constant linear speed control cancelled
G94Feed rate per minute
G95Feed rate per revolution

12. HNC milling machine G code

G-codeExplain
G00Positioning (fast moving)
G01Linear cutting
G02Clockwise circular arc
G03Counterclockwise tangent arc
G04suspend
G07Virtual axis assignment
G09Quasi stop verification
*G17XY face assignment
G18XZ face assignment
G19YZ face assignment
G20Inch input
*G21Mm input
G22Pulse equivalent
G24Mirror on
*G25Mirror off
G28Return to reference point
G29Return from reference point
*G40Cancel tool diameter offset
G41Tool diameter left offset
G42Tool length + direction offset
G43Tool length + direction offset
G44Tool length offset in one direction
*G49Cancel tool length offset
*G50Zoom off
G51Retract and release
G52Local coordinate system setting
G53Direct machine coordinate system programming
*G54Workpiece coordinate system 1 Selection
G55Workpiece coordinate system 2 selection
G56Workpiece coordinate system 3 selection
G57Workpiece coordinate system 4 selection
G58Workpiece coordinate system 5 Selection
G59Workpiece coordinate system 6 selection
G60Unidirectional positioning
*G61Precise stop verification method
G64Continuous mode
G68Rotation transformation
*G69Rotation cancel
G73High speed deep hole drilling cycle
G74Left spiral cutting cycle
G76Fine boring cycle
*G80Cancel fixed cycle
G81Central drilling cycle
G82Reverse boring cycle
G83Deep hole drilling cycle
G84Right spiral cutting cycle
G85Boring cycle
G86Boring cycle
G87Reverse boring cycle
G88Boring cycle
G89Boring cycle
*G90Use absolute value command
G91Using the increment command
G92Set workpiece coordinate system
*G94Feed per minute
G95Feed per revolution
*G98Fixed cycle return to starting point
G99Return to fixed cycle R point

13. HNC M code

M-codeExplain
M00Program stop
M01Select Stop
M02Program end (reset)
M03Spindle forward rotation (CW)
M04Spindle reversal (CCW)
M05Spindle stop
M06Change knife
M07Cutting fluid on
M09Cutting fluid off
M98Subroutine call
M99End of subroutine

14. KND 100 milling machine G code

G-codeGroupExplain
G001Positioning (fast moving)
G01Linear cutting
G02Clockwise circular arc
G03Counterclockwise tangent arc
G040Suspend
G172XY face assignment
G18XZ face assignment
G19YZ face assignment
G280Machine return to origin
G29Return from reference point
*G407Cancel tool diameter offset
G41Tool diameter left offset
G42Tool diameter right offset
*G438Tool length + direction offset
*G44Tool length offset in one direction cancels the tool length offset
G49Cancel tool length offset
*G5314 machine tool coordinate system selection
G54 workpiece coordinate system 1 Selection
G55 workpiece coordinate system 2 selection
G56 workpiece coordinate system 3 selection
G57 workpiece coordinate system 4 selection
G58 workpiece coordinate system 5 Selection
G59 workpiece coordinate system 6 selection
G739high speed deep hole drilling cycle
G74left spiral cutting cycle
G76 fine boring cycle
*G80 cancel fixed cycle
G81 drilling cycle (spot drilling)
G82 drilling cycle (boring stepped holes)
G83 deep hole drilling cycle
G84tapping cycle
G85boring cycle
G86borehole circulation
G87reverse boring cycle
G88boring cycle
G89 boring cycle
*G903use absolute value command
G91 use incremental value command
G920 set workpiece coordinate system
*G9810 fixed cycle return to starting point
*G99 return to fixed cycle r point

15. KND 100 lathe G code

G-codeGroupExplain
G001Positioning (fast moving)
G01Linear cutting
G02Clockwise arc cutting (CW, clockwise)
G03Counter clockwise arc cutting (CCW, counter clock)
G040Pause (dwe11)
G10Offset value setting
G206Imperial input
G21Metric input
G270Check reference point return
G28Reference point return
G29Return from reference point
G31Jumping function
G321Thread cutting
G36 X-axis automatic tool deviation setting
G37 Z-axis automatic tool deviation setting
G407Cancel tool tip radius offset
G41Nose radius offset (left)
G42Nose radius offset (right)
G500Coordinate system setting
G54Workpiece coordinate system
G55—G59Workpiece coordinate system
G700Finishing cycle
G71Internal and external diameter rough cutting cycle
G72Step rough cutting cycle
G73Forming repeat cycle
G74End face deep hole machining cycle
G75Outer circle and inner circle cutting cycle
G76Thread cutting cycle
G901(inside and outside diameter) cutting cycle
G92Thread cutting cycle
G94(step) cutting cycle
G9612Constant linear speed control
G97Constant linear speed control cancelled
G985Feed rate per minute
G99Feed rate per revolution

16. KND 100 M code

M-codeInstruction
M00Program stop
M01Select Stop
M02Program end (reset)
M03Spindle forward rotation (CW)
M04Spindle reversal (CCW)
M05Spindle stop
M06Change knife
M08Cutting fluid on
M09Cutting fluid off
M10Clamping
M11Release
M32Lubrication on
M33Lubrication off
M99End of subroutine

17. GSK980 lathe G code

G-codeGroupFunction
G001Positioning (fast moving)
*G01Linear interpolation (cutting feed)
G02Arc interpolation CW (clockwise)
G03Circular interpolation CCW (counterclockwise)
G040Pause, quasi stop
G28Return to reference point
G321Thread cutting
G500Coordinate system setting
G65 Macro program command
G700Finishing cycle
G71Outer circle rough turning cycle
G72End rough turning cycle
G73Closed cutting cycle
G74End face deep hole machining cycle
G75Outer circle, inner circle, grooving cycle
 1Outer circle, inner circle, turning cycle
G92Thread cutting cycle
 End cutting cycle
G962Constant linear speed on
G97Constant linear speed off
*G983Feed per minute
G99Feed per revolution

18. GSK980T M instruction

M-codeInstruction
M03Spindle forward rotation
M04Spindle reversal
M05Spindle stop
M08Coolant on
M09Coolant off (no output signal)
M32Lubrication on
M33Lubrication off (no output signal)
M10Spare
M11Spare tip (no signal output)
M00The program is suspended. Press the ‘cycle start’ program to continue
M30The program ends and returns to the beginning

19. GSK928 TC / TE G code

G-codeFunction
G00Positioning (fast moving)
*G01Linear interpolation (cutting feed)
G02Arc interpolation CW (clockwise)
G03Circular interpolation CCW (counterclockwise)
G32Tapping circulation
G33Thread cutting
G71Outer circle rough turning cycle
G72End rough turning cycle
G74End face deep hole machining cycle
G75Outer circle, inner circle, grooving cycle
G90Outer circle, inner circle, turning cycle
G92Thread cutting cycle
G94Outer circle inner conical surface circulation
G22Local cycle start
G80End of local cycle
*G98Feed per minute
G99Feed per revolution
G50Set workpiece absolute coordinate system
G2610. Z-axis back reference
G27X-axis back to reference point
G29Z axis back to reference point

20. GSK928 TC / TEM code

M-codeInstruction
M03Spindle forward rotation
M04Spindle reversal
M05Spindle stop
M08Coolant on
M09Coolant off (no output signal)
M32Lubrication on
M33Lubrication off (no output signal)
M10Spare
M11Spare tip (no signal output)
MOOProgram pause, press’ cycle start ‘program to continue
M30The program ends and returns to the beginning

21. GSK990M G Code

G-codeGroupExplain
G001Positioning (fast moving)
G01Linear cutting
G02Clockwise circular arc
G03Counterclockwise tangent arc
G040suspend
G172XY face assignment
G18XZ face assignment
G19YZ face assignment
G280Machine return to origin
G29Return from reference point
*G407Cancel tool diameter offset
G41Tool diameter left offset
G42Tool diameter right offset
*G438Tool length + direction offset
*G44Tool length minus direction offset
G49Cancel tool length offset
*G5314 machine tool coordinate system selection
G54 workpiece coordinate system 1 Selection
G55 workpiece coordinate system 2 selection
G56 workpiece coordinate system 3 selection
G57 workpiece coordinate system 4 selection
G58 workpiece coordinate system 5 Selection
G59workpiece coordinate system 6 selection
G739 high speed deep hole drilling cycle
G74 left spiral cutting cycle
G76 fine boring cycle
*G80 cancel fixed cycle
G81 drilling cycle (spot drilling)
G82 drilling cycle (boring stepped holes)
G83deep hole drilling cycle
G84 tapping cycle
G85 boring cycle
G86 borehole circulation
G87 reverse boring cycle
G88 boring cycle
G89 boring cycle
*G903 use absolute value command
G91 use incremental value command
G920 set workpiece coordinate system
*G9810 fixed cycle return to starting point
*G99 return to fixed cycle r point

22. GSK990M M code

M-codeInstruction
M00Program stop
M01Select Stop
M02Program end (reset)
M03Spindle forward rotation (CW)
M04Spindle reversal (CCW)
M05Spindle stop
M06Change knife
M08Cutting fluid on
M09Cutting fluid off
M10Clamping
M11Release
M32Lubrication on
M33Lubrication off
M98Subroutine call
M99End of subroutine

23. GSK928MA G-code

G-codeExplain
G00Positioning (fast moving)
G1Linear cutting
G02Clockwise circular arc
G03Counterclockwise tangent arc
G04Delay waiting
G17XY face assignment
G18XZ face assignment
G19YZ face assignment
G28Machine return to origin
G29Return from reference point
*G40Cancel tool diameter offset
G41Tool diameter left offset
G42Tool diameter right offset
*G43Tool length + direction offset
*G44Tool length offset in one direction
G49Cancel tool length offset
*G53Machine coordinate system selection
G54Workpiece coordinate system 1 Selection
G55Workpiece coordinate system 2 selection
G56Workpiece coordinate system 3 selection
G57Workpiece coordinate system 4 selection
G58Workpiece coordinate system 5 Selection
G59Workpiece coordinate system 6 selection
G73High speed deep hole drilling cycle
G74Left spiral cutting cycle
G80Cancel fixed cycle
G81Drilling cycle (spot drilling)
G82Drilling cycle (boring stepped holes)
G83Deep hole drilling cycle
G84Right tapping circulation
G85Boring cycle
G86Drilling cycle
G89Boring cycle
*G90Use absolute value command
G91Use incremental value command
G92Set floating coordinate system
*G98Fixed cycle return to starting point
*G99Return to fixed cycle r point
G10 G11Rough milling in circular groove
G12 G13Full circle internal finish milling
G14 G15Cylindrical finish milling
G22System parameter operation (mode)
G23Parameter value jump
G27Mechanical zero point detection
G28Quickly locate the program through the middle point
G31Quick return to R datum
G34 G35Finish milling in rectangular groove
G38 G39Rectangular external finish milling

24. GSK928MAMcode

M2The program ends and stops. Stop the spindle, turn off the coolant, eliminate the G93 coordinate offset and tool offset, and return to the starting program section (not running). After executing M2, the system will switch to the reference workpiece coordinate system.
M3Spindle forward rotation
M4Spindle reversal
M5Stop spindle
M8Turn on the cooling pump
M9Turn off the cooling pump
M12Pause: wait for the “run” key to continue running (press the emergency stop key to stop)
M30At the end of the program, eliminate the tool offset and return to the starting program segment (not running). After executing M30, the system will switch to the reference workpiece coordinate system.
M32Lubrication on;
M33Lubrication off;
M98Call subroutine
M99Subroutine end return

25. Mitsubishi E60 milling machine G code

G-codeGroupExplain
※G001Position positioning (rapid feed)
*G01Straight line repair
G02Clockwise arc cutting (CW)
G03Counterclockwise arc cutting (CCW)
G040suspend
G05High speed machining mode
G09Stop the check correctly
G10Program parameter input / correction input
G11Program parameter input cancel
G12Circular cutting CW
G13Circular cutting CCW
*G172Plane selection X-Y
※G18Plane selection z-x
G19Plane selection Y-Z
※G206Imperial directive
G21Metric instruction
G270Reference origin check
G28Reference origin reset
G29Start point reset
G30The 2nd ~ 4th reference origin reset
G31Jumping function
G331Thread cutting
G370Automatic tool length measurement
G38Tool diameter correction vector assignment
G39Angle arc correction tool
*G407Tool diameter correction cancellation
G41Tool diameter correction left
G42Tool diameter correction right
G438Tool length correction (+)
G44Tool length correction (I)
*G49Tool length correction quantity cancellation
G520Local coordinate system setting
G53Selection of mechanical coordinate system
*G5412Workpiece coordinate system 1 Selection
G5512Workpiece coordinate system 2 selection
G56 Workpiece coordinate system 3 selection
G57 Workpiece coordinate system 4 selection
G58 Workpiece coordinate system 5 Selection
G59 Workpiece coordinate system 6 selection
G600Unidirectional position positioning
G6113Make sure to stop the inspection mode
G62 Automatic angle feed rate adjustment
G63 Tapping mode
*G64 Cutting mode
G739Fixed cycle (step cycle)
G74 Fixed circulation (reverse tapping)
G76 Fixed cycle (fine boring)
*G80 Fixed cycle cancellation
G81 Fixed circulation (drilling / lead hole)
G82 Fixed cycle (drilling / counter boring)
G83 Fixed circulation (deep drilling)
G84 Fixed circulation (tapping)
G85 Fixed cycle (boring)
G86 Fixed cycle (boring)
G87 Fixed cycle (reverse boring)
G88 Fixed cycle (boring)
G89 Fixed cycle (boring)
*G903Absolute value instruction
*G91 Incremental value instruction
G920Mechanical coordinate system setting
G935Counterclockwise feed
*G94 Asynchronous cutting (feed per minute)
*G95 Simultaneous cutting (feed for each drilling)
*G9617The cycle speed must be controlled effectively
*G97 The cycle speed control must be invalid
*G9810Fixed cycle starting point reset
G99 Fixed cycle r-point reset

26. DASEN 3I milling machine G code

G-codeGroupExplain
G001Position positioning (rapid feed)
*G01Straight line repair
G02Clockwise arc cutting (CW)
G03Counterclockwise arc cutting (CCW)
G040suspend
G05High speed machining mode
G09Stop the check correctly
G10Program parameter input / correction input
G11Program parameter input cancel
G12Circular cutting CW
G13Circular cutting CCW
*G172Plane selection X-Y
※G18Plane selection z-x
G19Plane selection Y-Z
※G206Imperial directive
G21Metric instruction
G270Reference origin check
G28Reference origin reset
G29Start point reset
G30The 2nd ~ 4th reference origin reset
G31Jumping function
G331Thread cutting
G370Automatic tool length measurement
G38Tool diameter correction vector assignment
G39Angle arc correction tool
*G407Tool diameter correction cancellation
G41Tool diameter correction left
G42Tool diameter correction right
G438Tool length correction (+)
G44Tool length correction (I)
*G49Tool length correction quantity cancellation
G520Local coordinate system setting
G53Selection of mechanical coordinate system
*G5412Workpiece coordinate system 1 Selection
G5512Workpiece coordinate system 2 selection
G56 Workpiece coordinate system 3 selection
G57 Workpiece coordinate system 4 selection
G58 Workpiece coordinate system 5 Selection
G59 Workpiece coordinate system 6 selection
G600Unidirectional position positioning
G6113Make sure to stop the inspection mode
G62 Automatic angle feed rate adjustment
G63 Tapping mode
*G64 Cutting mode
G739Fixed cycle (step cycle)
G74 Fixed circulation (reverse tapping)
G76 Fixed cycle (fine boring)
*G80 Fixed cycle cancellation
G81 Fixed circulation (drilling / lead hole)
G82 Fixed cycle (drilling / counter boring)
G83 Fixed circulation (deep drilling)
G84 Fixed circulation (tapping)
G85 Fixed cycle (boring)
G86 Fixed cycle (boring)
G87 Fixed cycle (reverse boring)
G88 Fixed cycle (boring)
G89 Fixed cycle (boring)
*G903Absolute value instruction
*G91 Incremental value instruction
G920Mechanical coordinate system setting
G935Counterclockwise feed
*G94 Asynchronous cutting (feed per minute)
*G95 Simultaneous cutting (feed for each drilling)
*G9617The cycle speed must be controlled effectively
*G97 The cycle speed control must be invalid
*G9810Fixed cycle starting point reset
G99 Fixed cycle r-point reset

27. DASEN 3I lathe G code

G-codeGroupExplain
G001Fast mobile positioning
※G01Straight line repair
G02Arc gap (CW, Clockwise Clock)
G03Arc gap repair (CCW, counter clock)
G040suspend
G09Correct stop
G10Program parameters / correction input
G11Program parameter / correction input mode cancelled
※G172X-Y plane selection
※G18Z-x plane selection
※G19Y-Z plane selection
※G206Imperial input
G21Metric input
G270Reference point reset check
G28Automatic reference point reset
G29Reset from reference point
G30Reset of reference points 2, 3 and 4
G31Jumping function
G331Thread cutting
G34Variable thread cutting
G370Automatic tool correction
*G407Tool diameter correction cancellation
G41Tool diameter correction (left side)
G42Tool diameter correction (right side)
G46Tool diameter correction (automatic direction selection)
G520Local coordinate system setting
G53Selection of mechanical coordinate system
※G5412Workpiece coordinate system selection 1
G55Workpiece coordinate system selection 2
G56Workpiece coordinate system selection 3
G57Workpiece coordinate system selection 4
G58Workpiece coordinate system selection 5
G59Workpiece coordinate system selection 6
G6113Correct stop check mode
G62Automatic angle speed control
G63Tapping mode
G64Cutting mode
G709Finish cutting cycle
G71Straight turning rough cutting cycle
G72End face rough cutting cycle
G73Spindle table movement in rough machining cycle
G74End cutting cycle
G75Straight turning cycle
G76Thread cutting cycle
G77From cutting cycle
G78Tooth fixation cycle
G79End cutting fixed cycle
G80Machining hole cycle command cancel
G83Deep drilling cycle (Z-axis)
G84Tapping cycle (Z axis)
G85Boring cycle (Z axis)
G87Deep hole drilling cycle (x-axis)
G88Tapping cycle (x-axis)
G89Boring cycle (x-axis)
※G903Absolute value command
※G91Incremental value command
G920Coordinate system setting / spindle speed setting
※G945Asynchronous feed (feed per minute)
※G95Synchronous feed (feed per revolution)
※G9617Cycle speed control on
※G97Cycle speed must be controlled off
*G9810Fixed cycle
Initial value reversion
G99Fixed cycle
R-point reset

28. Huaxing lathe G code

G-codeExplain
G00Fast positioning
G01Linear interpolation
G02Clockwise circular interpolation
G03Counterclockwise circular interpolation
G04delayed
G09Feed quasi stop
G20Independent subroutine call
G22Independent subroutine definition
G24When the independent subroutine definition is finished, return to the calling program
G25Jump processing
G26Block call subroutine call in machining program
G27Infinite loop
G30Magnification cancellation
G31Magnification definition
G47Short linear speed automatic transition
G48cancel
G54~G59Workpiece coordinate system selection
G71Internal and external circular cutting
G72Face cutting compound cycle
G73Closed contour compound cycle
G74Return to machine reference point (mechanical origin)
G75Return to tool setting point
G76Return to machining start point
G77Restore the current coordinate system
G81Cylindrical machining cycle
G82End face machining cycle
G85Inch rigid tapping cycle
G86Metric thread machining cycle
G87Inch thread machining cycle
G90Absolute value mode programming
G91Incremental value programming
G92Set program zero
G96Constant linear speed cutting is effective
G97Cancel constant linear speed cutting
G98Cancel feed per revolution
G99Set feed per revolution
P = parameter assignment

29. Huaxing lathe M code

M instructionExplain
M01Conditional stop
M02Program end and shutdown
M03Spindle forward rotation
M04Spindle reversal
M05Spindle stop
M06Cooling on
M07Cooling off
M08Workpiece clamping
M09Workpiece loosening
M10Turn on the specified relay
M11Turn off the specified relay
M20Set tool complement number
M21The program ends and returns to the beginning of the program
M71~M85Relay pulse output

30. Huaxing milling machine G code

G-codeExplain
 G01linear interpolation
G02Clockwise arc interpolation or spiral interpolation
G03Counterclockwise arc interpolation or spiral interpolation
G04delayed
G09Servo quasi stop in place
G11The block is mirrored along the Y axis
G12The block is mirrored along the X axis
G13The program block is processed by mirror image at the origin
G17Select the xoy plane
G18Select the x0z plane
G19Select the y0z plane
G20Subroutine call
G22subprogram declaration
G24The subroutine definition ends and returns to the calling program
G25Jump processing
G26Transfer processing
G27Infinite loop
G30Zoom in / out magnification cancel
G31Definition of magnification / reduction ratio
G40Cancel tool radius compensation
G41Left tool radius compensation
G42Right tool radius compensation
G43Establish tool length compensation
G44Undo tool length compensation
G47Short linear speed automatic transition
G48Cancel the automatic transition of short linear speed
G54~G59Workpiece coordinate system selection
G73High speed deep hole machining cycle
G74Return to machine reference point (mechanical origin)
G75Return to tool setting point
G76Return to program zero from current position
G78Fine boring cycle
G81Central hole drilling cycle
G82Central drilling cycle with pause
G83Deep hole machining cycle
G84Metric rigid tapping cycle
G85Inch rigid tapping cycle
G86Boring cycle (automatic return)
G87Reverse boring cycle
G88Boring cycle (manual return)
G89Boring cycle with pause
G90Absolute value mode programming
G91Incremental value programming
G92Set workpiece coordinate system
P = parameter assignment

31. Huaxing milling machine M code

G-codeExplain
M00Program pause
M01L ×× (K ××)
M02Program end and shutdown
M03Spindle forward rotation
M04Spindle reversal
M05Spindle stop
M08Cooling on
M09Cooling off
M10Workpiece clamping
M11Workpiece loosening
M20K ×× Relay No
M21K ×× shut ×× Relay No
M30The program ends and returns to the beginning of the program
M71~M85Relay pulse output

32. Renhe 32T G code

G code  Explain
 G00 quick point positioning instructions
G01Linear interpolation instruction
G02、G03Circular interpolation instruction
G04Program delay instruction
G26、G27Return to starting point instruction
G28、G29
G22、G80Program loop instruction
G23Rectangular loop instruction
G37、G38G39、G36Return hard reference point command
G82、G83Thread cycle command
G46、G47G48、G49Return soft reference point command
G96、G97Constant linear speed cutting function

33. Renhe 32T M code

M instruction Explain
M00Program pause instruction
M02Program end instruction
M30Spindle stop, program end command
M20Automatic cycle command
M03Spindle forward rotation command
M04Spindle reverse command
M05Spindle stop command
M06Wait for instructions after sending a letter
M26Sending instructions
M21Wait for instructions after sending a letter
M97Program jump instruction
M98Subroutine call instruction
M99Subroutine return instruction

34. SKY 2003N M G-code

G-codeGroupTypeFunction
G00011Positioning (fast moving)
G01Linear interpolation (feed)
G02Arc interpolation (clockwise)
G03Arc interpolation (counterclockwise)
G02+ZRight helix interpolation
G03+ZLeft spiral interpolation
G04022suspend
G17041XY plane selection
G181ZX plane selection
G19YZ plane selection
G40071Tool compensation erase
G41Tool compensation left
G42Tool compensation right
G4308Tool length forward compensation
G44Tool length negative compensation
G49Tool length compensation erasure
G5011Zoom, mirror off
G5111Zoom, mirror on
G5414Workpiece coordinate system 1 Selection
G55Workpiece coordinate system 2 selection
G56Workpiece coordinate system 3 selection
G57Workpiece coordinate system 4 selection
G58Workpiece coordinate system 5 Selection
G59Workpiece coordinate system 6 selection
G6803Coordinate rotation
G6903Coordinate rotation erasure
G7315Step cycle
G74Counter attack tooth circulation (machining center)
G76Fine boring cycle (machining center)
G80Fixed cycle erasure
G81Drilling and spot facing cycle
G82Drilling and reverse boring cycle
G83Deep hole drilling cycle
G84Tapping circulation
G85/G86Boring cycle
G87Reverse boring cycle
G88/G89Boring cycle
G9000Absolute value programming
G91Incremental value programming
G9205Coordinate system setting
G9816Return to initial plane
G99Return to r-point plane

35. SKY 2003N M M code

GroupM-codeFunction
AM00,M01,M02The program stops, the program chooses to stop, and the program ends
BM03,M04,M05Spindle forward rotation, spindle reverse rotation, spindle stop
CM06Automatic tool change
DM08,M09Coolant on, coolant off
EM98,M99Call the subroutine and the subroutine returns

How do you select the appropriate G-codes and M-codes for programming based on different CNC systems?

To select the appropriate G-codes and M-codes for programming based on different CNC systems, a comprehensive approach considering system specifics, processing requirements, and industry best practices is essential. Here’s an optimized explanation:

System-Specific Knowledge:

Thoroughly understand the characteristics and capabilities of the specific CNC system you’re working with (e.g., Fanuc, Siemens, Heidenhain). Each system may have unique implementations of G and M codes, custom cycles, or proprietary functions. Consult the manufacturer’s programming manuals and keep updated on the latest firmware versions and supported features.

Code Functionality and Hierarchy:

Master the fundamental functions of G and M codes:

  • G-codes: Motion control, coordinate system selection, canned cycles, etc.
  • M-codes: Auxiliary functions like spindle control, coolant management, tool changes.
    Understand the modal nature of certain codes and their hierarchy within the control system to avoid conflicts and ensure proper execution.

Process-Driven Selection:

Choose codes based on the specific machining operations and part requirements:

  • For contouring: G01 (linear interpolation), G02/G03 (circular interpolation)
  • For rapid movements: G00 (rapid positioning)
  • For complex geometries: Consider using parametric programming or canned cycles
  • For tool management: Appropriate M-codes for tool changes and coolant control

Optimization for Efficiency:

Select codes that optimize machining efficiency:

  • Use high-speed machining codes when applicable (e.g., G05.1 for Fanuc)
  • Implement canned cycles (e.g., G81 for drilling) to reduce program length and simplify programming
  • Utilize advanced features like tool center point control (TCPC) for 5-axis machining when available

Coordinate Systems and Workpiece Setup:

Properly select and utilize coordinate system codes:

  • G54-G59 for workpiece coordinate systems
  • G17/G18/G19 for plane selection in circular interpolation and canned cycles
    Consider using features like coordinate system rotation (G68) for multi-sided machining when appropriate.

Safety and Compliance:

Incorporate safety-related codes and best practices:

  • Use M00 (program stop) or M01 (optional stop) for critical inspection points
  • Implement G43 (tool length compensation) to prevent collisions
  • Include M30 (program end and rewind) to ensure proper program termination

Machine-Specific Optimizations:

Leverage machine-specific features:

  • For high-speed machining centers: Use look-ahead functions (e.g., G05.1 Q1 for Fanuc)
  • For multi-axis machines: Implement RTCP (Rotation Tool Center Point) functions when available
  • For turn-mill centers: Utilize specialized codes for synchronizing spindles and live tooling

Testing and Validation:

Rigorously test your code selections:

  • Use simulation software to verify tool paths and identify potential issues
  • Perform dry runs and single block execution to ensure proper code functionality
  • Validate the program on the actual machine, starting with reduced feed rates for safety

Documentation and Standardization:

Develop and maintain a standardized code library for common operations within your organization. This promotes consistency, reduces programming errors, and facilitates knowledge transfer among team members.

By following this comprehensive approach, you can select the most appropriate G and M codes for your specific CNC system, ensuring efficient, safe, and optimized machining processes. Remember to continuously update your knowledge as CNC technology and programming techniques evolve.

In practical CNC machining, how can G-codes and M-codes be effectively combined to enhance machining efficiency and precision?

In practical CNC machining, effectively combining G-codes and M-codes is crucial for enhancing machining efficiency and precision. This integration requires a deep understanding of both code types and their strategic application within the machining process.

G-codes, which control tool movement and cutting operations, form the backbone of CNC programming. Key G-codes include G00 (rapid positioning), G01 (linear interpolation), G02/G03 (circular interpolation), and G81-G89 (canned cycles for drilling, boring, and tapping). M-codes, on the other hand, manage auxiliary functions such as coolant control (M08/M09), spindle control (M03/M04/M05), and tool changes (M06).

To optimize machining efficiency and precision:

  1. Streamline tool paths: Utilize advanced G-code functions like G70 (finishing cycle) and G71-G73 (stock removal cycles) for efficient material removal. Implement high-speed machining techniques using G05 (high-speed mode) when appropriate, reducing cycle times while maintaining accuracy.
  2. Optimize cutting parameters: Combine G96 (constant surface speed control) with appropriate M-codes for spindle speed control to maintain optimal cutting conditions throughout the process, especially for parts with varying diameters.
  3. Intelligent coolant management: Use M08/M09 in conjunction with through-tool coolant activation (e.g., M88) at critical points in the program. This ensures proper cooling and chip evacuation, particularly during high-precision operations or when machining difficult materials.
  4. Adaptive tool changes: Implement smart tool change strategies using M06 in combination with tool life monitoring G-codes (G43.4 for tool length compensation). This minimizes unnecessary tool changes while ensuring consistent machining quality.
  5. Coordinate system optimization: Utilize multiple coordinate systems (G54-G59) in conjunction with G92 (coordinate system setting) to minimize setup times for complex parts or multi-operation jobs.
  6. Probing and in-process measurement: Integrate probing cycles (G31) with M-codes for automatic workpiece alignment and in-process dimension checking, enhancing overall precision and reducing scrap rates.
  7. Macro programming: Develop custom macros that combine G-codes and M-codes for frequently repeated operations. This not only improves programming efficiency but also ensures consistency in complex machining sequences.
  8. Optimized acceleration/deceleration: Use G05.1 (AI contour control) in conjunction with appropriate M-codes for servo control to optimize machine dynamics, particularly for complex contours or high-speed operations.
  9. Synchronized auxiliary operations: Coordinate M-codes for auxiliary functions (e.g., pallet changes, bar feeders) with G-code sequences to minimize non-cutting time and maximize machine utilization.
  10. Advanced canned cycles: Utilize specialized canned cycles like G76 (fine boring cycle) or G83 (peck drilling cycle) in combination with appropriate M-codes for coolant and spindle control to optimize challenging operations.

By strategically combining these G-codes and M-codes, CNC programmers can significantly enhance both machining efficiency and precision. This approach requires a thorough understanding of the machine’s capabilities, the workpiece material properties, and the specific requirements of each machining operation. Continuous optimization and refinement of these code combinations, based on real-world performance data and emerging technologies, will further push the boundaries of CNC machining capabilities.

Don't forget, sharing is caring! : )
Shane
Author

Shane

Founder of MachineMFG

As the founder of MachineMFG, I have dedicated over a decade of my career to the metalworking industry. My extensive experience has allowed me to become an expert in the fields of sheet metal fabrication, machining, mechanical engineering, and machine tools for metals. I am constantly thinking, reading, and writing about these subjects, constantly striving to stay at the forefront of my field. Let my knowledge and expertise be an asset to your business.

You May Also Like
We picked them just for you. Keep reading and learn more!

Milling Machine Basics: A Comprehensive Guide

Ever wondered how intricate metal parts are crafted with precision? This article unveils the magic of milling machines, exploring their various types and key components. Dive in to understand how…

The 10 Best Drilling Machine Manufacturers in China

Have you ever wondered who the top players are in China's drilling machine industry? This article introduces the leading manufacturers dominating the market, highlighting their innovations, extensive product ranges, and…
MachineMFG
Take your business to the next level
Subscribe to our newsletter
The latest news, articles, and resources, sent to your inbox weekly.
© 2024. All rights reserved.

Contact Us

You will get our reply within 24 hours.