G-code List for CNC [Complete List] - MellowPine (2024)

G-code is a series of preparatory commands used to control CNC machines. It can be programmed manually or using software programs.

G-codes Used on CNC Mills

The following is a list of G-codes used to program CNC mills and machining centers.

G codeFunction
G00Rapid positioning
G01Linear interpolation
G02Clockwise circular interpolation
G03Anticlockwise circular interpolation
G04Dwell or Pause (used in a separate block)
G09Exact stop (for stopping the axes)
G10Setting programmable input data
G11Canceling data setting mode
G15Canceling polar coordinate command
G16Interpretspolar coordinate command
G17Commands designated to the XY plane
G18Commands designated to the ZX plane
G19Commands designated to the YZ plane
G20Imperial/English units of input
G21Metric units of input
G22Turns on stored stroke check
G23Turns off the stored stroke check
G25Turns on spindle speed fluctuation detection
G26Turns off spindle speed fluctuation detection
G27Checks the machine’s zero position
G28Machine returns to its zero position (point A)
G29The machine returns to point A, then to the location specified on G29
G30The machine returns to point A, then to a zero position (point B)
G31Skip function
G40Cancels the cutter radius compensation
G41Compensates the left cutter radius
G42Compensates the right cutter radius
G43Compensates for a positive tool length
G44Compensates for a negative tool length
G45Position compensation – single increase
G46Position compensation – single decrease
G47Position compensation – double increase
G48Position compensation – double decrease
G49Cancels the tool length offset
G50Cancels the scaling function
G51Scaling function
G52Switches to a local/child zero position
G53Switches to the machine’s default zero position
G54Work coordinate offset I
G55Work coordinate offset 2
G56Work coordinate offset 3
G57Work coordinate offset 4
G58Work coordinate offset 5
G59Work coordinate offset 6
G60Positions the machine in a single direction
G61Stops the machine
G62Modal automatic corner override
G63Tapping mode
G64Cutting mode
G65Calling custom macro commands (one time)
G66Calling custom macro commands (on every machine movement)
G67Cancels custom macro call commands
G68Rotates the coordinate system at an angle
G69Cancels the coordinate system rotation
G73Peck and canned drilling cycles
G74Left-hand rigid tapping or threading cycle
G76Fine boring cycle
G80Cancels active canned cycles
G81Drilling cycle
G82Dwell drilling cycle
G83Deep hole peck-drilling cycle
G84Right-hand rigid tapping or threading cycle
G85Reaming cycle
G86Boring cycle
G87Back boring cycle
G88Boring and dwelling cycle
G89Back boring and dwelling cycle
G90Absolute dimensioning mode
G91Incremental dimensioning mode
G92Setting an offset on the coordinatesystem
G98The tool returns to the initial position
G99The tool returns to the R plane in a fixed cycle

M-codes Used on CNC Mills

In a typical CNC program, G-codes and M-codes are used in combination. M-code controls the machine functions like the spindle on/off, tool change, coolant on/off, etc.

Following are some of the M-codes associated with programming CNC mills.

M-CodeFunction
M00Compulsory program stop
M01Optional program stop
M02End of the program (can end with reset, but no rewind)
M03Spindle rotation (normal)
M04Spindle rotation (reverse)
M05Spindle stop
M06Automatic tool change
M07Turns on the coolant mist
M08Coolant ON (turns on the coolant pump)
M09Coolant OFF (turns off the coolant pump)
M19Spindle orientation along 0 to 360 degrees
M30The program ends with reset and rewind
M48Turning off the feed rate override cancel
M49Turning on the feed rate override cancel
M60Automatic pallet change
M78B-axis clamp
M79B axis unclamp
M98Subprogram call
M99Subprogram end

G-code Used on CNC Lathes

Since CNC lathes have a unique machining setup, they are programmed using certain lathe-specific codes.

In a CNC program, these lathe-specific G-codes are used with other general G-codes to complete the program.

G32 is an example of one such lathe-specific G-code that is used to execute a CNC threading cycle.

It takes in the input from the CNC operator and removes material to produce different types of threads like circular threads, acme threads, etc.

Following is a list of G-codes used to program CNC Lathes.

G-codeFunction
G00Rapid positioning
G01Linear interpolation
G02Clockwise circular interpolation
G03Anticlockwise circular interpolation
G04Dwell or Pause (used in a separate block)
G09Exact stop (for stopping the axes)
G10Setting programmable input data
G11Data Setting mode cancel
G20Imperial/English units of input
G21Metric units of input
G22Turns on stored stroke check
G23Turns off the stored stroke check
G25Turns on spindle speed fluctuation detection
G26Turns off spindle speed fluctuation detection
G27Checks the machine’s zero position
G28Machine returns to its zero position (point A)
G29The machine returns to point A, then to the location specified on G29
G30The machine returns to point A, then to a zero position (point B)
G31Skip function
G32To cut screw threads
G35Clockwise circular threading cycle
G36Counterclockwise circular threading cycle
G40Cancels the cutter radius compensation
G41Compensates the left cutter radius
G42Compensates the right cutter radius
G50Position register, Set spindle speed range
G52Switches to a local/child zero position
G53Switches to the machine’s default zero position
G54Work coordinate offset 1
G55Work coordinate offset 2
G56Work coordinate offset 3
G57Work coordinate offset 4
G58Work coordinate offset 5
G59Work coordinate offset 6
G61Stops the machine
G62Modal automatic corner override
G64Cutting mode
G65Calling custom macro commands (one time)
G66Calling custom macro commands (on every machine movement)
G67Cancels custom macro call commands
G68Rotates all axes to a specific angle
G69Cancels G68 comand rotation
G70Finishing cycle
G71Rough turning cycle along the Z-axis direction
G72Rough turning cycle along the X-axis direction
G73Pattern repetition cycle
G74Drilling cycle
G75Grooving cycle
G76Threading cycle
G90Cutting cycle A (Group type A)
G90Absolute positioning command (Group type B)
G91Incremental positioning command (Group type B)
G92Thread cutting cycle (Group type A)
G92Registers tool position (Group type B)
G94Cutting cycle B (Group type A)
G94Feedrate per minute (Group type B)
G95Feedrate per revolution (Group type B)
G96Constant surface speed (CSS) cutting mode
G97Cancels G96 command
G98Feedrate per minute (Group type A)
G99Feedrate per revolution (Group type A)

