FANUC CNC Lathe Commands (G/M Code): A Complete Guide | MachineMFG

FANUC CNC Lathe Commands (G/M Code): A Complete Guide

5
(2)

G00▲: Quick Point Positioning

G00 X__Z__

G01: Linear Interpolation

G01 X__Z__F__

G01: Bevel or Fillet Command

G01 X(U)      Z(W)     C
G01 X(U)      Z(W)    R

The values of X (U) and Z (W) represent the coordinates of the hypothetical intersection point between adjacent lines AD and DE within the workpiece coordinate system, where X and Z are the absolute coordinate values, and U and W are the incremental coordinate values. The C value signifies the distance relative to the chamfer starting point. The R value denotes the radius of the fillet arc.

G02: Clockwise Arc Interpolation

G02X__Z__R__F__              
G02X__Z__ I__K__ F__

R represents the radius of the arc. When the central angle of the arc ranges from 0° to 180°, R assumes a positive value; for a central angle between 180° and 360°, R takes on a negative value. I and K denote the incremental coordinates of the arc’s center relative to the X and Z axes from the starting point of the arc, that is, the center’s coordinates subtract the starting point coordinates (I is represented by the radius value). When I and K are zero, they can be omitted.

G03: Counter-clockwise Arc Interpolation

G03 X__Z__R__F__
G03X__Z__ I__K__ F__

Identical to G02.

G04: Pause

G04 X1.5; or G04 P1500; P without a decimal point.

G07.1 (G107): Cylindrical Interpolation

G07.1IPr (Effective); G07.1IP0 (Cancellation);

G10▲: Programmable Data Input

G10 P __X__ Z__R__ Q__

G11: Cancellation of Programmable Data Input

G12.1 (G112): Polar Coordinate Instruction

G13.1▲: Cancellation of Polar Coordinates

G17: Selection of XY Plane

G18▲: Selection of XZ Plane

G19: Selection of YZ Plane

G20: Inch Input

G21: Millimeter Input

G22: Enable Stored Stroke Detection

G23: Disable Stored Stroke Detection

G27: Reference Point Return Check

G27 X(U)     Z(W)

The tool is checked for its return to the designated X, Z coordinates as specified in the program, using the G00 command. If the return is accurate, the indicator light illuminates. However, discrepancies result in system alarms on the machine tool.

G28: Automatic Return to Reference Point

G28 X(U) Z(W); X and Z are the points passed during the return process.

G29: Return to the reference point

G29 X(U)     Z(W)

From the reference point, passing through the midpoint to the specified X and Z positions, the midpoint is the point designated by G28, hence, this command can only appear after G28.

G30: Return to the set point

G30 P2/P3/P4 X Z

P2, P3, P4 represent the 2nd, 3rd, and 4th reference points respectively, while X and Z are the intermediate points.

Meaning: The tool passes through the intermediate points to reach the positions of the 2nd, 3rd, and 4th reference points.

G31: Jump function

G32: Equal pitch threading

G32X(U)_Z(W)_F_Q_

G32 Z(W) F; (Cylindrical thread)

G32 X(U) F; (End face thread)

G32 X(U) Z(W) F; (Conical thread)

Note:

1. When programming, the cut-in and cut-out segments should be incorporated into the thread turning program.

2. For machining conical threads, when the angle α is less or equal to 45 degrees, the thread lead is specified in the Z-axis direction; when the angle α is greater than 45 degrees and less or equal to 90 degrees, the thread lead is specified in the X-axis direction.

3. Q represents the starting angle of the thread, without a decimal point, and the unit is 0.001°.

G34: Variable Pitch Thread

G34  X(U)  Z(W)  F  K ; (Conical thread)

K represents the increment (positive value) or decrement (negative value) of the pitch per revolution, the rest is the same as G32.

G36: Automatic Tool Compensation X

G36 X

G37: Automatic Tool Compensation Z

G37 Z

G40: Tip Radius Compensation Cancellation

G41: Left offset for tool tip radius

