CNCBUY.NET

CNC G-Code & M-Code Reference Manual

Standard ISO 6983 numerical control syntax, modal behaviors, parameter definitions, and dialect compatibility across Fanuc, Haas, and Siemens controllers.

ISO 6983 & RS-274-D Reference
G00 Rapid Positioning Motion
Motion Modal

Moves the cutting tool to a specified coordinate at the maximum rapid traverse speed with non-cutting motion.

Standard Syntax Format:
G00 X[val] Y[val] Z[val]
Practical Program Example:
G00 X100.0 Y50.0 Z5.0
Fanuc Compatibility

In Fanuc, non-linear dog-leg traverse may occur between axes unless linear rapid interpolation parameter is active.

Haas Automation

Haas defaults to rapid traverse with setting 101 modifying linear vs non-linear behavior.

Siemens SINUMERIK

In Siemens, rapid positioning can also be programmed with POS or POSA.

G01 Linear Feed Interpolation
Motion Modal

Moves the tool in a straight line at a controlled feed rate (F) to remove material accurately.

Standard Syntax Format:
G01 X[val] Y[val] Z[val] F[rate]
Practical Program Example:
G01 X50.0 Y25.0 Z-5.0 F250.0
Fanuc Compatibility

F value remains active for subsequent modal motion blocks.

Haas Automation

Supports exact stop check (G09) and corner rounding.

Siemens SINUMERIK

In Siemens SINUMERIK, F is programmed as feed per minute (G94) or revolution (G95).

G02 Circular Interpolation (Clockwise)
Motion Modal

Interpolates an arc in clockwise direction at the programmed feed rate using I/J/K center offsets or R radius.

Standard Syntax Format:
G02 X[val] Y[val] I[val] J[val] F[rate] OR G02 X[val] Y[val] R[val] F[rate]
Practical Program Example:
G02 X50.0 Y50.0 I25.0 J0.0 F150.0
Fanuc Compatibility

Full 360-degree circles must use I, J, K vector offsets; R cannot specify full 360 degrees.

Haas Automation

Positive R indicates an arc angle <= 180 degrees; negative R indicates an angle > 180 degrees.

Siemens SINUMERIK

Supports helical interpolation when a Z depth axis coordinate is combined with XY circular motion.

G03 Circular Interpolation (Counter-Clockwise)
Motion Modal

Interpolates an arc in counter-clockwise direction at the programmed feed rate.

Standard Syntax Format:
G03 X[val] Y[val] I[val] J[val] F[rate]
Practical Program Example:
G03 X0.0 Y50.0 R25.0 F180.0
Fanuc Compatibility

Arc center vector I/J/K is incremental from starting point regardless of G90/G91 absolute/incremental mode.

Haas Automation

Haas Setting 85 controls max arc error tolerance.

Siemens SINUMERIK

Siemens supports AP (polar angle) and RP (polar radius) programming formats.

G04 Dwell Time
Non-Modal Non-Modal

Pauses all axis motion for a defined time or spindle revolutions, frequently used for chip breaking and bottom finishing.

Standard Syntax Format:
G04 P[milliseconds] OR G04 X[seconds]
Practical Program Example:
G04 P1000 (1-second dwell)
Fanuc Compatibility

Fanuc interprets P1000 as 1.0 second or 1,000 milliseconds depending on system parameters.

Haas Automation

Haas accepts X1.0 or P1000 for a 1-second pause.

Siemens SINUMERIK

Siemens uses G04 F[sec] or G04 S[revs].

G17 XY Plane Selection
Plane Selection Modal

Selects the XY plane for circular interpolation (G02/G03), tool radius compensation (G41/G42), and canned drilling cycles.

Standard Syntax Format:
G17
Practical Program Example:
G17 G90 G00 X0.0 Y0.0
Fanuc Compatibility

Default plane for 99% of vertical milling centers.

Haas Automation

Haas boots into G17 as active modal plane.

Siemens SINUMERIK

In Siemens, tool length compensation acts along Z in G17.

G18 ZX Plane Selection
Plane Selection Modal

Selects the ZX plane, standard for CNC turning centers and horizontal milling radial arcs.

Standard Syntax Format:
G18
Practical Program Example:
G18 G02 X20.0 Z-10.0 R10.0
Fanuc Compatibility

Standard default plane on 2-axis lathes.

