COMMON CNC CRASHES — PART 1 OF 3

CNC Tool Change Problems: ATC Errors, Wrong Tool, and Tool Change Collisions

Tool change errors are one of the leading causes of CNC machine crashes. They happen on the first cycle of a new program, after a post processor update, after a tool setup change — and they are almost always preventable. This article covers the main failure modes and how G-code simulation catches each one before the machine does.

Why Tool Changes Are High-Risk

A tool change involves coordinated movements across multiple axes, a mechanical exchange of tools in the spindle, and a return to the next cutting position — all at rapid speed. Every step must happen in the correct sequence and with the correct geometry. A failure at any point can result in a collision between the tool, the spindle, the workpiece, the fixture, or the tool changer itself.

The problem is structural: tool change sequences are generated by the post processor, not directly by the CAM toolpath. A post processor that generates incorrect retract moves, incorrect M-code sequences, or incorrect tool number references will produce a G-code file that looks valid but executes dangerously on the machine.

CAM simulation does not simulate tool changes — it simulates toolpaths. The tool change sequence is invisible to it. G-code simulation is the only verification method that catches tool change errors before the machine does.

What Actually Happens During M06

In the CAM simulation, a tool change is instant: one tool disappears, another appears. On the machine, M06 runs a macro defined by the machine builder — a chain of axis moves, pneumatic or hydraulic actuations and spindle functions. The exact sequence varies by machine, but the structure is consistent:

  1. Safe Z retract — Z moves to the tool change position, usually machine Z home, reached by G91 G28 Z0 in the program or by the M06 macro itself. The tool must clear the part, fixtures and clamps.
  2. Spindle orientation (M19) — the spindle turns to the angle where its drive key lines up with the slot in the tool holder.
  3. ATC arm engagement — the arm reaches the spindle and grips both the current tool and the incoming one from the magazine.
  4. Unclamp and extraction — the drawbar releases the current tool and the arm pulls it out of the spindle taper.
  5. Arm rotation — typically 180°, swapping the incoming and outgoing tools.
  6. Insertion and clamp — the new tool goes into the taper, the drawbar clamps it and the control receives a clamp confirmation.
  7. Arm retract — the arm returns home, clear of spindle and magazine.
  8. First move of the new tool — the program continues, typically with G43 and a move to the first position of the next operation.

A crash can happen at step 1 (insufficient retract), step 2 (orientation failure), step 5 (arm rotation without clearance), step 8 (first move without the right compensation), or between any two steps because of how the program is structured. The CAM simulation skips steps 1 to 7 and shows only the result of step 8.

ATC Errors: Automatic Tool Changer Failures

An ATC (Automatic Tool Changer) error occurs when the machine's tool change sequence fails to complete correctly. This can happen for mechanical reasons — a worn gripper, a contaminated tool holder, a misaligned magazine — but many ATC errors in new programs are caused by incorrect G-code output from the post processor.

Wrong M06 Sequence

The standard FANUC tool change command is M06 Tn, where n is the tool number. But the order of operations around this command matters: the spindle must be stopped (M05), the coolant must be off (M09), and the Z axis must be at the machine's reference position before the ATC engages. (For a deeper look at verifying Fanuc macros and tool changes, check out our Fanuc Robodrill G-Code Simulator guide.)

A post processor that outputs M06 while the spindle is still running, or before the Z axis has completed its retract, can trigger an ATC fault alarm — or in worse cases, cause the ATC arm to engage while the spindle is still moving.

; Incorrect sequence — spindle not stopped before tool change
S3000 M03
G00 Z5.
M06 T02     ; M05 missing — spindle still running

; Correct sequence
M05         ; Stop spindle
M09         ; Coolant off
G91 G28 Z0. ; Return to Z machine zero
M06 T02     ; Tool change — safe

Tool Number Mismatch

On machines with a fixed tool magazine, the tool number in the G-code must correspond to the physical position in the magazine. If the post processor outputs T03 but tool 3 in the magazine is not the tool the program expects — because a previous setup used a different tool assignment — the machine will load the wrong tool without any alarm. The program continues, cutting with incorrect geometry, incorrect length, and potentially incorrect material removal.

Spindle Orientation Failure (M19)

Before the ATC arm engages, the spindle must stop at a fixed angle. On most modern machining centers the M06 macro handles this internally. On older machines, on machines where the builder changed M19 behavior, or where orientation is a separate M-code in the program, a wrong or missing orientation makes the arm try to engage a misaligned drive key. The result ranges from an ATC alarm to damage to the holder, the arm or the spindle face.

The post-processor is often the cause. On a machine whose M06 macro already orients the spindle, an explicit M19 before M06 is usually harmless but occasionally raises an alarm. On a machine whose M06 does not orient, leaving out M19 means the tool change starts with the spindle at a random angle. And on machines that need an angle parameter (M19 P or M19 R), a bare M19 orients to a default angle that may not match the arm.

