The varied uses for M99
M99 can be used for several purposes. Here are the ones we know of:
As an end of sub-program command
The is the most common application for M99. As you probably know, a sub-program is called with M98. In the M98 command, a P word specifies the sub-program being called. The command:
N050 M98 P1000
Will call program O1000. At the end of this sub-program, an M99 tells the control to go back to the main program to the command after the calling M98 and continue executing.
To end a main program (rewind and continue)
M99 can also be used to end a main program when you want the machine to return to the beginning of the program and continue executing (without stopping). This is commonly needed in bar feeding turning centers to keep the bar advancing. (An end-of-bar signal from the bar feeder is what stops the machine at the completion of the bar.)
Another such application is with pallet changing machining centers that have two pallets. Since there is often no relationship between the two jobs running on the machine, it makes sense to use sub-programs to control the pallet changing system:
N005 M98 P1000 (run pallet A)
N010 M60 (pallet change)
N015 M98 P4003 (run pallet B)
N020 M60 (pallet change)
N025 M99 (return to beginning and continue)
In this application, M99 is being used as part of a control program that runs both pallets. The program for one of the pallets is O1000. The program for the other is O4003. Both of these sub-programs must also end with M99.
If you're wondering about safety, most pallet-changing machining centers have a stand-by on the pallet changer that must be pressed before a pallet change can occur - so if a person is in the middle of loading parts when an M60 is executed, the machine will wait for the stand-by button to be pressed before it will change pallets.
As an unconditional branch command (like a GOTO statement)
In a main program (not a sub-program), an M99 can be used to change the order of program execution. A P word within the M99 command tells the machine the sequence number (acting as a statement label) to which to branch. The command
N060 M99 P150
tells the machine to go to line N150 and continue. Again, this command must be in a main program. (If it is in a sub-program, the machine will go back to the main program and continue executing from line N150 of the main program - we know of no feasible application for this function).
M99 used as an unconditional branch can be helpful when you want to change the machining order in a program. Maybe you have a poor process - or you just want to see if there is an improvement if one tool in the program is run before another. With just a few changes to the program, you can make the machine bounce from tool to tool to get the machining order you want.