CNC knowledge base

G-code course

Free G-code course from scratch: 10 lessons with examples and exercises – from program structure to a complete part program. This section has 10 articles: Lesson 1, Lesson 2, Lesson 3, Lesson 4, Lesson 5, Lesson 6 and more.

10Lessons

Lesson 1: What a CNC Program Is and How It Runs

A CNC program is a sequence of blocks (lines), each made of words: an address letter followed by a number, such as G01, X50.0 or F1200. Modal codes stay active until replaced by another code of the same group, so a…

Lesson 2: Coordinate Systems and Work Offsets

Machine zero is a fixed reference point set by the machine builder, while work zero (G54–G59) is a point on the part chosen by the programmer, whose machine coordinates are stored in the offset table. In G90 coordinates…

Lesson 3: Rapid and Linear Moves G00 and G01

G00 is rapid positioning at maximum machine speed, never used for cutting, and its path may not be straight. G01 is a straight move at the programmed feed F, given in mm/min under G94. The tool rapids above the point…

Lesson 4: Arcs G02 and G03

G02 is a clockwise arc and G03 a counter-clockwise arc, viewed from the positive end of the axis perpendicular to the plane (from +Z in G17). An arc is defined by its end point and either radius R (negative R for arcs…

Lesson 5: Tools, Spindle and Coolant – T, M06, G43 H, M03 and M08

A tool is changed with T and M06, and its length is applied with G43 plus an H number that must match the tool number, together with a Z move; G49 cancels the length offset. S, M03, M04 and M05 control the spindle, M08…

Lesson 6: Cutter Radius Compensation G41, G42 and G40

Cutter radius compensation lets you program the part contour instead of the cutter centre path: G41 offsets the cutter to the left of the direction of travel, G42 to the right, G40 cancels it, and the offset amount…

Lesson 7: Holes – Spot Drilling, Drilling and Tapping with Canned Cycles

On a milling machine a tapped hole is usually made with three tools: a spot drill (G81 or G82), a tap drill (G81 or G83) and a tap (G84, preceded by M29 S for rigid tapping on Fanuc). This lesson writes a complete…

Lesson 8: Pockets, Depth Steps and Subprograms

A rectangular pocket is milled by entering the material on a ramp or helix rather than plunging straight down, with a stepover of up to about 50–60 % of the tool diameter and several depth steps. The repeated depth step…

Lesson 9: Lathe Programming Basics

On a lathe the Z axis lies along the spindle centre line and X is usually programmed as a diameter; the work zero sits on the part face at the centre line. In a Fanuc lathe program (system A), G96 with a G50 S limit…

Lesson 10: Program Verification, Safe Start-Up and a Complete Part Program

A new CNC program is first checked by simulation and on the control graphics, then run in air with Z raised, in single block, with reduced rapid and feed overrides and a hand on Feed Hold. After the first part is…