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

Get Instant Quote

CNC programming guide

How to Program Its CNC Machine: A Shop-Floor Walkthrough

This guide is for engineers and programmers who need to turn a 3D model into a machined part. It covers the full chain from CAD prep to first-article check, with the numbers we actually use on our machines.

±0.005 mm tolerance127 CNC machines16 five-axis centersDFM in 12 hours
How to program its CNC machine for 5-axis engine parts
Quick answer

Key takeaways

Programming starts at CADFix the model first: closed solids, defined datums, no zero-thickness walls. CAM cannot repair a bad model.
Toolpath choice drives costAdaptive clearing with 8–12% stepover removes material fast; a parallel finish at 0.3–0.5 mm stepover sets the surface.
The post-processor is not optionalA generic post will output the wrong G-code dialect, wrong coolant codes and wrong rotary directions.
Offsets and probing decide the first partSet work offsets from stock, not from the model. Verify with a probe or indicator before the first cut.
Prove it with a first-article checkMeasure the first part against the drawing before the run continues. One scrapped part beats fifty.
The workflow

What happens before the first line of G-code

Programming a CNC machine means writing the instruction set that moves the tool, spindle and fixture through a defined sequence to cut a part from a blank. The output is G-code, but the decisions come earlier: how the part is held, which features are cut in which order, and which tolerances actually need to be held.

At our Dongguan plant, we run 127 high-precision CNC machines across three plants, including 16 simultaneous 5-axis machining centers and 16 mill-turn centers. The programming approach changes with the feature: a 5-axis toolpath can reach a port or a blade in one setup, while a 3-axis part with simple pockets is faster to program and faster to run.

The chain is always the same. CAD model, DFM review, stock and fixture plan, CAM toolpaths, post-processed G-code, setup on the machine, first-article inspection. Skip a link and you pay for it at the machine, not at the desk.

The tolerance target matters from the start. If the drawing calls for ±0.005 mm on a bore, that bore needs a separate finishing pass, a rigid setup and a warm machine. If the same bore is ±0.1 mm, a single pass may be enough. Programming the same part to two different tolerance bands is two different jobs.

  • 1
    Model readinessClosed solids, defined datums, no slivers or zero-thickness faces.
  • 2
    Material decisionAluminum 6061 at 3,000–6,000 rpm, Ti-6Al-4V at 200–600 rpm with heavy coolant.
  • 3
    Fixture decisionA vise for prismatic parts, soft jaws for thin walls, a rotary table for 360° access.
Step 1

How to program its CNC machine: prepare the CAD model for CAM

Clean the solid before you import it into CAM. Remove threads that will be tapped at the machine, chamfers smaller than 0.5 mm, and any cosmetic fillets a ball nose cannot reach. Add the stock model, and confirm the model origin matches the datum that the shop will touch off.

Check wall thickness against the material. A 0.8 mm wall in 6061 aluminum is routine; the same wall in 17-4PH stainless will deflect and chatter unless you support it. For thin-wall parts, plan a two-pass approach: rough with 0.5 mm stock left, then finish with light radial engagement.

Define the datum scheme on the drawing, not in your head. Typical: a primary face for Z, two edges or a bore for X and Y. On a 5-axis part, the datum should live on a surface that stays accessible through all orientations. If it does not, the operator will re-clamp and lose the position.

Decide the feature order. Deep pockets first, then thin walls, then holes, then cosmetic surfaces. Cutting a thin wall before the surrounding material is removed is a common cause of vibration marks that no finish pass can remove.

  • 1
    Minimum internal radiusKeep it at 1.0× tool radius or larger to avoid a slow, high-load corner.
  • 2
    Thread calloutsModel them as simple cylinders; leave tapping for the machine or a separate operation.
Step 2

Build toolpaths in CAM: speeds, stepover and strategy

Start with the stock and fixture model. Rough with an adaptive or dynamic clearing path that keeps radial engagement between 8% and 12% of the cutter diameter. This spreads the load along the flute and lets you run higher feed rates without tool breakage. For 6061 aluminum with a Ø12 mm end mill, a typical roughing set is 6,000 rpm, 2,500 mm/min feed, 6 mm axial depth and 1.2 mm radial stepover.

