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

Get Instant Quote

CNC programming basics

What Program Do CNC Machines Use?

A CNC machine runs on G-code: a text file of coordinates, feed rates, spindle speeds and switch commands. CAM software writes that file from your 3D model. This page explains the layers, the limits, and how the choice affects your part.

G-code and M-codeCAM and post-processorsController dialectsTolerance impact
what program do cnc machines use
Two layers

What Program Do CNC Machines Use? Start With Two Layers

Every CNC machine reads a program file, but the file is only the bottom layer. The top layer is the CAM system that turns your STEP or IGES model into toolpaths. The bottom layer is the controller dialect the machine actually executes. When a shop says it programs a part, it means both layers were built and matched.

The machine never sees your CAD model. It sees lines like G1 X42.5 Y-18.0 F350, plus switches such as M8 for coolant and M3 for spindle start. A curve that looked smooth on screen becomes a chain of straight moves and arcs. How tight that chain follows the surface decides whether the part holds ±0.005 mm or drifts out of tolerance.

So the honest answer to what program do CNC machines use is two-part: a CAM-generated toolpath file, delivered in a controller-specific dialect of G-code. People often shorten this to just G-code, and that is fine in conversation, but it hides where most programming errors actually come from.

The split matters when you quote a job. A shop running only three-axis mills may need more setups and more fixture work than one with 16 simultaneous 5-axis machining centers. Same part, same G-code language, very different number of program files.

  • 1
    Top layerCAM software: model in, toolpaths out.
  • 2
    Bottom layerController dialect: the G-code the machine executes.
  • 3
    The gapPost-processor settings decide how well the two match.
Inside G-code

G-Code: The Words the Machine Actually Reads

G-code is a list of modal commands. G0 moves fast to a position, G1 feeds in a straight line, G2 and G3 cut arcs clockwise or counter-clockwise. Once a mode is set, it stays set until you change it. That is why a missing G1 can send a cutter home at rapid speed instead of cutting.

A typical block reads G1 X42.5 Y-18.0 Z-3.2 F350 S8000. X, Y and Z are coordinates in millimeters or inches, depending on the G20 or G21 setting. F is feed in mm/min, S is spindle speed in rpm. Get the unit mode wrong and a 50 mm move becomes 50 inches.

On a 5-axis machine, two more axes appear. Some controllers use rotary letters A and B, others use table coordinates. FANUC, Siemens and Heidenhain all accept G-code, but arcs, canned cycles and rotary wording differ enough that a file written for one controller can alarm out on another.

For a part with a ±0.005 mm bore, the programmer also picks the approach: helical interpolation, a boring head cycle, or a reamer. The G-code looks similar. The result does not. This is where programming turns into a machining decision, not a typing exercise.

  • 1
    G0 / G1Rapid positioning versus controlled feed.
  • 2
    G2 / G3Clockwise and counter-clockwise arcs.
  • 3
    G20 / G21Inch or metric mode. Check before cutting.
  • 4
    G54 to G59Work offsets for multiple fixtures or vices.
Auxiliary functions

M-Code and the Commands That Are Not Cuts

M-code handles everything that is not axis motion: spindle on and off, coolant on and off, tool changes, program stop, program end. M3 starts the spindle clockwise, M5 stops it, M8 floods coolant, M6 calls the next tool. On a mill-turn center, M-code also switches between milling and turning mode.

These lines are short and easy to skim past, which is exactly why they cause trouble. A missing M8 on a deep pocket in 316 stainless will burn a carbide end mill in minutes. An M0 stop placed correctly lets an operator flip a part and re-clamp, saving a second program file.

There is also a class of non-G-code languages. Some shops use macro or parametric programming, where the controller computes coordinates from variables. Others run conversational programming directly at the machine, typing geometry instead of importing a CAM file. Both still emit the same underlying motion commands.

For prototypes, conversational programming at the machine can be faster than a full CAM session. For a 10,000-part run, it usually is not. The program has to be repeatable and documented, because it will be re-posted and re-verified many times.

  • 1
    M3 / M5Spindle start and stop.
  • 2
    M8 / M9Coolant on and off.
  • 3
    M6Tool change.
  • 4
    M30Program end and reset.
Model to metal

How CAM Software Turns a Model Into a Program

The CAM programmer imports the 3D model, sets the stock, picks the workholding, and chooses tools from a library. Roughing clears most of the material with a larger cutter. Semi-finishing removes the stair-steps. Finishing follows the surface, and the stepover here decides the surface finish you measure as Ra.

A stepover of 0.3 mm with a 6 mm ball nose can land in the Ra 0.8–1.6 μm band on aluminum. Push the stepover to 1.0 mm and you are closer to Ra 1.6–3.2 μm as-machined, which may be fine for a bracket and not fine for a sealing face.

Then comes the post-processor. This is the translation layer that converts the generic toolpath into the exact syntax of one controller. A post that is wrong by a decimal place, or that writes arcs in a format the machine rejects, produces either an alarm or a scrap part. Neither shows up in your CAD file.

Finally the program is verified. Most shops run a simulation and a dry run above the stock before cutting metal. On a first-article part in titanium or Inconel, that step is not optional. One wrong rapid move into a fixture costs more than the programming hour it would have taken to catch it.

  • 1
    RoughingLarge cutter, high material removal.
  • 2
    FinishingSmall stepover sets the Ra value.
  • 3
    Post-processorTranslates toolpaths to one controller dialect.
  • 4
    VerificationSimulation plus dry run before the first cut.
