1. Meaning of Letters in CNC Programs
O: Program number – sets the program number
N: Block number – sets the program sequence number
G: Preparatory function code
X / Y / Z: Dimensional characters – axis movement commands
A / B / C / U / V / W: Additional axis movement commands
R: Arc radius
I / J / K: Arc center coordinates (vector values)
F: Feed rate – sets the feed speed
S: Spindle speed – sets the spindle rotation speed
T: Tool function – sets the tool number
M: Miscellaneous function – on/off control functions
H / D: Tool offset number – sets the tool offset
P / X: Dwell time – sets the delay time
P: Subprogram number command – sets subprogram numbers (e.g., subprogram call: M98 P1000
)
L: Repeat count – sets the number of repetitions for a subprogram or fixed cycle (e.g., M98 P1000 L2
; omitting L means L1)
P / W / R / Q: Parameters – used in fixed cycles (e.g., tapping cycle G98/(G99) G84 X_ Y_ R_ Z_ P_ F_
)
2. Common G-Code Explanations
G00: Rapid positioning
G01: Linear interpolation
G02: Circular/helical interpolation (clockwise)
G03: Circular/helical interpolation (counterclockwise)
G04: Dwell or delay time
Example: G04 X1000
or G04 X1.0
G04 P1000
means a 1-second dwell
G09: Exact stop check (verifies the tool is within the target range)
G10: Programmable data input
G17: Select XY plane (X axis or its parallel axis)
G18: Select ZX plane (Y axis or its parallel axis)
G19: Select YZ plane (Z axis or its parallel axis)
G20: Inch input mode
G21: Metric input mode
G28: Return to reference point
Format: G91/(G90) G28 X__ Y__ Z__
– returns via an intermediate point to the reference position (absolute/incremental mode)
G29: Return from reference pointG91/(G90) G29 X__ Y__ Z__
– from the start point, pass the reference point and return to the target position
G30: Return to 2nd, 3rd, or 4th reference point
Example:G91/(G90) G30 P2 X__ Y__ Z__
– return to the 2nd reference point (P2 can be omitted)
G40: Cancel cutter radius compensation
G41: Cutter radius compensation left (tool to the left in feed direction)
G42: Cutter radius compensation right (tool to the right in feed direction)
G43: Tool length compensation + direction
G44: Tool length compensation − direction
G49: Cancel tool length compensation
G50: Cancel scaling
G51: Scaling – format:
ON: G51 X_ Y_ Z_ P_
OFF: G50
Where X/Y/Z set the scaling center and P is the scaling factor (1–999999, integers only; P800 means 0.8 scaling)
G52: Set local coordinate system
G53: Select machine coordinate system
G54–G59: Select work coordinate systems 1–6
G60: Single-direction positioning – eliminates backlash
G61: Exact stop check – decelerates and checks tolerance near the target position
G62: Automatic cornering feed rate adjustment
G63: Tapping cycle
G64: Normal cutting mode – no deceleration between segments
G65: Macro call
G66: Modal macro call
G67: Cancel modal macro call
G68: Coordinate rotation – format:
G17: G68 X_ Y_ R_
G18: G68 X_ Z_ R_
G19: G68 Y_ Z_ R_
G69: Cancel coordinate rotation
G73: Peck drilling cycle
G74: Left-hand tapping cycle
G76: Fine boring cycle (with oriented retraction)
G80: Cancel fixed cycle
G81: Simple drilling cycle
G82: Drilling cycle with dwell at the bottom
G83: Peck drilling cycle
G84: Right-hand tapping cycle
G85–G89: Boring cycles (various types)
G90: Absolute programming
G91: Incremental programming
G92: Set work coordinate system
G98: Return to initial point in fixed cycle retract
G99: Return to R-point in fixed cycle retract
3. Common M-Code Explanations
M00: Unconditional program stop
M01: Optional program stop
M02: End of program
M03: Spindle on clockwise
M04: Spindle on counterclockwise
M05: Spindle stop
M08: Coolant on (external)
M09: Coolant off (all)
M26: Coolant on (internal)
M30: End of program and return to start
M84: Check pallet 1
M95: Check pallet 2
M98: Call subprogram
M99: Return to main program
M135: Rigid tapping
M417: Machine pallet 1 check
M418: Machine pallet 2 check
M419: End pallet check
M433: Tool breakage detection
M462: Transfer pallet number
4. Common Arithmetic in CNC Programming
Addition: #i = #j + #k
Subtraction: #i = #j - #k
Multiplication: #i = #j * #k
Division: #i = #j / #k
Sine: #i = SIN[#j]
Arcsine: #i = ASIN[#j]
Cosine: #i = COS[#j]
Arccosine: #i = ACOS[#j]
Tangent: #i = TAN[#j]
Arctangent: #i = ATAN[#j]
Square root: #i = SQRT[#j]
Absolute value: #i = ABS[#j]
Round: #i = ROUND[#j]
Round down: #i = FIX[#j]
Round up: #i = FUP[#j]
Natural log: #i = LN[#j]
Exponential: #i = EXP[#j]
Logical OR: #i = #j OR #k
Logical XOR: #i = #j XOR #k
Logical AND: #i = #j AND #k
BCD to Binary: #i = BIN[#j]
Binary to BCD: #i = BCD[#j]
5. Logical Operators
EQ: Equal to
NE: Not equal to
GT: Greater than
GE: Greater than or equal to
LT: Less than
6. Program Branching and Loops
Unconditional jump: GOTO
Conditional jump: IF [condition]
Example:IF [condition] GOTO n
– if the condition is met, jump to block nIF [condition] THEN
– e.g., IF [#I EQ #J] THEN #K = 0
7. Loop Statements
WHILE [condition] DO m (m = 1, 2, 3…)
...
ENDm
If the condition is true, the program between DOm
and ENDm
is executed repeatedly until the condition becomes false. Otherwise, execution continues after ENDm
.
If you want, I can also reformat this into a professionally designed CNC programming quick reference table so it’s easier to read and print for workshop use. That would make it look like a real machinist’s handbook page.