M-Code

M-Codes

“G” stands for Geometry and hence the G-Code commands are responsible for the movements of the machine that create the geometry of the part.
“M” stands for Machine (or Miscellaneous) and the M-Codes are responsible for Machine commands that cause particular operations of the equipment.
Unlike G-codes, that can appear multiple times on same line, M-Code are limited to one code per line.

List of M-codes

CODE ACTION EXPLANATION
M00 Machine Stop The Machine will stop the operation in the middle of the program
M01 Optional Stop The machine will stop in the middle of the program only if the optional stop button is "On".
M02 Program End End of Program
M03 Spindle on CW direction The spindle will start to rotate in CW direction at the speed given in the S parameter
M04 Spindle on CCW direction The spindle will start to rotate in CCW direction at the speed given in the S parameter
M05 Spindle stop The spindle will stop rotating
M06 Automatic tool change (ATC) The machine will change the tool and pick from the Turret/Magazine a new tool according to the "T" parameter
M07 Mist (Shower) Coolant On A spray of coolant fluid droplets
M08 Flood Coolant On An overflowing of coolant fluid.
M09 Coolant off Shut down the coolant (Both M07 & M08)
M30 End of Program The spindle will start to rotate in CW direction at the speed given in the S parameter
M41-M44 Gear selection Select the gear suitable for the spindle speed (ON lathe Machines)
M48 Feedrate override On Operator feedrate override is respected
M49 Feedrate override Off Operator feedreate override is ignored.
M98 Subprogram call Passes control to the subprogram number provided in parameter P
M99 Subprogram end Placed at end of the subprogram and returns the control to the main program one line after the line it was called from.