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 |
M07 | Cooling (air cooling) on |
M08 | Coolant on |
M09 | Coolant off |
M13 | 4th axls clamp |
M14 | 4th axls unclamp |
M15 | 5th axls clamp |
M16 | 5th 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-code | Description |
---|---|
M00 | Mandatory program stop |
M01 | Optional program stop |
M02 | End of program (usually no reset and rewind) |
M03 | Spindle rotation normal – clockwise |
M04 | Spindle rotation reverse – counterclockwise |
M05 | Spindle rotation stop |
M07 | Coolant mist ON |
M08 | Coolant pump motor ON |
M09 | Coolant pump motor ON |
M10 | Chuck or collet open |
M11 | Chuck or collet close |
M12 | Tailstock quill IN |
M13 | Tailstock quill OUT |
M17 | Turret indexing forward |
M18 | Turret indexing reverse |
M19 | Programmable spindle orientation |
M21 | Tailstock body forward |
M22 | Tailstock body reverse |
M23 | Gradual pull-off from thread ON |
M24 | Gradual pull-off from thread OFF |
M30 | End of program with reset and rewind |
M41 | Gear range selection – low gear |
M42 | Gear range selection – medium gear 1 |
M43 | Gear range selection – medium gear 2 |
M44 | Gear range selection – high gear |
M48 | Feedrate override cancel OFF – feedrate override switch effective |
M49 | Feedrate override cancel ON – feedrate override switch ineffective |
M98 | Subprogram call |
M99 | Subprogram 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.