Haas Automation

Haas lathes boot into G18 automatically.

Siemens SINUMERIK

Allows tool nose radius compensation G41/G42 in ZX space.

G19 YZ Plane Selection
Plane Selection Modal

Selects the YZ plane for circular arc interpolation and compensation perpendicular to X axis.

Standard Syntax Format:
G19
Practical Program Example:
G19 G03 Y30.0 Z-20.0 J15.0 K0.0
Fanuc Compatibility

Used in 4-axis and 5-axis multiaxis machining for side-face interpolation.

Haas Automation

Fully supported across Haas NextGen controls.

Siemens SINUMERIK

In Siemens, tool length acts along X axis in G19.

G20 Inch Unit Input
Units Modal

Sets the machine coordinate programming system to imperial inches.

Standard Syntax Format:
G20
Practical Program Example:
G20 G90 G54
Fanuc Compatibility

Scale changes input coordinates; machine mechanical pitches remain metric internally.

Haas Automation

Haas Setting 9 controls inch/metric display.

Siemens SINUMERIK

Equivalent to G70 in Siemens SINUMERIK.

G21 Metric Unit Input (Millimeters)
Units Modal

Sets the machine coordinate programming system to metric millimeters.

Standard Syntax Format:
G21
Practical Program Example:
G21 G90 G54
Fanuc Compatibility

Standard international programming mode for modern manufacturing.

Haas Automation

Global standard across European and Asian tooling.

Siemens SINUMERIK

Equivalent to G71 in Siemens SINUMERIK.

G28 Return to Machine Zero / Reference Point
Reference Non-Modal

Commands the machine axes to return to their absolute mechanical home reference limit switches via an intermediate point.

Standard Syntax Format:
G28 [axis coordinates]
Practical Program Example:
G91 G28 Z0.0 (Safely home Z first)
Fanuc Compatibility

Crucial: always execute in G91 incremental mode to prevent crashing into intermediate points.

Haas Automation

Haas G28 home position can be tested safely using Singe Block.

Siemens SINUMERIK

In modern Siemens, SUPA or G75 is preferred over legacy G28.

G40 Tool Radius Compensation Cancel
Cutter Compensation Modal

Cancels cutter radius compensation (G41/G42) and returns control to spindle centerline positioning.

Standard Syntax Format:
G40 G01 X[val] Y[val] F[rate]
Practical Program Example:
G40 G01 X0.0 Y0.0 F500.0
Fanuc Compatibility

Must be executed on a non-cutting departure move at least equal to cutter radius.

Haas Automation

Haas requires a linear feed move to safely disengage cutter comp.

Siemens SINUMERIK

In Siemens, G40 cancel move also removes 3D tool vectors.

G41 Cutter Radius Compensation Left
Cutter Compensation Modal

Offsets the tool to the left of the programmed cutting vector by the radius defined in the tool offset register (Climb milling).

Standard Syntax Format:
G41 D[offset_number] G01 X[val] Y[val]
Practical Program Example:
G41 D01 G01 X20.0 Y0.0 F300.0
Fanuc Compatibility

The cornerstone of modern climb milling and tight bore/contour sizing.

Haas Automation

Haas lookahead buffer analyzes 2 to 5 blocks to prevent gouging.

Siemens SINUMERIK

In Siemens, tool radius is automatically derived from active tool master geometry register.

G42 Cutter Radius Compensation Right
Cutter Compensation Modal

Offsets the tool to the right of the programmed path (Conventional milling or back-side lathe profiling).

Standard Syntax Format:
G42 D[offset_number] G01 X[val] Y[val]
Practical Program Example:
G42 D02 G01 X50.0 Y100.0 F250.0
Fanuc Compatibility

Widely used in CNC turning for tool nose radius compensation along OD profiles.

Haas Automation

Requires quadrant orientation code T1-T9 in lathe offset table.

Siemens SINUMERIK

In Siemens, derives tool direction automatically from lathe tool tip orientation.

G43 Tool Length Compensation Positive
Tool Offset Modal

Applies tool length offset from the tool table to compensate for variations in cutter gauge length.

Standard Syntax Format:
G43 H[tool_number] Z[clearance_plane]
Practical Program Example:
G43 H01 Z50.0
Fanuc Compatibility

Always pair with H code matching the tool number (e.g. T1 with H1).

