M-code reference

M30: End of program and rewind

M30 is end of program and rewind. Ends the program and returns to the first line, ready for the next part. It is non-modal, so it acts only on the line it is written on.

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.

TypeM-code
MachineMill and lathe
GroupProgram control
ModalNo: acts only on its own line

M30 example

M30

End, rewind, ready for the next part.

WordWhat it means here
M30End of program and rewind

Codes people confuse with M30

CodeWhat 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.

  • M00 Program stop
  • M01 Optional stop
  • M02 End of program
  • M97 Local subprogram call (Haas)
  • M98 Subprogram call
  • M99 Subprogram end / return

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

  1. What does M30 do? (Mill and lathe)

  2. Which code: Ends the program and returns to the first line, ready for the next part.(Mill and lathe)

  3. What does M02 do? (Mill and lathe)

Show the answers
  1. Ends the program and returns to the first line, ready for the next part.
  2. M30
  3. Ends the program. On many controls it does not rewind to the start.

Drill this code with the rest of the core set

More practice hubs

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.

Free preview · no card Try G-Code Sprint