Program Structure Errors Around M06

  • Canned cycle not canceled. G80 must cancel drilling or tapping cycles before M06. Without it, depending on the control, the cycle is canceled automatically, an alarm is raised, or the tool change runs inside the active cycle mode with unpredictable results.
  • Cutter compensation still active. G41/G42 should be canceled with G40 before M06; otherwise the compensation for the new tool can produce an alarm or an unexpected first move.
  • T-word called too late. On most machining centers the next tool should be selected with the T-word during the previous operation, so the magazine indexes while machining continues. Calling T and M06 together forces the magazine to index during the change, which slows it down and on some machines causes a timing conflict and an ATC alarm.
  • Restart after an interrupted tool change. If an E-stop or feed hold stops the program mid-change, the arm may be left in an intermediate position. Restarting from the M06 block starts the change again with the arm away from home — a collision between the arm and the spindle or magazine.

Wrong Tool Loaded

Loading the wrong tool is one of the most damaging errors in CNC machining — and one of the hardest to detect until damage has occurred. The machine does not know what tool is physically in the spindle; it only knows what tool number the operator registered at the control. If the registration is wrong, the machine executes the program with no indication of a problem.

CRASH SCENARIO

Wrong Diameter Tool in Spindle

A 16mm end mill is registered as T02 on the machine. The programmer specified a 12mm end mill for T02 in the CAM setup. The post outputs the correct tool call, but the physical tool is wrong. The program runs, the 16mm tool cuts a path designed for 12mm, overcuts the part, and potentially contacts the fixture wall. The machine sees no alarm — it is cutting exactly as programmed.

HOW EUREKA3X CATCHES THIS

In Eureka3X, every tool is defined with its actual geometry — diameter, length, holder body dimensions. If you load a tool with the wrong diameter into the simulation, the material removal engine immediately shows the incorrect stock removal. Gouge detection flags any contact between the tool body and finished surfaces. You see the error before any metal is cut.

Tool Length Offset Errors

Tool length offset (TLO) is the measured distance between the spindle face and the tool tip. The machine uses this value to calculate the actual Z position of the cutting edge. If the offset is wrong — entered incorrectly, measured on a different tool, or not updated after a tool replacement — the machine cuts at the wrong Z depth on every operation in the program.

The Three Ways TLO Goes Wrong

  • Offset not set: A new tool is loaded but the length offset register is empty or contains a value from a previous tool. The program runs with Z compensation that does not correspond to the current tool.
  • Offset measured incorrectly: Manual measurement error, tool not seated correctly in the holder during measurement, or the wrong compensation mode active (G43 vs G44).
  • Post processor outputs wrong H number: The post generates G43 H03 but the tool length is registered in offset register H02. The machine applies the wrong compensation value for the entire program.
; G43 activates tool length compensation — H must match the correct register
G43 H03 Z50. ; If tool length is in H02, this applies wrong offset
G43 H02 Z50. ; Correct — H number matches the tool's registered offset

WHY TLO ERRORS ARE DANGEROUS

A tool length offset error of even 5mm can drive the tool into the workpiece surface on the approach move — at rapid speed, before any cutting begins. The machine has no way to detect this: it is executing the programmed Z move exactly as written, with the offset it was given. The crash happens before the first chip.

Tool Change Collision: The Retract Problem

The most common tool change collision pattern follows a predictable sequence: the program completes one operation, calls for a tool change, and the post processor does not generate a safe retract to machine Z home before issuing M06. The ATC attempts to execute the tool change while the spindle is still positioned over the workpiece or fixture.

On compact machines like the FANUC Robodrill — where the working envelope is small and fixtures are physically close to the spindle during machining — this retract error consistently causes spindle-to-fixture or spindle-to-workpiece collisions during the tool change move.

G00 Z100 is not always safe. In work coordinates, Z100 means 100 mm above work zero. If work zero is on top of a tall fixture — or was set incorrectly — Z100 can be inside the fixture. G53 Z0, a retract to machine Z home in machine coordinates, is safe regardless of the active work offset, because machine coordinates are fixed to the machine structure.

The post-processor's clearance height may not match your setup. CAM systems output one clearance height before every M06, set once in the job setup, in work coordinates. A tall fixture, a tombstone or a vise with extended jaws can reach above it, and the M06 then runs with the tool too close to an obstruction. The CAM simulation doesn't show it, because it models neither the retract path nor the ATC arm.

The First Move of the New Tool

After M06 the machine sits at the tool change position, while the next operation may start at a completely different XY location. The moves in between cross the work envelope at intermediate positions that the CAM simulation never shows — and the new tool may be much longer than the previous one.

  • Post-generated moves through the fixture. A rapid XY move before the Z descent can carry the new, longer tool through a fixture component. CAM shows the XY endpoint and the Z descent separately, both correct; the path between them is invisible.
  • G43 called after the first move. If the post-processor outputs an XY move and then a Z descent before activating G43 for the new tool, the descent uses the gauge line instead of the tool tip and crashes by the full tool length. See G43 tool length compensation.
