This master page is designed as a permanent CNC programming reference covering the complete workflow from machine startup to finished production parts. It combines controller logic, G-code fundamentals, modal behavior, macro safety, alarm recovery, restart discipline, and real-world machining practices used in professional shops.
Always verify controller-specific manuals because implementations differ between Fanuc, Haas, Siemens, Heidenhain, and other systems.
══════════════════════════════════════════════════════════════════════════════
SECTION 1 — HOW CNC MACHINES ACTUALLY EXECUTE PROGRAMS
══════════════════════════════════════════════════════════════════════════════
CNC controllers operate as state machines.
Each executed block modifies internal memory including:
- positioning mode
- active work offset
- feed interpretation
- compensation status
- canned cycle memory
Movement equals stored machine state plus the new command.
Most crashes occur when programmers assume a neutral machine state.
Professional discipline rebuilds logic intentionally.
Typical rebuild block:
G90 G17 G40 G49 G80
G94
G54
This resets positioning, plane, compensation, canned cycles, and feed mode.
══════════════════════════════════════════════════════════════════════════════
SECTION 2 — SAFE START, SAFE END, AND SAFE RESTART SYSTEM
══════════════════════════════════════════════════════════════════════════════
Safe Start Template:
G90 G17 G40 G49 G80
G94
G54
T01 M06
S8000 M03
M08
G43 H01 Z100.
Safe End Template:
G80
G40 G49
M09
G53 Z0
G53 X0 Y0
M05
M30
Safe Restart Principle:
Never restart below:
- tool length activation
- work offset selection
- compensation entry
Minimal restart rebuild:
G90 G17 G40 G49 G80
G94
G54
G00 Z100.
══════════════════════════════════════════════════════════════════════════════
SECTION 3 — COMPLETE G-CODE CORE REFERENCE
══════════════════════════════════════════════════════════════════════════════
Motion:
G00 Rapid positioning
G01 Linear feed move
G02 Clockwise arc
G03 Counterclockwise arc
G04 Dwell pause
Plane Selection:
G17 XY plane
G18 ZX plane
G19 YZ plane
Programming Mode:
G90 Absolute positioning
G91 Incremental positioning
Units:
G20 Inch
G21 Metric
Offsets:
G54–G59 Work coordinate systems
Machine Coordinate Motion:
G53 Machine coordinate move
G28 Reference return (safe usage commonly with incremental mode)
Compensation:
G40 Cancel cutter comp
G41 Cutter comp left
G42 Cutter comp right
Tool Length:
G43 Tool length compensation
G49 Cancel length comp
Feed Modes:
G94 Feed per minute
G95 Feed per revolution
Canned Cycles:
G80 Cancel cycle
G81 Drill
G82 Drill dwell
G83 Peck drill
G84 Tap (machine dependent)
G85–G89 Boring families depending on controller.
Always cancel canned cycles using G80 before repositioning.
══════════════════════════════════════════════════════════════════════════════
SECTION 4 — M-CODE CORE FUNCTIONS
══════════════════════════════════════════════════════════════════════════════
Spindle:
M03 CW rotation
M04 CCW rotation
M05 Stop spindle
Coolant:
M08 Coolant on
M09 Coolant off
Tool Change:
M06 Automatic tool change
Program Control:
M00 Stop
M01 Optional stop
M30 End program rewind
Machine-specific M-codes control pallets, probes, doors, or chip conveyors.
Always confirm with machine documentation.
══════════════════════════════════════════════════════════════════════════════
SECTION 5 — MODAL MEMORY AND CRASH PATTERNS
══════════════════════════════════════════════════════════════════════════════
Controllers remember active modes.
Typical dangerous inheritance:
Incremental positioning left active:
G91 → unexpected rapid movement.
Feed mode inherited:
G95 milling overload.
Compensation restart:
G41 active → sideways jump.
Forgotten canned cycle:
Missing G80 → unexpected drilling move.
Professional rule:
Never assume machine neutrality.
══════════════════════════════════════════════════════════════════════════════
SECTION 6 — OFFSET STACKING EXPLAINED
══════════════════════════════════════════════════════════════════════════════
Actual tool position equals layered transformations:
Machine Zero
- Work Offset
- Tool Length Offset
- Cutter Compensation
- Local Shift
- Rotation
Incorrect layer causes silent displacement.
Common failure:
Wrong G54 produces perfect geometry in the wrong location.
══════════════════════════════════════════════════════════════════════════════
SECTION 7 — MACRO PROGRAMMING SAFETY CONCEPTS
══════════════════════════════════════════════════════════════════════════════
Macro logic allows intelligent programs.
Example concept:
Stop machine if wrong tool loaded.
IF[#4120 NE 12] THEN #3000=1 (LOAD TOOL 12)
Conceptual uses:
- tool verification
- part counters
- safety position checks
System variable numbering varies by controller.
Always verify documentation.
══════════════════════════════════════════════════════════════════════════════
SECTION 8 — RAPID MOTION REALITY
══════════════════════════════════════════════════════════════════════════════
Rapid positioning moves axes simultaneously.
Unsafe assumption:
Vertical retract occurs first.
Professional motion:
G00 Z100.
G00 X200 Y150.
Clear vertically before lateral travel.
══════════════════════════════════════════════════════════════════════════════
SECTION 9 — ALARM ROOT CAUSE THINKING
══════════════════════════════════════════════════════════════════════════════
Alarms protect hardware.
Typical root causes:
- servo overload
- overtravel
- illegal compensation
- spindle mismatch
Instead of resetting alarms blindly:
Identify which system layer triggered protection.
══════════════════════════════════════════════════════════════════════════════
SECTION 10 — FEEDS AND SPEEDS DISCIPLINE
══════════════════════════════════════════════════════════════════════════════
Tool life depends on chip load.
Common mistake:
Reducing feedrate during fear.
Result:
Heat increases.
Coating failure occurs.
Better adjustment:
Reduce radial engagement.
Maintain chip thickness.
══════════════════════════════════════════════════════════════════════════════
SECTION 11 — REAL PROGRAM MINI EXAMPLE
══════════════════════════════════════════════════════════════════════════════
G90 G17 G40 G49 G80
G94
G54
T01 M06
S6000 M03
M08
G43 H01 Z100.
G00 X0 Y0
G01 Z-5. F300
G01 X50.
G01 Y50.
G00 Z100.
M09
G53 Z0
M05
M30
══════════════════════════════════════════════════════════════════════════════
SECTION 12 — PROFESSIONAL SHOP DISCIPLINE
══════════════════════════════════════════════════════════════════════════════
Elite shops rely on:
- single block prove-out
- reduced rapid override first run
- restart checklists
- probe verification routines
Experience alone does not prevent crashes.
Process discipline does.
══════════════════════════════════════════════════════════════════════════════
FINAL UNDERSTANDING
══════════════════════════════════════════════════════════════════════════════
CNC programming mastery is not memorizing commands.
It requires controlling modal memory, compensation layers, restart logic, machine coordinates, and physical machining behavior simultaneously.
Machines execute logic exactly as defined.
Professionals design that logic before pressing Cycle Start.
Leave a comment