NC technology - M codes

M codes and G codes are defined as a code telling machine what type of action to perform. The M codes specifically points toward controlling which function need to be ON / OFF


Basically machine codes are programmed using PLC, so it is very possible that one machine have a different code than the other. Some of the codes are standardized for ease of use and programming
Here is some list of widely used M codes.


M00 Unconditional stop
M01 Conditional stop
M02 End of program
M03 Spindle clockwise
M04 Spindle counterclockwise
M05 Spindle stop
M06 Tool change (see Note below)
M19 Spindle orientation
M20 Start oscillation (configured by G35)
M21 End oscillation
M30 End of program
M40 Automatic spindle gear range selection
M41 Spindle gear transmission step 1
M42 Spindle gear transmission step 2
M43 Spindle gear transmission step 3
M44 Spindle gear transmission step 4
M45 Spindle gear transmission step 5
M46 Spindle gear transmission step 6
M70 Spline definition, beginning and end curve 0
M71 Spline definition, beginning tangential, end curve 0
M72 Spline definition, beginning curve 0, end tangential
M73 Spline definition, beginning and end tangential
M80 Delete rest of distance using probe function, from axis measuring input
M81 Drive On application block (resynchronize axis position via PLC signal during the block)
M101-M108 Turn off fast output byte bit 1 (to 8)
M109 Turn off all (8) bits in the fast output byte
M111-M118 Turn on fast output byte bit 1 (to 8)
M121-M128 Pulsate (on/off) fast output byte bit 1 (to 8)
M140 Distance regulation “on” (configured by G265)
M141 Distance regulation “off”
M150 Delete rest of distance using probe function, for a probe input (one of 16, M151-M168)
M151-M158 Digital input byte 1 bit 1 (to bit 8) is the active probe input
M159 PLC cannot define the bit mask for the probe inputs
M160 PLC can define the bit mask for the probe inputs (up to 16)
M161-M168 Digital input byte 2 bit 1 (to bit 8) is the active probe input
M170 Continue the block processing look ahead of the part program (cancel the M171)
M171 Stop the block processing look ahead of the probe input part program segment (like a G10)
M200 Activate the handwheel operation in the automatic mode (to introduce an offset in the program)
M201-M208 Select the axis (by number from 1 to 8) for the handwheel operation
M209 Activate the handwheel operation in the automatic mode, with PLC control of the axis selection
M210 Deactivate the handwheel input while in the automatic mode
M211 Deactivate this handwheel feature and also remove the handwheel offset (if any)
M213 Spindle 2 clockwise
M214 Spindle 2 counterclockwise
M215 Spindle 2 stop
M280 Switchable spindle/rotary axis, rotary axis on, first combination
M281 Switchable spindle/rotary axis, rotary axis on, second combination
M290 Switchable spindle/rotary axis, spindle enabled, first combination
M291 Switchable spindle/rotary axis, spindle enabled, second combination

Other machine functions, like tool change (usually M06) or coolant control, have their M-code value specified by the PLC application not by the CNC software. Most of the M-code values in above list are configurable.

Other M-codes (up to M699) can be handled by the PLC application based on the particular machine requirements.

0 comments: