Introduction
A skilled machinist can turn a shaft on a manual lathe to within a couple of hundredths of a millimetre. Give the same machinist the same drawing tomorrow and the part will be very slightly different. Give it to a different machinist and it will be different again.
CNC removed that variation. The thousandth part comes off the machine identical to the first, because a human is no longer deciding where the tool goes a program is. The operator’s skill moved from the handwheels to the keyboard.
That shift did more than improve consistency. Because a computer can coordinate several axes moving at once, shapes that were effectively impossible by hand became routine. Every curved mould cavity, every turbine blade, every aluminium phone body exists because of it.
This guide explains what CNC machining is, how the machine is built, how NC differs from CNC and DNC, and how to read the G-code that drives it all. Written in plain language for mechanical and production engineering students.
What Is CNC Machining?
CNC stands for Computer Numerical Control. CNC machining is a subtractive manufacturing process in which a computer program controls the movement of machine tools that remove material from a workpiece to produce a finished part.
Three ideas are packed into that definition:
- Subtractive – material is cut away, the opposite of 3D printing, which adds material
- Numerical – tool positions are expressed as coordinates and numbers, not as operator judgement
- Computer controlled – a program, not a person, decides the tool path
CNC is not itself a machining process. Turning, milling, drilling and grinding are the processes. CNC is the method of controlling them. A CNC lathe performs exactly the same turning operation as a manual lathe the difference is who moves the tool.
That distinction matters, and it appears in exams. Asked “is CNC a machining process?”, the correct answer is no: it is a control technology applied to machining processes.
How CNC Machining Works
The route from idea to finished part runs through five stages.
1. CAD model. The part is designed in software such as SolidWorks, Fusion 360 or CATIA, producing a 2D drawing or 3D solid model.
2. CAM programming. CAM software takes the model and generates tool paths deciding which tool to use, where it travels, at what speed and feed, and in what order. It outputs G-code.
3. Program transfer. The G-code file is sent to the machine’s controller by network, USB or direct link.
4. Machine setup. The operator loads the tools into the magazine, clamps the workpiece, and sets the work offset telling the machine where the part’s zero point sits on the table.
5. Machining. The controller reads the program block by block, converts each instruction into signals for the drive motors, and the tool cuts the part.
The important thing to notice is that the machine does not know what the part looks like. It has no model, no drawing, no concept of the shape. It simply executes a list of coordinate moves, one line at a time. All the intelligence lives in the program.
NC vs CNC vs DNC
These three terms describe the evolution of machine control, and telling them apart is a standard exam question.
NC (Numerical Control) was the original 1950s technology. Instructions were stored on punched tape or punched cards and read by the machine as it ran. There was no memory and no computer. Editing a program meant physically making a new tape, and the tape was re-read every time the program looped.
CNC (Computer Numerical Control) puts a dedicated computer inside each machine. The program is stored in memory, can be edited on the machine, and the controller can perform calculations, run canned cycles, apply tool offsets and diagnose faults.
DNC (Direct or Distributed Numerical Control) connects several CNC machines to a central computer over a network. Programs are stored centrally and distributed to machines as needed. In its modern form distributed numerical control each machine still has its own controller, and the central computer manages program storage, version control and production data.
| Feature | NC | CNC | DNC |
|---|---|---|---|
| Control unit | Hardwired electronics | Dedicated computer per machine | Central computer serving many machines |
| Program storage | Punched tape or cards | Machine memory | Central server |
| Program editing | New tape required | Edited at the machine | Edited centrally and distributed |
| Flexibility | Very low | High | Very high |
| Number of machines | One | One | Many |
| Cost | Low | Moderate | High |
| Status | Obsolete | Industry standard | Used in large plants |
A useful one-line summary: NC reads instructions, CNC stores and processes them, DNC distributes them across a shop floor.
G Code and M Code List
CNC programs are written in a language standardised as RS-274, universally called G-code.
Two families of instruction do the work:
- G codes are preparatory functions controlling geometry and motion where the tool goes and how
- M codes are miscellaneous functions controlling machine actions spindle, coolant, tool changes, program stops
Common G Codes
| G code | Function |
|---|---|
| G00 | Rapid positioning (no cutting) |
| G01 | Linear interpolation (cutting in a straight line) |
| G02 | Circular interpolation, clockwise |
| G03 | Circular interpolation, counter-clockwise |
| G04 | Dwell (pause for a set time) |
| G17 / G18 / G19 | Select XY, XZ or YZ plane |
| G20 / G21 | Inch units / metric units |
| G28 | Return to machine home position |
| G40 / G41 / G42 | Cancel / left / right cutter compensation |
| G43 | Tool length compensation |
| G54–G59 | Work coordinate offsets |
| G80 | Cancel canned cycle |
| G81 | Simple drilling cycle |
| G83 | Peck drilling cycle |
| G84 | Tapping cycle |
| G90 / G91 | Absolute / incremental positioning |
| G94 / G95 | Feed per minute / feed per revolution |
| G96 / G97 | Constant surface speed / constant spindle speed |
Common M Codes
| M code | Function |
|---|---|
| M00 | Program stop |
| M01 | Optional stop |
| M02 | End of program |
| M03 | Spindle on, clockwise |
| M04 | Spindle on, counter-clockwise |
| M05 | Spindle stop |
| M06 | Tool change |
| M08 | Coolant on |
| M09 | Coolant off |
| M30 | End of program and rewind |
| M98 / M99 | Call subprogram / return from subprogram |
Modal and Non-Modal Codes
A modal code stays active until cancelled or replaced. Set G01 and every following move is a feed move until you write G00. Set G21 and the machine stays in millimetres.
A non-modal code acts once and expires. G04 (dwell) pauses only in the block where it appears.
Understanding this saves a great deal of typing and prevents a common class of crash, where a programmer forgets that a modal code from twenty lines earlier is still active.
Absolute vs Incremental Programming
G90 (absolute) measures every coordinate from the part zero point. X50 means “go to the position 50 mm from origin.”
G91 (incremental) measures every coordinate from the current tool position. X50 means “move 50 mm further in X from wherever you are now.”
Absolute is safer and more common, because an error in one line does not accumulate into every subsequent move. Incremental is convenient for repeating identical features at regular spacing.
Structure of a Part Program
A program is made of blocks (lines), each containing words. A word is an address letter plus a number G01 is address G with value 01, X50.0 is address X with value 50.0.
Here is a simple milling program that cuts a 50 × 30 mm rectangular pocket outline, 2 mm deep:
O0001 (Program number)G21 G17 G40 G80 G90 (Metric, XY plane, no comp, cancel cycles, absolute)G54 (Select work offset)T01 M06 (Load tool 1)S1200 M03 (Spindle 1200 rpm, clockwise)G00 X0 Y0 (Rapid to start point)G43 H01 Z5.0 (Tool length comp, 5 mm above surface)G01 Z-2.0 F100 (Feed down to 2 mm depth)G01 X50.0 F200 (Cut along X)G01 Y30.0 (Cut along Y)G01 X0 (Cut back along X)G01 Y0 (Cut back to start)G00 Z50.0 (Rapid retract)M05 (Spindle off)M30 (End program and rewind)
Read it line by line and the logic is clear: set up the conditions, load the tool, start the spindle, approach safely, cut the shape, retract, shut down. Almost every CNC program follows this same skeleton.

