Master CNC programming for beginners
This page explains what actually happens between a CAD model and a finished cut. It is written for junior engineers, machinists moving to the office, and buyers who need to read a program before they approve a part. Read it and you can judge whether a tool path, a feed rate or a setup is sound.

In this article
- 1
- 2
- 3
- 4
- 5
- 6
What a CNC program actually controls
A CNC program is a list of instructions that moves a spinning tool through material. Nothing more. Every line either positions an axis, turns a function on or off, or sets a condition the controller will use later. G-code covers motion and geometry: G00 for rapid positioning, G01 for straight feed, G02 and G03 for clockwise and counterclockwise arcs. M-code covers machine functions such as spindle start, spindle stop, coolant on and tool change.
The controller reads this list and drives servomotors on each axis. A three-axis mill moves X, Y and Z. A four-axis machine adds a rotary table, and a simultaneous five-axis machine tilts and rotates the tool or the table while it cuts. The program does not know what the part looks like. It only knows coordinates, feed rates and spindle speeds. If the numbers are wrong, the machine will still follow them exactly.
That is the first lesson for anyone trying to master CNC programming for beginners work: the machine is obedient, not clever. It has no sense of a good cut. A feed rate that is too high will break a 6 mm end mill in aluminium. A feed rate that is too low will rub the same tool until it work-hardens the surface. Both come from the same line of code.
Every program also carries a setup assumption. The zero point, the fixture, the tool lengths and the stock size all live outside the code, in the machine and in the operator's head. Two shops can run identical programs on identical machines and get different parts because the setup differs. Keep that in mind as you read any program, including your own.
Work coordinates, offsets and why parts move
The machine has a home position it can always find. The part does not. Work coordinate systems bridge that gap. G54 through G59 store the distance from machine home to the corner or center you chose as part zero. On a typical vertical mill, X0 Y0 Z0 is the top corner of the stock or a datum on the fixture. On a lathe, Z0 is usually the finished face and X0 is the spindle centerline.
Tool length offsets are the second half of the puzzle. Each tool sits a different distance out of its holder, so the controller needs to know how far to travel before the tip touches the part. H registers hold that number. If you forget to call the right H value, a 12 mm flat end mill will plunge to the depth meant for a 6 mm drill. That is a crash, not a tolerance issue.
Cutter radius compensation, G41 and G42, tells the controller to offset the path by the tool radius so you can program the part outline instead of the tool center. It sounds convenient. It also hides errors, because the program no longer shows where the tool center travels. Many shops program the tool center directly for simple 2.5D work and use G41 only when the geometry repeats across many sizes.
When a part comes out shifted by a constant amount, the cause is almost always an offset or a datum choice, not the geometry. When one feature is off and the rest are good, look at the tool, the holder or the depth of cut. Those two symptoms separate setup errors from cutting errors, and they are the fastest diagnostic you have.
Feeds, speeds and the load the tool can carry
Cutting speed is surface speed, the rate at which the material passes the cutting edge. It is written in meters per minute for metric work. Feed is the distance the tool advances per tooth, in millimeters per tooth. Spindle speed in rpm links the two. A 10 mm carbide end mill in 6061 aluminium runs around 300 to 500 m/min surface speed, which lands near 9,500 to 16,000 rpm. A 10 mm end mill in 316 stainless runs near 60 to 100 m/min, so roughly 1,900 to 3,200 rpm.
Chip load matters more than rpm for tool life. Each tooth should take a chip thick enough to cut rather than rub. In aluminium, 0.05 to 0.15 mm per tooth is a common starting range for a 10 mm tool. Run the same chip load on a 3 mm tool and you will snap it, because the core is too thin to carry the bending load. Scale the chip load with the tool diameter.
Depth of cut and width of cut set how much of the flute is engaged. A light radial cut with a full axial depth is the usual choice on a 40-taper machine, because it keeps the load axial and reduces deflection. A heavy radial cut at shallow depth is common on a router or a small machine with less rigidity. Neither is wrong. The machine decides.
Listen to the cut and read the chips. Thin, silver, curled chips from aluminium mean the load is healthy. Powder or dust means you are rubbing. Blue chips on steel mean the heat is going into the part. Cutting speed through the material should be set from the tool maker's data, then adjusted for the actual machine, holder and fixture stiffness.
Roughing, finishing and where the tolerance comes from
Roughing removes bulk material and leaves a small allowance for finishing. A typical allowance is 0.3 to 0.5 mm on walls and floors. Rough with the largest tool the geometry allows, because a larger tool removes material faster and deflects less. Finishing then takes that allowance in one or two passes with a sharper, often smaller tool.
Tolerance does not come from the finishing pass alone. It comes from the whole chain: machine geometry, tool runout, holder stiffness, thermal growth and the fixture. A machine that holds ±0.005 mm on a 50 mm aluminium part may hold ±0.02 mm on the same part in titanium, because the cutting forces are higher and the tool pushes off. The number on the drawing is a target, not a property of the machine.
Surface finish follows the same logic. A fine finish of Ra 0.2–0.8 μm usually needs a small stepover, a sharp tool and a rigid setup. A high finish of Ra 0.8–1.6 μm is normal for production milling. As-machined surfaces at Ra 1.6–3.2 μm are fine for most brackets and housings. Chasing a finer finish than the function needs adds cost and cycle time for nothing.
In-process measurement closes the loop. Measure the first part, adjust the wear offset, then run the batch. On a 100-part run, checking every tenth part catches tool wear before it reaches the tolerance limit. This is how a shop holds a 99.99% qualification rate across a production run.
When manual programming stops being the right tool
Manual G-code works well for 2.5D profiles, pockets, drilled hole patterns and simple turned parts. It is fast to write, easy to read at the machine, and quick to edit when a dimension changes. For a one-off bracket with six holes and a pocket, hand-written code is often faster than opening CAM.
CAM earns its place when the geometry stops being describable in a few lines. A contoured surface, a fillet that blends into three faces, or a part that needs the tool to tilt at a fixed angle all push toward CAM. Five-axis tool paths also need collision checking that no one can do by hand. The software pays for itself the first time it prevents a holder from hitting the table.
There is a middle path. Many job shops program the simple features by hand and open CAM only for the one difficult surface. That keeps the program readable and the setup predictable. It also means the operator can verify most of the code without a simulation run.
The decision is not about skill. It is about geometry complexity and how many times the part will run. One part with a freeform surface: CAM. Two thousand identical brackets: CAM with a proven template. Ten prototypes with changing dimensions: often manual code plus a good setup sheet.
Manual G-code vs CAM programming: which fits the job
Pick the column that matches the geometry, not the shop's habit.
| Factor | Manual G-code | CAM programming |
|---|---|---|
| Geometry | 2.5D profiles, pockets, hole patterns | Freeform surfaces, blended fillets, 5-axis |
| Part quantity | 1 to 20 pieces | 20 pieces up to 10,000+ runs |
| Editing speed | Seconds for one dimension | Minutes to re-post the tool path |
| Collision risk | Low on 3-axis, high on multi-axis | Checked in simulation before cutting |
| Skill needed | Coordinates, offsets, feeds | Tool path strategy, stock model, post |
| Best fit | Prototypes, repairs, simple fixtures | Complex parts, repeat production |
The call we would make
If the part can be described in a dozen lines of G-code, write it by hand and check it at the machine. If the geometry needs a tilted tool or a blended surface, use CAM and simulate it before the first cut.
Questions beginners ask
How long does it take to learn G-code?
You can read and edit basic G-code within a few weeks of daily practice. Writing a full program for a simple 2.5D part, including tool changes and offsets, usually takes one to three months of supervised work.
Getting comfortable with feeds, speeds and setup decisions takes longer, because those depend on the machine and the material in front of you. Treat the first year as building judgement, not memorising codes.
Do I need to know math to program CNC machines?
Basic trigonometry is enough for most work. You need sine, cosine and tangent to calculate hole positions on a bolt circle and to find tangent points on arcs.
CAM software handles the heavy geometry. What it cannot do is tell you whether the resulting tool path is safe on your machine, so you still need to read coordinates and understand what the numbers mean.
Which is more important, feed rate or spindle speed?
Feed rate per tooth is the number that decides tool life. Spindle speed only sets the surface speed. If the chip load is too low, the edge rubs and wears quickly no matter how the rpm is set.
Start from the tool maker's surface speed to get rpm, then set feed from the chip load you want. Adjust after you see and hear the first cut.
Why did my part come out undersized on every feature?
A constant error across all features points to an offset problem, not a geometry problem. Check the tool length offset, the work coordinate system and the cutter radius compensation value.
If the error is roughly twice the tool runout, the tool is cutting oversize because it is not concentric. Indicate the tool in the holder and reseat it.
Can I program a five-axis part by hand?
You can write a fixed-angle 3+2 program by hand if the setup is simple and the angles are known. Full simultaneous five-axis motion is a different task, because the tool vector changes continuously.
Use CAM and run a simulation with the real holder and fixture model. The cost of a collision on a five-axis machine is far higher than the cost of the software licence.
What should be in a setup sheet?
List the work coordinate system, the zero point, every tool with its number and offset register, the stock size, and the fixture. Add the program number and the revision date.
A setup sheet that fits on one page gets used. A ten-page document gets ignored, and the operator will set the part from memory instead.
Send us your drawing and we will check the program logic
Quotation and free DFM analysis within 12 hours, plus 100% inspection before shipment.
12-hour quote100% inspectionNDA on request