M-codes Used on CNC Lathes

M-CodeFunction
M00Compulsory program stop
M01Optional program stop
M02End of the program (can end with reset, but no rewind)
M03Spindle rotation (normal)
M04Spindle rotation (reverse)
M05Spindle stop
M07Turns on the coolant mist
M08Coolant ON (turns on the coolant pump)
M09Coolant OFF (turns off the coolant pump)
M10Chuck jaw open
M11Chuck jaw close
M12Quill moves toward the tailstock
M13Quill moves out of the tailstock
M17Forward turret indexing
M18Reverse turret indexing
M19Spindle orientation
M21Tailstock move forward
M22Tailstock move backward
M23Gradually pull out of the thread
M24Turns off thread gradual pull-out
M30The program ends with reset and rewind
M41Selects a low-gear transmission
M42Selects a gear higher than on M41 (if any)
M43Selects a gear higher than on M42 (if any)
M44Selects a high-gear transmission
M48Turning off the feed rate override cancel
M49Turning on the feed rate override cancel
M98Subprogram call
M99Subprogram end

List of Letter Blocks on G-code

Letters and numbers are the building blocks of a G-code program. So far, I’ve only listed the popular number blocks. Now I’ll introduce the letter blocks.

G and M are the most used letters in a G-code program. This is because the letter G is used to call out the general functions, and M is used to call the miscellaneous/machine functions.

Following are the other letter blocks used in a G-code program.

LetterDenotes
AMachine’s A-axis
BMachine’s B-axis
CMachine’s C-axis
DDiameter/radius compensation for tool
EPrecise feed rate (used on lathes for threading operations)
FFeed rate
HCutter length
ICenter of an arc along the X-axis
Also in G87 as X offset
JCenter of an arc along the Y-axis
Also in G87 as Y offset
KCenter of an arc along the Z-axis
Also in G87 as Z offset
LNo. of loop repetitions
To specify the register that needed to be edited using G10
NProgram line/block number
ONaming the program
PParameter address forG-codes and M-codes
QFeed increment in canned cycle
RRadius of arc
Retract length in canned cycle
SSpindle speed
TTool selection
UAssociated with A-codes
VAssociated with B-codes
WAssociated with C-codes
XMachine’s X-axis
YMachine’s Y-axis
ZMachine’s Z-axis

List of G-code Commands

CommandG-codes
Non-modalG04, G09, G10, G11, G27, G28, G29, G30, G31, G37, G45, G46, G47, G48, G50, G51, G52, G53, G60, G60, G70, G71, G72, G73, G74, G75, G76, G92
MotionG00, G01, G02, G03
CuttingG32, G35, G36, G90, G92, G94
Feed rateG93, G94, G95
Polar inputG15, G16
Plane selectionG17, G18, G19
DimensioningG90, G91
Stored strokesG22, G23
Unit inputG20, G21
Cutter radius offsetG40, G41, G42
Tool length offsetG43, G44, G49
CyclesG73, G74, G76, G80, G81, G82, G83, G84, G85, G86, G87, G88, G89
ReturnG98, G99
Canceling scaling G50
Image mirroringG68, G69
Coordinate systemG54, G55, G56, G57, G58, G59
Coordinate rotationG68, GG69
Cutting modeG61, G62, G63, G64
Macro modeG66, G67
Constant Surface SpeedG96, G97
Spindle speed fluctuationG25, G26

These G-code commands are used for milling and turning applications, but some of them are job specific.

For example, the polar input, tool length offset, coordinate rotation, return, and plane selection commands are only used for milling jobs.

Whereas in the case of programming lathes, constant surface speed, mirror image, and cutting cycles are some of the lathe-specific commands.

Frequently Asked Questions

What is CNC programming?

CNC programming is the process of automating the machining process of a CNC machine by writing a CNC program using G-code. This task is usually performed by a CNC machinist.

Is learning G-code easy?

Yes,learning G-codeis easy if you understand its structure and its building blocks. A G-code program is a command to the CNC machine directing it to perform specific tasks. If you can understand the purpose of each building block, then you can easily learn CNC programming.

How is the G-code program generated?

The G-code programs are generated using CAM (Computer-Aided Manufacturing) software programs. This software analyses geometrical data from design files and generates program code for specific machines to manufacture the part.

G-code List for CNC [Complete List] - MellowPine (2024)

References

Top Articles
Latest Posts
Article information

Author: Catherine Tremblay

Last Updated:

Views: 6224

Rating: 4.7 / 5 (67 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Catherine Tremblay

Birthday: 1999-09-23

Address: Suite 461 73643 Sherril Loaf, Dickinsonland, AZ 47941-2379

Phone: +2678139151039

Job: International Administration Supervisor

Hobby: Dowsing, Snowboarding, Rowing, Beekeeping, Calligraphy, Shooting, Air sports

Introduction: My name is Catherine Tremblay, I am a precious, perfect, tasty, enthusiastic, inexpensive, vast, kind person who loves writing and wants to share my knowledge and understanding with you.