G41(G42)G01(G00) X   Z   F
G40 G01(G00) X   Z   F

For the front tool holder, the external circle is G42 with position number 3, and the boring hole is G41 with position number 2. The following figure shows the position number for the front tool holder, with positions 2 and 3, and 1 and 4 reversed on the rear tool holder, while the rest remains the same.

G42: Right offset for tool tip radius

G50: Coordinate system setting or maximum speed limit

G50  X    Z   or G50 S  

G50.3: Workpiece coordinate system preset

G50.2: Polygon turning cancellation

G51: Polygon turning

G52: Local coordinate system

G52 X20 Z20: The X\Z values represent the position of the local coordinate system origin within the original workpiece coordinate system.

If G52 X0 Z0: this cancels the local coordinate system, restoring the original coordinate system origin.

G53: Selection of machine tool coordinate system

Deselect the workpiece coordinate system and choose the machine tool coordinate system.

(G90) G53 X_ Y_ Z_: it’s valid in the absolute command (G90), but invalid in the incremental command (G91).

Note:

(1) The tool diameter offset, tool length offset, and tool position offset must be canceled prior to assigning its G53 command. Otherwise, the machine tool will move according to the assigned offset values.

(2) Before executing the G53 command, manually or using the G28 command, return the machine tool to the origin. This is because the machine tool coordinate system must be set before issuing the G53 command.

G54▲: Selection of workpiece coordinate system 1

G54; Power on by default.

G55-59: Selection of workpiece coordinate systems 2-6

G65: Non-modal call of macro program

Class A uses the FANUC 0TD system, while Class B uses the FANUC 0I system.

Local variables are #1-#33, shared variables are #100-#149, #500-#549, and system variables are #1000 and above.

Macro programs end with M99, and can be invoked with M98 or “G65 P(program number)L(count)”.

The format for Class A programs is: G65 H(a)P(b)Q(c)R(d), where a is the H code, b is the result variable, and c, d are two operation variables.

Class B macro program operation command.

Assignment#i=#jFloor function#i=FUP[#j]
Addition#i=#j+#kNatural logarithm#i=LN[#j]
Subtraction#i=#j-#kExponential function#i=EXP[#j]
Multiplication#i=#j*#kOr#iOR#j
Division#i=#j/#kExclusive or#iXOR#j
Sine#i=SIN[#j]And#iAND#j
Inverse Sine#i=ASIN[#j]BCD to BIN conversion#i=BIN[#j]
Cosine#i=CON[#j]BIN to BCD conversion#i=BCD[#j]
Inverse Cosine#i=ACON[#j]EqualsEQ
Tangent#i=TAN[#j]Not equal toNE
Inverse Tangent#i=ATAN[#j]/[#k]Greater thanGT
Square Root#i=SQRT[#j]Greater than or equal toGE
Absolute Value#i=ABS[#j]Less thanLT
Rounding#i=ROUND[#j]Less than or equal toLE
Ceiling#i=FIX[#j] 

Control command: GOTO n – Unconditional jump

IF [condition expression] GOTO n – Conditional jump statement

WHILE [condition expression] DO m (m=1, 2, 3…) – Loop command

END m;

G66: Macro Program Modal Invocation

G67: Macro Program Modal Invocation Cancellation

G70: Internal and External Cylindrical Fine Turning Compound Fixed Cycle

Programming Format: G70 P(ns) Q(nf)

Where:

  • ns represents the start program segment number of the precision machining process;
  • nf signifies the end program segment number of the precision machining process;

Notes:

(1) The G70 command cannot be used independently; it must be combined with G71, G72, G73 commands to complete the precision machining fixed cycle, i.e., after rough turning the workpiece with G71, G72, G73 commands, G70 is used to specify the precision turning fixed cycle, removing the allowance left by rough machining.

(2) In this case, the F, S, T commands in the G71, G72, G73 program segments are invalid; only the F, S, T in the ns~nf program segments are effective. When the F, S, T commands are not specified in the ns~nf program segments, the F, S, T of the rough turning cycle are effective.

