You’re in a foreign land. You ask how far is it to the nearest hotel. They quickly tell you, it’s a ways about 1000 cana, you can’t miss it though. Cana? Do you have a clue how far you have to go?
Code: 20 and 21
Action: Sets cutting mode to Inch units (G20) or Milimeter units (G21)
ANSI Std: Yes
Conflicting G Codes Any other G code in Group 05
CNC machines have no idea what to do, where to go, or how fast to do it unless to describe your intentions in a language they understand.
Cana is an archaic unit of measure of 1.5708 meters. Clearly not something the machine will understand.
What the CNC controls do understand is millimeters and inches. But they need to know which unit of measure to use.
The G20/G21 commands tell the machine which unit of measure to use. If you are programming in Inches, use the G20.
Otherwise, use G21 to tell the control that distances will be in Millimeters.
Like the G94 and G95 commands, the G21 is modal and a set it and forget it command. There are settings in the control that determine the default starting condition for CNC machines.
Whether the default startup mode for the machine is G20 or G21 mode is usually set by the machine tool builder based on the customer requirements. However at any time you or your maintenance department can set the machine to start in the mode that you most commonly use.
So have no fear. With proper use of the G20 and G21 commands your machine will always know how far it is to the destination point.
For a complete introduction to the fundamentals of CNC programming, take a look at 7 Easy Steps to CNC Programming . . . A Beginner’s Guide or 7 Easy Steps to CNC Programming . . . A Beginner’s Guide, the Ebook