GreatLight CNC Machining Factory logo
CNC Machining
Rapid Prototyping
Materials
Industries
News
About GL

Get Instant Quote

Control Basics

How CNC Machine Is Controlled?

This guide explains how a CNC machine is controlled, from the controller loop to G-code, offsets and feed overrides. It is written for engineers and machinists who need to set up a program, run a first article and judge whether a cut will hold tolerance.

±0.005 mm tolerance16 five-axis centersNo minimum order quantity12-hour quote
CNC machine is controlled by a controller unit and servo drives
Quick answer

Key takeaways

The controller closes the loopIt compares commanded position with encoder feedback every few milliseconds and corrects the axis drive.
G-code is the command languageG-codes set motion mode; M-codes switch spindle and coolant on or off.
Offsets decide where the tool cutsWork offset sets part zero, tool offset sets the cutter length and radius.
Feed and speed override protect the cutStart at 50% rapid and 50% feed on a new program, then step up after the first article passes.
The controller loop

How the controller loop keeps the tool on path

Every CNC machine is controlled by a loop that repeats many times per second. The controller reads the next block of the program, calculates the target position for each axis, and sends a command to the servo drive. The drive moves the motor, and an encoder or glass scale reports the actual position back. The controller compares target and actual, then adjusts the command. This is a closed loop.

The loop rate matters. On a typical machining center the position loop closes every 1–4 ms. If the loop is slower, the axis can lag during a fast direction change and leave a witness mark at the corner. That is one reason a machine can hold ±0.005 mm on a straight cut but show a step on a tight radius.

The controller also manages the spindle, tool changer, coolant and pallet system through PLC logic. These are not position loops. They are sequence controls. When a tool change hangs, the fault is usually in the PLC sequence or a proximity switch, not in the motion loop.

For the engineer sending a part out, the practical point is this: control quality depends on the mechanical loop as much as the electronics. A worn ball screw or a loose thrust bearing will show up as backlash, and no controller tuning can remove it.

Program flow

From CAM file to machine motion: how the program is controlled

The program path starts in CAM. The post-processor converts toolpaths into machine-specific G-code. A Fanuc post will not run correctly on a Heidenhain control without edits. Check the post before the first run.

At the machine, the operator loads the program and sets the work offset. G54 is the common default. The work offset tells the controller where part zero sits in machine coordinates. Get this wrong and the tool will cut air or crash into the vise.

Tool offsets come next. The length offset (H) tells the controller how long the tool is. The radius offset (D) tells it the cutter diameter. If the radius offset is wrong by 0.1 mm, a contour will be off by 0.1 mm on the wall. Always verify offsets in single-block mode with rapid override at 25% before a full cycle.

The controller then executes the program block by block. Modal commands stay active until changed. If you command G01 once, every following move is a feed move until a G00 or G02 appears. This is a common source of crashes for new programmers.

Speeds and feeds

How feed, speed and override control the cut

The controller does not choose feeds and speeds. The programmer does, and the operator can override them at the panel. Feed override typically ranges from 0% to 200%. Rapid override is usually 25%, 50% or 100%.

For aluminum 6061 with a 10 mm carbide end mill, a starting surface speed of 300–500 m/min and a chip load of 0.05–0.10 mm per tooth works for roughing. For 316 stainless, drop surface speed to 80–120 m/min and keep the chip load at 0.03–0.06 mm per tooth. These are starting points, not rules.

The load meter on the controller shows spindle load. If it sits above 80% for a long roughing pass, reduce feed or take a lighter axial depth. If it sits below 30%, you are leaving cycle time on the table.

Feed override is not a substitute for a correct program. If a program needs 150% override to cut well, the feeds are wrong. Fix the program, not the override.

Troubleshooting

Diagnosing control faults: symptom, cause, action

Control faults usually show up as three symptoms: the machine stops with an alarm, the part is out of tolerance, or the surface finish changes mid-cut. Match the symptom to the cause before touching any parameter.

If the machine alarms on a following error, check the load meter and the tool condition first. A dull tool increases cutting force and the axis lags. If the tool is sharp and the load is low, the drive or the guideway is the problem.

If the part is out of tolerance but the program is proven, check thermal drift. Measure the machine at the start and end of a shift. A spindle that grows 0.02 mm will push bores undersize by that amount.

If the finish changes mid-cut, look at the coolant and the chip evacuation. A chip recut will leave a mark on the wall. Adjust the coolant aim or add a peck cycle for deep pockets.

