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.
- Pre-startup checks before cycle start
- What the startup block G21 G17 G90 G40 G49 G80 actually does
- Safe approach and retraction strategy
- What state a mid-program restart needs
- Why you cannot just jump to a line number
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
| Code | What It Does | Why It Matters |
|---|---|---|
| G21 | Metric units (mm) | Prevents inch/mm mismatch — 25.4× errors |
| G17 | XY plane selection | Required before circular interpolation (G02/G03) |
| G90 | Absolute programming | Coordinates refer to work zero, not incremental |
| G40 | Cancel cutter compensation | Prevents unexpected G41/G42 offset from previous program |
| G49 | Cancel tool length offset | Prevents inherited H offset from another tool |
| G80 | Cancel canned cycles | Prevents 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)
- Check the part is securely clamped; chips and coolant clear from the work area.
- Confirm the right tool is in the spindle and H/D offset numbers match the setup sheet.
- Read the first block: units (G21), plane (G17), distance mode (G90), compensation canceled (G40 G49 G80).
- Jog the tool to a known safe position; check that Z retracts above all fixtures and clamps.
- 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
- Note where the program stopped: block number, tool, operation, current modal state.
- 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.
- Jog the tool to a known safe position away from the part.
- Manually establish the missing state: call the correct tool with its H offset, select G54, set G90, cancel any cycles.
- Move the tool to a safe approach point above the restart location.
- Use single-block to step through the first few resumed blocks, verifying motion before continuous run.
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:
- Replace the broken drill. If the new drill differs in length, update the H offset.
- The program was in G90, G54, G81 modal. You cannot just jump to the hole-4 line.
- Instead: manually position above hole 4, call the tool with H offset, re-issue G81 with correct R/Z/F, then drill remaining holes.
- After drilling, G80 before moving away.
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
- Jogging near the break point and pressing cycle start — without rebuilding modal state.
- Assuming "from the top" is always safe — it is the safest option, but not always practical for long programs or after a tool change.
- Using the same startup block for mill and lathe — G17/G49 do not apply to lathes.
- Assuming single-block or feed override prevents collisions — they slow the motion but do not prevent the crash.
- Forgetting G80 before repositioning — an active drilling cycle makes every X/Y move a hole.
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.