Haas Automation

Haas Setting 15 ensures H code matches active Tool number to prevent crashes.

Siemens SINUMERIK

Siemens handles length compensation implicitly upon T[name] D1 execution.

G53 Machine Coordinate System Positioning
Coordinate System Non-Modal

Moves axes in the unalterable mechanical machine coordinate system, bypassing fixture work offsets.

Standard Syntax Format:
G53 G00 Z0.0
Practical Program Example:
G53 G00 Z0.0 (Retracts Z to max travel for tool change clearance)
Fanuc Compatibility

Non-modal; applies only to the block in which it is commanded.

Haas Automation

Safest method on Haas to retract tool before table indexing or pallet rotation.

Siemens SINUMERIK

In Siemens, SUPA command performs identical function.

G54 Work Coordinate System 1 (Primary Fixture Offset)
Work Offsets Modal

Establishes the primary part datum origin (X0 Y0 Z0) for the first workpiece fixture.

Standard Syntax Format:
G54
Practical Program Example:
G54 G00 X0.0 Y0.0
Fanuc Compatibility

Modal; remains active until G55-G59 or extended work offsets (G54.1 P1-P48) are called.

Haas Automation

Standard default work offset in all CAM post-processors.

Siemens SINUMERIK

Siemens equivalent is G54 (trans or frame setting).

G70 Finishing Cycle (Lathe)
Canned Cycles Non-Modal

Executes a single finishing pass over a profile rough-turned by G71, G72, or G73.

Standard Syntax Format:
G70 P[start_block] Q[end_block] F[rate]
Practical Program Example:
G70 P100 Q200 F0.12
Fanuc Compatibility

Reads the contour geometry defined between N100 and N200 and applies fine finish feed rate.

Haas Automation

Supported natively on Haas ST-series turning centers.

Siemens SINUMERIK

In Siemens, Cycle95 performs multi-pass roughing and finishing.

G71 Stock Removal Turning Cycle (Lathe)
Canned Cycles Non-Modal

Automatically calculates and executes multiple longitudinal roughing passes along Z-axis for OD/ID turning.

Standard Syntax Format:
G71 U[depth] R[retract] / G71 P[start] Q[end] U[finish_X] W[finish_Z] F[rate]
Practical Program Example:
G71 U2.0 R0.5
G71 P100 Q200 U0.4 W0.1 F0.25
Fanuc Compatibility

Standard 2-line Fanuc format; cuts cycle programming from hundreds of lines to two.

Haas Automation

Haas supports both Type I (monotonic) and Type II (pocketing/recess) profiles.

Siemens SINUMERIK

Siemens uses Cycle95 with contour call.

G76 Multi-Pass Threading Cycle (Lathe)
Threading Non-Modal

Automatic multi-pass screw cutting cycle with controlled infeed angle, spring passes, and compound threading.

Standard Syntax Format:
G76 P[mra] Q[min_depth] R[finish_allowance] G76 X[minor_dia] Z[end_Z] P[thread_depth] Q[first_depth] F[pitch]
Practical Program Example:
G76 P020060 Q100 R0.05
G76 X27.5 Z-30.0 P1250 Q300 F2.0 (M30x2.0 thread)
Fanuc Compatibility

P-word in first block controls spring passes, chamfer angle, and thread flank infeed (60 deg for metric/UN).

Haas Automation

Haas Setting 95/96 controls thread chamfer angle and lead-in.

Siemens SINUMERIK

Siemens uses Cycle97 for single and multi-start threads.

G80 Canned Cycle Cancel
Drilling Cycles Modal

Cancels all canned drilling, boring, and tapping cycles (G81-G89).

Standard Syntax Format:
G80
Practical Program Example:
G80 G00 Z50.0
Fanuc Compatibility

Crucial before transitioning back to milling or pocketing moves.

Haas Automation

Always included immediately following canned cycle point lists.

Siemens SINUMERIK

Required across Fanuc, Haas, and Siemens platforms.

G81 Standard Drilling Cycle
Drilling Cycles Modal

Feeds continuously into hole depth at feed rate F and rapidly retracts to initial or R clearance plane.

Standard Syntax Format:
G81 X[val] Y[val] Z[depth] R[clearance] F[rate]
Practical Program Example:
G81 X25.0 Y25.0 Z-15.0 R2.0 F120.0
Fanuc Compatibility

