G20 G-Code Command
The G20 command is a standard G-code command used in computer numerical control (CNC) machining. It is used to set the units of measurement for the CNC machine. Specifically, the G20 command sets the machine to use inches as the unit of measurement.
How G20 G-Code Command is used
Here’s an example of a G-code program that uses the G20 command to set the units of measurement to inches and includes a spindle on command for 2000 rpm:
% (Program to drill a hole)
G20 (Set units to inches)
M3 S2000 (Turn on spindle at 2000 RPM)
G0 X0 Y0 Z2 (Rapid move to starting position)
G98 G81 R.1 Z-0.5 F10.0 (Move down to drilling depth at a feed rate of 10 inches per minute)
G00 X1.0 Y1.0 F5.0 (Move to the drilling location at a feed rate of 5 inches per minute)
G98 G81 R.1 Z-1.0 F5.0 (Drill the hole to a depth of 1 inch at a feed rate of 5 inches per minute)
M5 (Turn off spindle)
G0 X0 Y0 Z0 (Rapid move to starting position)
M30 (End of program)
In this example, the G20 command sets the units of measurement to inches. The M3 command turns on the spindle at 2000 RPM. The program then moves to the starting position (X0, Y0, Z2) using a rapid move (G0). The G81 commands are used to move the machine to the drilling location and drill the hole to a depth of 1 inch. The M5 command turns off the spindle, and the program ends with a rapid move to the starting position and the M30 command.