M02: End of program
What M02 does
M02 ends the program and resets the machine. On older controls it does not rewind, which is why M30 replaced it in most programs. On many modern controls the two behave the same.
| Type | M-code |
|---|---|
| Machine | Mill and lathe |
| Group | Program control |
| Modal | No: acts only on its own line |
M02 example
M02 Program ends.
| Word | What it means here |
|---|---|
M02 | End of program |
Codes people confuse with M02
| Code | What it does instead |
|---|---|
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. |
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: M02
-
What does
M02do? (Mill and lathe) -
Which code: Ends the program. On many controls it does not rewind to the start.(Mill and lathe)
-
What does
M30do? (Mill and lathe)
Show the answers
- Ends the program. On many controls it does not rewind to the start.
- M02
- Ends the program and returns to the first line, ready for the next part.
Frequently asked questions
- What does M02 mean in CNC programming?
- End of program. Ends the program. On many controls it does not rewind to the start.
- Is M02 modal?
- No. M02 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 M02 and M30?
- M02 (end of program): ends the program. On many controls it does not rewind to the start. M30 (end of program and rewind): ends the program and returns to the first line, ready for the next part.
- What is the difference between M02 and M00?
- 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.
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.