G-codes move the axes; M-codes switch everything else on and off. They also mark the moments that matter for monitoring — when a program pauses, when it ends, and when a part is done.
Common M-codes
M00
- Function
- Program stop — waits for cycle start
M01
- Function
- Optional stop — only if the optional-stop switch is on
M02
- Function
- End of program (no rewind on some controls)
M30
- Function
- End of program and rewind to the start
M03 / M04 / M05
- Function
- Spindle clockwise / counter-clockwise / stop
M06
- Function
- Tool change
M08 / M09
- Function
- Coolant on / off
| Code | Function |
|---|---|
| M00 | Program stop — waits for cycle start |
| M01 | Optional stop — only if the optional-stop switch is on |
| M02 | End of program (no rewind on some controls) |
| M30 | End of program and rewind to the start |
| M03 / M04 / M05 | Spindle clockwise / counter-clockwise / stop |
| M06 | Tool change |
| M08 / M09 | Coolant on / off |
These are the widely shared basics. Numbers above these are often assigned by the machine builder, so the same code can mean different things on two machines.
How M-codes affect running vs idle
A program sitting on M00 or M01 has stopped, but some controls still report it as “in automatic”. Builder-specific M-codes that wait for an outside signal — a pallet change, a door, a bar feeder — can look like running time too. ThingConnect lets you name such a waiting M-code per machine; while the control sits on it, the time is recorded as idle with that label, not as time in cycle.
M-codes and part counting
Many programs count a part at M30, either through the control’s own counter or by incrementing a macro variable just before it. ThingConnect measures cycle time from those part-count increases, so where the count happens in the program decides where one cycle ends and the next begins.
