M30: End of program and rewind
What M30 does
M30 ends the program, resets the machine and rewinds to the start so the next cycle start runs the program again. It is the normal last line of a production program.
| Type | M-code |
|---|---|
| Machine | Mill and lathe |
| Group | Program control |
| Modal | No: acts only on its own line |
M30 example
M30 End, rewind, ready for the next part.
| Word | What it means here |
|---|---|
M30 | End of program and rewind |
Codes people confuse with M30
| Code | What it does instead |
|---|---|
M02 | End of program. Ends the program. On many controls it does not rewind to the start. |
M00 | Program stop. Stops the program until the operator presses cycle start. |
M29 | Rigid tapping mode (Fanuc). Locks spindle rotation to the feed for the next tapping cycle. |
Other codes in the program control group
These also act only on their own line.
Meanings follow the common Fanuc-style standard that Haas, Okuma (EIA mode), Mitsubishi, LinuxCNC and most other controls share for this code. Options and parameters change details from machine to machine, so check the manual for your control.
Quick check: M30
-
What does
M30do? (Mill and lathe) -
Which code: Ends the program and returns to the first line, ready for the next part.(Mill and lathe)
-
What does
M02do? (Mill and lathe)
Show the answers
- Ends the program and returns to the first line, ready for the next part.
- M30
- Ends the program. On many controls it does not rewind to the start.
Frequently asked questions
- What does M30 mean in CNC programming?
- End of program and rewind. Ends the program and returns to the first line, ready for the next part.
- Is M30 modal?
- No. M30 acts only on the line where it is written; the next line goes back to whatever modal codes were already active.
- What is the difference between M30 and M02?
- M30 (end of program and rewind): ends the program and returns to the first line, ready for the next part. M02 (end of program): ends the program. On many controls it does not rewind to the start.
- What is the difference between M30 and M00?
- M30 (end of program and rewind): ends the program and returns to the first line, ready for the next part. M00 (program stop): stops the program until the operator presses cycle start.
G-Code Sprint is an educational practice tool only. It is not a CNC simulator, machine controller, safety manual, or replacement for instruction. Always follow your instructor, employer, machine manual, and shop procedures.