CNC Program Stop, End & Restart M-Codes: M00, M01, M02, M30 Explained
Program control M-codes manage when a CNC program stops, ends, or restarts.
They are essential for safe tool changes, inspections, and automated cycle control.
📌 1. M00 — Program Stop
M00 pauses the program completely until the operator presses Cycle Start.
- Spindle and coolant stop automatically.
- Axis position is held.
- Used for part checks, manual tool changes, or fixture adjustments.
Example:
M00 (INSPECT SURFACE FINISH)
📌 2. M01 — Optional Stop
M01 works like M00 but only executes if the “Optional Stop” switch is ON.
Perfect for optional inspections during setup runs.
Example:
M01 (OPTIONAL INSPECTION)
Keep
M01in non-critical parts of the program to reduce downtime during full production.
📌 3. M02 — Program End (Simple Stop)
M02 marks the end of the program.
- All motion and outputs stop.
- Control returns to the program start position (depending on the machine).
- Does not automatically rewind or reset tool numbers.
Example:
M02
Used mainly in older controls or subprograms.
📌 4. M30 — Program End & Reset
M30 is the modern standard for main program end.
- Stops spindle and coolant.
- Rewinds the program to the top.
- Resets modal conditions.
Example:
M30 (END OF MAIN PROGRAM)
%
📌 5. Typical Program Structure
%
O2001 (FULL PROGRAM STRUCTURE)
G90 G17 G40 G80 G21
T01 M06
S2500 M03
M08
(--- MACHINING ---)
G01 X50. Y0. Z-20. F200
M00 (INSPECT PART)
M01 (OPTIONAL STOP FOR OPERATOR)
(--- END SEQUENCE ---)
M09
M05
G91 G28 Z0
M30
%
📌 6. Haas Program End Options
Haas supports both M02 and M30, but M30 is preferred.
Additional commands like M99 (return from subprogram) or M97 (local jump) may follow.
📌 7. Siemens Sinumerik Equivalents
M00 STOP
M02 END
M30 RESET AND REWIND
📌 8. Heidenhain Equivalents
STOP M00
END PGM NAME MM
Heidenhain programs automatically reset spindle and coolant at end of file.
📌 9. Best Practices
- Use M00 for mandatory manual actions (probe, tool clean, chip clear).
- Use M01 for optional checks — not required every run.
- Always finish main programs with M30.
- Avoid leaving the spindle or coolant on during stops.
- Comment each M-code for clarity (especially M00 and M01).
📌 10. Common Mistakes
| Mistake | Result |
|---|---|
| Using M02 in subprogram | Unexpected restart or control reset |
| Forgetting M09/M05 before M30 | Spindle or coolant keeps running |
| Using M00 too often | Slower production cycles |
| No M30 at end | Control stays idle, not reset |
📌 11. Future Trends (2025–2030)
- Smart program restarts — resume machining mid-toolpath safely.
- AI-assisted error recovery — CNC detects abnormal stop reason and suggests fixes.
- Connected stop logs — machine data uploaded to MES/ERP automatically when M00 or M01 triggers.
✅ Conclusion
Understanding M00, M01, M02, and M30 ensures safe and controlled CNC program execution.
By structuring stops and program ends correctly, you prevent mistakes, improve operator safety, and achieve smooth, repeatable production cycles.
Leave a comment