Whether a program comes from CAM software or is typed at the machine, the control executes it as G-code. The name comes from the “G” words that set motion, but a program is a mix of G-codes, M-codes and values for feed, speed and tool.
Reading a line of G-code
N40 G01 X50.0 Z-20.0 F0.2 reads as: block 40, feed in a straight line to X50 Z−20 at 0.2 mm per revolution. N numbers the block, G sets the motion, X/Y/Z give the target, and F, S and T set feed, spindle speed and tool.
Common G-codes
G00
- Function
- Rapid positioning — move fast, not cutting
G01
- Function
- Linear interpolation — straight-line feed (cutting)
G02 / G03
- Function
- Circular interpolation — clockwise / counter-clockwise arc
G17 / G18 / G19
- Function
- Select the XY / XZ / YZ plane for arcs
G20 / G21
- Function
- Inch / millimetre units
G28
- Function
- Return to machine reference position
G40 / G41 / G42
- Function
- Cutter compensation off / left / right
G54
- Function
- First work offset (G55–G59 for others)
G90 / G91
- Function
- Absolute / incremental positioning
| Code | Function |
|---|---|
| G00 | Rapid positioning — move fast, not cutting |
| G01 | Linear interpolation — straight-line feed (cutting) |
| G02 / G03 | Circular interpolation — clockwise / counter-clockwise arc |
| G17 / G18 / G19 | Select the XY / XZ / YZ plane for arcs |
| G20 / G21 | Inch / millimetre units |
| G28 | Return to machine reference position |
| G40 / G41 / G42 | Cutter compensation off / left / right |
| G54 | First work offset (G55–G59 for others) |
| G90 / G91 | Absolute / incremental positioning |
Lathes and mills share most of these but differ on some, and each control maker adds its own codes.
Modal codes and the machine’s state
Most G-codes are modal — they stay in force until replaced — so at any moment a control has a set of active codes: the motion mode, plane, units, work offset and compensation. On controls that expose it, ThingConnect reads that active set along with the running program’s name, so it is clear which program a machine is on and in what mode. Program end and pause are handled by M-codes.
Modal state is also why proving out a program matters. If a block assumes G90 absolute positioning but an earlier block left the control in G91 incremental, every following move lands somewhere else. Starting each program, and each tool, with a safe line that restates the key modes — units, plane, positioning, compensation off — removes that risk.
