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. This holds true even if you restart your program. Until you cancel the command or change it, the G20 code would remain.
This can cause trouble if you aren’t paying attention.
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.
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 needs 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 does exactly what was intended.
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 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.
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 units in your program.
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.