Every letter of the alphabet is used as a machine address code. In fact, some are used more than once, and their meaning changes based on which G-code appears in the same block.
Codes are either modal, which means they remain in effect until cancelled or changed, or non-modal, which means they are effective only in the current block.
The table below lists the most common address codes.
Code |
Meaning |
A | Rotation about X-axis. |
B | Rotation about Y-axis. |
C | Rotation about Z-axis. |
D | Cutter diameter compensation (CDC) offset address. |
F | Feed rate. |
G | G-Code (preparatory code). |
H | Tool length offset (TLO). |
I | Arc center X-vector, also used in drill cycles. |
J | Arc center Y-vector, also used in drill cycles. |
K | Arc center Z-vector, also used in drill cycles. |
M | M-Code (miscellaneous code). |
N | Block Number. |
O | Program Number. |
P | Dwell time. |
Q | Used in drill cycles. |
R | Arc radius, also used in drill cycles. |
S | Spindle speed in RPM. |
T | Tool number. |
X | X-coordinate. |
Y | Y-coordinate. |
Z | Z-coordinate. |
Here are the most common alphabetic address code definitions, examples and restrictions of use. Most modern machines use these codes.
Rotation about the X, Y or Z-axis respectively. The angle is in degrees and up to three decimal places precision.
G1 A30.513 B90.
Used to compensate for tool diameter wear and deflection. D is accompanied by an integer that is the same as the tool number (T1 uses D1, etc). No decimal point is used. It is always used in conjunction with G41 or G42 and a XY move (never an arc). When called, the control reads the register and offsets the tool path left (G41) or right (G42) by the value in the register.
G1 G41 X1. D1
Sets the feed rate when machining lines, arcs or drill cycles. Feed rate can be in Inches per Minute (G94 mode) or Inverse Time (G93 mode). Feed rates can be up to three decimal places accuracy (for tap cycles) and require a decimal point.
G1 X1. Y0. F18.
Always accompanied by an integer that determines its meaning. Most G-codes are modal. Expanded definitions of G-codes appear in the next section of this chapter.
G2 X1. Y1. I.25 J0.
This code calls a tool length offset (TLO) register on the control. The control combines the TLO and Fixture Offset Z values to know where the tool is in relation to the part datum. It is always accompanied by an integer (H1, H2, etc), G43, and Z coordinate.
G43 H1 Z1.
For arc moves (G2/G3), this is the incremental X-distance from the arc start point to the arc center. Certain drill cycles also use I as an optional parameter.
G2 X.1 Y2.025 I0. J0.125
For arc moves (G2/G3), this is the incremental Y-distance from the arc start point to the arc center. Certain drill cycles also use J as an optional parameter.
G2 X.1 Y2.025 I0. J0.125
For an arc move (G2/G3) this is the incremental Z-distance from the arc start point to the arc center. In the G17 plane, this is the incremental Z-distance for helical moves. Certain drill cycles also use J as an optional parameter.
G18 G3 X.1 Z2.025 I0. K0.125
Always accompanied by an integer that determines its meaning. Only one M-code is allowed in each block of code. Expanded definitions of M-codes appear later in this chapter.
M8
Block numbers can make the CNC program easier to read. They are seldom required for CAD/CAM generated programs with no subprograms. Because they take up control memory most 3D programs do not use block numbers. Block numbers are integers up to five characters long with no decimal point. They cannot appear before the tape start/end character (%) and usually do not appear before a comment only block.
N100 T2 M6
Programs are stored on the control by their program number. This is an integer that is preceded by the letter O and has no decimal places.
O0002 (PROJECT 1)
Dwell (delay) in seconds. Accompanied by G4 unless used within certain drill cycles.
G4 P.1
The incremental feed distance per pass in a peck drill cycle.
G83 X1. Y1. Z-.5 F12. R.1 Q.1 P5.
Arcs can be defined using the arc radius R or I,J,K vectors. IJK's are more reliable than R's so it is recommended to use them instead. R is also used by drill cycles as the return plane Z value.
G83 Z-.5 F12. R.1 Q.1 P5.
Spindle speed in revolutions per minute (RPM). It is an integer value with no decimal, and always used in conjunction with M3 (Spindle on CW) or M4 (Spindle on CCW).
S3820 M3
Selects tool. It is an integer value always accompanied by M6 (tool change code).
T1 M6
Coordinate data for the X-axis. Up to four places after the decimal are allowed and trailing zeros are not used. Coordinates are modal, so there is no need to repeat them in subsequent blocks if they do not change.
G1 X1.1252
Coordinate data for the Y-axis.
G1 Y1.
Coordinate data for the Z-axis.
G1 Z-.125
The following is a list of commonly used special characters, their meaning, use, and restrictions.
All programs begin and end with % on a block by itself. This code is called tape rewind character (a holdover from the days when programs were loaded using paper tapes).
Comments to the operator must be all caps and enclosed within brackets. The maximum length of a comment is 40 characters and all characters are capitalized.
(T2: .375 END MILL)
Codes after this character are ignored if the Block Delete switch on the control is on.
/ M0
This character is not visible when the CNC program is read in a text editor (carriage return), but does appear at the end of every block of code when the program is displayed on the machine control.
N8 Z0.1 ;