Setup sequence

Step by step: run a new program safely

  • 1
    Warm up the spindleRun the warm-up cycle for 10–15 minutes at 25%, 50% and 75% of max rpm. Cold spindles grow as they heat, which shifts Z by 0.01–0.03 mm.
  • 2
    Check the work offsetTouch off X, Y and Z with a probe or edge finder. Confirm G54 values against the setup sheet. Use a gauge block on Z if the probe is not calibrated.
  • 3
    Verify tool offsetsMeasure each tool length on the presetter or with a dial indicator on the table. Enter H and D values. Never assume the previous job's offsets are still valid.
  • 4
    Run single block at 25% rapidStep through the first 10–20 blocks. Watch the distance-to-go display. If a rapid moves toward the part faster than expected, stop.
  • 5
    Air cut the first passRaise Z by 20–50 mm and run the roughing pass in air. Listen for tool change noise and check the coolant aim.
  • 6
    Cut the first article at 50% feedStart with feed override at 50%, then step to 100% after the first feature looks correct. Measure before running the rest.
  • 7
    Measure and adjustCheck critical dimensions with a micrometer or CMM. If a dimension is off, adjust the tool offset, not the program geometry.
  • 8
    Log the settingsRecord offsets, feeds, speeds and any changes. The next run starts from a known state.
Control comparison

Open-loop vs closed-loop control: what changes on the floor

Use this table to judge what a control type means for your part.

FeatureOpen-loop (stepper)Closed-loop (servo)
Position feedbackNone; counts pulsesEncoder or scale on each axis
Typical accuracy±0.05 mm on light cuts±0.005 mm or better
Behavior under loadCan lose steps, no alarmController corrects and alarms on error
Best forHobby, light engraving, woodMetal parts, tight tolerance, production
Cost and upkeepLower cost, simpleHigher cost, needs tuning
Failure signPart drifts over the runAxis fault or following error alarm
FAQs

Frequently asked questions

What is the difference between G-code and M-code?

G-codes control motion and modes: G00 rapid, G01 feed, G02 and G03 arcs, G54 work offset. M-codes control machine functions: M03 spindle on clockwise, M08 coolant on, M06 tool change, M30 program end.

A block can hold both, for example G01 X50.0 Y25.0 F200 M08. The controller reads the motion first, then the machine function.

Why does the machine alarm with a following error?

The axis is not keeping up with the commanded position. Common causes are a dull tool, too aggressive a feed, a tight spot in the guideway, or a drive that needs tuning.

Reduce feed override and check the load meter. If the alarm repeats on a light cut, call maintenance. Do not keep resetting the alarm and running.

Can I run a program without setting tool offsets?

No. Without length offsets the controller does not know where the tool tip is, and the first rapid move will likely crash. Radius offsets are also needed for cutter compensation.

If you are only drilling on a drill press style operation, you still need a length offset for each drill.

How often should offsets be checked?

Check work offsets at the start of every job and after any crash. Check tool offsets whenever a tool is changed, and at least once per shift on a long run.

On a 24-hour run, thermal growth can move Z by 0.01–0.02 mm. A mid-run check catches it before parts go out of tolerance.

What does feed override do to surface finish?

Lower feed override increases the effective chip load per tooth if the spindle speed stays the same, which can improve finish on some materials but overload the tool on others. Higher override reduces chip load and can cause rubbing.

Use override for setup and proving. Once the program is proven, run at 100% and adjust feeds in the program.

When should the program be changed instead of the offset?

If one feature is off but the rest are correct, adjust the offset. If the whole part shifts, check the work offset. If the error follows the toolpath shape, the program or CAM output is wrong.

Changing offsets to fix a program error hides the real problem and will fail on the next run.

Send us your part and control requirements

We run 127 high-precision CNC machines, including 16 simultaneous 5-axis centers, and inspect 100% of parts before shipment. Upload your drawing for a quote and DFM feedback within 12 hours.

12-hour quote100% inspectionNo minimum order quantity

Follow us

More from GreatLight

We publish setup notes, tooling trials and inspection data from the factory floor.

FacebookTikTokYouTubeLinkedInInstagramThreadsPinterest

Trusted by engineers and manufacturers worldwide

Tesla Ford Motor Company BYD Auto Denso Magna International Boeing Airbus Medtronic KUKA FANUC