Welcome to our comprehensive guide to using the G20 CNC code. Whether you’re a beginner learning CNC programming or an experienced machinist, understanding the G20 CNC code is extremely important.
In this guide, we’ll break down everything you need to know about this unit mode command, including how, when, and why to use it.
What does the G20 code do?
A G20 code switches the CNC into inch mode.
Once the G20 code is used, all sizes and locations in the program will be treated as inch values until the mode is changed. This includes canned cycles and subprograms.
This type of G code is called a modal command.
Modal commands remain in effect until they are canceled or changed to another code in the same group.
This holds true even if you restart your program.
Many, but not all modal codes have a cancel command to turn the mode off.
Note: There is no cancel command for unit modes. One of the unit mode codes must be active.
For this reason, most CNC programs will be created with start-up or safety commands. The safety commands make sure that the machine is always in the correct modes.
Learn CNC Programming – It’s Easier Than You Think!
Learning G Code doesn’t have to be difficult…
If you know what to focus on.
Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.
Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!Make Learning G Code Easy
G20 [inch mode] vs G21 [mm mode]
It should be pretty obvious from the names but the other unit mode to consider is G21 – Metric mode.
When G21 is the active units code, the machine will read all locations and values as in metric (mm).
Neither code can be canceled. The only way to turn on off is to switch to the other.
It is not advised to switch between units in your program.
When to use a G20 code?
A G20 code can be found at any point within the program, but the most likely location is at the start of the program or at the start of a new section of code.
For instance, you might use the G20 command immediately before starting a drilling cycle.
The machine may already be in inch mode, but placing the G20 command immediately before the drill cycle will ensure the program is in inch mode.
All kinds of things can happen when machining and it isn’t uncommon for the machine to crash or some part of a program to need to be re-run.
Placing the safety commands (G20 in this case) at the start of the new block of code makes sure your machine is in the correct unit mode when running that block of code.
With this example, the customer won’t be happy if you give them holes that are 1mm instead of 1 inch. If it goes the other way and you make a hole that is 1 inch instead of 1mm, just tell them that the extra work is on the house.
What to think about when using a G20 code?
When you use a G20 code you simply need to be aware of what type of units you are working in.
Most machine shops will work in only one unit mode, either inches or mm.
There are definitely some shops out there that will use mixed units, but in most cases CNC programs will be written in one or the other for every program they make.
Know whether your parts are in inches or mms.
Codes that are similar to G20
All of the codes listed in the table below are modal commands that affect the way the CNC machine interprets size and location values that are entered.
Ready to master CNC programming?
Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!Master G Code Today