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

Get Instant Quote

Programming guide

How to Programing CNC Machines

A practical walkthrough for engineers and machinists who need to turn a CAD model into a cutting program. We cover the setup sheet, G-code blocks, work offsets, feed and speed ranges, dry run, and the mistakes that scrap parts on the first run.

±0.005 mm tolerance16 five-axis centers127 CNC machinesDFM in 12 hours
how to programing cnc machines
Quick answers

Key takeaways

Program is a document, not a fileThe setup sheet decides success more than the G-code does. Write it first.
Tolerances set the strategy±0.05 mm and ±0.005 mm need different tools, passes and inspection plans.
Simulate before you cut metalStock simulation plus a dry run catches most collisions before the spindle turns.
Offsets are the real controlG54 and tool length offsets are how you steer the cut on the machine.
CAM is not automaticSoftware generates paths from what you tell it. Garbage in, broken end mill out.
Fundamentals

What CNC programming actually controls

A CNC program is a list of instructions that move the spindle, the table and the tool changer in a fixed order. Every line does one of a few things: move an axis, set a speed, change a tool, turn coolant on or off, or read a position. That is the whole language. The hard part is not the syntax. It is deciding what motion produces the geometry you drew.

Manual programming suits simple work. A plate with six holes, a shaft with two diameters, a chamfer on a bracket. You can write those by hand at the machine and prove them out in 20 minutes. CAM programming suits anything with freeform surfaces, deep pockets, or more than a handful of tools. On a 5-axis part with a curved blade, hand-written code is not realistic.

The program never exists alone. It sits inside a setup sheet that lists the stock size, the datum, the tool list, the offset numbers and the inspection points. A clean G-code file with a vague setup sheet will still produce scrap. A plain file with a precise setup sheet usually runs.

Feature count drives programming time more than part size. One 300 mm bracket with four holes may take less time to program than a 40 mm housing with twelve intersecting pockets. Count the setups before you count the money.

  • 1
    G-code and M-codeG moves geometry, M handles machine events like spindle and coolant.
  • 2
    CAM outputToolpaths and post-processed code generated from a CAD model.
  • 3
    Setup sheetStock, datum, tools, offsets, inspection. The part's real instruction set.
Inputs

Read the drawing before you open CAM

Start with the tolerance callouts. A general ±0.1 mm on a bracket means you can rough close to size and finish light. A ±0.005 mm bore on the same drawing means you need a separate finishing pass, a rigid setup and a measurement plan. The tolerance decides the tool, the pass and the inspection, not the other way around.

Next, look at surface finish. Ra 0.8–1.6 μm from a finishing end mill is achievable with a light radial stepover and a sharp tool. A mirror finish on aluminium usually means a polishing step after machining. If someone asks for Ra 0.2–0.8 μm on a deep pocket wall, plan a dedicated finishing tool and expect a longer cycle.

Then check geometry for machining risk. Deep pockets with a small corner radius force a small tool, and small tools deflect. Thin walls move when you release the vise. Threads close to a shoulder may need a single-point tool rather than a tap. Flag those features on the setup sheet before CAM.

Finally, confirm the material. 6061 aluminium cuts fast and forgiving. 316L stainless work-hardens if you dwell. Ti-6Al-4V needs low surface speed and steady feed. The same toolpath with the same feed will behave differently in each.

Strategy

Plan setups, datums and tool lists

Count the setups and try to reduce them. Every re-fixture adds a datum error. A part that needs three setups may hold ±0.05 mm across features with careful workholding. If the drawing calls for ±0.005 mm between features on different faces, one setup on a 5-axis or mill-turn machine is the safer route.

Pick the datum the way an inspector will. If the drawing dimensions from a face and a bore, use that face and bore in the program. Datum choices that only make sense to the programmer create arguments at inspection. Write the datum on the setup sheet with the offset number, for example G54 on the front face, G55 on the flipped side.

Build the tool list from the features, not from the tool crib. List the tool number, diameter, corner radius, flute count and the offset pocket it will use. On a typical aluminium bracket, that is a face mill, two roughers, two finishers, a drill set, and a tap or thread mill. Keep the list short and the offsets readable.

