M-code reference
M30 M-Code: Program End and Rewind
Program End and Rewind — Ends the program, resets modal states, stops spindle and coolant, rewinds to the start, and increments the parts counter on most machines.
| Property | Value |
|---|---|
| Code | M30 |
| Function | Program End and Rewind |
| Used on | Mills and lathes |
What does M30 do?
Ends the program, resets modal states, stops spindle and coolant, rewinds to the start, and increments the parts counter on most machines.
M30 example
G91 G28 Z0
G28 Y0
M30Tips
- Anything after M30 is ignored.
- Use M99 instead for continuous bar-feeder loops.
M-codes vary between machine builders. Codes from M00 to M09, M30 and M98/M99 are nearly universal; most others are defined by the machine builder. Always check the M-code list in your machine manual.
Related codes
Most-used M-codes
| Code | Function |
|---|---|
M00 | Program Stop |
M01 | Optional Stop |
M03 | Spindle On Clockwise |
M04 | Spindle On Counter-Clockwise |
M05 | Spindle Stop |
M06 | Tool Change |
M08 | Flood Coolant On |
M09 | Coolant Off |
M98 | Subprogram Call |
M99 | Subprogram Return / Loop |
Frequently asked questions
What does M30 mean on a CNC machine?
M30 is Program End and Rewind. Ends the program, resets modal states, stops spindle and coolant, rewinds to the start, and increments the parts counter on most machines.