Tool Change ErrorDetectable by Dry RunDetectable by G-Code Simulation
Missing Z retract before M06Partial — operator may miss itYes — collision flagged automatically
Wrong tool number in magazineNo — machine loads without alarmYes — wrong geometry shows incorrect stock removal
Tool length offset errorNo — visible only when Z is wrongYes — Z position error shown in simulation
Wrong H number in G43No — applied silentlyYes — Z offset mismatch visible
Spindle running during M06Partial — may not be visibleYes — sequence error flagged
Canned cycle still active at M06 (missing G80)Partial — alarm or unpredictable behaviorYes — modal conflict flagged at the M06 block
New tool's repositioning move through the fixturePartial — operator may miss itYes — collision shown with the new tool's geometry

What Eureka3X Shows You

When you simulate a G-code program in Eureka3X, every tool change is executed in the virtual machine environment with full collision detection active. The simulation checks:

  • Retract position before M06 — is the spindle clear of the workpiece, fixture, and clamps before the tool change executes?
  • Tool geometry in the spindle — the simulation uses the actual tool and holder dimensions you define, making wrong-tool scenarios immediately visible through incorrect material removal
  • Z position after tool change — does the new tool approach the workpiece correctly with the programmed length compensation?
  • Holder body clearance — does the holder body (not just the cutting edge) clear all obstacles during the approach after tool change?

THE RESULT

Every tool change error that would cause a crash on the machine is flagged in the simulation — with the exact G-code line, a visual indicator in the 3D view, and a description of the collision or error. You fix it at the desk. The machine never sees the problem.

What the CAM Simulation Doesn't Show

A CAM simulation shows the last toolpath of the outgoing tool, an instantaneous tool change, and the first toolpath of the incoming tool. It does not show:

  • The Z retract path to the tool change position, and whether it clears the fixture
  • The spindle orientation sequence and whether M19 is called correctly
  • The XY repositioning moves from the tool change position to the first operation
  • When G43 is activated relative to the first Z move
  • The state of canned cycles, cutter compensation and other modal codes at M06

Because the simulation executes the posted G-code, you can also step through the change block by block — retract, M06, G43, first move — and check each one against the machine model.

Frequently Asked Questions

My CAM system has a clearance height setting for tool changes. Why isn't that enough?

The CAM clearance height is one fixed value in work coordinates, set once for the job. If your workholding varies in height across the table, or an operation's work zero puts the clearance below the tallest fixture component, it is not enough for that specific tool change. Simulation shows the real retract path against the real fixture for every tool change.

What is the difference between G91 G28 Z0 and G53 Z0 for the tool change retract?

G91 G28 Z0 is an incremental zero move followed by a return to the reference point: a two-step sequence through an intermediate point. G53 Z0 moves directly to machine Z home in machine coordinates. G53 Z0 is generally more predictable; G91 G28 Z0 is correct and standard on most Fanuc machines, but some configurations interpret it differently.

How do I check that my post-processor outputs a correct tool change sequence?

Read the NC file around each M06. The sequence should be: retract to safe Z → cancel active cycles and compensation (G80, G40) → M19 if your machine needs it → M06 → G43 Hxx with a Z move to safe height → XY move to the first position → Z descent to machining depth. Any deviation is a potential crash source.

My tool change works on 99% of programs. Why does it fail on specific ones?

Usually one of three dependencies: fixture height (the failing program has taller workholding), tool length (a longer tool doesn't clear the fixture on the repositioning move), or modal state (the program leaves a modal code active at M06 that others don't). Simulating that specific program shows which one applies.

Can simulation catch ATC mechanical failures?

It catches programming errors that cause ATC failures — insufficient retract, wrong M19, wrong structure around M06. It does not catch hardware failures such as worn cams, low air pressure or damaged grippers; those need maintenance, not a program fix.

After a tool change crash, how do I recover safely?

If the ATC arm is left in an intermediate position, do not restart the program from the M06 block. Power down, clear the alarm and step through the tool change macro manually in MDI — M19 for spindle orientation, then the individual ATC steps in the order given in the machine builder's maintenance manual. An automatic restart from an intermediate ATC state is one of the surest ways to turn a recoverable situation into spindle damage.

Catch Tool Change Errors Before They Reach the Machine

Simulate every tool change — retract sequence, tool geometry, length compensation — in a virtual machine with full collision detection. Includes a production-ready FANUC Robodrill. 30-day free trial, no credit card required.

No credit card required · Windows 10/11 · Dedicated GPU required

Common CNC Crashes — Series