Machine Fundamentals for Programmers
Before writing code, you need to know what the machine actually moves. This page covers axes, spindle, turret, tool magazine, and the critical difference between machine zero and work zero.
Concept
Every CNC machine has a set of linear axes (X, Y, Z) and optionally rotary axes (A, B, C). The machine moves the tool relative to the workpiece along these axes. On a mill, the tool rotates in the spindle and moves in X, Y, and Z. On a lathe, the workpiece rotates in the spindle and the tool moves in X (radial) and Z (axial). Understanding which one rotates — tool or workpiece — explains most of the differences between mill and lathe programming.
Machine zero (machine home, reference position) is a fixed physical position established when the machine is turned on and homed. Work zero (program zero, G54 origin) is where you choose the part origin — typically a corner or center of the workpiece. The machine always knows where it is relative to machine zero; the work offset tells it where the part is.
Why It Matters
The same X20 means different things on different machines. On a mill, X20 moves the tool 20 mm in the X direction. On a lathe in diameter mode, X20 means the tool is at a 20 mm diameter — the actual radial movement from X40 to X20 is only 10 mm. If you treat lathe X as a linear coordinate like a mill, you will cut diameters wrong by a factor of two.
Coordinates being legal does not mean they are safe. Assume the jaw occupies Y ≥ 40 mm and overlaps the cutter in X and Z. A Ø10 mm cutter has a 5 mm radius. At center Y35, its outer edge reaches Y40: this is tangency with zero clearance, not a safe stand-off. For an illustrative 1 mm geometric gap, keep the center at Y34 or less when approaching from smaller Y. Check the holder envelope and positioning uncertainty separately. The machine envelope tells you where it can go; the fixture envelope tells you where it may go. Always visualize the fixture, tool, and spindle before commanding a move.
How It Works
Mill Axes
- X — left/right table movement
- Y — in/out table movement
- Z — spindle up/down
- A/B/C — rotary axes (if equipped)
- Spindle — holds the rotating tool
- Tool magazine / ATC — stores tools, changes them with M06
Lathe Axes
- X — radial movement (programmed in diameter)
- Z — axial movement along the spindle
- C — spindle orientation / rotary axis (on sub-spindle or live-tool machines)
- Turret — holds multiple tools, indexes with T code
- Chuck — holds the rotating workpiece
Both machines have a reference position (machine zero) that they return to on power-up. The work offset (G54) shifts the coordinate system from machine zero to the part. For machine architecture details beyond programming, see Machine Systems.
Mill vs Lathe at a Glance
| Mill / Machining Center | CNC Lathe | |
|---|---|---|
| What rotates | Tool (spindle) | Workpiece (chuck) |
| Linear axes | X, Y, Z | X, Z |
| X meaning | Linear position (mm) | Diameter (mm) |
| Tool holding | Tool changer + magazine | Turret |
| Coolant | Flood through spindle | Flood through turret |
Machine Zero vs Work Zero
Machine zero is the fixed reference point the machine establishes on power-up by moving each axis to a home switch. It never changes. Work zero is where you define the part origin using a work offset (G54). You set G54 by touching the part edge with an edge finder or probe. The controller computes: machine position = machine zero + work offset + programmed coordinate. This three-layer relationship is the core mental model of CNC.
Example
Mill: Tool moves from X10 to X30. Actual travel = 20 mm.
Lathe (diameter mode): Tool moves from X40 to X30. Actual radial travel = (40 − 30) / 2 = 5 mm, because X is programmed as diameter.
This is why lathe programmers think in diameters: X30 means "cut to a 30 mm diameter," not "move 30 mm radially."
Common Mistakes
- Confusing machine zero with work zero — machine zero is fixed; work zero is where you set the part. They are not the same.
- Ignoring turret/fixture envelope — the tool tip may be clear of the part while the toolholder or turret collides with the chuck or fixture.
- Judging axis direction from a photo — always use the right-hand rule and machine documentation, not what the photo looks like.
Practice
1. On a lathe, the tool moves from X50 to X46. What is the actual radial depth of cut?
Show answer
(50 − 46) / 2 = 2 mm radial depth. X is diameter mode.
2. Why does the same XYZ coordinate not guarantee the toolholder is clear of the fixture?
Show answer
The coordinate describes the tool tip position. The toolholder, shank, and turret extend beyond the tip and may collide even when the tip is clear. You must consider the full tool assembly envelope.
3. What happens to work zero when you turn the machine off and back on?
Show answer
The machine re-homes to machine zero. The G54 work offset is stored in the controller's memory and should still be correct — but you should always verify the part position before cutting.
Sources
- Haas G00 Rapid Positioning — supports rapid motion behavior.
- Haas G01 Linear Interpolation — supports feed motion and F command rules.
- Program examples and speeds/feeds are classroom teaching assumptions; verify against tooling catalogs and machine documentation.