Engineering impact

Why the Program Choice Shows Up in Your Part

Programming decisions leave marks on the finished part. Tool entry angles, lead-in radius and cut direction change the load on the cutter. A light radial engagement with a fast feed can remove material efficiently; a full-width cut in the same slot can chatter and leave marks you then have to polish out.

Setup count is another visible result. A part that needs five sides can be run as five three-axis setups or one 5-axis setup. Fewer setups mean fewer datum shifts, and datum shifts are a common source of stack-up error on tight-tolerance features. That is a programming and fixturing choice, not a machine capacity limit.

Lead time moves with the same lever. On a simple two-setup bracket, CAM time is a small fraction of the job. On a thin-wall housing with deep pockets, programming and verification can take longer than the cutting. Knowing which one you have helps you read a quote sensibly.

None of this requires you to write G-code. It does help to know that a shop asking for a clean STEP file, a defined tolerance on the critical features, and a note about which surfaces matter is doing its job properly.

  • 1
    Chatter controlEntry angle and radial engagement drive stability.
  • 2
    Datum stackingFewer setups means fewer accumulated errors.
  • 3
    Quote realityComplex geometry shifts cost toward programming time.
Shop practice

What We Do at GreatLight

We run 127 high-precision CNC machines across three wholly-owned plants, including 16 simultaneous 5-axis machining centers, 12 four-axis mills, 27 three-axis machines and 16 mill-turn centers. Maximum processing size is 4,000 mm, with a Ø400 mm rotary table on the 5-axis side. That mix lets a programmer pick the machine that suits the part instead of forcing the part onto one machine.

Programming starts from your STEP file. We run DFM analysis and return a quotation within 12 hours, and production can start within 24 hours. Parts ship in 3–5 days on typical jobs. We hold ±0.005 mm and finish down to Ra 0.2–0.8 μm where the drawing calls for it.

Every part gets 100% inspection before shipment, with raw material checks, in-process monitoring and final reports on request. We work to ISO 9001:2015, IATF 16949:2016, ISO 13485:2016 and ISO 27001:2022. Uploads are confidential, and an NDA is available on request.

There is no minimum order quantity. One prototype and a 10,000-part run go through the same programming and verification steps. The difference is how much of the work is reused.

  • 1
    MaterialsAluminum, stainless, steel, copper alloys, titanium and plastics.
  • 2
    FinishingAnodizing, plating, powder coating, blasting and laser marking.
  • 3
    IndustriesAerospace, automotive and EV, medical, robotics, electronics.
Comparison

Matching the Program Approach to the Job

Pick the row that matches your part, then read the trade-off column.

Job typeProgram approachTrade-off
One-off prototype, simple shapeConversational programming at the machineFast to start, weak documentation for repeats
Prototype, complex 3D surfaceCAM with 3-axis toolpathsNeeds more setups and fixtures
Production run, multi-face partCAM with 5-axis toolpathsHigher programming effort, fewer setups
Tight bore, ±0.005 mmCAM plus boring or reaming cyclesExtra cycle time per hole
Thin-wall or deep pocketCAM with trochoidal and high-feed pathsLonger verification before first cut
Turned shaft with milled flatsMill-turn program, single setupRequires a mill-turn center
Customer-supplied G-codePost-check against the controllerAlarm risk if dialect does not match

The Practical Rule

If the geometry is simple and the quantity is one, conversational programming at the machine is faster. If the part has 3D surfaces, tight bores or more than two faces, use CAM with a verified post-processor for your controller. There is no single best program. There is only the one that matches the part, the quantity and the machine.

FAQs

Frequently Asked Questions

Can I send my own G-code for you to run?

Yes, with a caveat. We still check it against the controller on the target machine, because FANUC, Siemens and Heidenhain differ on arcs, canned cycles and rotary wording.

If the file was posted for a different controller, expect a rewrite rather than a straight run.

How long does programming take for a complex part?

It depends on the geometry, not on a fixed number. A simple two-setup bracket is quick. A thin-wall housing with deep pockets can take longer to program and verify than to cut.

We return DFM feedback and a quotation within 12 hours, so you see the programming implications before the job starts.

What is the difference between G-code and CAM-generated code?

G-code is the language. CAM-generated code is one file written in that language for one controller.

The post-processor is the bridge. It takes a generic toolpath and writes the exact syntax the machine expects.

How do you hold ±0.005 mm on a programmed part?

Tolerance comes from the combination of program strategy, machine condition and inspection. The programmer picks the cycle, the operator sets the offsets, and inspection confirms the result.

For tight bores, that usually means helical interpolation or a boring cycle rather than a plain end mill pass.

Do you program differently for prototypes and production?

The geometry work is the same. The difference is documentation and reuse.

A production program is written to be re-posted, re-verified and run many times, so the setup sheets and tool lists matter more.

Which file format should I send?

STEP is the safest choice for 3D geometry, with IGES as a fallback. PDF or DXF drawings help for tolerance callouts and datum notes.

Add a note on which surfaces are critical and which are cosmetic. That single line often changes the program strategy.

Send a Model, Get Programming Feedback

Share your STEP file and we will return DFM notes and a quotation within 12 hours, with the programming approach spelled out.

12-hour quote100% inspectionNo minimum order

Follow us

More CNC Programming 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