How does the NC program control CNC
An NC program is a list of G-code blocks that tells the machine where to move, how fast, and with which tool. This guide shows how the control reads that list, converts each line into servo commands, and closes the loop with feedback. Written for engineers and buyers who need to judge a process, not just watch a spindle turn.

In this article
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
Key takeaways
What an NC program control CNC block actually contains
Look at a single line of G-code: N120 G01 X45.0 Y12.5 Z-3.2 F250. The N number is a sequence label. G01 selects linear interpolation. X, Y, and Z are the target point in the active work coordinate system. F250 sets feed at 250 mm/min. Nothing here mentions motor current, acceleration, or jerk. Those are decided later, inside the control.
The control parses each block into a motion segment. It compares the new target with the current position, then plans a trajectory that respects the machine's acceleration limits. If the block asks for a move faster than the axis can accelerate to, the control stretches the ramp. The programmed feed is a request, not a guarantee.
Modal commands stay active until changed. Once G01 appears, later blocks without a G-code still cut in linear mode. This is why a missing G00 before a rapid move can drag a tool through a part. Programmers who hand-edit code learn to re-state the mode after every tool change.
Units matter from the first line. G20 selects inches, G21 selects millimeters. A program written in inches and run under G21 moves 25.4 times farther than intended. On a 4,000 mm machine that error reaches the limit switches in under a second.
- 1G-code describes intentPosition, feed, speed, tool. Not motor behavior.
- 2Modal state persistsRe-state G00/G01 after every tool change.
- 3Check G20/G21 earlyOne wrong unit line ruins the whole setup.
How the NC program control CNC path becomes axis motion
After parsing, the control interpolates. For a straight cut it splits the segment into small time slices, often 1–4 ms each. For each slice it computes a position for every axis, including any rotary axis on a 5-axis center. The result is a stream of setpoints, not a single command.
Each setpoint goes to the drive as a velocity or torque demand. On a modern machining center the servo loop closes at 1–4 kHz. That is far faster than the block rate, which is why the control, not the program, owns the fine motion detail.
Look-ahead is what keeps corners sharp. The control reads 50–200 blocks ahead, slows into tight radii, and speeds up on long straights. Turn look-ahead off on a hard corner and the machine overshoots. Turn it too aggressive and the feed never reaches the programmed value.
On simultaneous 5-axis work the problem gets harder. The control must keep the tool tip on path while rotating two axes. Rotary acceleration limits, not linear limits, usually cap the feed. A 16-center shop running 5-axis parts tunes these limits per machine, not globally.
- 1Interpolation splits the move1–4 ms slices turn a line into setpoints.
- 2Servo loop is faster than G-code1–4 kHz loop, block rate far lower.
- 3Look-ahead controls corners50–200 blocks of preview smooth the path.
Offsets: where the NC program control CNC thinks zero is
Before any cut, the control combines three references. Machine zero is fixed by the builder. Work offset (G54–G59) shifts the part origin. Tool length offset (H) shifts the tool tip. The programmed X, Y, Z are added to these values to find the real target.
A wrong work offset is the most common cause of a crash on a proven program. The code did not change. The setup did. Touching off a new vise or fixture and forgetting to re-probe the corner moves every feature by the setup error.
Tool length matters just as much. A 0.05 mm error in a length offset shows up directly in Z depth. On a 30-tool job, one mis-measured tool can scrap a batch before anyone notices. Presetters and in-machine probing both work; the key is that the number in the offset table matches the tool in the spindle.
Rotary and 5-axis work adds a fourth reference, the pivot point. The control needs the distance from the rotary centerline to the spindle gauge line. Get that wrong and the tool path tilts around the wrong point. The error grows with the distance from center.
- 1Three references combineMachine zero, work offset, tool length.
- 2Setup changes, code does notRe-probe after every fixture move.
- 3Length error goes straight into Z0.05 mm offset error is 0.05 mm depth error.
Feedback: how the NC program control CNC corrects itself
The control never assumes the axis reached the commanded point. Linear scales or rotary encoders report actual position every loop cycle. The difference between commanded and actual is the following error. The drive pushes harder when the error grows and eases off as it shrinks.
This is why cutting force changes do not automatically ruin size. If the tool loads up, the axis lags for a moment, the encoder sees it, and the drive catches up. The limit is the loop gain. Too low and the axis lags on hard corners. Too high and it hums or chatters.
Thermal growth is the error feedback cannot remove. A spindle running at 12,000 rpm warms the head and shifts the tool tip over hours. The encoder measures the axis, not the part. On long runs, warm-up cycles and in-process probing keep the size stable.
Backlash and lost motion sit partly outside the loop too. A worn ball screw reverses with a small dead band. On a climb-mill finish pass that dead band shows up as a step. Regular backlash measurement and compensation keep it small, but replacement is the real fix.
- 1Following error drives correctionEncoder reports, drive adjusts each cycle.
- 2Loop gain has a sweet spotToo low lags, too high chatters.
- 3Thermal drift is outside the loopWarm-up and probing hold the size.
What to change in the program before the first cut
Feed and speed come from tool material, part material, and depth of cut, not from habit. In 6061-T6 aluminum a 10 mm carbide end mill can run 3,000–6,000 rpm at 1,500–3,000 mm/min. In 316 stainless the same tool drops to 600–1,200 rpm. Copy the aluminum numbers into stainless and the tool breaks in seconds.
Tool path strategy changes the result more than feed alone. Constant-engagement paths keep radial load steady, which reduces chatter and tool wear. On deep pockets, a trochoidal path lets the tool cut at full depth with a light radial bite. The cycle time may drop, and the finish usually improves.
Entry and exit moves deserve as much attention as the cut. A straight plunge into solid material overloads the center of an end mill. Helical or ramp entry spreads the load. On exit, a small lead-out arc avoids leaving a witness mark on the wall.
Finally, leave stock for the finish pass. Rough with 0.3–0.5 mm radial stock, then finish with a sharp tool at light load. The finish pass sets size and surface. On a ±0.005 mm tolerance, the finish pass is the only one that matters for the final number.
- 1Match feed to materialAluminum and stainless numbers are not interchangeable.
- 2Control radial engagementSteady load cuts chatter and tool wear.
- 3Ramp in, arc outAvoid straight plunges and witness marks.
- 4Separate rough and finish0.3–0.5 mm stock, then a light finish pass.
Step by step: proving an NC program control CNC setup
- 1Confirm units and planeCheck G20/G21 and G17/G18/G19 at the top of the program. One wrong unit line moves the tool 25.4 times the intended distance. Fix it before anything else.
- 2Check the work offsetProbe or touch off X, Y, and Z zero, then verify the G54 values against the setup sheet. Re-probe after any fixture move. A 0.1 mm setup error is a 0.1 mm part error.
- 3Verify every tool lengthCompare the offset table with the presetter list for all tools in the job. Mismatched lengths show up as depth errors, not as alarms.
- 4Dry run above the partRaise Z by 50–100 mm and run the full program with rapids at 25–50%. Watch for missing G00 moves and unexpected axis reversals.
- 5Cut one part and measureMachine a single piece, then measure the critical features. Compare against the drawing before releasing the batch. Note any size that sits near the tolerance limit.
- 6Adjust offsets from the measurementIf the part runs 0.03 mm oversized, shift the relevant offset by 0.03 mm and re-cut. Change one variable at a time so you know what worked.
- 7Lock the proven setupRecord offsets, tool numbers, and program revision. Any later edit to the code restarts the proof process from step four.
When the program is the cause and when it is not
Use this table to separate programming errors from machine and setup errors before you change code.
| Symptom | Likely cause | First check |
|---|---|---|
| Every feature off by the same amount | Work offset | Re-probe G54 X, Y, Z |
| Z depth wrong on one tool only | Tool length offset | Compare offset table with presetter |
| Size drifts over a long run | Thermal growth | Warm-up cycle and in-process probing |
| Step mark on a reversed wall | Backlash | Measure lost motion, check compensation |
| Corners overshoot or round off | Look-ahead setting | Adjust acceleration and preview blocks |
| Chatter on deep pockets | Radial engagement | Move to constant-engagement path |
| Tool breaks on first cut | Feed and speed | Recheck material-specific cutting data |
| Alarm on rapid move | Soft limit or wrong unit | Check G20/G21 and travel limits |
Questions engineers ask about NC program control
Does the NC program control the machine directly?
No. The program describes target positions, feeds, and tools. The control turns those into motion commands, and the servo drives execute them.
Between the two sits interpolation, look-ahead, and the feedback loop. The program sets intent; the control and drives decide how the axes actually move.
Why does the same program cut differently on two machines?
Acceleration limits, loop gain, backlash, and thermal behavior differ between machines, even of the same model.
A program proven on one center may need feed and look-ahead adjustments on another. Treat the first part on a new machine as a trial cut.
Can I hold ±0.005 mm with an NC program alone?
The program gets the tool to the right place, but the machine, tool, and setup hold the size. Thermal drift, tool wear, and fixture rigidity all matter.
In practice, ±0.005 mm comes from a controlled process: warm-up, sharp tooling, light finish passes, and measurement between operations.
What causes a program that ran fine yesterday to crash today?
Usually the setup, not the code. A moved fixture, a re-loaded part, or a changed tool length offset shifts every target point.
Re-probe the work offset and verify tool lengths after any setup change. The dry run above the part catches most of these before contact.
How much stock should I leave for the finish pass?
For most materials, 0.3–0.5 mm radial stock after roughing works well. Harder materials may need less to avoid work hardening.
Keep the finish pass at light load with a sharp tool. That pass sets the final size and surface finish, so it should not fight a heavy cut.
Does 5-axis work need a different approach to offsets?
Yes. Rotary and 5-axis setups need the pivot point, the distance from the rotary centerline to the spindle gauge line, entered correctly.
An error there tilts the tool path around the wrong point, and the size error grows with distance from center. Verify the pivot before the first cut.
Send us your drawing and get a program review
We quote and return a free DFM analysis within 12 hours, then machine from one prototype to 10,000+ part runs with 100% inspection before shipment.
12-hour quote±0.005 mm tolerance100% inspectionNo minimum order