GM Code CNC Processing PDF Guide
A G-code and M-code reference written for engineers who need to read a program, not memorize one. We cover what each word does, the modal rules that trip people up, and where a PDF guide is genuinely useful on the shop floor.

What gm code cnc processing actually is
gm code cnc processing is the act of turning a list of letter-number words into machine motion. A program is a stack of blocks. Each block is one line, and each line carries words such as G01, X50.0, F250 or M08. The controller reads the blocks in order and moves the machine. Nothing about it is abstract once you see the format.
The G letter is preparation. It tells the controller what kind of motion or mode comes next. G00 is rapid positioning, G01 is linear feed, G02 and G03 are arcs. The M letter is miscellaneous, which is a polite way of saying machine functions. M03 starts the spindle forward, M05 stops it, M08 turns coolant on.
Everything else is data. X, Y and Z are coordinates. F is feed rate in mm/min or in/min. S is spindle speed. T selects the tool, and H or D picks the offset register that goes with it. A block can hold several words at once, and the controller parses all of them before it moves an axis.
Read a real line and the logic shows up fast. N100 G01 X50.0 Y25.0 F250 M08 means: line 100, feed in a straight line to that point, at 250 mm/min, with coolant on. Nothing in that line is a command to a person. It is a command to a servo.
G words and M words do different jobs
G words set the mode of the machine. Most of them are modal, which means the controller remembers the last one until another G word in the same group replaces it. Write G01 once and the next twenty lines will all feed in a straight line, even if those lines only carry X and Y values.
M words fire an action. Some are modal too, but most are one-shot. M08 turns coolant on and it stays on. M30 ends the program and rewinds it. If you forget M09 before a tool change on some controllers, coolant keeps running through the change and floods the workholding.
The trap is that modal state follows the toolpath, not the comment. A leftover G41 cutter compensation or G43 tool length offset from an earlier operation will silently shift every cut that follows. Good PDF references print the modal groups next to the code list for exactly this reason.
Group 01 is the big one: G00, G01, G02 and G03 all live there. Only one can be active. Group 02 covers plane selection, G17, G18 and G19. Group 03 is units, G20 for inches and G21 for millimeters. Start a program in the wrong unit group and every dimension is off by a factor of 25.4.
How to use a PDF guide without memorizing it
A PDF guide is a lookup table, not a textbook. You do not read it front to back. You keep it open on a second screen, search the word you are staring at, and close it. The value is in the layout: a single alphabetical or numeric list, one line per word, with the modal group printed beside it.
What makes a guide usable is that it separates reading from writing. Reading a program means searching for the one word you do not recognize. Writing a program means checking the group first so you do not stack two words from the same group in one block. Those are different tasks and a good guide supports both.
The failure mode of most downloaded guides is that they mix controllers. A Haas M-code list is not a Siemens list, and neither matches a Mitsubishi wire EDM. Check the cover page for the controller family before you trust a line. If the guide does not name the control, treat it as a general reference only.
Print the ten words you actually use and tape them to the machine. For most 3-axis milling work that is G00, G01, G02, G03, G17, G21, G43, G54, M03 and M08. A four-page cheat sheet beats a 300-page PDF you never open. The rest can stay in the file.
Where hand-written code still makes sense
Nobody hand-writes a five-axis impeller program in G&M code. CAM software handles the surface math, the tool axis tilt and the collision checks. What engineers still write by hand is the small stuff: a facing pass, a spot drill, a deburr loop, a probe routine, a recovery block after a tool breaks.
That is the boundary. If the geometry can be described with a few coordinates, a radius and a feed, writing it directly is faster than opening a CAM session. If the geometry needs a surface model, hand code becomes a liability. The line between the two is usually around the point where you need more than two axes moving together.
In our own shop the mix is roughly what you would expect. CAM generates the part geometry, and hand-written or edited code handles setup blocks, work offsets, in-process probing and rework paths. On a 4,000 mm part the setup blocks matter as much as the toolpath, because a wrong G54 costs more than a slow feed.
One practical rule: if a hand-written block cannot be verified in a dry run within a few minutes, put it back in CAM. Air-cutting a program with the spindle stopped and the Z offset raised is cheap. Scrapping a near-finished part is not.
Modal, offset and unit mistakes that scrap parts
The mistakes repeat across shops. A missing G21 in the header sends a metric program through an inch controller. A G43 without a correct H number cuts air or, worse, cuts the vise. A G41 left active from a previous operation shifts the next profile by half a tool diameter.
Offset errors are the expensive ones because the code looks fine. The program reads perfectly, the simulation is clean, and the part is still wrong because the tool length register was loaded with the wrong number. Verify offsets at the machine, not in the file.
Arc errors come next. G02 and G03 need the correct plane active, and some controls reject an arc whose start and end radius do not match within a tolerance. A radius mismatch of 0.01 mm can throw an alarm on one control and cut a visible step on another.
Coolant and spindle state are the quiet ones. An M03 without a matching M05 before a manual tool change, or an M08 that never gets an M09, is a safety issue before it is a quality issue. Treat every M word as something a person has to be able to see and hear.
Common words and when they matter
Values are typical for a Fanuc-style controller. Always confirm against the machine builder's manual.
| Word | What it does | When it matters |
|---|---|---|
| G00 | Rapid move, no cutting | Positioning between cuts; watch clearance |
| G01 | Linear feed at F rate | Every straight cutting pass |
| G02 / G03 | Clockwise / counterclockwise arc | Radii, fillets, circular pockets |
| G17 / G18 / G19 | Selects the active plane | Needed before G02 or G03 on some controls |
| G20 / G21 | Inch / metric input | First line of the program, every time |
| G28 | Return to machine home | Setup, recovery after an alarm |
| G41 / G42 | Cutter compensation left / right | Profiles where tool radius must be trimmed |
| G43 | Applies tool length offset | Before the first cut with a new tool |
| G54–G59 | Work coordinate systems | Multiple vises or fixtures on one table |
| M03 / M04 / M05 | Spindle forward / reverse / stop | Start and end of every cutting cycle |
| M06 | Tool change | Only at safe Z and spindle stop |
| M08 / M09 | Coolant on / off | Deep pockets, aluminium, difficult chips |
| M30 | End program and rewind | Last block of the file |
When to read code and when to hand it off
Read the code when you are setting up, proving out or recovering a job. Hand the geometry to CAM when more than two axes move together or the surface has to be smooth. Do not hand-write what you cannot air-cut in five minutes.
Questions engineers ask about G&M code
Is G-code the same on every CNC machine?
No. G00, G01, G02 and G03 are close to universal, and so are M03, M05 and M30. Beyond that, the word numbers drift between Fanuc, Haas, Siemens, Mitsubishi and Heidenhain controls.
Treat a downloaded PDF guide as controller-specific until you check the cover page. If it does not name the control family, use it for general reading only and confirm anything critical against the machine builder's manual.
Can I edit a CAM program by hand without breaking it?
Yes, and it is normal practice. Setup blocks, work offsets, feed overrides, probing routines and rework paths are commonly edited by hand after CAM posts the file.
Keep the edits small and isolated. Change one thing, air-cut it, then run it. Editing a toolpath by hand inside a five-axis swarf cut is where people get into trouble.
What does modal mean in a CNC program?
Modal means the controller remembers the word until another word from the same group replaces it. G01 stays active for every following line that only carries coordinates.
This is convenient and dangerous at the same time. A G41 or G43 left active from an earlier operation will keep acting on cuts far downstream. That is why good reference guides print the modal group next to each code.
Do I need a PDF guide if my CAM software posts the code?
If you only press start, no. If you set up, prove out or troubleshoot the machine, yes. You will need to read a program someone else wrote and find the one word causing the alarm.
Most shops get by with a short printed cheat sheet of the ten to fifteen words they actually use, plus the full manual somewhere on the network for the rest.
How does G&M code change on a five-axis machine?
It adds rotary axes, usually A, B or C, and it adds more offset and kinematics handling. A simultaneous five-axis move needs the controller to know the tool center point, so G43.4 or a similar function becomes part of the picture.
That is the point where hand-writing stops being practical. The machine we run has 16 simultaneous 5-axis machining centers, and every one of them is fed by CAM for the part geometry.
What tolerance can be held once the code is correct?
Correct code is a precondition, not the result. On our machines, tight work runs to ±0.005 mm (±0.0002 in) with surface finish from Ra 0.2–0.8 μm on fine work and Ra 0.8–1.6 μm on standard high-finish passes.
Those numbers depend on the tool, the material and the setup as much as on the program. Inspection is 100% before shipment, with reports on request.
Send a drawing, get a program plan
Upload your part files and we will return a quotation with a free DFM analysis within 12 hours, plus a review of how the part should be programmed and set up.
12-hour quote100% inspectionNo minimum order quantity