20 Common G-Code Commands and What They Do

G-code is the language CNC machines use to operate, and understanding its most common commands is essential for beginners and seasoned machinists alike. These commands control the machine’s movements, functions, and tool actions. Let’s dive into 20 of the most frequently used G-code commands, what they do, and why they’re important.

1. G00 – Rapid Positioning

This command moves the tool quickly to a specified position without cutting. It’s used to save time when moving the tool across the workpiece.

Example:

G00 X10 Y20

Moves the tool to X=10, Y=20 as fast as possible.

2. G01 – Linear Interpolation

Used for straight-line cutting at a specified feed rate.

Example:

G01 X10 Y10 F100

Moves the tool to X=10, Y=10 at a feed rate of 100 units per minute.

3. G02 – Circular Interpolation (Clockwise)

Cuts a circular path in a clockwise direction.

Example:

G02 X20 Y20 I10 J0

Cuts a clockwise arc to X=20, Y=20 with a center offset of I=10, J=0.

4. G03 – Circular Interpolation (Counterclockwise)

Cuts a circular path in a counterclockwise direction.

Example:

G03 X20 Y20 I10 J0

Cuts a counterclockwise arc to X=20, Y=20 with a center offset of I=10, J=0.

5. G20 – Set Units to Inches

Sets the machine to use inches as the unit of measurement.

Example:

G20

Switches to inch mode.

6. G21 – Set Units to Millimeters

Sets the machine to use millimeters as the unit of measurement.

Example:

G21

Switches to millimeter mode.

7. G28 – Return to Home Position

Sends the tool to the machine’s predefined home position.

Example:

G28

Moves the tool to the home position.

8. G90 – Absolute Positioning

Specifies that all coordinates are absolute, relative to the origin.

Example:

G90

Ensures coordinates refer to the origin.

9. G91 – Incremental Positioning

Specifies that all coordinates are incremental, relative to the current position.

Example:

G91

Switches to incremental mode.

10. G40 – Cancel Tool Radius Compensation

Disables any tool radius compensation that was previously applied.

Example:

G40

Turns off tool radius compensation.

11. G41 – Tool Radius Compensation Left

Offsets the tool to the left of the programmed path to account for its radius.

Example:

G41 D1

Activates left compensation using tool diameter 1.

12. G42 – Tool Radius Compensation Right

Offsets the tool to the right of the programmed path to account for its radius.

Example:

G42 D1

Activates right compensation using tool diameter 1.

13. G17 – Select XY Plane

Specifies that cutting will take place in the XY plane.

Example:

G17

Cuts are made in the XY plane.

14. G18 – Select ZX Plane

Specifies that cutting will take place in the ZX plane.

Example:

G18

Cuts are made in the ZX plane.

15. G19 – Select YZ Plane

Specifies that cutting will take place in the YZ plane.

Example:

G19

Cuts are made in the YZ plane.

16. G43 – Apply Tool Length Compensation

Adjusts for the length of the tool to ensure accurate machining.

Example:

G43 H1

Applies tool length offset for tool number 1.

17. G49 – Cancel Tool Length Compensation

Disables any tool length compensation that was previously applied.

Example:

G49

Turns off tool length compensation.

18. M03 – Spindle On (Clockwise)

Turns the spindle on in a clockwise direction.

Example:

M03

Starts the spindle spinning clockwise.

19. M05 – Spindle Stop

Turns the spindle off.

Example:

M05

Stops the spindle.

20. M06 – Tool Change

Initiates a tool change.

Example:

M06 T2

Changes to tool number 2.

360 Key Takeaways

  • G-code commands control every aspect of CNC machine operation, from movement to tool changes.
  • Basic commands like G00, G01, and M03 are essential for getting started.
  • Understanding G-code allows you to troubleshoot and customize programs for specific projects.
  • Practice and experimentation are key to mastering G-code programming.

Conclusion

Learning G-code commands might seem challenging at first, but it’s a crucial step in becoming a confident CNC operator. Start by familiarizing yourself with these 20 common commands, and you’ll have a solid foundation to tackle more complex projects. Remember, practice makes perfect, so don’t hesitate to experiment and learn by doing.