Reserve a spot for the probe or edge finder. Even if the operator uses a touch-off block, the program should assume a known origin. Programs that rely on the operator eyeballing a corner are the ones that scrap parts.

CAM

Build the toolpath, then the code

Import the model in STEP or IGES, set the stock, and define the coordinate system to match the datum on the setup sheet. Run a stock simulation before anything else. If the simulated stock does not match the real block, the program is already wrong.

Rough with a constant stepover. On 6061 aluminium with a Ø12 mm three-flute carbide rougher, 8 mm depth of cut, 40–50 percent stepover and 3,000–4,000 mm/min feed is a workable starting range on a rigid machine. The same tool in 316L drops to roughly 600–900 mm/min with 2–3 mm depth of cut. If the machine chatters, reduce depth before reducing feed.

Finish with a light radial stepover, typically 0.3–0.5 mm on a Ø10 mm finisher, and a feed that keeps the chip load steady. Constant velocity mode matters on corners. Without it, the control slows at every direction change, the chip thins, and the tool rubs instead of cutting.

Generate the code with the correct post-processor for the machine. A program posted for a different control may read the same but behave differently on arcs, tool changes and canned cycles. Check the first 30 lines and the tool change block every time.

On the machine

Touch off, dry run, then cut

Load the program in memory, not from a USB stick mid-cycle. Set the tool length offsets with a setter or a gauge block, and record every value. Set the work offset from the datum face. If the machine has a probe, use it. If not, edge-find twice and split the difference.

Run a dry run with the tool offsets active and the spindle off or at low speed. Watch the distance-to-go display through every rapid move. Most crashes happen on rapids into a clamp, a vise jaw or a fixture the CAM model never saw. The dry run is where you catch them.

Cut the first part at reduced feed. Feed override at 50 percent for the first roughing pass tells you whether the setup is rigid and the chip load is right. If the sound changes or the load meter climbs, stop and check. Do not push through a bad first pass.

Measure the first finished feature before running the rest. If a 20.000 mm bore comes out at 20.040 mm, you can correct the cutter compensation before the second part. If you wait until the pallet is finished, you have a box of scrap.

Quality

Verify the program against the drawing

Program verification is a checklist, not a feeling. Take the drawing, pick the tightest three dimensions, and measure them on the first article. Then measure a feature on each face to confirm the datums transferred correctly. If a hole pattern is off by the same amount in one direction, the work offset is wrong, not the tool.

Keep inspection records with the program. The setup sheet, tool list, offset values and first-article numbers form the package that lets you run the job again next month without re-solving it. Shops that skip this step pay for it in setup time on the repeat order.

When a feature is out of tolerance, decide whether to adjust the program or the offset. A consistent error across all features points to the offset. A single feature off while its neighbours are good points to the toolpath or the tool. Change one thing at a time and re-cut.

On parts that will be inspected 100 percent, plan the measurement in the program. Stop positions, clearance for a CMM probe, and a clean surface for a micrometer all matter. A program that machines a perfect part but leaves no room to measure it is not finished.

For runs above a few dozen parts, keep a first-article record and a spare setup sheet at the machine. Programming a job and then handing it off with no documentation is how the same problems come back on the next order.

Step by step

How to programing cnc machines: 7 steps

