Top 50 G-Codes for CNC Programming

Top 50 G-Codes for CNC Programming

CNC programmers rely heavily on G-codes to control the movements and operations of a machine. G-codes, or “preparatory codes,” instruct the machine on actions such as linear and circular motion, tool changes, spindle control, and coolant activation. Among the most essential G-codes are G00 for rapid positioning, G01 for linear interpolation, G02 and G03 for clockwise and counterclockwise circular interpolation, and G28 for returning to the machine home position. Other frequently used codes include G04 (dwell), G17–G19 (plane selection), G20/G21 (inch/metric selection), G40–G42 (cutter compensation), G43–G44 (tool length compensation), and G54–G59 (work offsets). Mastering these codes ensures precise machining, reduces errors, and streamlines the programming process, making them indispensable for any CNC professional.

Beyond the basics, advanced G-codes expand the programmer’s ability to optimize production. Codes like G73, G81–G89 control drilling cycles, while G90 and G91 manage absolute and incremental positioning. G96 and G97 adjust spindle speed modes, and G98/G99 define return points in cycles. Understanding the interplay of these codes allows for complex multi-axis machining, pocketing, threading, and repetitive operations with minimal manual intervention. By mastering the top 50 G-codes, CNC programmers not only improve efficiency and accuracy but also gain the flexibility to tackle a wide range of machining challenges confidently.

1. G00 – Rapid Positioning

  • Function: Moves the tool quickly to a specified coordinate.
  • Usage: Non-cutting moves to position the tool.
  • Example: G00 X50 Y25 Z5

2. G01 – Linear Interpolation

  • Function: Moves the tool in a straight line at a programmed feed rate.
  • Usage: Cutting along a straight path.
  • Example: G01 X100 Y50 F200

3. G02 – Circular Interpolation Clockwise

  • Function: Moves the tool in a clockwise arc.
  • Usage: Cutting circular paths or arcs.
  • Example: G02 X50 Y50 I10 J0 F100
    (I & J are center offsets from the start point)

4. G03 – Circular Interpolation Counterclockwise

  • Function: Moves the tool in a counterclockwise arc.
  • Example: G03 X50 Y50 I10 J0 F100

5. G04 – Dwell

  • Function: Pauses the machine for a set time.
  • Example: G04 P2 (pauses for 2 seconds)

6. G05 – High-Precision/High-Speed Interpolation

  • Function: Used for smooth cutting with high precision (HSM machines).

7. G06 – Parabolic Interpolation

  • Function: Advanced code for smooth curve interpolation in 5-axis CNCs.

8. G07 – Cylindrical Interpolation

  • Function: Used for turning operations in cylindrical coordinates.

9. G08 – Acceleration Control

  • Function: Used in some CNCs for precise acceleration/deceleration control.

10. G09 – Exact Stop Check

  • Function: Machine stops exactly at the programmed point before continuing.

11. G10 – Programmable Offsets / Tool Offsets

  • Function: Sets work offsets or tool offsets.
  • Example: G10 L2 P1 X0 Y0 Z0 (sets G54 work offset)

12. G11 – Cancel Offsets

  • Function: Cancels previously programmed work offsets.
  • Example: G11 L2 P1

13. G12 – Circular Pocket Milling Clockwise

  • Function: Mill a circular pocket clockwise.
  • Example: G12 X50 Y50 I10 J10 Z-5 F100

14. G13 – Circular Pocket Milling Counterclockwise

  • Function: Mill a circular pocket counterclockwise.
  • Example: G13 X50 Y50 I10 J10 Z-5 F100

15. G15 – Cancel Polar Coordinate Interpolation

  • Function: Cancels polar coordinate mode.

16. G16 – Polar Coordinate Interpolation

  • Function: Program in polar coordinates rather than Cartesian.
  • Example: G16 X100 R90

17. G17 – XY Plane Selection

  • Function: Selects XY plane for circular interpolation (default on milling machines).

