← Back to CNC Programming

Safe Program Start, Retraction, and Restart

Running from the top restores a known start state, but it is not a guarantee of safety by itself. When you must restart mid-program after a tool break or alarm, you must rebuild the modal state the controller has already forgotten. This page covers startup blocks, safe approach/retract, and the mid-program restart procedure.

What you will learn:

Concept

Safe programming means the machine always starts from a known state: correct tool, correct offsets, correct work zero, correct spindle direction, and a clear path from tool change position to the first cut. The startup block sets these conditions explicitly rather than relying on whatever the previous program left behind. Because G codes are modal, the controller remembers settings from the last program that ran — which may be completely different from what your new program expects.

Restart after a tool break, dimension stop, or alarm is different. You cannot simply position the tool near the last cut line and press cycle start. The controller has lost (or never had) the tool length offset, cutter compensation, work offset, feed mode, and cycle state that earlier lines established. Jumping to N80 without rebuilding that state means the controller moves in X/Y correctly but with the wrong Z height and wrong offsets.

Why It Matters

Every crash that happened on a CNC machine started as an assumed state. "The previous program was fine, so this one should be too" is how tools break into the fixture. The startup block exists precisely because the controller's modal state is unpredictable between programs. Similarly, mid-program restart errors — leftover G91, wrong H offset, active G81 — are among the most common causes of second crashes (after the first tool break already stopped the machine).

How It Works

The Startup Block, Line by Line

O1001
G21 G17 G90 G40 G49 G80
CodeWhat It DoesWhy It Matters
G21Metric units (mm)Prevents inch/mm mismatch — 25.4× errors
G17XY plane selectionRequired before circular interpolation (G02/G03)
G90Absolute programmingCoordinates refer to work zero, not incremental
G40Cancel cutter compensationPrevents unexpected G41/G42 offset from previous program
G49Cancel tool length offsetPrevents inherited H offset from another tool
G80Cancel canned cyclesPrevents drilling cycle from triggering on first XY move

This block does not set the offsets — it cancels old ones so they can be re-established cleanly. After G49, Z moves are at machine position; after G43 H01, Z moves include the tool length. The order matters: cancel first, then set new values.

Before Cycle Start (Mill Example)

  1. Check the part is securely clamped; chips and coolant clear from the work area.
  2. Confirm the right tool is in the spindle and H/D offset numbers match the setup sheet.
  3. Read the first block: units (G21), plane (G17), distance mode (G90), compensation canceled (G40 G49 G80).
  4. Jog the tool to a known safe position; check that Z retracts above all fixtures and clamps.
  5. Single-block the first few blocks; verify motion before switching to continuous run.

Mill vs Lathe Startup

A mill startup uses G21 G17 G90 G40 G49 G80. A lathe uses different codes: G21 G97 G99 (constant RPM, feed per revolution). Lathes do not use G17 (plane) or G49 (length offset) the same way. Do not copy a mill startup block into a lathe program — the G codes mean different things or do not exist.

Safe Approach and Retraction

The rule: always move Z first when approaching, and Z first when retracting. When approaching the part: rapid XY to the position at a safe Z height, THEN feed down to cut depth. When retracting from a cut: rapid Z up to safe height, THEN move XY. This prevents the tool from traveling sideways at cut depth and crashing into the fixture or part.

A common crash pattern: after finishing a cut, the program does G00 X50 Y50 while the tool is still at Z-5. The tool drags sideways through the part, gouging everything in its path. The fix: G00 Z50 before any XY move.

Mid-Program Restart Procedure

  1. Note where the program stopped: block number, tool, operation, current modal state.
  2. Identify every modal state that the restart block depends on: G90/G91, G54 offset, H tool length, G41/G42, G94/G95 feed mode, any active G80+ cycle.
  3. Jog the tool to a known safe position away from the part.
  4. Manually establish the missing state: call the correct tool with its H offset, select G54, set G90, cancel any cycles.
  5. Move the tool to a safe approach point above the restart location.
  6. Use single-block to step through the first few resumed blocks, verifying motion before continuous run.
Safe Approach Z up, XY first 1. Rapid XY at safe Z 2. Feed Z down Crash Pattern XY move at cut Z = gouge
Safe approach (left): XY first at safe Z, then feed down. Crash pattern (right): XY move while tool is at cut depth.

Example

A drilling program stops at hole 4 of 6 because the drill broke. The program used G81 with G99 (retract to R plane). To restart:

Three failure modes to recognize: (1) leftover G91 means coordinates are interpreted as distances, not positions; (2) wrong H number means Z depth is off by the tool length difference; (3) an active G81 means any X/Y move drills a hole even if you think you are just repositioning.

Common Mistakes

Practice

1. A program restart leaves G91 active. What happens when the next block says X50?

Show answer

The tool moves 50 mm in X from its current position (incremental), not to absolute X50. You must issue G90 first.

2. Why is G80 needed after a restart at a drilling block?

Show answer

If a canned cycle is still modal, any subsequent X/Y move executes a drill. You must explicitly G80 before repositioning.

3. You broke a drill and replaced it with one 3 mm longer. What offset must change?

Show answer

The H (tool length) offset. Without updating it, the Z depth will be off by 3 mm, potentially drilling too deep or not deep enough.

4. Why does the startup block cancel G49 before calling G43 H01?

Show answer

G49 cancels any inherited tool length offset from the previous program. If you called G43 H01 while another H was still active, the machine might use the wrong length. Cancel first, then set the new one.