Miscellaneous function codes

M-CODE

M-code, or miscellaneous function codes, are essential commands used in CNC (Computer Numerical Control) machines to control various auxiliary functions beyond the primary machining operations. These codes play a crucial role in automating processes, enhancing precision, and ensuring the smooth operation of the machine. From controlling the spindle and coolant systems to managing tool changes and coordinate systems, M-codes provide a standardized way to execute a wide range of machine functions.

M-Code for Milling

An list of all the possible M-codes for a specific milling machine would depend on the make and model of the machine. However, here are some common M-codes that are used on many milling machines:

M00 Program stop
M01 Optional program stop
M02 End of program
M03 Spindle on clockwise
M04 Spindle on counterclockwise
M05 Spindle stop
M06 Tool change
M07Cooling (air cooling) on
M08 Coolant on
M09 Coolant off
M134th axls clamp
M144th axls unclamp
M155th axls clamp
M165th axls unclamp
M30 End of program with rewind
M41 Gear selection (cutting speed)
M48 Enable overrides
M49 Disable overrides
M98 Subprogram call
M99 Subprogram end
M19 Orient spindle for angle measurement
M20 Return spindle to normal position
M21 Left-hand coordinate system
M22 Right-hand coordinate system
M24 Automatic tool changer start
M25 Automatic tool changer stop
M26 Automatic tool changer unclamp
M27 Automatic tool changer clamp
M28 Automatic pallet changer start
M29 Automatic pallet changer stop
M30 Automatic pallet changer unclamp
M31 Automatic pallet changer clamp
M48 Allow feed and rapid override
M49 Prohibit feed and rapid override
M50 Exact stop check on
M51 Exact stop check off
M52 Spindle speed override on
M53 Spindle speed override off
M54 Feed override on
M55 Feed override off
M56 Rapid override on
M57 Rapid override off

M-code for Turning

The following table is a fairly comprehensive reference listing of the most typical and common M-codes (miscellaneous functions) used for CNC turning (CNC lathes). Only a very few M-codes are industry standard and common to all controls.

M-codeDescription
M00Mandatory program stop
M01Optional program stop
M02End of program (usually no reset and rewind)
M03Spindle rotation normal – clockwise
M04Spindle rotation reverse – counterclockwise
M05Spindle rotation stop
M07Coolant mist ON
M08Coolant pump motor ON
M09Coolant pump motor ON
M10Chuck or collet open
M11Chuck or collet close
M12Tailstock quill IN
M13Tailstock quill OUT
M17Turret indexing forward
M18Turret indexing reverse
M19Programmable spindle orientation
M21Tailstock body forward
M22Tailstock body reverse
M23Gradual pull-off from thread ON
M24Gradual pull-off from thread OFF
M30End of program with reset and rewind
M41Gear range selection – low gear                                                       
M42Gear range selection – medium gear 1                                             
M43Gear range selection – medium gear 2                                             
M44Gear range selection – high gear                                                         
M48Feedrate override cancel OFF – feedrate override switch effective
M49Feedrate override cancel ON – feedrate override switch ineffective
M98Subprogram call
M99Subprogram end or Macro end

It’s important to note that this is not a definitive list, and the codes that are available to you may vary depending on the specific machine you’re using. It’s always recommended to consult the machine’s manual for a complete list of codes and their usage.

Leave a Reply