CNC Safe Start & End Blocks: G-Code Templates for Reliable Programs
Every CNC program should begin and end with safe, reliable blocks that reset modal conditions and ensure machine safety.
This guide explains Safe Start Blocks and End Blocks, with templates for Fanuc, Haas, Siemens, and Heidenhain.
📌 1. What is a Safe Start Block?
A Safe Start Block initializes the CNC state before machining begins.
It ensures:
- Cancelled cutter comp & cycles
- Correct plane selection (XY, ZX, etc.)
- Tool length and spindle speed set properly
- Safe rapid positioning
📌 2. Fanuc Safe Start Block Example
%
O7000 (SAFE START TEMPLATE)
G90 G17 G40 G49 G80 G21
G54
T01 M06
S2500 M03
G43 H01 Z100.
M08
(--- MACHINING STARTS HERE ---)
...
| Code | Function |
|---|---|
| G90 | Absolute mode |
| G17 | XY plane |
| G40 | Cancel cutter compensation |
| G49 | Cancel tool length offset |
| G80 | Cancel drilling cycle |
| G21 | Metric mode |
| G54 | Work offset |
📌 3. Haas Safe Start Block Example
Haas is nearly identical to Fanuc:
G90 G17 G40 G49 G80 G20
G54
T1 M06
S1500 M03
G43 H01 Z100. M08
- G20 = inch mode (instead of G21 metric)
📌 4. Siemens Safe Start
TRAFOOF
G90 G17 G40 G80
CYCLE832("ROUGHING")
TOOL CALL 1 Z S2000
M03
- TRAFOOF cancels TCP/MCS transformation.
- TOOL CALL replaces T-code.
📌 5. Heidenhain Safe Start
BEGIN PGM SAFE_START MM
CYCL DEF 7.0 DATUM SHIFT
TOOL CALL 1 Z S2500
L Z+100 R0 FMAX M03 M08
📌 6. Safe End Block – Fanuc / Haas
(--- MACHINING ENDS HERE ---)
G91 G28 Z0
G91 G28 X0 Y0
M09
G53 Y0
M30
%
| Code | Function |
|---|---|
| G28 | Return to reference position |
| M09 | Coolant off |
| M30 | End program & reset |
📌 7. Haas Variation with G53
G53 Z0 (Machine Z-home)
G53 X0 Y0 (Machine XY-home)
M30
- G53 → Direct machine coordinate move (safer than G28 in some cases).
📌 8. Siemens End Block
L Z+500 R0 FMAX
M05
M09
M30
📌 9. Heidenhain End Block
L Z+200 R0 FMAX M09
M05
END PGM SAFE_START MM
📌 10. Best Practices
- Always cancel offsets & cycles in safe start.
- Always retract Z-axis before moving XY.
- Use G53 instead of G28 when possible to avoid unexpected motion.
- Standardize templates across all shop programs.
📌 11. Example – Complete Program Template
%
O8000 (SAFE TEMPLATE)
G90 G17 G40 G49 G80 G21
G54
T01 M06
S2500 M03
G43 H01 Z100. M08
(--- MACHINING CYCLE ---)
G01 X50. Y50. Z-20. F200
...
(--- END ---)
G91 G28 Z0
G91 G28 X0 Y0
M09
M05
M30
%
✅ Conclusion
Safe Start and End Blocks are essential for repeatable, reliable CNC programs.
By standardizing your templates, you reduce risk, improve efficiency, and protect both machine and operators.
Leave a comment