8 Basic CNC Programming
8.4 NC Codes
126
Example Code: Use of O Code
M98 P50000 ;call to first subprogram
…;after first subprogram is finished, M99 code returns to this point
…
M98 P60000 ;call to second subprogram
…;after second subprogram is finished, M99 code returns to this point
…
O50000 ;start of subprogram N50010 ;first line of subprogram
N50020 ;second line of subprogram
N50030 M99 ; last line of subprogram
…
O60000 ;second subprogram
N60010 ;first line of second subprogram
N60020 ;second line of second subprogram
N60030 M99 ; last line of second subprogram
8.4.15.
P Code: Subprogram Reference Number
P codes are used with the following codes:
Info Table: Use of P Code
Used with Code
To
Section
Page
G31
Reference a GOTO target block.
M98
Reference a subprogram using the subprogram block number.
M99
Specify a return block number as a GOTO target.
8.4.16.
Q Code: Depth of Cut and Peck Depth
The Q code is used in canned cycles to define the depth of cut. In drilling cycles Q specifies the
incremental depth of each peck.
9.6 Canned Cycle Programming, pg. 135.
8.4.17.
R Code: Drilling Start Location
Use the R code in canned cycles to specify a Z axis reference point for peck drilling. The point can be at
the material surface or at another reference point. See
9.6.2 G81 & G83: Straight and Peck Drilling, pg.
The R code is also used to specify the rotation angle, in degrees, with the G68 code. See
Rotation Group, pg. 115.