M00 vs M01 vs M02 vs M30: CNC Program Stops and End Commands Explained
Every CNC program needs to pause, stop, or reset at the right time — and that’s where M00, M01, M02, and M30 come into play.
While they seem similar, each serves a specific purpose in controlling program flow, especially during tool changes, inspections, or job transitions.
🧠 Quick Definitions
| M-Code | Description | Requires Operator Action? | Resumes From? |
|---|---|---|---|
M00 | Unconditional stop | Yes | Same line |
M01 | Optional stop (only if enabled) | Yes (if Optional Stop ON) | Same line |
M02 | End of program | No | Start of program |
M30 | End and rewind (Reset & Start) | No | Beginning again |
🟨 M00 – Unconditional Program Stop
M00
- Pauses execution immediately
- Machine stops: spindle, feed, coolant
- Operator must press Cycle Start to continue
- Use for mandatory inspections, manual tool changes, or part clearance
🟩 M01 – Optional Stop (With Toggle)
M01
- Acts only if Optional Stop switch is ON on the control panel
- Skipped entirely if switch is OFF
- Great for semi-automated inspection points or conditional stops
🔧 Example:
...
G01 Z-15 F150
M01 ; Stop only if toggle ON
G00 Z100
...
Ideal during prototype runs, can be skipped in production.
🟥 M02 – End of Program
M02
- Tells the control that the program has ended
- Most machines stop completely
- Does not rewind the program
- Use for one-time jobs or subprograms
🟦 M30 – End of Program + Reset + Rewind
M30
- Ends the program and resets the program counter
- Rewinds to the start (line 0 or O-code)
- Most commonly used at the end of main programs
- Used for repeatable cycles, automated loops, or part counters
🔁 Typical Usage Flow
%
O1000
(Tool 1 Roughing)
...
M00 ; Manual inspection
...
(Tool 2 Finishing)
...
M01 ; Optional check
...
M30 ; End, reset and ready for next part
%
✅ Best Practices
- Use
M00only for critical manual interventions - Use
M01for optional quality checks - Use
M30at the end of main programs - Use
M02in subprograms or when no rewind is desired - Always comment the reason for stops (
; Check bore size, etc.)
🧠 Summary Table
| M-Code | Function | Used In | Operator Required? | Rewinds? |
|---|---|---|---|---|
| M00 | Unconditional stop | Setup/manual check | ✅ Yes | ❌ No |
| M01 | Optional stop (toggle) | Optional inspections | ✅ (if ON) | ❌ No |
| M02 | End of program | Subprograms/one-offs | ❌ No | ❌ No |
| M30 | End + rewind | Main program ends | ❌ No | ✅ Yes |
Leave a comment