Ideal for shallow holes (< 3x drill diameter), spot drilling, and countersinking.

Haas Automation

Point coordinates on subsequent lines will repeat the cycle automatically.

Siemens SINUMERIK

Siemens uses Cycle81 (centering/drilling).

G83 Deep Hole Peck Drilling Cycle
Drilling Cycles Modal

Drills in incremental peck steps (Q), retracting fully to clearance plane R between pecks to clear chips and admit coolant.

Standard Syntax Format:
G83 X[val] Y[val] Z[depth] R[clearance] Q[peck_depth] F[rate]
Practical Program Example:
G83 X0.0 Y0.0 Z-50.0 R2.0 Q5.0 F100.0
Fanuc Compatibility

Essential for deep hole drilling (> 4x diameter) to prevent chip compaction and drill breakage.

Haas Automation

Haas supports Setting 52 for variable depth reduction on successive pecks.

Siemens SINUMERIK

Siemens uses Cycle83 with degression factor.

G84 Rigid Tapping Cycle
Tapping Cycles Modal

Synchronizes spindle rotation precisely with Z-axis feed rate for tapping threads without floating tap holders.

Standard Syntax Format:
G84 X[val] Y[val] Z[depth] R[clearance] F[feed]
Practical Program Example:
G84 X0.0 Y0.0 Z-20.0 R5.0 F250.0 (or pitch based on G95)
Fanuc Compatibility

Spindle must reach exact bottom, stop in 0.05s, reverse, and back out along exact pitch.

Haas Automation

Haas Rigid Tapping supports tapping speeds up to 2,000 RPM.

Siemens SINUMERIK

Siemens uses Cycle84 or Cycle840 for synchronized tapping.

G90 Absolute Distance Mode
Positioning Mode Modal

All programmed coordinates are interpreted as absolute distances from the active work coordinate datum (G54).

Standard Syntax Format:
G90
Practical Program Example:
G90 G01 X100.0 Y50.0
Fanuc Compatibility

Standard programming mode for 99% of CNC production programs.

Haas Automation

Default power-on modal condition on Haas and Fanuc mills.

Siemens SINUMERIK

In Siemens, G90 or AC (absolute coordinate) can be used on individual words.

G91 Incremental Distance Mode
Positioning Mode Modal

All programmed coordinates represent incremental motion distances from the current tool position.

Standard Syntax Format:
G91
Practical Program Example:
G91 G28 Z0.0
Fanuc Compatibility

Essential for subroutine steps, bolt circles, and safe G28 machine zero returns.

Haas Automation

Must switch back to G90 immediately after incremental block to avoid positioning runaways.

Siemens SINUMERIK

In Siemens, IC (incremental coordinate) can be appended to any axis value without switching whole block.

M00 Mandatory Program Stop
Program Control Non-Modal

Halts the program execution, shuts off spindle and coolant. Operator must press Cycle Start to continue.

Standard Syntax Format:
M00
Practical Program Example:
M00 (Inspect part or clear chips)
Fanuc Compatibility

Used before manual tool checks, chip clearing, or part flipping.

Haas Automation

All axes hold position with drives active.

Siemens SINUMERIK

Standard ISO universal stop function.

M01 Optional Program Stop
Program Control Non-Modal

Conditionally pauses program execution only if the Optional Stop toggle switch is active on the CNC front panel.

Standard Syntax Format:
M01
Practical Program Example:
M01
Fanuc Compatibility

Standard practice to insert M01 between every tool change for safe shop floor prove-out.

Haas Automation

Operator can ignore M01 during unattended batch runs by turning Optional Stop off.

Siemens SINUMERIK

Universal across Fanuc, Haas, Siemens, Mazak, and Okuma.

M03 Spindle Start Clockwise (Forward)
Spindle Control Modal

Starts spindle rotation in clockwise direction when viewed looking down the spindle onto workpiece.

Standard Syntax Format:
M03 S[rpm]
Practical Program Example:
M03 S8000
Fanuc Compatibility

Standard direction for right-hand milling cutters, carbide inserts, and standard drills.

Haas Automation

Spindle reaches target speed before next axis motion begins.

Siemens SINUMERIK

Universal standard across all machine tools.

M04 Spindle Start Counter-Clockwise (Reverse)
Spindle Control Modal

