M99 Subprogram end and return
Fanuc M-code · Mill and lathe
Ends a subprogram and returns to the line after the M98 call. In a main program, M99 jumps back to the start and loops.
Format
M99 [P]
Addresses
| Address | What it does |
|---|---|
P | Sequence number to return to |
How it works
Non-modal.
Example program
O2000 (GROOVE SUBPROGRAM)
G01 U-.4 F.003 (PLUNGE GROOVE, INCREMENTAL)
G00 U.4 (RETRACT)
W-.25 (STEP TO NEXT GROOVE)
…
G01 U-.4 F.003 (PLUNGE GROOVE, INCREMENTAL)
G00 U.4 (RETRACT)
W-.25 (STEP TO NEXT GROOVE)
…
The full 5-line example is in the app. Example is in inch. Check offsets and clearances first.
Watch out for
- M99 at the end of a main program loops forever. Good for bar feeding, dangerous if not meant.
- With P the return goes to that N number instead of the next line.
Related codes
M99 on other controls
The same number can mean something different on another control.
| Control | Meaning |
|---|---|
| Haas NGC | Subprogram return or loop |
| Doosan (Fanuc) | End of sub program |
| DMG Mori MAPPS (Fanuc) | Sub-program end Repeat program |
| Mazak (EIA) | EIA → EIA Return to main EIA program |
| Okuma OSP | Subprogram return (Lathes & Mills) |
| Mitsubishi M70 M80 | Subprogram end and return |
| Brother Speedio | Subprogram end |
| Heidenhain TNC (ISO) | Cycle call in a positioning block |
| LinuxCNC Tormach | Fanuc style subprogram return |
| Mach3 Mach4 | Subprogram return |
| Centroid CNC12 Acorn | Return from subprogram or macro |
| Hurco WinMax (NC) | Subprogram return |
| Fadal | End of subprogram, or line jump |
| Swiss (Citizen Star) | Subprogram return or program loop |
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 M99 in the app All Fanuc M-codes