3D G-Code CNC Simulator & Toolpath Verifier

Inspect 3D cutting trajectories, verify modal G/M-code states, detect axis overtravels, and calculate machining cycle times before running on physical CNC machine tools.

G-Code Editor

0/0
⚠ COLLISION DETECTED — Simulation Paused
VIEW
LINE 0 / 0 — READY
00:00 / 00:000%
SPEED1.0×
Machine State
State
IDLE
Pos X
0.000
Pos Y
0.000
Pos Z
0.000
Units
mm (G21)
Motion
Active Code
Coord Sys
G54
Programmed Feed
0 mm/min
Effective Feed
0 mm/min
Spindle & Tool
Spindle RPM
0
Direction
STOPPED
Current Tool
T1
Coolant
OFF
Progress
Line
0 / 0
Progress
0%
Elapsed
00:00
Remaining
00:00
Distance Traveled
0 mm
Feed Rate vs Time
Spindle RPM vs Time
Axis Position (Z) vs Time
Cycle Time Breakdown
Machine Limits
Travel X
Travel Y
Travel Z
Rates
Rapid Rate (mm/min)
Actions

Interactive User Guide

How to load programs, inspect 3D toolpaths, and verify machining parameters

1. Loading, Editing & Syntax Verification

Load raw NC programs directly via file upload (.nc, .gcode, .tap, .txt) or select pre-configured sample programs from the demo dropdown (Facing, Profile Contour, Circular Pocket, Drill Grid). The live syntax highlighter flags G-codes, M-codes, coordinates, and feed rates in real-time.

2. 3D Viewport Navigation & Plane Projection

Left-click and drag inside the WebGL canvas to orbit around the workpiece. Right-click or Shift-drag to pan the table horizontally and vertically. Scroll to zoom directly into cutter engagement zones. Use the quick-view buttons (Top XY, Front XZ, Side YZ, Isometric) to verify depth passes and vertical clearance heights.

3. Motion Playback, Step-Through & Scrubbing

Press Play (or Spacebar) to animate tool movement at programmed feed rates. Use the Step Forward / Step Back controls to inspect critical moves line-by-line. Drag the timeline scrub bar to jump to any percentage of total cycle execution or adjust playback speed from 0.1× to 5.0×.

4. Real-Time Telemetry & Trajectory CSV Export

Monitor instantaneous spindle RPM, active feed rate, modal coordinate state, cut distance vs. rapid distance ratio, and cycle time. Export high-resolution PNG toolpath screenshots for setup sheets or download full CSV motion trajectories containing coordinate checkpoints for validation.

Sultan Saudagar — Mechanical Engineer
Written & Verified by
Sultan SaudagarMechanical Engineer

Specializing in CNC manufacturing, multi-axis machining, toolpath dynamics, and CAD/CAM post-processors. This guide bridges CAM post-processor outputs with the messy physical reality of the machine shop floor.

Why Virtual Dry-Runs Save Spindles (Bridging CAM Defaults with Shop Reality)

Ask any seasoned machinist about their worst shop-floor memory, and they will likely describe a high-speed rapid move plunging directly into a hardened steel vise jaw at 2:00 AM. In CAM software, toolpaths exist in a sanitized universe where clamps are transparent, fixtures never flex, and rapid positioning moves (G00) travel in perfectly straight vectors. On a real 3-axis machining center, an unverified G-code block with an omitted coordinate shift or a forgotten G43 H# tool length offset will destroy a $15,000 cartridge spindle before your hand can reach the red E-stop button.

This g-code simulator parses your raw numerical control code exactly as an industrial CNC controller does—line-by-line, tracking modal states, checking axis boundaries, and calculating true 3D spatial displacements. Testing your code in an interactive CNC simulator online lets you catch missing decimal points, improper retract planes, and dangerous rapid traverse moves before a single chip leaves the raw billet.

The CNC Modal State Machine: The Hidden Traps of Sticky G-Codes

