top of page

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:

  • O0001

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

512 views1 comment

Recent Posts

See All

Tapping on a turning center (without canned cycles)

Unless your Fanuc controlled turning center came with live tooling, it’s likely that you don’t have canned cycles (G80-G89) like those you find on machining centers. You might have G74 and G75, the mu

Can you speed up your tool change time?

Machining centers, of course, have automatic tool changing devices to automate the tool changing process. Current models boast very fast tool changing times and you may be quite satisfied with tool ch

1 Comment

I have found the return from subroutine a very powerful tool in macro programming. Your example "N060 M99 P150" I have used extensively. The most prevalent is return from an error. In my Macro programs if data is entered that is vetted to be outside some tolerance the macro throws and alarm to alert the operator or setup person. I have found that if the "jump-off" is within an operating program the operator might be able to press start and resume with erroneous data. Especially if the parameter that resets the program to the top on RESET is not set. So I return to N9000 which is the error handling zone of each macro:




The Error number…

bottom of page