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

Get Instant Quote

CNC programming guide

Learn Six Steps to Play CNC Machine Tool Programming

This guide is for design engineers, CAM programmers and shop leads who need a repeatable way to prepare a part for a CNC machine tool. Six steps, from the job definition to the first cutting pass. Read it and you will know what to fix before the spindle ever turns.

±0.005 mm tolerance127 CNC machines16 five-axis centers12-hour DFM review
Six steps to play CNC machine tool programming on a machining center
Quick answer

Key takeaways

The job definition drives everythingDatums, stock size and critical features decide the toolpath before you open CAM.
Tool and machine must match the geometryA deep pocket on a 3-axis mill is a different job than the same pocket on a 5-axis center.
Verify in simulation, then in airRun the program with the tool offset away from the stock before the first real cut.
Tolerance is a process result, not a wish±0.005 mm needs the right tool holding, feeds and inspection plan, not just a tight number in the drawing.
Step 1 and 2

Define the job before you write one line

Programming starts at the drawing, not at the keyboard. Read the part print and write down four things: the material, the stock form, the datum scheme and the features that actually matter. On a typical aluminum housing, maybe only two bores and one face carry the tight tolerance; everything else can run at Ra 1.6–3.2 μm and general shop tolerance. Mark those critical features in red. If you skip this, you will spend hours optimizing a pocket that nobody measures.

Stock form sets your first operation. A 6061-T6 plate that arrives saw-cut on all six faces gives you a clean top face to reference. A casting or a forged blank does not. On a sand casting, the first cut is usually a rough facing pass of 0.5–1.0 mm to establish a flat datum, because the surface can move 0.3–0.8 mm from part to part. Program that cleanup pass before any feature work. On a 4,000 mm long weldment, the same logic applies at a larger scale: establish one straight edge, then work from it.

Write the datum plan down and keep it with the program. A datum that lives only in the programmer's head is a scrap source. Most shops use a 3-2-1 scheme: three points on the primary face, two on the secondary, one on the tertiary. Number them and stamp the same numbers on the setup sheet the operator will read at the machine.

  • 1
    Critical features listBores, fits and sealing faces first. Cosmetic surfaces and clearance holes later.
  • 2
    Stock allowanceLeave 0.3–0.5 mm on faces that will be finished after heat treatment or stress relief.
  • 3
    Heat treatment orderFor 4140 or 17-4PH, decide whether the part is machined before or after hardening. It changes the whole sequence.
Step 3

Choose the tool and the machine capacity

Tool selection follows geometry, not habit. A Ø10 mm 4-flute carbide end mill is a good general choice in aluminum at 6,000–10,000 rpm with a 0.05–0.10 mm tooth feed. The same cutter in 316L stainless drops to 1,200–2,000 rpm. If the pocket corner radius is R3, you need a cutter smaller than Ø6 mm to clear the corner, and a small cutter in a deep pocket will deflect. Check the length-to-diameter ratio. Anything past 4:1 in a finishing pass will push you off tolerance.

Machine choice is about reach and axes. A part with features on five sides either goes on a 5-axis center or needs three separate setups on a 3-axis machine. Three setups means three datum transfers and three chances to stack error. If the tolerance is ±0.005 mm and the features are on different faces, a simultaneous 5-axis machine removes that stack. If the part is a simple plate with holes, a 3-axis machine with a vise is faster and cheaper to set up.

Pay attention to the travels. A 750 × 1,150 × 550 mm envelope covers most automotive brackets and medical instrument frames. Long extrusions and frame rails need the 4,000 × 400 × 150 mm travel. Putting a part on a machine that barely fits leaves no room for the fixture, and a fixture that hangs off the table is a crash waiting to happen.

  • 1
    Corner radius ruleCutter diameter must be smaller than twice the smallest inside corner radius.
  • 2
    Pocket depth ruleKeep depth under 4× cutter diameter for finishing, or step down and use a longer reach only when needed.
  • 3
    Rotary workA Ø400 mm rotary table handles most round parts, but check clearance for the tool holder at the extreme angles.