Unlike standard procedural code where functions execute in clean isolation, a CNC controller operates as a continuous state machine. A single modal command stays active indefinitely across thousands of blocks until explicitly canceled or overridden by another code in the same modal group.

$$\Delta d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}, \qquad t_{\text{move}} = \frac{60 \cdot \Delta d}{F} \quad [\text{seconds}]$$

The most dangerous modal mistakes fall into three classic categories:

  • Absolute (G90) vs. Incremental (G91) Mode Confusion: In G90 mode, commanding Z-2.0 places the tool tip exactly 2 mm below the active work zero (G54). If an incremental canned cycle or subprogram left the machine in G91, that same Z-2.0 command plunges 2 mm deeper from wherever the tool currently stands. Repeating that block inside a loop quickly rams the tool holder into the part.
  • Arc Interpolation Plane Mismatches (G17 / G18 / G19): Circular arc codes (G02 clockwise, G03 counter-clockwise) rely on center offset vectors (I, J, K). In the standard XY plane (G17), I and J define the arc center. If a previous tapping or side-milling routine left G18 (ZX plane) active, your controller will immediately fault with an "Arc Radius Mismatch" or execute a wild, distorted arc through the stock.
  • Missing Tool Length Offsets (G43 H#): Modern machines use quick-change tool carousels where every tool has a unique measured gage length. Executing a cut without commanding G43 H# Z50.0 immediately following M06 T# causes the controller to treat the spindle face as the tool tip—driving the actual tool 100 to 200 mm too deep into the table.

Radial Chip Thinning & Tool Deflection: Why Programmed Feed is a Lie

In traditional full-width slotting (where radial engagement ae = D), the maximum chip thickness (hm) produced by the cutting tooth equals the programmed feed per tooth (fz). However, modern high-efficiency machining (HEM) strategies use light radial stepovers (ae = 0.05 · D to 0.25 · D) paired with full axial flute depth (ap = 2 · D).

When radial engagement drops below 30% of the cutter diameter, the cutting edge enters and exits the cut so quickly that the true chip thickness becomes significantly smaller than the programmed linear advance per tooth:

$$f_{z,\text{effective}} \approx \frac{h_m}{\sqrt{a_e / D}} \quad \iff \quad F_{\text{adjusted}} = N \cdot z \cdot \left( \frac{h_m}{\sqrt{a_e / D}} \right)$$

If you program an adaptive toolpath at ae = 1.2 mm with a Φ 12 mm end mill without compensating for chip thinning, your cutter will take chips measuring only 0.02 mm instead of the intended 0.08 mm. Rather than shearing cleanly, the cutting edge rubs against the material, generates extreme frictional heat, work-hardens alloys like 304 stainless steel, and burns out the carbide coating within minutes.

Cutter Deflection Under Heavy Radial Loads

Solid carbide end mills are stiff, but they behave mechanically as cantilever beams clamped inside the tool holder collet. The lateral cutting force (Fp) bends the tool tip outward, producing dimensional taper on vertical walls:

$$\delta = \frac{F_p \cdot L^3}{3 E \cdot I} = \frac{64 \cdot F_p \cdot L^3}{3 \pi E \cdot D^4}$$

Notice the L3 and D4 terms. If you double your tool stickout length (L), your tool tip deflects 8 times more under the exact same cut. If you drop from a Φ 12 mm to a Φ 6 mm tool, deflection surges by a factor of 16. Always choke up on the cutter in the collet to the shortest possible reach that clears your vise jaws.

CNC Troubleshooting Matrix: Common G-Code Errors & Shop-Floor Fixes

When a program alarms out or produces dimensional errors, use this quick diagnostic reference to isolate the root cause:

Observed Failure / AlarmRoot G-Code / Setup CausePhysical Shop-Floor ConsequenceImmediate Remediation
Spindle Crash on Rapid (G00)Missing clearance height before XY repositioning; uncancelled G91 mode.Cutter plows through vise clamps or stock boundaries at 30 m/min.Retract to Z+25.0 mm minimum before issuing any rapid XY positioning block.
Arc Endpoint / Radius ErrorCenter vectors (I, J) do not match target (X, Y) within controller tolerance.Controller halts with format alarm; machine stops mid-cycle.Check active plane (G17); verify CAM post-processor decimal precision (minimum 4 decimal places).
Snapped End Mill on Pocket EntryVertical plunge (G01 Z-) without center-cutting geometry or pilot hole.Chips pack in non-cutting center web, locking the tool and shearing the shank.Program a 2°–3° helical ramp entry (G02/G03 with Z descent) or pre-drill entry holes.
Tapered / Out-of-Square SidewallsExcessive tool stickout (L/D > 4) causing elastic cantilever deflection.Pocket dimensions are tight at the top and undersized at the floor by 0.05–0.15 mm.Reduce tool overhang; add a dedicated semi-finish and spring pass with ae ≤ 0.1 mm.
Extreme Chatter / Screeching NoiseTooth passing frequency matches machine natural resonance; excessive radial engagement.Chipped carbide flutes, severe surface ripples (Ra > 6.3 μm), damaged spindle bearings.Shift spindle RPM by ± 10–15%; switch to variable-helix end mills; reduce radial stepover.
Part Dimensions Scaled by 25.4×Unit mode mismatch: Imperial G20 executed on Metric drawing (or vice versa).Overtravel alarm on first move, or microscopic 1 mm cut programmed as 1 inch.Explicitly command G21 (Metric) or G20 (Imperial) in the initial safety block.

Worked Engineering Example: High-Speed Pocketing in 6061-T6 Aluminum

Let us walk through a complete, messy machining calculation for roughing an aerospace bracket pocket in 6061-T6 aluminum on a 3-axis vertical machining center (VMC):

  • Workpiece Material: Aluminum 6061-T6 (Specific cutting energy kc = 700 N/mm2)
  • Cutter Geometry: Φ 12.0 mm 3-flute solid carbide end mill (z = 3, stickout L = 36.0 mm, E = 600 GPa)
  • Target Surface Speed: Vc = 350 m/min
  • Desired True Chip Thickness: hm = 0.08 mm/tooth
  • Adaptive Cut Strategy: Radial width ae = 3.0 mm (25% of D), Axial depth ap = 15.0 mm (1.25 × D)

Step 1: Spindle Speed (N)

$$N = \frac{1000 \cdot V_c}{\pi \cdot D} = \frac{1000 \cdot 350}{\pi \cdot 12.0} = \frac{350000}{37.699} \approx 9284\text{ RPM}$$

Step 2: Chip Thinning Compensation & Table Feed Rate (F)

Because radial immersion is only 25% (ae / D = 3.0 / 12.0 = 0.25), we apply the radial chip thinning factor:

$$f_z = \frac{h_m}{\sqrt{a_e / D}} = \frac{0.08}{\sqrt{0.25}} = 0.16\text{ mm/tooth}, \qquad F = 9284 \cdot 3 \cdot 0.16 \approx 4456\text{ mm/min}$$

Step 3: Volumetric Material Removal Rate (MRR)

$$\text{MRR} = \frac{a_p \cdot a_e \cdot F}{1000} = \frac{15.0 \cdot 3.0 \cdot 4456}{1000} \approx 200.52\text{ cm}^3/\text{min}$$

Step 4: Net Spindle Cutting Power & Torque

Assuming a spindle mechanical transmission efficiency η = 88%:

$$P_c = \frac{\text{MRR} \cdot k_c}{60000 \cdot \eta} = \frac{200.52 \cdot 700}{60000 \cdot 0.88} \approx 2.66\text{ kW} \quad (3.56\text{ HP}), \qquad M_c = \frac{9550 \cdot 2.66}{9284} \approx 2.74\text{ N}\cdot\text{m}$$

Step 5: Cantilever Tool Tip Deflection Check

Estimated radial cutting force component Fp ≈ 0.35 · Fc ≈ 160 N. The second moment of area for the Φ 12 mm solid cylinder is I = π · 124 / 64 ≈ 1017.9 mm4:

$$\delta = \frac{F_p \cdot L^3}{3 E \cdot I} = \frac{160 \cdot 36^3}{3 \cdot (600 \times 10^3) \cdot 1017.9} \approx 0.0041\text{ mm} \quad (4.1\text{ }\mu\text{m})$$

Instructor's Takeaway: A deflection of 4.1 μm is completely safe for roughing and leaves plenty of stock allowance for precision finishing. If you are milling gear teeth blanks or custom splines, you can cross-check tooth contact stresses with our Gear Simulator. If your machine features high-pressure spindle coolant delivery, verify pump delivery flow rates with our Hydraulic Flow Calculator.

Four Practical Rules of Thumb from 15 Years on the Shop Floor

  1. The "Z-Plus-Fifty" Safety Protocol: Start every program with an explicit safety line that cancels active canned cycles and sets absolute mode: G00 G90 G40 G80 G49 G17 G21. When testing a brand-new setup, set your Z-work offset 50.0 mm above the real stock, turn rapid override down to 25%, and watch the tool perform its full dry-run safely in mid-air.
  2. Never Plunge Straight Down on Solid Metal: Flat-bottom end mills cannot cut in pure vertical descent unless they have center-cutting geometry, and even then chips pack tightly in the center dead zone. Always program a 2° to 3° continuous helical ramp (G02/G03 with simultaneous Z descent) to maintain smooth chip evacuation.
  3. Watch Out for Internal Corner Engagement Spikes: When an end mill cuts into an internal 90° sharp corner, the cutter engagement angle instantly jumps from 25% up to 75%–100%. This causes a sudden 3× spike in cutting force, tool chatter, and corner gouging. Always program adaptive corner trochoids or fillet corners with a radius at least 10%–15% larger than the tool radius.
  4. Lead-in Vectors for Cutter Compensation (G41/G42): Never turn on cutter radius compensation (G41 or G42) on an arc or directly against the finished wall. Always command G41 D# on a straight-line lead-in move that is longer than the tool diameter, allowing the controller to calculate the offset vector before making physical contact with the stock.

Frequently Asked Questions

Why do CNC programs crash during rapid moves even when CAD simulation looked fine?

CAD/CAM simulations often render sanitized geometry without modeling actual controller modal states, fixture clamp heights, or multi-axis dogleg rapid trajectories. In G00 rapid motion, many CNC controllers slew individual axes at maximum speed rather than interpolating a straight line, causing the cutter to dip unexpectedly into vises or clamps.

What causes the common 'Arc End Point / Radius Mismatch' alarm on G02/G03 moves?

This occurs when the distance from the arc center (defined by I, J, K) to the start coordinate differs from the distance to the programmed target endpoint by more than the machine's tolerance (typically 0.01 mm). This is usually caused by post-processor rounding errors, plane mismatches (G17 vs G18/G19), or using incremental I/J vectors while in absolute mode.

What is radial chip thinning and when must feed rate be adjusted?

Radial chip thinning occurs when the radial depth of cut (stepover ae) is less than 30% of cutter diameter. The flute engages for a shorter duration and produces a chip thinner than the programmed feed per tooth. To maintain the intended maximum chip thickness and avoid cutter rubbing, the programmed feed rate must be increased using fz = hm / sqrt(ae / D).

What is the difference between G90 Absolute and G91 Incremental positioning?

In G90 absolute mode, all axis coordinates (X, Y, Z) reference the active Work Coordinate System origin (such as G54). In G91 incremental mode, coordinates dictate the distance and direction to move relative to the tool's current position. Forgetting to cancel G91 before a return move is one of the most common causes of spindle crashes.

Can this simulator run programs post-processed for Haas, Fanuc, and Siemens?

Yes. The simulator interprets standard ISO 6983 / RS-274D syntax supported across Haas, Fanuc, Siemens, Heidenhain (ISO mode), Mazak, and GRBL controllers, including 3D linear paths, circular arcs, canned drilling cycles, and coordinate shifts.

Related Engineering Simulation Tools

Explore more interactive mechanical design calculators