G0
Rapid positioning move
X Y Z G90 G0 X50 Y25 (rapid to XY)
G0 Z2 (rapid down to clearance) Reference
Our CNC simulators run real, Fanuc-style G-code — not a simplified toy interpreter. Below are all 60 supported commands, with their parameters and a working example for each. Type them into the MDI line or run them as a full program, and watch the material get removed exactly as your code cuts it.
Positioning, feed moves, arcs and thread cutting.
Rapid positioning move
X Y Z G90 G0 X50 Y25 (rapid to XY)
G0 Z2 (rapid down to clearance) Linear interpolation move
X Y Z F G1 X80 Y25 F150 (feed move at 150 mm/min) Circular interpolation, clockwise
X Y Z I J K F X Y Z R F G17 G2 X40 Y20 I10 J0 F120 (CW arc, centre = current + I,J)
G2 X40 Y20 R10 F120 (same arc using radius R) Circular interpolation, counterclockwise
X Y Z I J K F X Y Z R F G17 G3 X20 Y20 I0 J10 F120 (CCW arc, centre = current + I,J) Thread cutting (spindle-synchronized feed move)
X Z F M3 S800
G32 Z-30 F1.5 (single-point thread pass, F = pitch) Dwell (P = milliseconds, X = seconds)
P X G4 P500 (pause 500 ms)
G4 X2 (pause 2 seconds) Return to machine zero position
X Y Z G28 Z0 (return Z to machine zero)
G28 X0 Y0 (then return X and Y) Modal state that determines how the following coordinates are read.
Select XY plane for circular interpolation
G17 (XY plane — default for milling arcs) Select XZ plane for circular interpolation
G18 (XZ plane — default for lathe arcs) Select YZ plane for circular interpolation
G19 (YZ plane) Set units to inches
G20 (interpret coordinates as inches) Set units to millimeters
G21 (interpret coordinates as millimeters) Absolute positioning mode
G90 (coordinates are absolute positions)
G0 X10 Y10 Incremental positioning mode
G91 (coordinates are distances from current point)
G1 Z-2 (move 2 mm below current Z) How feed rate and spindle speed are interpreted — including constant surface speed for turning.
Feed rate per minute
F G94 F150 (feed expressed in mm per minute) Feed rate per spindle revolution
F G95 F0.2 (feed expressed in mm per spindle revolution) Constant Surface Speed (CSS)
S G96 S180 (hold 180 m/min surface speed; rpm varies with diameter) Constant spindle speed (RPM mode)
S G97 S1200 (hold a fixed 1200 rpm) Clamp maximum spindle RPM
S G96 S180 (constant surface speed)
G50 S3000 (clamp spindle to max 3000 rpm) Six work coordinate systems plus programmable offset setting, as on a Fanuc control.
Machine coordinate system (MCS)
G53 G0 Z0 (rapid in machine coordinates, ignoring work offset) Work coordinate system 1
G54 (select work offset 1) Work coordinate system 2
G55 (select work offset 2) Work coordinate system 3
G56 (select work offset 3) Work coordinate system 4
G57 (select work offset 4) Work coordinate system 5
G58 (select work offset 5) Work coordinate system 6
G59 (select work offset 6) Programmable offset setting
L P X Y Z G10 L2 P1 X-300 Y-250 Z-150 (set G54 origin; P1..P6 = G54..G59)
G10 L20 P1 X0 Y0 Z0 (set G54 so current position = 0) Cutter radius and tool length compensation.
Cancel tool radius compensation
G40 (cancel cutter radius compensation) Tool radius compensation left
G41 (cutter comp left — uses the mounted tool radius)
G1 X20 Y10 F150
G40 (cancel before retract) Tool radius compensation right
G42 (cutter comp right — uses the mounted tool radius)
G1 X20 Y10 F150
G40 (cancel before retract) Apply tool length compensation
T1 M6
G43 Z50 (apply tool length compensation) Cancel tool length compensation
G49 (cancel tool length compensation) Canned cycles with retract-mode control, the way a real controller repeats them hole after hole.
Simple drilling cycle: feed in, rapid retract
X Y Z R F G98 G81 X20 Y20 Z-12 R2 F100 (drill to Z-12, R = retract plane)
X40 (repeat at next hole) Drilling with dwell at bottom, rapid retract
X Y Z R P F G98 G82 X20 Y20 Z-12 R2 P300 F100 (drill + dwell 300 ms at bottom) Peck drilling: incremental steps with chip clearing
X Y Z R Q F G98 G83 X20 Y20 Z-25 R2 Q4 F80 (peck in 4 mm steps, clear chips) Tapping with synchronized spindle reversal
X Y Z R F G95
M3 S500
G84 X20 Y20 Z-15 R3 F1.25 (tap; F = pitch, spindle reverses to back out) Boring: feed in, retract at feed rate for a smooth finish
X Y Z R F G85 X20 Y20 Z-15 R2 F60 (bore in and out at feed for clean wall) Boring with spindle stop at bottom, rapid retract
X Y Z R F G86 X20 Y20 Z-15 R2 F60 (bore, stop spindle at bottom, rapid out) Back boring cycle
X Y Z R F G87 X20 Y20 Z-15 R2 F60 (boring cycle: feed in, rapid retract) Back boring with manual retract
X Y Z R P F G88 X20 Y20 Z-15 R2 P300 F60 (bore + dwell, spindle stops, program pauses for retract) Back boring with dwell, retract at feed rate
X Y Z R P F G89 X20 Y20 Z-15 R2 P300 F60 (bore + dwell 300 ms, retract at feed) Cancel canned drilling or boring cycle
G80 (cancel active drilling/boring cycle) Retract to initial Z plane
G98 G81 X10 Y10 Z-10 R2 F100 (retract to initial Z between holes) Retract to R plane level
G99 G81 X10 Y10 Z-10 R2 F100 (retract only to R plane between holes) Multi-pass roughing, finishing and threading cycles used on the CNC lathe.
Finishing cycle: single pass along the profile defined by P/Q
P Q G70 P10 Q20 (finish pass over profile N10..N20) Longitudinal roughing: Z-parallel passes stepping in X
U R P Q U W F G71 U2 R1 (cut depth 2 mm, retract 1 mm)
G71 P10 Q20 U0.5 W0.1 F150 (rough profile N10..N20, leave 0.5/0.1)
N10 G0 X20
G1 Z-30
N20 X40 Facing roughing: X-parallel passes stepping in Z
W R P Q U W F G72 W2 R1 (cut depth 2 mm, retract 1 mm)
G72 P10 Q20 U0.5 W0.1 F150 (face-rough profile N10..N20)
N10 G0 Z-30
G1 X40
N20 Z0 Threading cycle: multi-pass thread cutting
P Q R X Z P Q R F G76 P010060 Q0.05 R0.05 (1 finish pass, 60 deg tool, min cut 0.05)
G76 X18.2 Z-30 P0.9 Q0.3 F1.5 (thread: height 0.9, first cut 0.3, pitch 1.5) Start spindle clockwise
S M3 S1200 (spindle ON clockwise at 1200 rpm) Start spindle counterclockwise
S M4 S1200 (spindle ON counterclockwise at 1200 rpm) Stop spindle rotation
M5 (stop the spindle) Tool change
T T2 M6 (load tool 2 into the spindle) Coolant on
M8 (flood coolant ON) Coolant off
M9 (coolant OFF) Program pause
M0 (pause program — press start to resume) Program end without rewind
M2 (end of program) Program end with rewind
M30 (end of program and rewind to the start) Call a block repeatedly instead of copying it — local or external.
Local subprogram call
P L M97 P1000 L3 (run local block N1000 three times)
...
N1000
G91 G1 Z-2 F100 (step 2 mm deeper)
G90
M99 External subprogram call
P L M98 P1000 L3 (run program O1000 three times)
...
O1000
G91 G1 Z-2 F100 (step 2 mm deeper)
G90
M99 Subprogram end and return to caller
M99 (end of subprogram — return to the caller) Parametric, Fanuc-style macros: assign variables, compute expressions inline and drive the toolpath with loops and conditions. Trigonometry works in degrees.
#100 = 10 + 5
G1 X[#100 / 2] Y[(#100 + 2) * 0.5] F100 (X7.5 Y8.5) SIN Sine of an angle in degrees, e.g. SIN[30] COS Cosine of an angle in degrees, e.g. COS[60] TAN Tangent of an angle in degrees ASIN Arc sine, returns degrees ACOS Arc cosine, returns degrees ATAN Arc tangent, returns degrees SQRT Square root, e.g. SQRT[9] ABS Absolute value, e.g. ABS[-7] ROUND Round to the nearest integer FIX Truncate toward zero (drop the fraction) FUP Round away from zero LN Natural logarithm EXP Exponential, e^x GOTO n Jump to the line labelled Nn
IF [cond] GOTO n Jump to Nn when the condition is true
IF [cond] THEN #var = expr Assign a variable when the condition is true
WHILE [cond] DOn ... ENDn Repeat the block while the condition is true (n = 1-3, nestable)
Every command above runs in our simulators with real-time, GPU-accelerated material removal — the same code you would write on the shop floor.