Starts spindle rotation in counter-clockwise direction, required for left-hand threads and back-side turning.

Standard Syntax Format:
M04 S[rpm]
Practical Program Example:
M04 S1200
Fanuc Compatibility

Used with left-hand taps and certain cut-off grooving blades on lathes.

Haas Automation

Always check tool insert rotation direction before commanding M04.

Siemens SINUMERIK

Universal standard across all machine tools.

M05 Spindle Stop
Spindle Control Modal

Decelerates and stops spindle rotation under dynamic braking.

Standard Syntax Format:
M05
Practical Program Example:
M05
Fanuc Compatibility

Executed before tool changes, manual part measurement, or program termination.

Haas Automation

Brake brings spindle to complete standstill within milliseconds.

Siemens SINUMERIK

Universal across all CNC platforms.

M06 Automatic Tool Change (ATC)
Tool Changer Non-Modal

Commands the automatic tool changer to swap current tool with the pre-selected tool number in spindle.

Standard Syntax Format:
T[num] M06
Practical Program Example:
T02 M06
Fanuc Compatibility

In Fanuc, tool is staged with T02 and changed with M06.

Haas Automation

Haas executes tool change in 1.8 to 2.8 seconds depending on side-mount magazine.

Siemens SINUMERIK

In Siemens, tool change is configured either on M06 or directly upon T execution.

M08 Coolant On (Flood Coolant)
Coolant Control Modal

Activates high-volume flood coolant pump to wash away chips and lubricate tool cutting edges.

Standard Syntax Format:
M08
Practical Program Example:
M08
Fanuc Compatibility

Turns on primary flood nozzles around spindle nose.

Haas Automation

Can be combined with G01 feed moves or called on a dedicated block.

Siemens SINUMERIK

Haas Setting 32 controls coolant override.

M09 Coolant Off
Coolant Control Modal

Shuts off all coolant pumps (flood, mist, and through-spindle coolant).

Standard Syntax Format:
M09
Practical Program Example:
M09
Fanuc Compatibility

Executed before tool change and at program conclusion to keep machine enclosure clean.

Haas Automation

Stops pumps instantly and depressurizes lines.

Siemens SINUMERIK

Universal across all CNC builders.

M19 Spindle Orientation
Spindle Control Non-Modal

Rotates spindle to an exact calibrated mechanical angular position and locks it using encoder feedback.

Standard Syntax Format:
M19 OR M19 P[angle]
Practical Program Example:
M19
Fanuc Compatibility

Essential for boring bar retract (G76/G86) and automatic tool changer alignment.

Haas Automation

Haas allows precise angular orientation with P or R parameter (e.g. M19 P45.0).

Siemens SINUMERIK

In Siemens, SPOS[angle] commands exact spindle positioning.

M30 Program End and Reset (Rewind)
Program Control Non-Modal

Marks the end of the CNC part program, stops spindle and coolant, and rewinds program pointer back to head.

Standard Syntax Format:
M30
Practical Program Example:
M30
Fanuc Compatibility

Signals cycle complete to operator beacon light and updates parts-counter in control memory.

Haas Automation

Emits MTConnect Execution:READY or STOPPED event to factory telemetry dashboards.

Siemens SINUMERIK

Universal international standard ending for CNC G-code programs.

M98 Subprogram Call
Program Control Non-Modal

Jumps execution to an external or nested subprogram identified by program number P.

Standard Syntax Format:
M98 P[program_number] L[loop_count]
Practical Program Example:
M98 P1002 L4 (Executes subprogram O1002 four times)
Fanuc Compatibility

Reduces program size dramatically for repeated bolt patterns, multi-part fixtures, or multi-pass contours.

Haas Automation

Subprogram must terminate with M99 to return control to main program.

Siemens SINUMERIK

In Siemens, subroutines are called directly by subroutine file name (e.g. SUB_POCKET).

M99 Subprogram End / Return
Program Control Non-Modal

Terminates a subprogram called by M98 and returns execution to the next block of the calling program.

Standard Syntax Format:
M99
Practical Program Example:
M99
Fanuc Compatibility

If executed in a main program without M98 call, M99 loops the main program continuously for bar feeder runs.

Haas Automation

Standard return command in Fanuc, Haas, and Mazatrol EIA.

Siemens SINUMERIK

Siemens equivalent is RET.