There may be times when you need to have the machine execute a series of commands that are related to your program, but not necessarily part of the program. Consider, for example, a series of commands that are only needed during setup. One such series of commands is related to boring jaws on a CNC turning center.
You may have developed a special set of jaw boring commands in order to help the setup person bore jaws. These commands need only be executed once - during the setup. Yet you may not want to have two separate programs - one to bore jaws and another to machine the part. Doing so might cause confusion and the setup person would have to load two separate programs.
You can keep the jaw boring commands in with the machining program with this technique: Place the commands at the end of the program and after the program ending word (M30 or M02). During normal program execution (during the production run), the control will execute the end of program word and rewind the memory without seeing or executing the special series of commands.
Begin the special series of commands with a rememberable sequence number. I like N999. Include the commands you need followed by another end of program word (again, M30 or M02, whichever you use to end programs).
Here is an example. In this example, we're using the technique to enter some fixture offsets.
O0001 (Program beginning)
N235 G91 G28 Z0 M19
N240 M30 (End of program)
N999 G90 G10 L2 P1 X-10.3736 Y-12.0375 Y-9.1732
G10 L2 P1 X-12.0254 Y-13.0541 Y-10.0214
G10 L2 P1 X-11.8710 Y-13.278 Y-11.0248
G90 G10 L2 P1 X-9.2578 Y-10.5454 Y-8.5494
When the setup person wants to run the special sequence (in this case to set the fixture offsets), they will - in the EDIT mode - scan to N999. They'll execute the program from this point (in the AUTO or MEMORY mode). The machine will set all the fixture offsets and then, when it sees the second M30, will rewind to the beginning of the program and stop. It won't see the N999 sequence again unless the setup person scans to it in EDIT mode.
Again, this technique is very helpful whenever you want to have the machine execute a series of commands that is related to your program, but not actually part of it.
Do note that you may have a problem with program loading. Most machines are set to stop loading programs when an M02, M30, or M99 is read. In this case, the machine will stop reading the program before the N999 sequence can be loaded. A parameter controls when the machine will stop loading programs - at M02/M30/M99 or when an end of file terminator (the percent sign - %) is read. If you intend to use this technique, the parameter must be set, of course, to the latter.