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

Get Instant Quote

Process Guide

CNC Machining Understanding: The Decoding Process

This guide is for engineers and buyers who send a CAM file to a shop and want to know what happens next. It walks through the decoding process: how CAM toolpaths become G-code and M-code, how a control reads that code line by line, and where parts go wrong. Read it before you approve a setup sheet.

G-code & M-codePost-processor±0.005 mm12-hour DFM
CNC machining understanding of the decoding process on 5 axis engine parts
Quick read

Key takeaways

Decoding is translation, not magicA post-processor converts toolpaths into G-code and M-code that one specific control can execute.
The machine only sees coordinatesEvery cut is a position plus a feed. Nothing about your design intent survives unless the code carries it.
Post-processor errors cost the mostWrong work offset or arc plane is the fastest route to a scrapped first part.
Dry run every new programSingle block and distance-to-go on the first article catch most decode faults before metal moves.
Tolerance drives code detail±0.005 mm work needs posted tolerances, cutter comp, and in-process checks, not just a fast feed.
The chain

What the decoding process actually converts

A CAM system stores your part as toolpaths: a cutter moving through space with a feed rate, a spindle speed, and a stepdown. The control on a machine tool cannot read any of that. Decoding, sometimes called post-processing, is the step that rewrites toolpaths as a numbered list of blocks the control executes in order. Each block is one instruction. Read the list top to bottom and you have the exact motion of the machine.

The output is G-code for motion and M-code for machine functions. G00 is a rapid move, G01 a straight feed, G02 and G03 arcs clockwise and counterclockwise. M03 starts the spindle forward, M08 flood coolant on, M30 program end and reset. A typical block looks like N120 G01 X45.2 Y-12.8 Z-3.4 F380. That single line tells the machine to move to a point at 380 mm/min.

Two families sit behind the syntax. ISO code is the common baseline. Fanuc, Siemens, Heidenhain, Mitsubishi, and Haas each extend it and each expects slightly different wording. A program posted for one control may run on another, or it may alarm on line 20. That is why decoding is tied to a machine, not to a CAD file.

  • 1
    G-codeMotion, offsets, compensation, canned cycles.
  • 2
    M-codeSpindle, coolant, tool change, program stop.
  • 3
    Post-processorThe translator between CAM output and one control dialect.
Code structure

How a control reads a decoded program

A control reads blocks in order and holds a state. If G01 appears once, the next block without a G word still cuts in feed. The same applies to the work offset, the plane, and the feed rate. This is called modal state, and it is the single most common source of confusing behavior on the floor. A program that runs perfectly in simulation can cut air, or cut the vise, because a modal value was left over from the previous tool.

Decoding has to declare three things before the first cut. The work offset, usually G54, tells the control where part zero sits in machine travel. The tool length offset, G43 H01, tells it how long tool 1 is. Cutter compensation, G41 or G42 with a D register, tells it which side of the path the radius sits on. Miss any one and the first article is scrap.

Then comes the geometry. Arcs need a plane: G17 for XY, G18 for XZ, G19 for YZ. Feed modes matter too. G94 is feed per minute, G95 feed per revolution. On a lathe, G95 at 0.15 mm/rev is a sensible roughing feed for mild steel; the same number in G94 would be 0.15 mm/min and the tool would rub. Units are declared by G20 for inches and G21 for millimeters, and the file must match the control setting.

  • 1
    Modal trapsA leftover G41 or wrong plane carries into the next operation.
  • 2
    Offsets firstG54, G43 H, and D registers before any cutting move.
  • 3
    Unit checkG20 vs G21 mismatch scales every coordinate by 25.4.
Real limits

Where decoding breaks down in real shops

Post-processors are written for a machine model, not for every option on that machine. Add a rotary table, a bar feeder, or a high-pressure coolant unit and the post needs editing. The usual failure is not a crash. It is a wrong retract height, a tapping cycle that ignores a floating holder, or a tool change that calls the wrong pocket. These cost setup time on every run, not just the first.

Toolpaths also carry assumptions the code cannot express. A 3-axis program cannot reach an undercut no matter how clean the code is. A 5-axis program with a singularity near the tool axis will jerk, and the fix is in the CAM strategy, not in the G-code. When a first article shows chatter on a thin wall, the answer is usually a changed stepdown or a support, not a different feed word.

Tolerance is the other boundary. Decoded coordinates are exact, but the machine, tool, and material are not. Holding ±0.005 mm means the program has to leave finishing stock, use cutter compensation tied to a measured tool, and include in-process checks. A program that cuts to nominal in one pass may pass inspection once and fail on the next tool change.

Judgment

When a decoded program is good enough to release

Release a program when three things are true. The first article measures inside tolerance on every critical feature. The setup sheet matches what is actually on the machine, including offset values and tool numbers. And a second operator can run the job from that sheet without asking questions. If any of the three is missing, the program is a draft, not a release.

