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

Get Instant Quote

CNC programming guide

How to Program CNC Machines

A practical workflow for engineers and buyers who need to read, write, or review a CNC program. We cover drawing review, CAM setup, toolpath choice, speeds and feeds, simulation, and first-article checks. After this you can judge whether a program is ready for the machine.

12-hour quote±0.005 mm toleranceNo minimum order
how to program cnc machines
Quick answer

Key takeaways

Programming starts at the drawingA 3D model shows the shape. The 2D drawing sets tolerances, datum, and finish.
Datums before toolpathsPick the work zero and clamping first. Most scrap comes from a bad setup, not bad code.
Feeds come from the tool and materialUse chip load per tooth. Aluminium 6061 runs faster than 17-4PH stainless.
Simulate, then dry runCheck stock removal and tool reach in CAM, then run the first part with offsets.
First article tells the truthMeasure the first part against the drawing before the run continues.
Section 1

What you need before you write a line of code

A CNC program is a list of coordinates, feed rates, and spindle speeds. G-code moves the tool; M-code handles spindle, coolant, and tool changes. That part is simple. The hard part is deciding what the tool should do, in what order, and with what stock left on the part.

Before any CAM session, collect a complete package. The 3D model gives geometry. The 2D drawing gives tolerances, datum callouts, thread specs, and surface finish. If the part is aluminium 6061 with Ra 1.6–3.2 μm as-machined finish, a 3-axis program may be enough. If it has undercuts and five-sided features, you are looking at 5-axis work on one of our 16 simultaneous 5-axis centers.

Confirm the material grade and heat treatment. 6061-T6 cuts clean and holds tight tolerances. 304 stainless work-hardens, so you keep the cutter engaged and avoid dwelling. Titanium TC4 (Ti-6Al-4V) needs lower surface speed and more coolant. This decision changes every number in the program.

Also settle the machine. A program written for a 750 × 1,150 × 550 mm travel mill will not fit a compact 500 × 310 × 200 mm machine. Check spindle taper, available tools, and whether a Ø400 mm rotary table is needed. Get this wrong and the program is correct but useless.

  • 1
    Model + drawingBoth. The model alone hides tolerance and datum intent.
  • 2
    Material and temperDrives speeds, feeds, and tool coating.
  • 3
    Machine and workholdingTravel, spindle, vise or fixture, and zero position.
Section 2

Choose the coordinate system and workholding

Decide the work zero before you draw a single toolpath. On a 3-axis mill, X0 Y0 is usually a corner or a bore center, and Z0 is the top of the stock. On a 5-axis machine, the zero lives at the rotary center, and the post processor converts that into machine coordinates.

Match the zero to the datum on the drawing. If the drawing dimensions from a dowel pin hole, set X0 Y0 there. If it dimensions from two finished edges, use those. Programmers who pick a convenient corner instead of the drawing datum create a rework loop that costs more than the programming time.

Plan the clamping at the same time. Thin walls deflect. A 2 mm wall in aluminium will push away from the cutter unless you support it or take light finishing passes. Deep pockets need a stub or extended reach tool, and reach costs rigidity.

For the second operation, think about how the part sits after op 1. A soft jaw machined to the finished profile holds better than a standard vise. On mill-turn centers, the sub-spindle can pick up the part and finish the back side without a second setup.

  • 1
    Datum matches drawingAvoid a zero that forces manual math on every dimension.
  • 2
    Stock allowanceLeave 0.3–0.5 mm on faces for finishing.
  • 3
    Second op planDesign the soft jaw or fixture before op 1 runs.
Section 3

Build the toolpath in a logical order

Rough first, then semi-finish, then finish. Face the top, rough the pockets and profiles, then finish walls and floors. Leaving 0.2–0.3 mm on walls for the finishing pass keeps the load steady and the finish consistent.

Use the right strategy for the shape. Adaptive or trochoidal roughing keeps radial engagement low and works well in stainless and titanium. Parallel or spiral finishing suits curved surfaces. For flat floors, a face mill leaves a better finish than a small end mill in less time.

