Tel: +86 135 6223 3708 / +86-632-5550222           leader@cnctoo.com
Home » News » The meanings and functions of G code and M code for machining centers

The meanings and functions of G code and M code for machining centers

Author: Site Editor     Publish Time: 2025-08-04      Origin: Site

facebook sharing button
twitter sharing button
line sharing button
wechat sharing button
linkedin sharing button
pinterest sharing button
whatsapp sharing button
sharethis sharing button

The CNC machining center code collection refers to the instruction set used to control the operation of a CNC machining center (a type of numerical control machine tool). These codes are usually composed of letters and numbers, and each code has a specific meaning and function. Next, the editor of Huaya CNC will share with you the meanings and functions of G codes and M codes for CNC machining centers:


G Code (Preparation Function)

G-code is used to set the preparation functions of machine tools, such as tool path control, coordinate system selection, tool compensation, feed rate and spindle speed, etc. The following are some common G-codes and their functions:

'G00' : Quick Positioning command, enabling the tool to move to the designated position at the fastest speed.


'G01' : Linear interpolation command, moving the tool according to the set feed rate.


'G02' : Clockwise circular interpolation command.


'G03' : Counterclockwise circular interpolation command.


'G04' : Pause command, causing the tool to pause at the designated position for a specific period of time.


'G09' : Precise stop command, checking whether the tool position conforms to the preset tolerance range.


'G17' : Select the XY plane as the working plane.


'G18' : Select the XZ plane as the working plane.


'G19' : Select the YZ plane as the working plane.


'G20' : Set the input in inches.


'G21' : Set the input in millimeters.


'G28' : Returns the reference point detection command.


"G40" : Eliminate tool radius compensation.


'G41' : Enable left tool radius compensation.


'G42' : Enable right tool radius compensation.


"G43" : Tool length compensation + direction.


'G44' : Tool length compensation - direction.


'G49' : Cancel tool length compensation.


"G90" : Absolute Programming Mode.


"G91" : Incremental Programming mode.


"M Code (Accessibility)

The M code is used to control the auxiliary functions of the machine tool, such as tool changing, coolant control, spindle start and stop, etc. The following are some common M codes and their functions:

'M00' : The program stops unconditionally.


'M01' : Program condition stops.


'M02' : Program ends.


'M03' : The main shaft is rotating in the forward direction.


'M04' : Spindle reversal.


'M05' : Spindle stops.


'M06' : Tool exchange.


'M08' : The coolant is turned on.


'M09' : Coolant off.


'M30' : The program ends and returns to the beginning.


'M98' : Call the subroutine.


'M99' : The subroutine ends and returns to the main program.


The specific application and combination of these codes will determine the operation process and processing effect of the CNC machining center. When programming, programmers need to use these codes reasonably according to the processing requirements and the characteristics of the machine tool.

RECOMMENDED PRODUCTS
TENGDONG is your partner for Machine tool products, or contact
our Technology People directly with any questions.
TENGDONG Machine Tool
 Tel&whatsapp: +86 135 6223 3708
     Landline phone: +86-632-5550222
 Email: leader@cnctoo.com
  200 Meters East Of West Ring Road, 
Machinery Manufacturing Industrial 
Park,Economic Development Zone, 
Zaozhuang,Shangdong, China.
About Us
Product Center
Subscribe Newsletter
Promotions, new products and sales. Directly to your inbox.
Copyright © 2025 Zaozhuang Tengdong Machine Tool Co., Ltd. All Right Reserved