What Is CNC Programming?
CNC programming is the bridge between an engineering drawing and a moving cutting tool. This page explains what a program actually controls, how a drawing becomes coordinates, and when to program by hand versus using CAM.
Concept
CNC stands for Computer Numerical Control. A CNC machine follows a set of coded instructions — a program — that tells the spindle, axes, coolant, and tool changer what to do and when. CNC programming is the process of writing those instructions so the machine removes material from raw stock and produces the part shown on a drawing.
The program itself is a plain-text file (often called an NC file or G-code file) that lives on the machine's controller. It is not the same as a CAD drawing or a CAM project file. CAD defines geometry; CAM generates tool paths; the post-processor translates those paths into machine-specific G-code. The CNC programmer's job — whether manual or CAM-assisted — is to ensure the final G-code is correct, safe, and produces the intended part.
Why It Matters
Imagine a 60×40 mm plate with two holes: one at (10,10) and one at (50,30). The drawing gives you the dimensions, but the machine needs coordinates, speeds, feeds, and tool calls. A hole at (50,30) in the program does not mean "move 50 mm from where you are" — it means "go to X50, Y30 relative to the work zero." Confusing absolute and incremental coordinates is one of the most common beginner mistakes, and it can move a hole by exactly the wrong amount.
How It Works
The workflow from drawing to part always follows the same chain:
- Engineering drawing — defines geometry, dimensions, tolerances, material.
- Process planning — choose machine, fixturing, tools, operation order.
- Workholding — clamp the stock, set the datum, verify clearance.
- CNC program — write coordinates, speeds, feeds, tool changes.
- Program verification — dry run, single block, first part, inspect.
Manual programming means you write each G-code line yourself. It is fast for simple parts (straight turns, basic drilling, rectangular pockets) and gives you direct control. CAM programming uses software to generate tool paths from a 3D model. It is essential for complex 3D surfaces, multi-axis work, and high-volume production — but the output still needs human review. A CAM post-processor can produce code that looks right yet crashes the machine if the toolholder or fixture was not modeled.
A CNC program controls several machine systems at once: the spindle speed and direction, the linear axis positions and feed rates, tool selection and change, coolant on/off, and auxiliary functions like chuck clamp or tailstock. The controller reads the program line by line, interprets each word (e.g., X50, S2000, F300), and sends signals to the servo drives. Modal codes (like G01) stay active until canceled, which is why you can write three X moves without repeating G01.
| Manual Programming | CAM Programming | |
|---|---|---|
| Best for | Simple 2D parts, turning, drilling | Complex 3D surfaces, multi-axis |
| Setup time | Minutes | Hours (model, toolpaths, post) |
| Control | Full line-by-line control | Software-controlled; needs review |
| Cost | Free (text editor) | Software license + training |
NC vs CNC
NC (Numerical Control) is the older technology using punched tape. CNC (Computer Numerical Control) is the modern version with a dedicated computer controller. The terms are often used interchangeably today, but "NC program" still refers to the G-code file itself, while "CNC machine" refers to the controlled machine tool.
Example
Two holes on a plate: Hole 1 at (10,10), Hole 2 at (50,30). In plain language, the machine needs to: move above Hole 1, drill, retract, move above Hole 2, drill, retract.
G90 G54 G00 X10. Y10. (rapid to above hole 1)
S1500 M03
G43 H01 Z5. M08
G81 R2. Z-15. F120.
G00 X50. Y30. (rapid to above hole 2, still drilling cycle)
G80 G00 Z50. M09
Reading the numbers: X50 Y30 is the absolute target position. S1500 is spindle speed in RPM. F120 is feed rate in mm/min. G81 is the drilling canned cycle. You do not need to memorize every code yet — the point is that each letter-and-number pair controls one specific machine function.
Common Mistakes
- Treating coordinates as distances — X50 means "go to X50" (absolute), not "move 50 mm" (incremental). See Coordinate Systems.
- Thinking S is cutting speed — S is RPM. The surface speed (m/min) depends on tool diameter. See Spindle Speed & Feed.
- Assuming CAM output needs no review — the post-processor only knows what you told it. If units, work offset, or tool numbers are wrong, the code will faithfully execute the wrong path.
Practice
1. Hole 1 is at (10,10), Hole 2 is at (50,30). What are the delta X and delta Y between them?
Show answer
ΔX = 50 − 10 = 40 mm. ΔY = 30 − 10 = 20 mm.
2. A simple shaft with two straight turned diameters — would you program it manually or use CAM? Why?
Show answer
Manual. Straight turning on a lathe is a simple axisymmetric profile; G71/G70 cycles handle the roughing, and the programmer directly controls coordinates. CAM adds setup overhead without geometric benefit.
3. What is the difference between a CAD file and an NC file?
Show answer
CAD is the geometric model (drawing). NC is the machine-readable G-code that tells the controller how to move the tool. A CAM package sits between them: it takes CAD geometry, generates tool paths, and a post-processor outputs NC code for a specific machine.
Sources
- Haas G00 Rapid Positioning — supports rapid motion behavior.
- Haas G01 Linear Interpolation — supports feed motion and F command rules.
- Program examples and speeds/feeds are classroom teaching assumptions; verify against tooling catalogs and machine documentation.