← 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 verify the actual modal state — feed hold, reset, alarm, and power loss retain different information. This page covers startup blocks, safe approach/retract, and the mid-program restart procedure.

Level: KScope: Machine-neutral concepts; controller-specific examples are labelledPrerequisite: Machine Fundamentals for Programmers
After this lesson, you can:
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 may or may not retain tool length offset, cutter compensation, work offset, feed mode, and cycle state depending on how it was interrupted. Read the modal display rather than assume. 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 G94 G40 G49 G80
The Startup Block, Line by Line
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. G49 cancels the active tool length offset; it does not switch to machine coordinates (that is G53). 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 G94 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 for open milling with a clear Z channel: 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 canned 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.

What the Controller Actually Remembers

Between programs, the controller retains modal G codes, active work offset, and active H/D numbers. It does not retain your mental intent. If the last program ran G91 incremental and your new program starts with G00 X50 Y50 without G90, the controller moves 50 mm in X from wherever it happens to be. The startup block exists so every program begins from a documented state rather than from the previous operator's last mistake.

Safe Z Heights and Clearance Planes

A clearance plane is a Z height above which XY motion is safe across the whole setup. Choose it from the tallest fixture, clamp, and part protrusion, then add a margin. On a mill, Z50 or Z100 is common; on a lathe, the tool post must clear the chuck and any tailstock center. Program to that clearance plane before any non-cutting XY move. Never rely on "it will be fine" if the setup has changed since the program was written.

Spindle, Coolant, and Feed Override Safety

Spindle must be at the commanded direction and speed before the tool engages the work. Start spindle M03 (or M04) and allow it to reach speed before M08 and the first feed move. Feed and rapid overrides are set per the machine's first-article procedure; lowering override slows motion but is not a collision guarantee. Do not change feed override mid-thread or mid-rigid-tap — synchronous feed depends on the commanded rate.

Illustration for Spindle, Coolant, and Feed Override Safety. Its dimensions and assumptions are explained in the adjacent lesson text.Spindle, Coolant, and Feed Override Safety clearance plane Z50 feed down to cut Z up BEFORE XY
Approach: XY at clearance Z, feed down. Retract: Z up to clearance before XY moves sideways.
Illustration for Spindle, Coolant, and Feed Override Safety. Its dimensions and assumptions are explained in the adjacent lesson text.Spindle, Coolant, and Feed Override Safety 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.

Why Feed Hold Is Not a Restart Button

Pressing feed hold stops motion but leaves the machine in the same modal state. Resuming continues from where it paused. If you need to change something, you must cycle stop, rebuild state, and restart — not assume resume works after a manual jog.

Program End and Tool Change Position

A clean program end returns Z to a safe height, moves XY to the tool change position, cancels compensation, stops spindle and coolant, and ends with M30. This leaves the machine in a known place for the next setup. Ending mid-air at an arbitrary position makes the next operator guess.

Alarms and What They Mean for Safety

An alarm is the controller telling you a condition is unsafe to continue. Do not reset and cycle start without understanding the alarm. Common safety alarms: overtravel, spindle overload, servo following error, tool change fault. Clear the condition, not just the message.

Why the Startup Block Is Not Optional

Operators sometimes skip the startup block because the machine "was already on G21 G90." Between jobs, offsets get changed, modes get changed, and another program may have left G91 or G81 active. The startup block costs one line and removes that entire class of error.

Work Offset and Tool Offset Are Different

G54 moves the whole part zero. H01 moves the tool length. Changing one does not change the other. If you touch off Z on a new tool, update H, not G54. If you move the part, update G54, not H. Mixing these up is a classic second-crash cause.

Restart on a Lathe

On a lathe, restart additionally requires confirming spindle direction, chuck clamp, and tailstock. Do not restart a facing or cutoff operation near center without confirming the catcher and spindle condition. Radial moves near center carry more risk than on a mill.

Safe Tool Change Position

The tool change position must be a known XY/Z location where the spindle can reach the magazine or turret without hitting the part, fixture, or tailstock. Program to it explicitly rather than relying on the machine's default. On a pallet-change machine, confirm the pallet is seated and clamped.

Clamps, Vises, and Fixture Clearance

Before running, walk around the setup and identify the tallest point. Program clearance above it. A clamp head that sticks above the part is the most common Z-crash source. If the program was written for a different fixture, re-check clearance before the first cut.

Personal Safety

Do not reach into the machine while spindle is running. Keep doors closed during automatic cycles. Use appropriate eye protection. Long hair, loose clothing, and jewelry must be secured. Safety interlocks are there for a reason; do not defeat them.

Why You Cannot Trust Previous Programs

Even a program that ran perfectly yesterday may be unsafe today if the fixture, tooling, work offset, or stock has changed. Re-verify before every new job, not just the first one. "It ran fine yesterday" is not a setup check.

Restart After a Power Loss

Power loss loses absolute position on many machines. Re-home, re-verify work offset, and restart from a known point. Do not assume the controller remembers where it was.

Program Comments as Safety Notes

Use comments to flag dangerous moves, required tool numbers, and setup-specific notes. Future you (or another operator) reads those comments at the machine. A program without comments is a safety hazard over time.

Restart on a Multi-Tool Program

If you break tool 3 and need to restart at tool 3, call tool 3 with its H/D offsets before resuming. Do not resume the program from N80 and expect the controller to know which tool you installed.

Feed Hold and Restart Decisions

If you feed hold to inspect a cut, resume only if nothing changed and the machine's Run-Stop-Jog-Continue feature permits it (Haas). If you jogged, changed a tool, or altered an offset, rebuild state and restart from a known block rather than resume.

Safety Culture on the Shop Floor

Program safety is not a one-person job. Operators should feel comfortable stopping a cycle if something looks wrong, even if they are not sure. A stopped cycle costs minutes; a crash costs hours. Encourage reporting rather than blame.

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) on Haas mills, with a canned cycle active, a bare X/Y move repeats the cycle; an explicit G00/G01 cancels it. Use G80 to make intent clear.

Restart State Table (Illustrative)

Restart State Table (Illustrative)
ItemKnown before restartHow to establishFirst-cut state
Tool / H02T02 brokenReplace per OEM procedure; measure H02H02 loaded
G54Verified at setupCheck displayG54 active
Units / plane / modeG21 / G17Program G21 G17 G90 G94Absolute, mm/min
Cycle / compensationUnknown after interruptionG80 G40G81/G98 active, G40, G43 H02
Spindle / coolantUnknownS600 M03, then M08 (two blocks)Direction verified
Broken edge / holeInspectedDeburr; confirm part usableHole 4 may proceed
Clearance pathZ50 path verifiedMove to Z50 before XYZ50 above fixture

Fragment (hole 4, X60 Y20, Z-15; S/F are classroom values for this example):

G21 G17 G90 G94 G54 G80 G40
G00 G43 H02 Z50.
S600 M03
M08
G00 X60. Y20.
G98 G81 Z-15. R2. F100.
G80
G00 Z50.
M09
M05

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

On Haas mills, a bare X/Y repeats the active cycle; an explicit G00/G01 cancels it. Use G80 to make intent clear 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. What does G49 cancel? Does it also cancel G54?

Show answer

G49 cancels tool length compensation only. It does not cancel the work offset (G54). Re-establish the correct H at a known clearance, not blindly at an arbitrary position.

Continue with program verification for the later workflow used after the initial state and setup review.

Sources