Control the entry. Ramp or helix into the material instead of plunging straight down. A 3° ramp into aluminium is gentle. In hardened tool steel, use a shallower ramp and a smaller stepover.

Keep tool changes to a minimum. Every change adds runout and time. Group features by tool, not by feature type. If a Ø6 mm end mill can reach both a pocket and a slot, use it for both before switching to the Ø3 mm tool.

  • 1
    Rough to finishLeave 0.2–0.3 mm on walls and floors.
  • 2
    Adaptive roughingLower radial load, longer tool life in hard materials.
  • 3
    Ramp, do not plunge3° ramp in aluminium; shallower in steel.
Section 4

Set speeds and feeds from chip load

Surface speed and chip load drive everything. Surface speed depends on material; chip load depends on tool diameter and flute count. Feed rate equals spindle speed times chip load times number of flutes. That formula is the whole game.

For aluminium 6061 with a carbide 3-flute end mill, surface speed runs 300–500 m/min. For 304 stainless, drop to 80–120 m/min. For Ti-6Al-4V, 40–60 m/min. These are starting points, not laws. Listen to the cut and check the chips.

Chip color tells you a lot. Silver or light straw chips in steel mean you are in range. Blue or dark chips mean too much heat. If the tool squeals, reduce radial engagement before you reduce feed, because a light feed rubs and work-hardens the surface.

Watch the depth of cut. A radial engagement of 5–10% of tool diameter with a full axial depth is the adaptive roughing pattern. For finishing, keep radial engagement low and axial depth moderate to control deflection. A long tool will push off even at correct feeds.

  • 1
    Feed = RPM × chip load × flutesStart from the tool maker chart, then adjust.
  • 2
    Surface speed by material6061 fast, 304 slower, Ti-6Al-4V slowest.
  • 3
    Chip color checkSilver to straw is good. Blue means heat.
Section 5

Post process, simulate, and verify

The post processor turns CAM toolpaths into machine-specific G-code. It handles the machine's control dialect, rotary axis configuration, and safe retract positions. A generic post on a 5-axis machine will produce code that looks fine and crashes the first time.

Simulate the full program in CAM before it touches the machine. Check for gouges, holder collisions, and rapid moves through stock. Look at the leftover material map. If the simulation shows a thin web or an unsupported island, fix the toolpath order now.

On the machine, run a dry run with the tool offset above the stock. Use single block for the first few moves. Watch the distance-to-go display and the Z height. Confirm the tool change position and the coolant come on before the cut.

For a first article, run one part with conservative feeds, measure it, and adjust the wear offsets. Only then run the rest of the batch. Our inspection is 100% before shipment, but the program should be right before the parts reach inspection.

  • 1
    Machine-specific postA generic post is a crash waiting to happen.
  • 2
    Simulate collisionHolder, fixture, and rotary table clearance.
  • 3
    Dry run firstSingle block, offsets high, watch Z.
Workflow

Step by step: from drawing to first part

Follow this order. Skipping a step usually shows up as scrap at the machine.

  • 1
    1. Review the drawing and modelCheck tolerances, datum, finish, and threads. Note any feature that needs 5-axis access or a special tool. Flag anything you cannot measure.
  • 2
    2. Choose stock and workholdingPick stock size with 0.3–0.5 mm allowance on finished faces. Design the vise, soft jaw, or fixture. Confirm the part fits the machine travel.
  • 3
    3. Set the work coordinate systemSet X0 Y0 at the drawing datum and Z0 at the top of stock. For 5-axis, set the zero at the rotary center. Record it in the setup sheet.
  • 4
    4. Build roughing toolpathsFace the top, then rough pockets and profiles. Leave 0.2–0.3 mm on walls and floors. Use adaptive roughing with 5–10% radial engagement.
  • 5
    5. Build finishing toolpathsFinish walls, floors, and curved surfaces. Use a smaller stepover for Ra 0.8–1.6 μm. Add a spring pass if the wall deflects.
  • 6
    6. Set feeds and speedsCalculate from chip load. 6061 aluminium at 300–500 m/min surface speed; 304 stainless at 80–120 m/min; Ti-6Al-4V at 40–60 m/min. Adjust after the first cut.
  • 7
    7. Post and simulatePost with the correct machine post. Simulate the full program. Check holder and fixture clearance. Fix any rapid move through stock.
  • 8
    8. Dry run and first articleRun dry with offsets high, single block. Cut one part with conservative feed. Measure against the drawing, adjust offsets, then release the batch.