G71: Internal and External Cylindrical Fine Turning Compound Fixed Cycle

Programming Format: G71U (△d) R(e);

G71 P(ns) Q(nf) U (△u) W(△w) F   S   T   ;

Where:

  • ns: Refers to the start program number of the precision machining segment;
  • nf: Refers to the end program number of the precision machining segment;
  • △u: Represents the allowance left for precision machining in the radial direction (X-axis direction) (diameter value);
  • △w: Represents the allowance left for precision machining in the axial direction (Z-axis direction);
  • △d: Represents the depth of cut per time (radius value);
  • e is the radial retraction amount during tool retraction
  • F: Represents the feed speed during rough machining;  S: Represents the spindle speed during rough machining;
  • T: Represents the tool number used during rough machining.Notes:

(1) When the above instruction is used for inner contour machining of the workpiece, △u should be a negative value.

(2) When using G71 for roughing, only the F, S, T functions included in the G71 program segment are effective. The F, S, T functions included in the ns~nf program segment are ineffective for the roughing cycle, even if they are specified. Tool compensation can be performed, and the tool tip radius compensation can be programmed before G70, usually incorporated in the motion approaching the starting point. For example: G42G00X55Z2; G70P10Q20; G40G00X100Z50;

(3) This instruction is applicable where there’s a monotonic increase or decrease in the Z coordinate, and the X coordinate also changes monotonically. The Ns program segment must advance along the X axis, and Z values should not appear.

G72: End-face Rough Turning Composite Fixed Cycle

Programming format: G72W (△d) R(e);

G72 P(ns) Q(nf) U (△u) W(△w) F   S   T   ;

2. d: Z-direction back-cutting amount, without a sign; other parameters are the same as G71. The Ns program segment must feed in the Z direction and cannot contain an X value. When the above command is used for internal contour machining of the workpiece, △u should be a negative value.

Example: As shown in the figure, its program list is:

  • O4534;
  • N10 G50 X100.0 Z100.0;
  • N20 M03 S1000;
  • N30 G00 X100.0 Z5.0 M08;
  • N35 G72W3R0.5
  • N40 G72 P50 Q120 U0.5 W0.2 D3.0 F300;
  • N50 G00 Z-60.0;
  • N60 G01 Z-55.0 F200;
  • N70 X70.0;
  • N80 X50.0 Z-35.0;
  • N90 W15.0;
  • N100 X30;
  • N110 X20.0 W10.0;
  • N120 Z5.0;
  • N130 G00 X100.0 Z100.0 M09;
  • N140 M05;
  • N150 M30;

G73: Contour Duplication Cycle

Programming Format: G73 U(△i) W(△k) R (d);

G73 P(ns) Q(nf) U (△u) W(△w) F   S   T   ;

d: Represents the number of cycles in rough turning (layer count);

△i: During rough turning, the total allowance to be removed in the X-axis direction (tool withdrawal amount) and direction, radius value. That is: the raw size minus the smallest workpiece size divided by 2. The hole is a negative value.

△k: During rough turning, the total allowance to be removed in the Z-axis direction (tool withdrawal amount) and direction; △k is generally zero. The rest is the same as the G71 command.

G74: End-face Grooving Cycle / Drilling Cycle

G75: Radial Grooving Cycle

Programming Format: G75R (e);

G75 X (U) Z(W) P(Δi) Q(Δk) R (d)F;

  • e: Tool retraction distance;
  • X (U) Z(W): Final coordinates of the groove;
  • Δi: Depth of each cut in X direction, expressed as a radius without a sign;
  • Δk: Z-direction shift after the tool completes one radial cut, without a sign.
  • D: Tool retraction distance in the Z-direction when cutting the bottom, usually omitted.
  • F: Cutting feed speed.

Note:

1. The final depth and the final Z-direction offset are calculated by the system itself.

2. Δi, Δk are the minimum programming units, for instance, P1500 means a cut depth of 1.5 mm.

G76: Thread Cutting Compound Cycle