For titanium and Inconel, drop the surface speed hard. Ti-6Al-4V with a coated carbide end mill runs around 200–600 rpm with 0.05–0.1 mm per tooth and flood coolant. Heat stays in the cut, not in the tool. If the chips come off gray and powdery, you are rubbing, not cutting.

Finishing passes set the surface. For a Ra 0.8–1.6 μm finish, use a 0.3–0.5 mm stepover with a ball nose on curved surfaces. For flat faces, a face mill or a large-diameter end mill gives a better finish than a small tool. For a Ra 0.2–0.8 μm requirement, plan a separate finishing pass with a sharp, freshly set tool and a light depth of cut, around 0.1–0.2 mm.

Leave 0.2–0.3 mm of radial stock on surfaces that will be finish-machined after heat treatment or stress relief. Without that stock, the part moves and the final dimension misses.

  • 1
    Entry methodUse a helical or ramp entry. Plunging straight down loads the center of the tool.
  • 2
    CoolantThrough-spindle for deep pockets; flood for titanium and stainless.
  • 3
    Tool stick-outKeep it under 4× diameter where possible. More stick-out equals more chatter.
Step 3

Post-processing: turning CAM output into machine-ready code

The post-processor translates CAM toolpaths into the dialect of a specific machine. A DMG Mori 5-axis control, a Fanuc mill and a Haas lathe all read G-code, but they handle rotary axes, tool-change macros and canned cycles differently. Run the wrong post and you get a crash, not a part.

Verify the post output on the machine sim, not just the CAM sim. Check the tool numbers against the actual turret or carousel, confirm the work-offset codes (G54–G59) match the setup sheet, and confirm the coolant and spindle commands match the machine. On 5-axis parts, check the rotary limits and the direction of the A and C axes.

Program the safe moves. Set a clearance plane 5–10 mm above the stock and a retract height above the fixture. On a mill-turn center, define the transfer position between the main and sub spindle with clearance on all axes. Most collisions happen during a rapid move, not during a cut.

Keep a copy of the proven program with the setup sheet. The second run of the same part should not need a new prove-out.

Step 4

Offsets, probing and the first cut on the machine

Set the work offset from the actual stock, not from the model. Touch off the primary face for Z and the datum edges or bore for X and Y. If the machine has a probe, probe the stock and let the control set the offset. If not, use an indicator or an edge finder and record the numbers on the setup sheet.

Load the tools and set the length offsets with a tool setter or a gauge block. A 0.02 mm error in tool length is a 0.02 mm error in every Z dimension. For a ±0.005 mm part, that error is already four times the tolerance.

Run the first part with the rapid override down and the feed override at 50–70%. Watch the first few cuts: listen for chatter, check the chip color and check the load meter. If the load spikes in a corner, slow the feed there rather than reducing the whole program.

Measure the first part before you run the second. Check the critical dimensions against the drawing, and adjust the wear offsets. This is where a ±0.005 mm target is either held or lost.

  • 1
    Warm-upRun the spindle and axes for 10–15 minutes before a tight-tolerance cut.
  • 2
    Chip controlAdjust feed and coolant until chips break and clear the cut.
Follow along

Step by step: how to program its CNC machine