18. G18 – XZ Plane Selection

  • Function: Selects XZ plane for circular interpolation.

19. G19 – YZ Plane Selection

  • Function: Selects YZ plane for circular interpolation.

20. G20 – Programming in Inches

  • Function: Sets machine units to inches.
  • Example: G20

21. G21 – Programming in Millimeters

  • Function: Sets machine units to millimeters.
  • Example: G21

22. G28 – Return to Machine Zero

  • Function: Automatically moves tool to machine home position.
  • Example: G28 X0 Y0 Z0

23. G30 – Return to Secondary Home

  • Function: Returns to an alternate reference/home position.
  • Example: G30 X0 Y0 Z0

24. G31 – Skip Function (Probing)

  • Function: Used with CNC probing; moves until contact with a surface.
  • Example: G31 Z-10 F50

25. G33 – Thread Cutting

  • Function: Synchronizes spindle rotation with linear motion for threading.
  • Example: G33 Z-50 K5 F200

26. G34 – Pitch Compensated Threading

  • Function: Advanced threading with variable pitch.

27. G35 – Reverse Pitch Threading

  • Function: Cutting threads with reverse pitch.

28. G40 – Cancel Cutter Compensation

  • Function: Turns off tool radius compensation.

29. G41 – Cutter Compensation Left

  • Function: Offsets the tool to the left of the programmed path.
  • Example: G41 D01 X100 Y50 F150

30. G42 – Cutter Compensation Right

  • Function: Offsets the tool to the right of the programmed path.
  • Example: G42 D01 X100 Y50 F150

31. G43 – Tool Length Compensation Positive

  • Function: Applies tool length offset.
  • Example: G43 H01 Z50

32. G44 – Tool Length Compensation Negative

  • Function: Applies negative tool length offset.

33. G49 – Cancel Tool Length Compensation

  • Function: Cancels G43/G44 offsets.

34. G50 – Spindle Speed Limit / RPM Scaling

  • Function: Sets maximum spindle RPM.
  • Example: G50 S3000

35. G51 – Scaling ON

  • Function: Enables scaling of coordinates.
  • Example: G51 X2 Y2 (double size of moves)

36. G52 – Local Coordinate System

  • Function: Sets temporary work offset.
  • Example: G52 X10 Y20 Z0

37. G53 – Machine Coordinate System

  • Function: Moves using machine coordinates, ignoring work offsets.
  • Example: G53 Z0

38. G54 – Work Offset 1

  • Function: Sets first work coordinate system.
  • Example: G54

39. G55 – Work Offset 2

  • Function: Second work coordinate system.
  • Example: G55

40. G56 – Work Offset 3

  • Function: Third work coordinate system.

41. G57 – Work Offset 4

  • Function: Fourth work coordinate system.

42. G58 – Work Offset 5

  • Function: Fifth work coordinate system.

43. G59 – Work Offset 6

  • Function: Sixth work coordinate system.

44. G61 – Exact Stop Check ON

  • Function: Ensures machine stops at end of move before next move.

45. G64 – Cancel Exact Stop Check

  • Function: Default cutting mode; continuous motion without stopping.

46. G70 – Finishing Cycle (Turning)

  • Function: Finishing cycle in lathe operations.
  • Example: G70 P010 Q020 U0.5 W0.5 F0.25

47. G71 – Rough Turning Cycle

  • Function: Roughing cycle in lathe.
  • Example: G71 P010 Q020 U1 W0.5 F0.25

48. G72 – Finishing Cycle for Facing (Lathe)

  • Function: Finishing facing cycle.

49. G73 – Peck Drilling (High-Speed)

  • Function: High-speed drilling with pecking.
  • Example: G73 Z-20 R2 Q5 F100

50. G81 – Drilling Cycle

  • Function: Standard drilling cycle.
  • Example: G81 Z-20 R2 F150

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *