G Code

SECTION 1 – Common G-Codes

Know the function of each code.

G-code

Function

G00

Rapid positioning

G01

Linear interpolation

G02

Clockwise circular interpolation

G03

Counterclockwise circular interpolation

G04

Dwell

G18

X-Z plane selection

G20

Inch programming

G21

Metric programming

G28

Return to machine reference

G40

Cancel tool nose compensation

G41

Tool nose compensation left

G42

Tool nose compensation right

G50

Maximum spindle speed / coordinate setting, depending on control

G54–G59

Work coordinate systems

G70

Finishing cycle

G71

Longitudinal roughing cycle

G72

Facing roughing cycle

G73

Pattern repeating cycle

G74

Face grooving / peck drilling cycle

G75

OD/ID grooving cycle

G76

Multiple-pass threading cycle

G96

Constant surface speed

G97

Constant RPM

G98

Feed per minute

G99

Feed per revolution

SECTION 2 – G71 Longitudinal Roughing Cycle

Typical two-block format:

G71 U(depth) R(retract);

G71 P(start) Q(end) U(X allowance) W(Z allowance) F(feed);

Individual variables:

Variable

Meaning

U (first line)

Depth of cut in X

R

Retract amount between passes

P

First profile block number

Q

Last profile block number

U (second line)

X finishing allowance

W

Z finishing allowance

F

Cutting feed rate

Test questions

  1. What does the first-line U control?

  2. What does R control?

  3. What does P identify?

  4. What does Q identify?

  5. What does second-line U control?

  6. What does W control?

  7. Why would you leave finishing material on the part?

  8. What happens if P and Q reference the wrong blocks?

SECTION 3 – G70 Finishing Cycle

Typical format:

G70 P(start) Q(end);

Variable

Meaning

P

First profile block

Q

Last profile block

Test questions

  1. What is the purpose of G70?

  2. What does P identify?

  3. What does Q identify?

  4. Does G70 perform the roughing operation?

  5. Which cycle is commonly used before G70?

SECTION 4 – G72 Facing Roughing Cycle

Typical two-block format:

G72 W(depth) R(retract);

G72 P(start) Q(end) U(X allowance) W(Z allowance) F(feed);

Variable

Meaning

W (first line)

Depth of cut in Z

R

Retract amount

P

First profile block

Q

Last profile block

U

X finishing allowance

W (second line)

Z finishing allowance

F

Feed rate

Test questions

  1. What is the primary purpose of G72?

  2. What does first-line W control?

  3. What does second-line W control?

  4. How does G72 differ from G71?

SECTION 5 – G73 Pattern Repeating Cycle

Typical format:

G73 U(depth) W(depth) R(number of passes);

G73 P(start) Q(end) U(X allowance) W(Z allowance) F(feed);

Variable

Meaning

U (first line)

X direction pattern offset

W (first line)

Z direction pattern offset

R

Number of roughing passes

P

First profile block

Q

Last profile block

U (second line)

X finishing allowance

W (second line)

Z finishing allowance

F

Feed rate

Test questions

  1. What type of work is G73 best suited for?

  2. What does first-line U represent?

  3. What does first-line W represent?

  4. What does R determine?

  5. How is G73 different from G71?

SECTION 6 – G74 Through G76

G74 – Face Grooving / Peck Drilling

Variable

Meaning

X

Final X position

Z

Final Z position

R

Retract amount

P

Peck amount in X, commonly specified in integer units

Q

Peck amount in Z, commonly specified in integer units

F

Feed rate

G75 – OD/ID Grooving

Variable

Meaning

X

Final X position

Z

Final Z position

P

Peck increment in X

Q

Z-direction step

R

Retract amount

F

Feed rate

G76 – Multiple-Pass Threading

Common two-block format:

G76 P(m r a) Q(minimum cut) R(finish allowance);

G76 X(final diameter) Z(final length) R(taper) P(thread height) Q(first cut) F(pitch);

Variable

Meaning

P (first block)

Finish passes, chamfer amount, tool angle

Q (first block)

Minimum depth of cut

R (first block)

Finishing allowance

X

Final thread diameter

Z

Thread endpoint

R (second block)

Thread taper amount

P (second block)

Thread height

Q (second block)

First-pass depth

F

Thread pitch

SECTION 7 – Common M-Codes

M-code

Function

M00

Program stop

M01

Optional stop

M02

Program end

M03

Spindle clockwise

M04

Spindle counterclockwise

M05

Spindle stop

M08

Coolant on

M09

Coolant off

M30

Program end and reset

M98

Subprogram call

M99

Subprogram return / loop

Important: Chuck, tailstock, turret, and other auxiliary M-codes are often machine-builder specific. Always verify your machine’s M-code list.

SECTION 8 – Spindle and Feed Commands

Command

Function

S

Spindle speed

F

Feed rate

T

Tool selection and offset

X

X-axis position

Z

Z-axis position

I

X arc center offset

K

Z arc center offset

R

Radius or cycle-specific retract value