Reference

Starting parameters by material and operation

Carbide tool, flood coolant. Verify against your tool maker data before cutting.

MaterialSurface speedChip load (Ø6 mm, 3-flute)Notes
Aluminium 6061-T6300–500 m/min0.05–0.10 mm/toothFast, clean chips. Watch for built-up edge.
Stainless 30480–120 m/min0.03–0.06 mm/toothWork-hardens. Keep cutter engaged, no dwell.
Steel 4140120–180 m/min0.04–0.08 mm/toothRough at higher depth, finish light.
Titanium Ti-6Al-4V40–60 m/min0.02–0.05 mm/toothHeat stays in the tool. Heavy coolant.
17-4PH stainless60–100 m/min0.03–0.06 mm/toothCondition matters. Check heat treat first.
POM / PEEK200–400 m/min0.05–0.12 mm/toothSharp tool, high rake. Clear chips fast.

Program the setup first, the toolpaths second

A clean program on a bad work zero still makes scrap. Fix the datum, the clamping, and the stock allowance before you tune feeds. If the drawing package is incomplete, send it over and we will flag the gaps before cutting.

FAQs

Common questions

Can I program a CNC machine without CAM software?

Yes, for simple parts. Manual G-code works for facing, drilling, and basic profiles. It becomes slow and error-prone once you have 3D surfaces, many tools, or 5-axis work.

For a part with a few holes and a pocket, writing code by hand is fine. For anything with curved surfaces or tight tolerances at ±0.005 mm, CAM plus simulation is the safer path.

Do I need a post processor for my machine?

Yes. The post processor converts CAM output into the control dialect your machine reads. It also sets rotary axis behavior and safe retract positions.

A generic post may produce code that runs on a 3-axis mill but not on a 5-axis center with a trunnion table. Always verify the post against the machine builder's G-code list.

How do I know the feeds and speeds are right?

Start from the tool maker's chip load chart for the material. Run one part with conservative values. Check chip color, sound, and surface finish.

Silver or light straw chips and a steady sound mean you are close. Blue chips, squealing, or a poor finish mean adjust radial engagement or surface speed before changing feed.

What causes a CNC program to scrap a part?

Most scrap comes from setup, not code. Wrong work zero, loose clamping, or a tool offset error will ruin a correct program.

The rest comes from tool deflection on thin walls, chip recutting in deep pockets, and thermal growth on long runs. A dry run and a first-article check catch most of these.

How long does it take to program a part?

A simple 3-axis bracket can be programmed in a few hours. A 5-axis part with complex surfaces and tight tolerances can take a full day or more.

Programming time depends on drawing quality, feature count, and how many setups are needed. A complete package with clear datums cuts the time significantly.

Can you program and machine my part from a STEP file?

Yes. Send the STEP file plus a 2D drawing with tolerances and finish callouts. We review manufacturability and return a quotation with DFM analysis within 12 hours.

We machine from one prototype to 10,000+ part runs, with no minimum order quantity. Uploads are secure and confidential, and an NDA is available on request.

Send your drawing, get a programming and machining plan

We review your model and 2D drawing, return DFM feedback and a quotation within 12 hours, and machine the first part against the same program we quote.

12-hour quote100% inspectionNo minimum order

Follow

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