Work through these in order. Skipping step 2 or step 6 is the most common cause of scrapped first articles.

  • 1
    Write the setup sheetList stock size, material, datum faces, work offset numbers (G54/G55), tool list and inspection points. Keep it to one page. This document drives every later decision.
  • 2
    Plan the operations and count setupsGroup features by face and tool. Aim for one setup where tolerance allows. Note any feature that needs a flip, a fixture or a 5-axis move. Add a reminder for thin-wall and deep-pocket features.
  • 3
    Model the stock and set the coordinate systemImport STEP or IGES, define stock with 1–2 mm allowance per side, and place the CS at the datum from the setup sheet. Simulate the stock removal and confirm the model matches the real block.
  • 4
    Choose tools and starting parametersPick carbide for steel and titanium, high-speed steel for plastics. On 6061 aluminium: 3,000–4,000 mm/min and 8 mm depth of cut with a Ø12 mm rougher. On 316L: 600–900 mm/min and 2–3 mm depth of cut. Never start at the top of the range.
  • 5
    Rough, then finish with separate passesLeave 0.3–0.5 mm radial stock for finishing. Use constant velocity or high-feed mode through corners so the chip load stays steady. Reduce depth of cut before reducing feed if chatter appears.
  • 6
    Post and review the codeUse the post-processor for that specific control. Read the header, the tool change block and the first rapid move. Confirm arc format, units (G21) and plane selection (G17) match the machine.
  • 7
    Dry run, first article, then releaseRun with offsets active and watch distance-to-go. Cut the first part at 50 percent feed override. Measure the tightest three dimensions and the features on each face. Only then run the batch.
Decision table

Manual programming vs CAM programming

Pick the route by geometry and tolerance, not by habit.

FactorManual programmingCAM programming
Typical partPlates, shafts, simple bracketsFreeform surfaces, deep pockets, 5-axis
Feature countUnder about 10 featuresDozens of features or multiple faces
Programming time20–60 minutes at the control1–4 hours including simulation
Tolerance fit±0.05 mm and looser±0.005 mm with a planned finish pass
Tool changes2–4 tools5–20 tools, managed in the list
Best whenOne-off repair or simple repeat jobNew geometry, tight tolerance, repeat orders
Main riskArithmetic and offset mistakesBad stock or toolpath assumptions

Program the setup sheet, not just the part

Most scrapped first articles trace back to a missing datum or an unlisted tool, not a bad toolpath. Write the setup sheet, simulate the stock, dry run with offsets active, and measure the first part before you release the batch.

FAQs

Frequently asked questions

Do I need to write G-code by hand to program a CNC machine?

No. Most production work is posted from CAM software. What you do need is the ability to read the code and spot an obvious error in the header, the tool change block or the first rapid move.

Hand writing still helps for simple edits at the machine, like adding a chamfer pass or adjusting a feed on the fly.

What tolerance can programming and machining realistically hold?

GreatLight machines to ±0.005 mm (about ±0.0002 in) on qualified features, with surface finish from Ra 0.2–0.8 μm when a polishing step is planned. That level needs a rigid setup, a separate finishing pass and in-process measurement.

Looser features should stay loose on the drawing. Over-tolerancing everything raises cost and cycle time without improving the part.

Can the same program run on different materials?

The geometry portion can, but the speeds and feeds cannot. 6061 aluminium runs at 3,000–4,000 mm/min on a Ø12 mm rougher where 316L runs at 600–900 mm/min. Titanium and Inconel need lower surface speed again.

Keep a material block at the top of the program or a separate parameter set per material. Reusing aluminium feeds in stainless breaks tools.

How long does programming and machining take for a custom part?

Quotation and a free DFM analysis come back within 12 hours. Production can start within 24 hours, and parts typically ship in 3–5 days. Programming time sits inside that window and depends on feature count and the number of setups.

There is no minimum order quantity, so a single prototype and a 10,000-part run go through the same first-article check.

What happens if the first article does not meet the drawing?

We measure the tightest dimensions and the features on each face, then correct the offset or the toolpath and re-cut. One change at a time. Inspection reports are available on request, and every part is inspected before shipment.

If a feature can be adjusted on the machine, we fix it in the setup. If the geometry itself is the problem, we come back with a DFM note before running more parts.

Do I need to supply my own CAD files and are they kept confidential?

STEP, IGES and STL files are all workable, and we can also review a 2D drawing. If you only have a concept, our team can help with design for manufacturability before programming starts.

Uploads are secure and confidential. An NDA is available on request, and we hold ISO 27001:2022 for information security.

Send a model, get a quote and a DFM review

Upload your STEP file and we return a quotation plus a free DFM analysis within 12 hours. From one prototype to 10,000+ parts, programmed and inspected in-house.

12-hour quote100% inspectionNo minimum orderNDA on request

Follow

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