How a CNC Machine Works: From G-Code to Finished Cut
This guide follows the whole loop: CAD model, CAM toolpath, G-code, servo motion, and closed-loop feedback. It is written for engineers and buyers who need to judge whether a part suits CNC, and what to check when a cut drifts out of tolerance.

In this article
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
Key takeaways
What the controller actually does
A CNC machine works by turning a coordinate list into controlled motion. The CAM post-processor writes G-code such as G01 X10.0 Y20.0 F400, and the controller reads it block by block. Each block tells the axis where to go, how fast, and which spindle or coolant command to run at the same time.
The controller does not just replay the numbers. It compares the commanded position with the actual position from the encoder or linear scale, then adjusts the drive current. That loop runs at the servo update rate, often 1–4 kHz. On a good machine the following error stays in the single-digit micrometre range during a normal contour cut.
This is why a cheap control on a rigid frame can still hold tolerance, and a good control on a loose machine cannot. The control only corrects what the mechanics let it correct.
- 1Block look-aheadThe controller reads 20–200 blocks ahead to plan deceleration before corners.
- 2Feed overrideOperators trim feed from 50% to 150% without editing the program.
- 3Optional stopM01 pauses the cycle for a quick gauge check without losing position.
Servo drives, ball screws, and what limits accuracy
Each linear axis is a closed system: servo motor, coupling, ball screw, linear guide, and feedback device. The ball screw converts rotation into travel. A typical rolled screw has 0.05 mm per 300 mm lead error; a ground screw is much tighter. That error shows up directly in the part unless the control compensates for it.
Thermal growth is the quiet problem. A spindle running at 12,000 rpm for two hours can move 20–40 μm in Z. Shops that hold ±0.005 mm on long runs warm up the machine for 30–60 minutes first, and some run a warm-up program overnight.
Backlash and lost motion appear when the axis reverses direction. Climb milling with a light finishing pass hides some of it, but a worn thrust bearing will still leave a step on a wall. If a bore measures 0.02 mm different when approached from the other side, the backlash is the first thing to check.
- 1Linear scale vs encoderScales measure the table, not the motor, so they catch screw error.
- 2PreloadBall nut preload removes axial play but adds drag and heat.
- 3Rapid positioningRapids do not cut, but a bad approach vector can still scrap the part.
Tool offsets, wear, and why the first part is not the part
Every cutter has a length and a diameter that the control must know. The operator touches off each tool on a setter or a probe, then stores the offset in the register. If a 10 mm end mill is entered as 9.98 mm, every wall on that feature shifts by 0.01 mm.
Tools wear during the run. A carbide insert in 4140 steel may lose 0.02–0.05 mm of diameter over a few hundred parts. Shops that hold tight limits either probe the tool between parts or run a wear-compensation table that steps the offset as the count rises.
This is why the first article matters. We cut it, measure it, and adjust offsets before the run continues. On a ±0.005 mm feature the setup can eat the whole tolerance band if it is rushed.
- 1Touch-off errorA chip under the tool tip can shift the offset by 0.01 mm.
- 2RunoutA holder with 0.02 mm TIR cuts oversize on one flute.
- 3Pull-outA loose collet lets the tool creep deeper during heavy cuts.
Where CAM stops and the operator starts
CAM software turns the solid model into toolpaths, but it does not know the shop floor. The programmer picks the stock, the workholding, and the order of operations. A good setup cuts most of the part in one or two fixturings, because every refixture adds stack-up error.
Simulation catches collisions and gouges before the spindle turns. It does not catch chatter, thin-wall deflection, or a tool that cannot reach a corner. Those are judgment calls. On a deep pocket with a 6 mm cutter, a 4:1 length-to-diameter ratio is already pushing it; past 6:1 the finish will show it.
For 5-axis work the extra rotary axes let the tool approach a face at an angle. That shortens the effective stick-out and improves surface finish on contoured surfaces. It also means the post-processor and the machine kinematics must match exactly, or the part comes out in the wrong place.
- 1Rest machiningSmall cutters clean corners the roughing tool could not reach.
- 2Trochoidal pathsSpreads radial load so a 10 mm cutter can slot at full depth.
- 3Stock modelAn accurate stock keeps the first pass from cutting air or overloading.
In-process checks that catch drift early
A machine that only cuts and never measures is guessing. Probing the workpiece between operations confirms the datum is still where the program expects it. On a long run a 30-second probe cycle can save a scrapped batch of 200 parts.
CMM checks after machining give the final verdict, but they come too late to save the parts already cut. In-process gauging, tool breakage detection, and spindle load monitoring are the early warning systems. Spindle load climbing by 15% on the same program usually means a dull tool or a chip pack.
For a ±0.005 mm tolerance we inspect 100% before shipment and keep the reports on request. The point is not the paperwork. It is catching a shift before it becomes a trend.
- 1Datum checkProbe the fixture before the first cut on a new setup.
- 2Load monitoringRising spindle load points to wear or chip recutting.
- 3Temperature logA warm shop shifts dimensions more than most operators expect.
How a CNC machine works, step by step
- 11. Import the model and set the stockLoad the STEP file, define stock with 0.5–1.0 mm allowance on faces to be finished. A tight stock model prevents air cuts and overload.
- 22. Choose workholding before toolpathsVise, fixture plate, or soft jaws. Plan the datum so most features come from one side. Every refixture adds stack-up error.
- 33. Select tools and stepoverRough with 50–70% stepover, finish with 5–10%. Keep length-to-diameter under 4:1 where the geometry allows it.
- 44. Set speeds and feedsStart from surface speed: 6061 aluminium 300–500 m/min, 4140 steel 120–180 m/min. Then check chip load per tooth.
- 55. Simulate and postRun the full simulation including holder and fixture. Post the code with the correct machine kinematics and check the first block numbers.
- 66. Touch off tools and set offsetsUse a tool setter or probe. Record length and diameter. Confirm runout under 0.01 mm on finishing tools.
- 77. Cut the first article and measureCut one part, measure the critical features, and adjust offsets before the run continues. Do not skip this on a tight tolerance.
When a CNC machine works well, and when it does not
Use this to judge a part before quoting.
| Part feature | CNC fits | CNC struggles | What we check |
|---|---|---|---|
| Prismatic shape, 3 axes | Yes, one setup | Not an issue | Datum and workholding |
| Deep pocket, L/D over 6:1 | Possible | Chatter, poor finish | Tool stick-out and stepdown |
| Undercut or side holes | 4 or 5 axes | 3-axis cannot reach | Access angle and holder clearance |
| Mirror finish Ra 0.2 μm | With polishing | Direct cut is slow | Finish pass and media |
| Thin wall under 0.5 mm | With support | Deflection moves walls | Support and pass order |
| Hardened steel over 45 HRC | With correct tools | Rapid wear | Insert grade and coolant |
| One-off prototype | Yes, no MOQ | Setup dominates cost | Fixture reuse |
Common questions
Does a CNC machine work without a CAD model?
Yes, for simple parts. Conversational controls let an operator enter a pocket or a bolt circle at the panel. It is fast for brackets and plates.
For anything with freeform surfaces or tight tolerances, a CAD model and CAM toolpath are the normal route. Hand-written code does not scale and is hard to verify.
How does the machine know where the part surface is?
The operator sets a work offset by touching a tool or a probe to a known datum. That tells the control where part zero sits in machine coordinates.
A spindle probe automates this and can check several points to confirm the stock is sitting flat, not tilted.
What tolerance can a CNC machine hold in production?
On a rigid machine with the right workholding, ±0.005 mm is realistic on critical features. General features often run at ±0.05 mm without extra cost.
The limit comes from thermal growth, tool wear, and fixture rigidity more than from the control itself.
Why does the first part sometimes fail inspection?
Tool offsets, thermal state, and fixture seating are all different on the first cut. The machine is cold and the operator is still confirming the setup.
Measuring the first article and stepping the offsets closes most of that gap. After that the run is stable.
Can the same G-code run on a different machine?
Only if the kinematics and control match. A program written for a 3-axis mill will not run on a mill-turn center without a new post.
Even between two machines of the same model, offsets and tool registers are machine-specific and must be reset.
How do you keep confidential parts secure?
Uploads are handled as confidential, and we sign an NDA on request. Files stay inside the project team.
Our quality system is certified to ISO 27001:2022 for information security, alongside ISO 9001, IATF 16949, and ISO 13485.
Send a drawing, get a manufacturability read
We review your model, flag features that will not hold tolerance, and quote from one prototype to 10,000+ parts.
12-hour quote100% inspectionNo minimum order quantity