M02 End of program
Fanuc M-code · Mill and lathe
Ends the program and resets the control. Whether the program rewinds to the start depends on a parameter.
Format
M02
How it works
Non-modal.
Example program
G00 X3. Z1. M09 (CLEAR PART)
G28 U0 W0 (HOME)
M02 (END OF PROGRAM)
G28 U0 W0 (HOME)
M02 (END OF PROGRAM)
Example is in inch. Check offsets and clearances first.
Watch out for
- Most shops use M30 instead.
- Check the part counter behavior on your machine before relying on it.
Related codes
M02 on other controls
The same number can mean something different on another control.
| Control | Meaning |
|---|---|
| Haas NGC | Program end |
| Doosan (Fanuc) | Program end |
| DMG Mori MAPPS (Fanuc) | Program end |
| Mazak (EIA) | Program end |
| Okuma OSP | End of program (Lathes & Mills) |
| Mitsubishi M70 M80 | End of program |
| Brother Speedio | Program end |
| Siemens 840D 828D | End of main program |
| Heidenhain TNC (ISO) | End of program |
| Fagor 8055 8065 | End of program |
| LinuxCNC Tormach | Program end |
| Mach3 Mach4 | Program end |
| Centroid CNC12 Acorn | Restart program |
| Hurco WinMax (NC) | End of program |
| Fadal | End of program |
| Swiss (Citizen Star) | End of one cycle (Citizen) |
Every M-code for Fanuc in your pocket. The app has the full example programs, search by number or shop word, a line decoder and calculators for tapping, threading and drilling.
Open M02 in the app All Fanuc M-codes