Z-axis explained in CNC: the depth axis and what it controls
Z-axis explained in CNC starts with one fact: this axis sets depth. On a vertical machining center the spindle moves down and up; on a lathe the turret or the part moves along the same line. This page covers the drive train, the error sources that reach the tool tip, and the point where a 3-axis setup stops being enough.

In this article
- 1
- 2
- 3
- 4
- 5
- 6
- 7
Key takeaways
What the Z-axis actually does, explained in CNC terms
The Z-axis is the linear axis parallel to the spindle centerline on a vertical mill, or parallel to the part centerline on a lathe. Its job is depth. X and Y place the tool over a feature; Z decides how deep that feature goes. When a hole comes out 0.05 mm shallow or a pocket floor is thin enough to bow, the fault is almost always in the Z chain, not in the profile the CAM system generated.
That single function makes Z the axis most exposed to gravity and to cutting thrust at the same time. On a vertical mill the head carries the tool down against the part, so the reaction force pushes straight back up the column. Deep pockets, long reach tools and hard materials all load the same path. The machine has to hold position while that load changes from zero to several hundred newtons and back, thousands of times per minute.
Z also carries the tool length offset. Every tool in the magazine has a different gauge length, and the control adds that offset to the programmed Z value. A 0.01 mm error in the probe or the presetter becomes a 0.01 mm depth error on every feature that tool cuts. This is why tool setting discipline matters more on Z than on X or Y, where the offsets are usually shared or fixed by the fixture.
One more detail that catches people out: the direction convention. On most machines Z+ moves the tool away from the work, and Z- moves it into the work. Programs written for a horizontal machine or a lathe may flip this. Always check the machine definition before you trust a posted file, especially when a subcontractor runs the job on a different control.
- 1Depth controlSets hole depth, pocket floor height, step-down per pass and thread depth.
- 2Tool length compensationAdds the measured gauge length of each tool to the programmed value.
- 3Thrust pathCarries the axial cutting force from the tool tip back into the column or the bed.
Drive train and control loop behind the Z-axis
A typical Z assembly is a servo motor, a coupling, a preloaded ball screw, a linear guide or box way, and a feedback device. The ball screw converts rotation into linear motion. Preload removes the backlash that would otherwise show up as a dead band when the axis reverses. On a good machine that backlash is held under 0.005 mm, and the control can compensate for what remains.
Feedback comes from an encoder on the motor or from a linear scale mounted on the structure. Motor encoders measure rotation, so they miss screw growth and thermal expansion between the motor and the tool tip. Linear scales measure the actual slide position and close that gap. For work at ±0.005 mm, a machine with a Z linear scale is easier to hold in tolerance over a long run than one without.
The control closes the loop at a fixed sample rate, typically 1-4 kHz on modern CNC systems. It compares commanded position with feedback and adjusts motor current. Gains that are too low leave the axis lagging behind the commanded path, which rounds off the bottom of a pocket. Gains that are too high make the axis ring, and the ringing is written into the surface finish as chatter marks.
Counterbalance deserves a mention because it is invisible until it fails. A pneumatic cylinder or a counterweight offsets the weight of the head so the servo does not have to hold it up. When pressure drops, the head sags by a few micrometres and every Z position in the program shifts with it. If depth drifts slowly over an hour, check counterbalance pressure before you touch the offsets.
- 1Ball screw preloadRemoves backlash on reversal; usually held under 0.005 mm.
- 2Linear scaleMeasures slide position directly and catches thermal growth in the screw.
- 3CounterbalanceOffsets head weight; a pressure drop shifts every depth at once.
Why Z-axis error shows up at the tool tip
Cutting force pushes the tool up and away from the part. The tool holder, the spindle bearings, the head casting and the column all flex a little under that push. The sum is called deflection, and on a long-reach tool it can be 20-50 μm in a roughing pass. A finishing pass with a light radial engagement and a sharp tool brings that down to a few micrometres, which is why you rough and then finish rather than trying to cut to size in one go.
Thermal growth is slower but larger over a shift. The spindle bearings and the ball screw heat up as the machine runs. A screw 500 mm long grows about 6 μm per degree Celsius. Warm the machine for 20-30 minutes and it stabilizes; start cutting cold and the first parts will be high by a measurable amount. On tight work, run a warm-up cycle and check the first article, not the tenth.
Chip packing in a deep pocket is a Z problem, not a coolant problem. When chips cannot leave, the tool recuts them, load spikes, and the axis deflects under the transient. Peck drilling with a full retract, or a high-pressure through-tool coolant line, clears the zone and keeps the axial load steady. The depth reading becomes repeatable once the load stops jumping around.
Tool wear changes the effective length of the cutter. A worn end mill cuts slightly shorter than a fresh one because the edge is no longer sharp, and it rubs instead of shearing. On long runs, track tool life in the control and replace before the depth drifts out of tolerance. Measuring the floor of a test pocket every 50 parts is a cheap way to catch the trend early.
- 1DeflectionAxial force bends the tool and structure; worst on long reach and hard material.
- 2Thermal growthScrew and spindle expand with heat; about 6 μm per degree on a 500 mm screw.
- 3Chip packingRecut chips spike the load and move the axis; clear the pocket and the depth settles.
- 4Tool wearA dull edge rubs rather than shears, so the effective length changes.
Z-axis behavior: 3-axis versus 5-axis setups
On a 3-axis vertical mill the Z direction is fixed in space. The tool always approaches from above. That is fine for prismatic parts with open tops and floors you can reach straight down. It becomes a problem when a feature sits on a side wall, because the tool has to cut with its side while the Z thrust stays vertical. Side loading is the result, and side loading deflects the tool in the direction that matters least for depth but most for wall straightness.
A 5-axis machine tilts the part or the spindle so the tool axis stays close to the surface normal. The cutting thrust then runs along the tool axis, where the tool is stiffest, instead of across it. In a deep cavity this lets you use a shorter, thicker tool and still reach the floor. Depths come out more consistent, and the surface finish on the floor improves because the load path is stable.
The trade is setup and programming cost. A 5-axis cycle needs a verified post, collision checks and a fixture that holds the part rigidly through the tilt. For a simple bracket with five drilled holes, that overhead buys nothing. For a part with pockets on three faces, it can remove two refixtures and the depth variation that comes with each one.
A practical rule: if the part has features that need more than two setups on a 3-axis machine, or if a wall height exceeds three times the tool diameter, price the 5-axis route before you commit. The Z-axis explained in CNC terms is not just about going down. It is about keeping the thrust where the tool can take it.
- 13-axisBest for open-top parts, flat floors and through holes on one face.
- 25-axisBest for deep cavities, angled faces and walls taller than 3× tool diameter.
Depth strategy that keeps Z within ±0.005 mm
Plan the step-downs so the finishing pass removes a small, even amount of material. A typical roughing step-down is 0.5-2 mm depending on tool diameter and material, and the finishing allowance is 0.1-0.3 mm. If the finishing pass has to remove 1 mm, the axial load is high enough to deflect the tool and the floor will not be flat.
Use the shortest tool that reaches the floor. Stiffness falls with the cube of the length, so a tool 20 mm longer than needed can deflect eight times as much under the same load. If a deep pocket forces a long tool, reduce the step-down and the feed, and consider a relieved shank or a carbide shank to recover some rigidity.
Control the temperature before the first cut. Run the spindle at working speed for 20-30 minutes, or run the machine's warm-up program. Then set tool offsets and cut the first article. If the shop is not temperature controlled, note the room temperature on the inspection sheet so a later reading can be compared against it.
Inspect the feature that Z controls. Hole depth, pocket floor height and step height are the readings that catch a Z problem early. Measure them on the first article and at intervals during the run. Our own inspection covers raw material, in-process checks and a final pass before shipment, and reports are available on request.
- 1Step-downRough at 0.5-2 mm, leave 0.1-0.3 mm for the finisher.
- 2Tool lengthShortest tool that reaches; every extra 20 mm costs stiffness.
- 3Warm-up20-30 minutes at working speed before offsets are set.
Z-axis conditions and what to do
Use the left column to match your part, then read across.
| Condition | Typical cause | What to change |
|---|---|---|
| Pocket floor not flat | Axial deflection on a long tool | Shorten the tool, reduce step-down to 0.3 mm |
| Hole depth drifts over a shift | Thermal growth in screw and spindle | Warm up 20-30 min, recheck offsets |
| Depth shifts after a pause | Counterbalance pressure drop | Check air supply and cylinder pressure |
| First part high, later parts good | Cold machine at start of shift | Run a warm-up cycle before offsets |
| Chatter marks on the floor | Servo gain too high for the load | Lower gain or reduce feed on Z ramp |
| Depth varies part to part | Chip recut in a deep cavity | Peck with full retract, add through-tool coolant |
| Side wall tapered, floor good | Side load from a fixed vertical Z | Tilt the part on a 5-axis setup |
Pick the setup that matches the feature
If the part is open on top and the pockets are shallower than three times the tool diameter, a 3-axis machine holds ±0.005 mm with less setup risk. If the walls are tall, the floors sit on angled faces, or the same part needs three or more setups, move to a 4- or 5-axis machine so the Z thrust stays along the tool axis.
Z-axis questions engineers ask
Which direction is Z on a CNC machine?
On a vertical machining center, Z is parallel to the spindle. Z+ moves the tool away from the work and Z- moves it into the work, following the right-hand rule with X and Y.
On a lathe the convention is different. Z runs along the part centerline, and X is the diameter direction. Always read the machine definition before you trust a posted program.
Why does my hole depth change during a long run?
The most common cause is thermal growth. The ball screw and the spindle expand as they heat, so the same commanded Z cuts slightly deeper later in the shift. A warm-up cycle reduces the size of the shift but does not remove it.
The second cause is tool wear. A dull edge rubs and cuts shorter. Track tool life and replace before the depth leaves tolerance.
Does a linear scale on Z really help?
Yes, when you are working at tight depth tolerance. A motor encoder measures rotation and cannot see screw growth or thermal expansion between the motor and the tool tip. A linear scale measures the slide itself.
On work at ±0.05 mm the difference rarely shows. At ±0.005 mm it is the difference between holding tolerance all shift and chasing offsets.
When should I stop using a 3-axis machine?
When a feature needs more than two setups, when a wall is taller than about three times the tool diameter, or when pocket floors sit on faces that are not reachable from straight above.
Those cases push you into long tools and side loading, which is where depth error comes from. A tilt on a 4- or 5-axis machine usually costs less than the scrap it prevents.
What tolerance can a normal Z-axis hold?
On a well-maintained vertical machining center, ±0.005 mm is achievable on depth features with a short tool, a warm machine and a light finishing pass.
Long reach, hard material and a cold start widen that figure. Deep pockets in titanium or Inconel are the cases where we plan extra passes rather than promise the tight number.
How does coolant affect Z-axis accuracy?
Coolant does not change the axis, but it changes the load on it. When chips clear the pocket, the axial load stays steady and the deflection stays steady with it.
Through-tool high-pressure coolant is the most direct fix in deep cavities. Peck drilling with a full retract is the cheaper option when the tool allows it.
Send a part with deep pockets or tight floors
Share the model and we will review the Z features, suggest the tool and setup, and return a quotation with free DFM analysis within 12 hours.
12-hour quote±0.005 mm tolerance100% inspectionNo minimum order quantity