Usually the M99 we see appears at the end of the subprogram, which is used to end the subprogram and return to the main program.
But the code M99 does much more than that.
In addition to our common function of returning to the main program, M99 can implement loop and jump functions.
During automated processing, we can use robots or feeders to maintain the continuous processing status of the machine and achieve a "lights-out factory."
When the operator prepares the raw materials, the robot will promptly load and unload the raw materials and semi-finished products according to the program settings. Because this action is repetitive, our processing program also needs to be executed repeatedly, automatically opening the protective door of the machine tool, waiting for the loading and unloading of processing materials, automatically closing the protective door, and re-executing the processing code...
At this time, we will use the loop function of M99. Whether to execute the processing code again requires waiting for a signal from the robot or feeder.
According to the settings of the raw material in the feeder or robot, once the pallet or feeder is in the waiting state, the processing program will stop conditionally instead of executing in an infinite loop.
M99 is used at the end of the main program to cause the entire machining program to be executed in a loop;
Used at the end of a subroutine, it will return to the main program.
Before using the jump function of M99, there is one special reminder:
*Don't use duplicate line numbers*
Whether using GOTOnnnn or M99 Pnnnn, it will jump to the Nnnnn line unconditionally. Once there are multiple Nnnnn lines in the program, the control system will jump to any one of them. This is very dangerous for processing, so it is very important to set a unique line number.
To skip a large amount of code we will use the jump function. What should I do if I only want to skip a few lines of code in the program?
I believe you can find the answer in the video below.