Step 4

Build a toolpath that respects the fixture

A toolpath is a plan for removing material, and it has to fit inside the fixture you actually have. Start with the roughing pass. In aluminum, a 12 mm cutter at 2.5 mm depth of cut and 60–70 percent stepover clears material fast. In titanium TC4, drop to 0.5–1.0 mm depth and slow the surface speed to 30–50 m/min. Ramping into a pocket beats plunging straight down: a 2–3° ramp keeps the cutter engaged and avoids the tool rub that dulls corners.

Then think about how the part is held while you cut it. Thin walls deflect. If a wall is 1.5 mm thick and 30 mm tall, a full-depth finishing pass will chatter and leave marks. Rough it, leave 0.3 mm, then finish in two or three depth passes. For parts held only by a vise on the bottom 5 mm, do not run a heavy face cut on the top surface in the same setup without checking the clamping force.

Retract and approach moves matter more than most people expect. A tool that plunges through a finished surface will leave a witness mark. Set the clearance plane 5–10 mm above the stock and use lead-in arcs on finishing contours. On a part with a sealing face at Ra 0.8–1.6 μm, the entry point of the cutter should be off the seal, not on it.

  • 1
    Roughing stepover60–70 percent of cutter diameter in aluminum, 40–50 percent in stainless and titanium.
  • 2
    Finishing allowanceLeave 0.2–0.3 mm radial and 0.1 mm axial for the finish pass.
  • 3
    Thin wall sequenceRough both sides, then finish alternately to balance the cutting load.
Step 5 and 6

Verify the program, then monitor the first cut

Simulation catches crashes, not accuracy problems. A toolpath can be geometrically perfect and still cut the wrong size because the tool offset is wrong or the material moved during clamping. After simulation, run the program with the tool offset set 50 mm above the stock and the feed override at 10–25 percent. Watch the rapids. Most crashes happen on a rapid move to a clearance plane that is too low, not on a cutting move.

The first real cut is a measurement exercise. Stop after the roughing pass and check the stock condition. Then let the finish pass run and measure the critical features. If a bore comes out 0.02 mm under size, adjust the tool offset and re-cut. Do not chase a dimension by changing the program unless the offset has run out of range. On a ±0.005 mm tolerance, the offset is your fine adjustment and the program is your coarse plan.

Once the first part passes, freeze the setup. Record tool numbers, offsets, work offsets and the machine used. That record is what makes the second run repeatable. For production runs, inspect 100 percent of the first batch before releasing the rest. A process that drifts after 20 parts is a process problem, not an operator problem.

  • 1
    Air run ruleNever skip it. A 3-minute air run is cheaper than a broken tool holder.
  • 2
    First part inspectionMeasure the critical features, not the easy ones. Record the actual numbers.
  • 3
    Setup sheetTool list, offsets, work offsets, program number and machine. One page, no handwriting shortcuts.
Common mistakes

Where programmers lose time

The most common mistake is programming to the nominal drawing without checking the actual stock. If the plate arrives 0.5 mm thicker than nominal, the first facing pass either leaves a step or cuts too deep. Check the incoming stock with a caliper and adjust the first operation. This matters most on castings and forgings, where the surface can vary by 0.8 mm across a batch.

The second mistake is ignoring the setup sheet. A program that runs perfectly on one machine can scrap parts on another because the work offset or the vise jaw position changed. Keep the program and the setup sheet together. When a job comes back six months later, the setup sheet is what lets you run it without re-programming.

The third mistake is using the same feed and speed for every material. Aluminum and titanium do not behave alike. A program copied from a 6061 job and run on TC4 will burn the cutter in minutes. Keep a material table and update it with what actually works on your machines.

  • 1
    Stock checkMeasure the blank before the first cut. Adjust the facing pass to the real number.
  • 2
    Setup sheet disciplineOne page per job. Tool list, offsets, work offset, machine and program number.
  • 3
    Material-specific feedsKeep a table for aluminum, stainless, steel and titanium. Update it from real runs.