G76 P(m)(r) (α) Q(△d min) R(d)
G76 X(U) Z(W) R(i) P(k) Q(△d) F(L)

  • m — The number of precision machining repetitions, can be between 1 and 99, this is a modal value.
  • r — Chamfer amount at the end of the thread (the distance of oblique tool withdrawal in the Z-direction), it’s 0.0 to 9.9 times the thread pitch, unit is 0.1S, represented by two digits from 00-99.
  • α — Thread tip angle (thread tooth angle), you can select one from the following six options: 80°, 60°, 55°, 30°, 29°, and 0°, determined by two digits. This is a modal value.
  • △d min — Minimum tool back eating amount during cutting, specified as a radius value, in micrometers, without decimal.
  • d — Precision machining allowance, represented as a modal value with decimal radius value, in millimeters.
  • i — The difference in radius between the start and end points of the thread. When i is zero, it indicates standard straight thread cutting.
  • k — Depth of the thread. For external threads, k is calculated as 649.5P, for internal threads, k is calculated as 541.3P, specified as a radius value in micrometers, without decimal.
  • △d — The first cutting depth, specified as a radius value, in micrometers, without decimal.
  • X, Z — In absolute value programming, they represent the coordinates of the thread endpoint under the workpiece coordinate system. In incremental programming, they represent the incremental coordinate values of the cutting endpoint relative to the cycle start point, represented by U and W.
  • L — Thread pitch, in millimeters.

G90: Cylindrical/Conical Surface Single Fixed Cycle

G90 X(U) Z(W) R F;

R indicates half of the difference between the X-coordinate at the start point and the X-coordinate at the end point of the conical surface cutting. It can be negative, where negative indicates a regular cone and positive indicates an inverted cone. Without R, it is cylindrical cutting. Cutting Speed: G00 – G01 – G01 – G00.

G92: Thread Cutting Cycle

G92 X(U) Z(W) F R;

R = (X start point – X end point) / 2. R is non-modal and must be included in every sentence.

G94: End Face Cutting Cycle

Command format: G94 X(U) Z(W) F;

Tapered end face cutting command format: G94 X(U) Z(W) K F

Where, X, Z represent the absolute coordinate value of the cutting segment endpoint;

U, W represent the coordinate increment value of the cutting segment endpoint relative to the cycle start point; F represents feed rate. K represents the difference in Z-coordinate values between the start and end points of the cutting segment (usually a negative value), i.e., K=Z start point – Z end point.

G96: Constant linear speed execution

M3S300; Initial speed

G50S1000; Maximum speed limit 1000

G96S100; Spindle speed 100m/min

G97▲: Cancellation of constant linear speed, speed termination.

G97 S300; Cancellation of constant linear speed, speed is 300r/min

G98: Feed per minute

Unit: mm/min    Example: G98 G01 X20 F200

G99▲: Feed per revolution

Unit: mm/rev   Example: G99 G01 X20 F0.2;

M00: All actions stop.

M01: Program selection stop

Must press: Select stop key for it to be effective, equivalent to M00;

M02: Program termination

Cursor does not return.

M03/M04: Spindle forward (clockwise) / reverse (counter-clockwise)

M03 S300;

M05: Spindle stop

M08/09: Coolant on/off

M30: Program termination

Cursor returns to program start.

M98: Subroutine invocation

Programming format: M98 PxxxxL ;

or M98 Pxxxxxxxx ;

M99: Return to main program

In this, the four digits following the P address after calling represent the subroutine number, the call following the L address represents the call times. When the call times is 1, it can be omitted, and the repeated call times allowed is up to 999. When the eight digits follow the P address, the first four represent the call times, and the last four represent the subroutine number. When the call times is 1, it can be omitted.

If M99 P100; represents returning to the main program N100 program segment, if the subroutine performs M99 L2, it means the subroutine is forced to execute twice, regardless of how many times the main program requests.

T××××: Tool command

In T0101, the first two digits represent the tool number, while the last two digits denote the tool compensation number.

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Comment

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

Scroll to Top