Some jobs do not need a full decode cycle. A one-off bracket with ±0.1 mm callouts can run from a conversational control or a manual program in less time than it takes to post and simulate. The tradeoff flips once you expect three or more parts, or when a feature sits below ±0.02 mm. Then the setup cost of a proper post, prove-out, and archive pays back on the first repeat.

For parts we machine at GreatLight, the decoded program is paired with a first-article report on request. In-process monitoring runs through the batch, and 100% inspection happens before shipment. That is how the code stays tied to the drawing after the setup is torn down.

  • 1
    Release criteria
  • 2
    Skip the full cycle
  • 3
    Always decode properly
Workflow

Step by step: decoding a part from CAD to first cut

  • 1
    1. Freeze the model and the tolerance calloutsLock the revision before CAM starts. Mark every dimension tighter than ±0.05 mm and every surface below Ra 0.8 μm. These drive stock allowance and finishing strategy. Changing the model after posting forces a full re-decode.
  • 2
    2. Plan setup and work offsetsDecide how many setups the part needs and where zero sits in each. On a 3-axis job, put Z zero on the top face. On a mill-turn part, keep one datum through both spindles. Write the offsets into the setup sheet, not into a machinist's memory.
  • 3
    3. Select the post-processor and verify its headerMatch the post to the exact machine and control. Check the header for units, G54 through G59, tool change format, and safe Z. A header that retracts to Z100 in inch mode on a metric machine lifts the tool 100 mm, which may not clear the fixture.
  • 4
    4. Post and read the first 30 blocksLook for the unit word, the work offset, tool length compensation, and spindle direction. A missing G43 or an M04 instead of M03 is visible in seconds and saves a crash. Confirm the rapid plane clears the tallest feature plus 5–10 mm.
  • 5
    5. Simulate, then prove on the machine without stockRun the CAM simulation for gouges and holder collisions. Then dry run on the machine at rapid override down to 25%, single block on, distance-to-go displayed. Watch the tool position at every tool change before letting it cut.
  • 6
    6. Cut the first article and measure before the secondCut one part, then measure the critical features. For ±0.005 mm work, inspect and adjust the D register, then re-cut. Do not run the full batch on an unproven program; a single offset error multiplied by 200 parts is expensive.
  • 7
    7. Archive the proven program with its setup sheetSave the posted file, the offset values, the tool list, and the inspection result together. On a repeat order the next operator loads a known-good program instead of re-posting, which removes the decode risk entirely.
Reference

Common decode faults and how they show up

Use this when a first article behaves strangely.

SymptomLikely causeFix
Part cut 25.4× too largeG20/G21 unit mismatchPost in the control's unit system
Tool dives at first moveMissing G43 or wrong H registerAdd length comp before cutting
Mirrored featureG41/G42 swappedMatch comp side to climb milling
Arc alarms outWrong plane G17/G18/G19Set plane before G02/G03
Thread pitch wrong on latheG94 used where G95 belongsSwitch to feed per revolution
Chatter on thin wallStepdown too deep for the setupReduce radial depth, add support
Second part out of toleranceTool wear, no comp updateMeasure and adjust D register
FAQs

CNC machining understanding: decoding questions

Is the decoding process the same as post-processing?

In most shops, yes. Decoding and post-processing both describe turning CAM toolpaths into a machine-specific G-code and M-code file.

Some teams use decoding for the wider chain, including offset setup and prove-out, and post-processing only for the CAM export step. The code itself is the same either way.

Can I run a program posted for one machine on another?

Sometimes, but never without checking. Controls differ in canned cycles, tool change format, and how they handle subprograms and macros.

Compare the header and the first tool change block. If the two controls are from different builders, re-post instead of editing by hand.

Why does my simulation pass but the real part fail?

Simulation checks the toolpath, not the machine state. It does not know your vise, your tool holder, or whether G54 was set to the right corner.

Most real failures come from offsets, tool length, or a fixture collision that the CAM model never included.

How much stock should the decoded program leave for finishing?

For aluminum, 0.3–0.5 mm radial and 0.1–0.2 mm axial is a normal finishing allowance. For stainless and tool steel, 0.2–0.3 mm radial works better because the load is higher.

Below ±0.02 mm, leave enough for a spring pass and plan to adjust cutter compensation after measuring the first article.

Do you need the native CAM file or just the STEP model?

A STEP or IGES model plus a 2D drawing with tolerance callouts is enough. We build our own toolpaths and post them to our machines.

Native CAM files are useful when you want the same toolpath strategy repeated exactly, but they are not required for quoting or production.

How does the decode step affect lead time?

Quotation and free DFM analysis come back within 12 hours, and production can start within 24 hours after approval. Parts ship in 3–5 days for typical jobs.

A new program with tight tolerances adds a prove-out cycle for the first article. Sending complete tolerance callouts with the model removes most of that delay.

Send a model and get a decoded, proven process

Upload your STEP file and tolerance drawing. We return a quote, free DFM notes, and a setup plan within 12 hours.

12-hour quote100% inspectionNo minimum order

Follow

More process notes 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