Hangar CNC

G and M codes explained

G81

Simple drilling cycle (feed to Z, then rapid retract).

Learn this code in 10 minutes

Mini simulator

━ rapid · ━ cutting

Sample program

%
O1000
G21 G17 G40 G49 G80 G90
T1 M06
G54 G00 X0 Y0 S1200 M03
G43 Z5 H1 M08
G81 X10 Y10 Z-10 R2 F80
X30
X50
G80
G00 Z50
M05 M09
M30
%

Line by line

  1. O1000 : Program number: O1000.
  2. G21 G17 G40 G49 G80 G90 : Dimensions in millimetres. XY working plane (milling). Cancels tool radius compensation. Cancels tool length compensation. Cancels the active drilling cycle. Absolute positioning: relative to the work zero.
  3. T1 M06 : Tool change: tool no. 1 goes into the spindle.
  4. G54 G00 X0 Y0 S1200 M03 : Work offset no. 1 (G55 to G59: offsets 2 to 6). Rapid move to X=0, Y=0. Spindle speed: 1200 rpm. Spindle on, clockwise.
  5. G43 Z5 H1 M08 : Activates tool length compensation (H). Rapid move to Z=5. Coolant on.
  6. G81 X10 Y10 Z-10 R2 F80 : Simple drilling cycle (feed to Z, then rapid retract). Drilling down to Z=-10, retract plane R=2, at 80 mm/min.
  7. X30 : Same drilling at X=30.
  8. X50 : Same drilling at X=50.
  9. G80 : Cancels the active drilling cycle.
  10. G00 Z50 : Rapid move to Z=50.
  11. M05 M09 : Spindle stop. Coolant off.
  12. M30 : End of program, rewind to the start.

Common mistakes

Forgetting G80 after the holes: the next line drills again.

Free training, on phone or computer, in 5 languages.

Learn this code in 10 minutes