8 Basic CNC Programming
8.4 NC Codes
120
8.4.11.2.
L Code: Loop and Program Counter
The L code functions as a counter when used with codes M98 and M47:
Info Table: L Code Used as a Counter
When Used
With
L Specifies
Section
Page
M47
The number of times a program must be repeated.
8.4.12 M Codes:
Miscellaneous Codes
M98
The number of times a subprogram must be repeated.
8.4.12.
M Codes: Miscellaneous Codes
M codes control a variety of milling center functions while a part program is running.
The following general rules must be followed when using M codes:
Only one M code may be used in a program block.
M codes should be specified in their own blocks. Using M codes together with other codes in a
block can cause confusion about which code is executed first, however:
All M codes used to turn on a device, such as the spindle, execute at the beginning of the tool
motion for that block of NC code.
All M codes used to turn off a device execute after the tool motion for that block is
completed.
The supported M codes are listed in this table.
Info Table: Miscellaneous Mode Group
Subgroup
Code
Function
Program
Stop/End
Group
M00
Pause
Allows you to place a pause in your code. Acts like a G05 pause.
M01
Optional Stop
Allows you to place an optional pause in your code. Place an M01 in the block of code
where you would like to pause.
There are switches to activate or deactivate the Optional Stop code in the Run Settings
window (see
5.6.2 Modifying Run Settings, pg. 67) and on the Operator Panel (see
5.3.4.2 The Operator Panel, pg. 60).
With Optional Stop on, the M01 works like a G05 pause. With Optional Stop off, the
M01 code is ignored, and the other codes on the block are executed as usual.
M02
End of Program
Takes effect after all motion has stopped; turns off drive motors, and all outputs,
including the spindle and the accessory outlets.
M30
End of program: Same as M02.