A machine that lurches 25 times farther than commanded is not malfunctioning; it is obeying. G20, inch mode, is active, your millimeter numbers are being read as inches, and the only real question is which of four doors let inch mode in. Check them in order and this never costs you more than a minute again.
Which door let G20 in?
| Door | What happened | The tell |
|---|---|---|
| Program states no units | Machine kept whatever was active before | No G21 anywhere in the file |
| Leftover modal state | A previous job or MDI session ran G20 | Problem appears after someone else’s job |
| Power-on default | The control wakes up in inch | Problem appears after every restart |
| CAM post in inch | The program itself is G20 | G20 printed right there in the file |
The modal mechanics behind doors one and two are the heart of it: units are modal, so whatever was set last simply stays, as the LinuxCNC units reference and the standard G20/G21 guides describe. A program silent about units inherits a stranger’s choice.
How do you confirm it in ten seconds?
Open the control’s active G-codes page, the status screen listing current modal state, and read the units group: it says G20 or G21 outright. This display is the single most underused diagnostic on the machine; it answers mode questions, units, plane, positioning, instantly, where guessing from behavior answers them expensively. Make it the first stop whenever motion size looks wrong, the same reflex that catches the related scale trap of a missing decimal point.
What is the permanent fix?
Defense in two layers, because each covers the other’s gap. At the machine, set the power-on default parameter to metric so every restart wakes in G21; this kills door three. In every program, state G21 in the safety block, G21 G17 G40 G90, which kills doors one and two on any machine you ever run, including machines whose parameters belong to someone else. Door four is a CAM settings check: open the post output and look at the units line before the first run, part of reading any new program the way a program should be read.
A concrete version: a shop’s Monday-morning mystery, the first metric job after a weekend always overtraveling, traced to a Friday-night MDI habit of testing in inches. The power-on default was metric, but the machine had not been restarted, so door two stood open all weekend. One G21 added to the program template ended a recurring incident nobody had connected.
Why does this keep happening to careful people?
Because modal state is invisible and memory is retrieval-based. Units feel too basic to check, so nobody actively recalls them until motion goes wrong, the same recognition-without-retrieval trap behind forgetting which M-code turns off the coolant. The full conceptual background, what G20 and G21 each do and why the mismatch scales by 25.4, lives in G20 vs G21 inch vs metric; this page is the symptom-first version for the moment it bites.
Bottom line
Inch moves on a metric job mean G20 is active, let in by a silent program, leftover modal state, an inch power-on default, or an inch CAM post. Read the active-codes page to confirm in seconds, set the default to metric, and state G21 in every safety block so no machine’s history can surprise you. Making that units reflex automatic is what a recall routine on the G-code practice hub is for.
Sources
- LinuxCNC G-code reference (G20/G21 units)
- HelmanCNC: G20 G21 units inch and metric
- Wikipedia: G-code
Frequently asked questions
Why is my CNC moving in inches instead of mm?
G20 is active where you expected G21: the program states no units, a previous job or MDI left inch mode on, the power-on default is inch, or the CAM post output G20. The active-codes display confirms it instantly.
How do I check whether G20 or G21 is active?
Open the control’s active G-codes status page and read the units group. It shows the mode directly, in seconds.
How do I make my CNC always start in mm?
Set the power-on default parameter to metric, and state G21 in every program’s safety block anyway, so any machine’s leftover state is overridden.
What is the best way to learn the units codes so this stops happening?
Drill G20 and G21 with the modal setup codes until stating units is reflex. A free app like G-Code Sprint quizzes the everyday codes and repeats whichever ones you miss.
G-Code Sprint is a study and practice tool only. Always follow your instructor, employer, machine manual, and shop safety procedures.