Canned Cycles in CNC
A canned cycle is a single pre-programmed command that performs a complete multi-step operation which would otherwise take many lines of code.
Consider drilling one hole manually: rapid to position, rapid down to just above the surface, feed to depth, retract. Four blocks. For twenty holes, eighty blocks. With a canned cycle, you write the cycle once and then simply list the hole positions.
Common Milling Canned Cycles
| Code | Cycle |
|---|---|
| G81 | Simple drilling feed down, rapid retract |
| G82 | Drilling with dwell at the bottom, for flat-bottomed holes |
| G83 | Peck drilling retracts repeatedly to clear chips in deep holes |
| G84 | Tapping cycle, synchronised with spindle reversal |
| G85 | Boring cycle feeds down and feeds back out for a better finish |
| G80 | Cancels the active canned cycle |
Example. Drilling three holes 20 mm deep:
G81 X20.0 Y20.0 Z-20.0 R2.0 F100 X50.0 Y20.0 X80.0 Y20.0G80
The first block defines the cycle depth Z, retract plane R, feed rate F. Each following line only needs the new coordinates, because the cycle is modal and repeats automatically. The G80 cancels it.
Nine blocks of code have become four.
Common Turning Canned Cycles
| Code | Cycle |
|---|---|
| G71 | Rough turning cycle, multiple passes |
| G70 | Finishing cycle following G71 |
| G72 | Rough facing cycle |
| G74 | Peck drilling on a lathe |
| G76 | Threading cycle, multiple passes |
The lathe roughing cycles are especially powerful: you define the final profile once, state a depth of cut, and the controller works out how many passes are needed and generates them all.
Types of CNC Machines
- CNC milling machine and machining centre – rotating cutter, 3 to 5 axes, with automatic tool changer
- CNC lathe and turning centre – rotating workpiece, often with live tooling for milling and drilling
- CNC drilling machine – high-speed hole production in patterns
- CNC grinding machine – precision finishing of hardened parts
- CNC router – high-speed spindle over a large table, for wood, plastics and soft metals
- CNC EDM (wire and sinker) – spark erosion under programmed control
- CNC laser, plasma and waterjet cutters – profile cutting from sheet
- CNC press brake – programmed sheet metal bending
- Multi-tasking / mill-turn centres – combine turning and milling in one setup
CNC vs Manual Machining
| Factor | CNC machining | Manual machining |
|---|---|---|
| Control | Programmed instructions | Operator handwheels |
| Repeatability | Excellent; identical every time | Varies between parts and operators |
| Accuracy | Very high, ±0.01 mm or better | Depends on operator skill |
| Complex shapes | Multi-axis contours possible | Very limited |
| Setup time | Longer, needs programming | Shorter for simple jobs |
| Production speed | Very fast once running | Slow |
| Operator skill | Programming and setup skills | High manual skill |
| Labour needed | One operator can run several machines | One operator per machine |
| Cost of equipment | High | Low |
| Best for | Medium to high volume, complex parts | One-offs, repairs, simple jobs |
| Design changes | Edit the program | Re-machine by hand |
Manual machining is not obsolete. For a single bracket, a one-off repair, or modifying an existing part, a manual machine is faster and cheaper because there is nothing to program. Toolrooms and maintenance workshops still rely on them. CNC wins the moment you need the same part more than a few times, or need a shape that cannot be produced by two handwheels.
Advantages and Limitations of CNC Machining
Advantages
- Exceptional accuracy and repeatability across large production runs
- Complex 3D contours possible, especially on 4- and 5-axis machines
- Very high production rates once the program is proven
- One operator can supervise several machines
- Reduced human error and scrap
- Design changes need only a program edit
- Automatic tool changing reduces setup between operations
- Safer, since the operator is not close to the cutting zone
Limitations
- High capital cost for machines and CAM software
- Programming and setup skills are required
- Not economical for single simple parts
- Maintenance is specialised and expensive
- Machine downtime is costly
- Still a subtractive process, so material waste remains high
- A programming error can crash the machine and destroy tools or fixtures
Applications of CNC Machining
- Aerospace – turbine blades, structural brackets, airframe components machined from solid
- Automotive – engine blocks, cylinder heads, transmission housings, prototype parts
- Medical – implants, surgical instruments, prosthetic components
- Electronics – heat sinks, enclosures, connector housings
- Tool and die – injection mould cavities, press tools, jigs and fixtures
- Energy – valve bodies, pump components, turbine parts
- Prototyping – rapid production of functional metal and plastic prototypes
Frequently Asked Questions (FAQ)
1. What is CNC machining in simple words?
CNC machining is a manufacturing process in which a computer program controls machine tools that cut material away from a workpiece to make a finished part. CNC stands for Computer Numerical Control, and it is a subtractive process.
2. Is CNC a machining process?
No. Turning, milling, drilling and grinding are the machining processes. CNC is the control technology used to operate them automatically. A CNC lathe and a manual lathe perform the same turning operation only the method of controlling the tool differs.
3. What is the difference between NC, CNC and DNC?
NC used punched tape with hardwired electronics and no memory. CNC gives each machine its own computer, so programs are stored, edited and processed at the machine. DNC connects several CNC machines to a central computer that stores and distributes programs across the shop floor.
4. What are the main parts of a CNC machine?
The input device, the machine control unit containing the data processing unit and control loops unit, the drive system of servo motors and ball screws, the machine tool structure, and the feedback system of encoders and scales.
5. What is the difference between G code and M code?
G codes are preparatory functions that control geometry and tool motion, such as G00 rapid and G01 linear feed. M codes are miscellaneous functions that control machine actions, such as M03 spindle on and M08 coolant on.
6. What is the difference between G90 and G91?
G90 is absolute programming, where every coordinate is measured from the part zero point. G91 is incremental programming, where every coordinate is measured from the tool’s current position. Absolute is generally safer because errors do not accumulate.
7. What is a canned cycle in CNC?
A canned cycle is a single command that performs a complete multi-step operation, such as G81 for drilling or G83 for peck drilling. It replaces several blocks of code with one and can be repeated simply by listing new coordinates.
8. What is the difference between open loop and closed loop control?
Open loop control sends commands with no feedback, so positioning errors go undetected; it uses stepper motors and suits low-cost machines. Closed loop control measures actual position with encoders and corrects continuously; it uses servo motors and is standard on industrial CNC machines.
Conclusion
CNC did not invent a new way of cutting metal. Turning is still turning and milling is still milling. What changed is who decides where the tool goes.
Once that decision moved from an operator’s hands to a stored program, three things followed automatically. Parts became identical, because the program does not get tired or distracted.
Shapes became more complex, because a controller can coordinate five axes at once in a way no pair of hands can. And skill migrated the machinist’s expertise did not disappear, it moved upstream into programming, tooling and setup.
The rest of the subject is the machinery of that idea. The MCU decodes and calculates. Interpolation turns coordinates into smooth paths. Encoders close the loop so errors correct themselves. G-code carries the geometry, M-code handles everything else, and canned cycles compress the repetitive parts into single commands.
Read the short program in this article once more, line by line. Fourteen lines, and every one of them is a plain instruction you can follow. That is all a CNC machine ever receives and it is enough to make a jet engine.

