← LibraryCNC Numerical Control ProgrammingEngineering · Mechanical EngineeringLesson 50/50← PrevNext →
ArticlePublished 11 Jul 2026Updated 14 Jul 20266 min readBy Kevin Jogin
KEVOS® Knowledge Library · Engineering → Mechanical Engineering

Engineering / Mechanical Engineering

CNC Numerical Control Programming

A CNC machine follows a written program of coordinates and commands — the same cutting speeds and feeds of the earlier pages, now expressed as numbers a controller obeys. Learn the coordinate system, a handful of codes, and how to turn cutting data into a spindle speed, and the language opens up.

  • Reading time · 6 min
  • 7 sections
  • Spindle speed in code, worked
  • Constant surface speed
X Z G01 linear G02/G03 arc moves are built from straight lines and circular arcs
Doc №KL-ENG-MECH-108
SectionEngineering → Mechanical Engineering
Sheet1 of 1
DrawnKEVOS®
Date2026-07-11

§1A machine that reads

Computer numerical control replaces the operator’s hands with a program: a list of instructions telling the machine where to move, how fast, and what the spindle and coolant should do. The cutting physics is unchanged — only the control is.

Everything from the earlier pages still holds on a CNC machine — the cutting speed from N = 1000 V/(π D), the feed that sets finish, the depth that sets force — but instead of an operator turning handwheels, a controller reads a program and drives the axes with motors and lead-screws to the numbers it is given. This buys repeatability (every part identical), complex paths (curves and contours no handwheel could trace) and unattended running. The programmer’s job is to express the cut as coordinates and commands: where to go (§2), what to do there (§3), and at what speed and feed (§4). The language is simple in its parts; the skill is stringing them into a safe, correct path.

Contents

§2Axes and coordinates

A CNC machine positions the tool in a coordinate system — named axes with numbers — and those numbers can be given as absolute positions or as steps from where the tool is.

The axes follow a convention: X, Y, Z for the three linear directions (a mill uses all three; a lathe uses X across the diameter and Z along the axis), with rotary axes A, B, C where fitted. Positions are stated one of two ways, and confusing them is a classic error. In absolute mode (G90) every coordinate is measured from one fixed origin — the part zero — so X50 always means the same place. In incremental mode (G91) each coordinate is a step from the current position — X50 means fifty millimetres further on. Absolute is easier to check and recover from and is the usual choice; incremental suits repeated features. A work offset ties the program’s zero to the actual part on the table, so the same program runs wherever the part is clamped. Get the axes and the absolute-or-incremental mode right, and the geometry follows.

Contents

§3G-codes and M-codes

A CNC program is a list of blocks, each built from short codes: G-codes command motion and mode, M-codes command machine functions, and letter-addresses carry the numbers.

The core codes
CodeMeans
G00 / G01rapid move / straight-line cutting move (feed)
G02 / G03clockwise / anticlockwise circular arc
G20 / G21inch / millimetre units
G90 / G91absolute / incremental coordinates
S · F · Tspindle speed (rev/min) · feed · tool number
M03 / M05 · M08 / M09spindle on/off · coolant on/off
A block combines them: G01 X50 Z-20 F0.15 means “cut in a straight line to X50, Z−20 at 0.15 mm/rev.” G-codes set what kind of move and which modes are active (many are “modal” — they stay in force until changed), M-codes switch the spindle, coolant and other functions on and off, and the letter-addresses S, F and T carry the cutting numbers. A whole program is just many such blocks in sequence.
Contents

§4Speed and feed in the program

The S and F values in a program are exactly the spindle speed and feed of the earlier pages — so programming a cut begins with the same cutting-data calculation.

Example 1 — from cutting speed to an S word

To turn a 50 mm diameter at a recommended cutting speed of 120 m/min, the spindle speed is the familiar N = 1000 × 120/(π × 50) = 764 rev/min, so the program carries S764 M03 (spindle on, clockwise, at 764 rev/min). If the finish wants a feed of 0.15 mm/rev, the block adds F0.15. In other words, the programmer does the same speed-and-feed work as the manual machinist — pick the cutting speed for the material and tool, convert to rev/min through the diameter, choose the feed for the finish — and simply writes the results as S and F words. The CNC does not change the cutting data; it only asks for it in numbers. Everything the speeds-and-feeds page taught feeds straight into the program.

Contents

§5Interpolation

A CNC machine builds any path from two primitives — straight lines and circular arcs — moving several axes together so the tool follows the commanded shape. This coordinated motion is interpolation.

Linear interpolation (G01) drives the axes together in the right proportion to cut a straight line to a point at the programmed feed — the workhorse cutting move, in any direction (the hero). Circular interpolation (G02 clockwise, G03 anticlockwise) drives them so the tool sweeps a circular arc of a given radius or centre — how curves, radii and round pockets are cut. Between them, straight lines and arcs can approximate any profile, and a contour is programmed as a chain of G01 and G02/G03 moves. Rapid moves (G00) position the tool quickly between cuts, not for cutting. The controller does the continuous mathematics of coordinating the axes; the programmer supplies the endpoints and, for arcs, the radius or centre. This is why CNC can cut shapes no manual machine could trace by hand — the machine interpolates the path the program only outlines.

Contents

§6Constant surface speed

On a lathe, the cutting speed changes with diameter for a fixed rev/min — so CNC lathes offer a mode that varies the spindle speed automatically to hold the cutting speed constant as the diameter changes.

Example 2 — why the rev/min must change

Cutting speed is N × π D, so at a fixed spindle speed the edge cuts faster on a large diameter than a small one — a problem when facing across to the centre, or turning a stepped part. Constant surface speed (G96) solves it: the programmer commands a cutting speed, and the controller continuously adjusts the rev/min to hold it as the diameter changes. Turning at 120 m/min, the machine runs 764 rev/min at 50 mm diameter but 1528 rev/min at 25 mm — doubling the rev/min as the diameter halves, to keep the surface speed at 120 (recall N = 1000 V/(π D), inversely proportional to D). This keeps the finish and tool load uniform across changing diameters, and is switched back to a fixed rev/min (G97) for operations like drilling on centre or threading, where a steady spindle speed is needed. It is the earlier pages’ speed relationship, now enforced live by the control.

Contents

§7Quick reference

The working core of the page on one card rack.

Coordinates

X Y Z axes · G90 abs / G91 inc

work offset ties to the part

Codes

G00 rapid · G01 line · G02/03 arc

M03/05 spindle · M08/09 coolant

Speed/feed

S = 1000 V/(π D) · F = feed

D50 @ 120 → S764

Interpolation

lines + arcs → any profile

CSS (G96)

holds V as dia changes

764 → 1528 rpm (50→25 mm)

Contents

Continue learning

Grinding and Other Abrasive ProcessesArticle · Mechanical EngineeringGrinding Feeds and SpeedsArticle · Mechanical EngineeringMachining Nonferrous and Nonmetallic MaterialsArticle · Mechanical EngineeringScrew Machines, Band Saws and Cutting FluidsArticle · Mechanical Engineering