8 Basic CNC Programming
8.4 NC Codes
124
; Output part time statistics to file c:\Reports\Stats.txt (c:\Reports directory must exist)
M22 (c:\Reports\Stats.txt,A) Part #@C processed in @TC.
M47 L50 ; We want to process 50 parts.
8.4.12.2.
M99 Code: Return from SubProgram, Goto
The M99 code has two specific uses; it can be used as a command to return from a subprogram or it can
be used as a Goto command.
8.4.12.2.1.
Using M99 with Subprograms
When used in a subprogram, this code returns the program flow to the block following the last M98 (Call
to Subprogram) command.
If the M98 code is used together with an L code to specify multiple calls to the subprogram, the M99
code will return to the block containing the M98 code until all the specified number of subprogram calls
have been made; then it will proceed to the block following the M98.
You can use the P code with a block number to specify a different block to jump to; however, if this
feature is used from a nested subprogram call, all return targets are discarded. The rules for a Goto
target block apply to this use as well.
8.4.12.2.2.
Using M99 as a Goto Command
The M99 code can be used in the main NC program as a Goto command to jump to any line before the
first subprogram (as denoted by an O code).
Use the P code to identify the block number being jumped to. Control is transferred to the first
occurrence of this N code; it cannot be used to transfer control between chained programs.
This command can be used anywhere in the program to change the flow of program execution. It is
good programming practice to place this command on a line by itself to improve the program’s
readability, for example:
M99P50; Jump to line 50 in the current program.
8.4.12.3.
M105 Code: Operator Message
This command is used to display messages in the control software. It provides a way to display messages
to the operator on the message bar while an NC program is running. To pause the program with a
custom message, place a ! character at the start of the message.
By default, the message is centered, displayed as a Normal Message, and is persistent, meaning that it is
not cleared until the program clears it or until the next message is displayed.
The M105 code is used in the format:
M105 (the message); comment
This is illustrated in the example below.
Example Code: Use of M105
M105 (End of Roughing Segment); Normal Message, doesn’t pause
Message functionality can be altered using the special codes listed below.