The six steps

Six steps to play CNC machine tool programming

Follow the order. Each step closes a risk before the next one adds cost.

  • 1
    Read the drawing and list critical featuresWrite down material, stock form, datum scheme and the two or three features that carry tight tolerance. Mark feed and speed targets for the material group. Time spent here is cheaper than a re-cut.
  • 2
    Select the tool and the machineMatch cutter diameter to the smallest inside corner radius. Confirm the machine travel covers the part plus fixture. Decide whether the part needs 3-axis, 4-axis or simultaneous 5-axis work.
  • 3
    Build the toolpathRough with 60–70 percent stepover in aluminum, then semi-finish leaving 0.2–0.3 mm. Use ramp entry, lead-in arcs and a clearance plane 5–10 mm above stock.
  • 4
    Write the NC codeSet spindle speed, feed per tooth, tool offsets and work offsets. Keep the code readable: one operation per section, comments at every tool change.
  • 5
    Verify and testRun the simulation first. Then run the program in air with the tool offset 50 mm above the part. Check every rapid move and every retract for clearance.
  • 6
    Cut the first part and measureCut one part, measure the critical features against the drawing, and adjust offsets before running the batch. Record the offset change for the setup sheet.
Decision table

Choose the setup by part geometry

Match the machine and setup to the feature layout, not to the shop's favorite machine.

Part situationBest setupWatch out for
Flat plate, holes on one face3-axis vise, one setupDatum repeatability after re-clamping
Features on four sides4-axis mill with tombstoneRotary table backlash on finish passes
Features on five sides, tight toleranceSimultaneous 5-axis, one setupTool holder clearance at steep angles
Long frame, over 1,500 mm3-axis with 4,000 mm travelSag and clamping distortion along the length
Thin wall under 2 mmRough both sides, finish in stepsChatter marks and wall bowing
Hardened steel after heat treatFinish grind or hard millTool wear and size drift mid-batch

The program is only as good as the setup behind it

If you can define the job, match the tool and machine to the geometry, and verify before the first cut, the rest of the programming follows. Skip those steps and no amount of code will save the part.

FAQs

Frequently asked questions

Do I need CAM software, or can I write G-code by hand?

For a simple plate with a few holes, hand-written G-code is fast and easy to check. For a contoured 5-axis surface, hand-writing is impractical.

Use CAM for anything with 3D surfaces or more than two setups. Hand-code for simple drilling and facing when the geometry is clear.

What tolerance can a CNC machine tool hold in normal production?

On a stable setup with the right tool holding, ±0.005 mm is achievable on critical features. General features usually run at ±0.05 mm.

Tolerance depends on the feature, the material and the fixture. A thin wall will not hold the same number as a solid bore.

How do I decide between 3-axis, 4-axis and 5-axis?

Count the faces that need machining. One face, use 3-axis. Four sides, use 4-axis. Five sides or contoured surfaces, use 5-axis.

Fewer setups means less datum stack-up. If the tolerance is tight and the features are on multiple faces, 5-axis usually wins.

What should be on the setup sheet?

Tool list with numbers, tool offsets, work offsets, program number, machine and the datum scheme. Add the first-part measurement record.

Keep it to one page. An operator should not have to read a novel at the machine.

When should a part be programmed for a different machine?

When the part travel exceeds the machine envelope, when the required tolerance needs a machine with better geometry, or when the setup count would add too much error.

Moving a job to a larger or more capable machine is cheaper than scrapping a batch because the first machine could not reach the feature.

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

Compare the revision block first. If only a non-critical dimension changed, update the CAM model and re-post. If a datum or a critical feature changed, redo the job definition step.

Never patch a program for a critical change without re-verifying the toolpath and the setup sheet.

Send us the drawing and we will review the setup

Upload a STEP file and our engineers will return a quotation and a free DFM analysis within 12 hours. No minimum order quantity, from one prototype to 10,000+ part runs.

12-hour quote100% inspectionNDA on request±0.005 mm

Follow GreatLight

More machining notes

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