Use this sequence for a new part on a 3-axis or 5-axis mill.

  • 1
    Clean and prepare the CAD modelRemove cosmetic fillets under 0.5 mm and modeled threads. Confirm closed solid, defined datums and wall thickness above the material minimum. Add the stock model.
  • 2
    Plan the setup and fixtureChoose vise, soft jaws or a rotary table. For 5-axis parts, confirm the datum is reachable in all orientations. Define the number of setups and the transfer position between them.
  • 3
    Create roughing toolpathsUse adaptive clearing at 8–12% radial engagement. For 6061 aluminum, Ø12 mm end mill at 6,000 rpm, 2,500 mm/min, 6 mm axial depth. Leave 0.2–0.3 mm radial stock for finishing.
  • 4
    Create semi-finish and finish toolpathsSemi-finish at 0.5 mm stepover, finish at 0.3–0.5 mm for Ra 0.8–1.6 μm. Use a separate light pass at 0.1–0.2 mm depth for Ra 0.2–0.8 μm surfaces.
  • 5
    Post-process and verify the codeSelect the correct machine post. Check tool numbers, work offsets, rotary directions and clearance planes. Run the machine simulation before sending the program to the control.
  • 6
    Set the machine and prove the first partSet work offsets from stock, set tool length offsets with a setter, and run at 50–70% feed override. Watch the load meter and listen for chatter.
  • 7
    Inspect and adjustMeasure the first article against the drawing. Adjust the wear offsets for critical dimensions. Record the final offsets and program version on the setup sheet.
Decision table

Programming approach by part type and tolerance

Use this to decide the setup and toolpath strategy before you open CAM.

Part typeTypical toleranceSetupToolpath strategy
Prismatic bracket, 6061±0.05 mmVise, 2 setupsAdaptive rough, face finish
Thin-wall housing, 7075±0.02 mmSoft jaws, 2 setupsLight radial cuts, support walls
Medical instrument, 316L±0.01 mmFixture plate, 3 setupsSemi-finish then finish pass
Aerospace fitting, Ti-6Al-4V±0.005 mm5-axis, 1 setupAdaptive rough, ball nose finish
Turned shaft, 17-4PH±0.01 mmMill-turn, 1 setupRough turn, finish turn, mill flats
Prototype cover, ABS±0.1 mmVise, 2 setupsSingle rough and finish pass

The takeaway

Good CNC programming is mostly decisions made before CAM opens: datum, fixture, tolerance band and tool. Get those right and the G-code follows.

FAQs

Questions engineers ask about CNC programming

Can I program a CNC machine without CAM software?

Yes, for simple parts. Manual G-code works for a face, a straight pocket or a drilled hole pattern. It is fast for one or two features.

For contoured surfaces, deep pockets or 5-axis features, manual code is slow and error-prone. CAM handles the geometry and the collision checks. Most shops use both: CAM for the complex features, manual edits for small changes at the machine.

How do I choose the right cutting tool for a new part?

Start with the smallest internal radius on the part. The tool radius must be equal to or smaller than that radius. Then check the depth: a tool with 4× diameter stick-out is stiff, 8× is not.

For aluminum, use 3-flute carbide with polished flutes and high helix. For stainless and titanium, use 4 or 5 flutes with a coating and flood coolant. For finishing, a ball nose for curves and a face mill for flat surfaces.

What tolerance can programming alone achieve?

Programming sets the path, but the machine, the tool, the fixture and the temperature set the result. On a rigid setup with a warm machine, our process holds ±0.005 mm on critical features.

If the drawing needs that band, tell the programmer before CAM starts. It changes the toolpath, the number of passes and the inspection plan.

When should the part be programmed for 5-axis instead of 3-axis?

Use 5-axis when the part has features on multiple faces, when a single setup reduces the position error, or when a contoured surface needs a ball nose held normal to the surface.

Stay with 3-axis when all features are reachable from one direction. A 3-axis program is faster to write, faster to prove out and easier to inspect.

How do I handle a design change after the program is written?

Change the CAD model, then regenerate the affected toolpaths. Do not edit G-code by hand for a geometry change; the change will not carry to the next run.

Record the program revision and the model revision on the setup sheet. If the change moves a datum, the work offsets must be rechecked.

What should be on the setup sheet?

Program name and revision, model revision, machine, fixture, work-offset values, tool list with length offsets, spindle speeds and feed rates, inspection points and the first-article result.

A complete setup sheet lets the next operator run the part without re-programming it. It also makes the second run faster than the first.

Send us the model and we will program the part

Upload a STEP file and get a DFM analysis with the quotation in 12 hours. No minimum order quantity, from one prototype to 10,000+ part runs.

12-hour quote100% inspectionNDA on request

Follow us

More from the shop floor

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