G code/M code List
This list contains common codes from various builders. Note that all machines are configured differently, and codes—especially those above M79—often vary between manufacturers. Always confirm with your machine tool builder to ensure accuracy.
Typical G Command for a machining-center
| G code | Group | Function |
|---|---|---|
| *G00 | 01 | Positioning (rapid traverse) |
| *G01 | 01 | Linear interpolation (cutting feed) |
| G02 | 01 | Circular interpolation CW or helical interpolation CW (clockwise) |
| G03 | 01 | Circular interpolation CCW or helical interpolation CCW(counterclockwise) |
| G04 | 00 | Dwell |
| G05 | 00 | Al contour control (high-precision contour control compatible command |
| G05.1 | 00 | Al contour control /Smooth tolerance+ control |
| G05.4 | 00 | HRV3 on/off |
| G07.1 (G107) | 00 | Cylindrical interpolation |
| G08 | 00 | Al contour control (advanced preview control compatible command) |
| G09 | 00 | Exact stop |
| G10 | 00 | Programmable data input |
| G10.6 | 00 | Tool retract and recover |
| G10.8 | 00 | Programmable internal data change |
| G11 | 00 | Programmable data input mode cancel |
| *G15 | 17 | Polar coordinates command cancel |
| G16 | 17 | Polar coordinates command |
| *G17 | 02 | XpYp plane selection, Xp: X axis or its parallel axis |
| *G18 | 02 | ZpXp plane selection, Yp: Y axis or its parallel axis |
| *G19 | 02 | YpZp plane selection, Zp: Z axis or its parallel axis |
| G20 (G70) |
06 | Input in inch |
| G21 (G71) |
06 | Input in mm |
| *G22 | 04 | Stored stroke check function on |
| G23 | 04 | Stored stroke check function off |
| *G25 | 19 | Spindle speed fluctuation detection off |
| G26 | 19 | Spindle speed fluctuation detection on |
| G27 | 00 | Reference position return check |
| G28 | 00 | Automatic return to reference position |
| G28.2 | 00 | In-position check disable reference position return |
| G29 | 00 | Movement from reference position |
| G30 | 00 | 2nd, 3rd and 4th reference position return |
| G30.2 | 00 | In-position check disable 2nd, 3rd, or 4th reference position return |
| G31 | 00 | Skip function |
| G31.8 | 00 | EGB-axis skip |
| G33 | 01 | Threading |
| G37 | 00 | Automatic tool length measurement |
| G38 | 00 | Tool radius/tool nose radius compensation: preserve vector |
| G39 | 00 | Tool radius/tool nose radius compensation: corner circular interpolation |
| *G40 | 07 | Tool radius/tool nose radius compensation: cancel |
| G41 | 07 | Tool radius/tool nose radius compensation: left |
| G42 | 07 | Tool radius/tool nose radius compensation: right |
| G40.1 | 18 | Normal direction control cancel mode |
| G41.1 | 18 | Normal direction control on: let |
| G42.1 | 18 | Normal direction control on: right |
| G43 | 08 | Tool length compensation + |
| G44 | 08 | Tool length compensation - |
| G43.7 | 08 | Tool offset |
| G45 | 00 | Tool offset: increase |
| G46 | 00 | Tool offset: decrease |
| G47 | 00 | Tool offset: double increase |
| G48 | 00 | Tool offset: double decrease |
| *G49(G49.1) | 08 | Tool length compensation cancel |
| *G50 | 11 | Scaling cancel |
| G51 | 11 | Scaling |
| *G50.1 | 22 | Programmable mirror image cancel |
| G51.1 | 22 | Programmable mirror image |
| G50.4 | 00 | Cancel synchronous control |
| G50.5 | 00 | Cancel composite control |
| G50.6 | 00 | Cancel superimposed control |
| G51.4 | 00 | Start synchronous control |
| G51.5 | 00 | Start composite control |
| G51.6 | 00 | Start superimposed control |
| G52 | 00 | Local coordinate system setting |
| G53 | 00 | Machine coordinate system setting |
| G53.1 | 00 | Tool axis direction control |
| G53.2 | 00 | Selecting a machine coordinate system with feedrate |
| G53.6 | 00 | Tool center point retention type tool axis direction control |
| *G54 (G54.1) | 14 | Workpiece coordinate system 1 selection |
| G55 | 14 | Workpiece coordinate system 2 selection |
| G56 | 14 | Workpiece coordinate system 3 selection |
| G57 | 14 | Workpiece coordinate system 4 selection |
| G58 | 14 | Workpiece coordinate system 5 selection |
| G59 | 14 | Workpiece coordinate system 6 selection |
| G60 | 00 | Single direction positioning |
| G61 | 15 | Exact stop mode |
| G62 | 15 | Automatic corner override |
| G63 | 15 | Tapping mode |
| *G64 | 15 | Cutting mode |
| G65 | 00 | Macro call |
| G66 | 12 | Macro modal call A |
| G66.1 | 12 | Macro modal call B |
| *G67 | 12 | Macro modal call A/B cancel |
| G68 | 16 | Coordinate system rotation start or 3-dimensional coordinate conversion mode on |
| *G69 | 16 | Coordinate system rotation cancel or 3-dimensional coordinate conversion mode off |
| G68.2 | 16 | Tilted working plane indexing |
| G68.3 | 16 | Tilted working plane indexing by tool axis direction |
| G68.4 | 16 | Tilted working plane indexing (incremental multi-command) |
| G70.7 | 00 | Finishing cycle |
| G71.7 | 00 | Outer surface rough machining cycle |
| G72.7 | 00 | End rough machining cycle |
| G73.7 | 00 | Closed loop cutting cycle |
| G74.7 | 00 | End cutting off cycle |
| G75.7 | 00 | Outer or inner cutting off cycle |
| G76.7 | 00 | Multiple threading cycle |
| G72.1 | 00 | Figure copying(rotary copy) |
| G72.2 | 00 | Figure copying (linear copy) |
| G73 | 09 | Peck drilling cycle |
| G74 | 09 | Left-handed tapping cycle |
| G75 | 01 | Plunge grinding cycle |
| G76 | 09 | Fine boring cycle |
| G77 | 01 | Plunge direct sizing/grinding cycle |
| G78 | 01 | Continuous-feed surface grinding cycle |
| G79 | 01 | Intermittent-feed surface grinding cycle |
| *G80 | 09 | Canned cycle cancel Electronic gear box: synchronization cancellation |
| *G80.4 | 34 | Electronic gear box: synchronization cancellation |
| *G80.5 | 24 | Electronic gear box 2 pair: synchronization cancellation |
| G81 | 09 | Drilling cycle or spot boring cycle Electronic gear box: synchronization start |
| G81.4 | 34 | Electronic gear box: synchronization start |
| G81.5 | 24 | Electronic gear box 2 pair: synchronization start |
| G82 | 09 | Drilling cycle or counter boring cycle |
| G83 | 09 | Peck drilling cycle |
| G84 | 09 | Tapping cycle |
| G84.2 | 09 | Rigid tapping cycle (FS15 format) |
| G84.3 | 09 | Left-handed rigid tapping cycle (FS15 format) |
| G85 | 09 | Boring cycle |
| G86 | 09 | Boring cycle |
| G87 | 09 | Back boring cycle |
| G88 | 09 | Boring cycle |
| G89 | 09 | Boring cycle |
| G90 | 03 | Absolute programming |
| *G91 | 03 | Incremental programming |
| G91.1 | 00 | Checking the maximum incremental amount specified |
| G92 | 00 | Setting for workpiece coordinate system or clamp at maximum spindle speed |
| G92.1 | 00 | Workpiece coordinate system preset |
| G93 | 05 | Inverse time feed |
| *G94 | 05 | Feed per minute |
| G95 | 05 | Feed per revolution |
| G96 | 13 | Constant surface speed control |
| *G97 | 13 | Constant surface speed control cancel |
| G96.1 | 00 | Spindle indexing execution (waiting for completion) |
| G96.2 | 00 | Spindle indexing execution (not waiting for completion) |
| G96.3 | 00 | Spindle indexing completion check |
| G96.4 | 00 | SV speed control mode ON |
| *G98 | 10 | Canned cycle: return to initial level |
| G99 | 10 | Canned cycle: return to R point level |
| G107 | 00 | Cylindrical interpolation |
| *G160 | 20 | Infeed control cancel |
| G161 | 20 | Infeed control |
Note:
- When the power is turned on or the cleared state is set by a reset (bit 6 (CLR) of parameter No. 3402 is set to 1), modal G codes are placed in the following states:
(1)G codes marked with "*"in G code lists are enabled.
(2)When the system is cleared due to power-on or reset, whichever specified, either G20 or G21, remains effective.
(3) Bit 7(G23) of parameter No. 3402 is used to specify whether G22 or G23 is to be selected upon power-on. The selection of G22 or G23 is not, however.changed when the CNC is cleared upon a reset. When the system is cleared due to reset, whichever specified, either G22 or G23, remains effective. - G codes of group 00 except G10 and G11 are single-shot G codes.
- Alarm PS0010 is displayed when a G code not listed in the G code list is specified or a G code without a corresponding option is specified.
- G codes of different groups can be specified in the same block.If G codes of the same group are specified in the same block, the G code specified last is valid.
- If a G code of group 01 is specified in a canned cycle for drilling, the canned cycle is canceled in the same way as when a G80 command is specified. G codes of group 01 are not affected by G codes for specifying a canned cycle
- When G code system A is used for a canned cycle for drilling, only the initial level is provided at the return point.
- G codes are displayed for each group number.
Reference: 《FANUC Series 0i-MODEL F Plus CONNECTION MANUAL_FUNCTION, B-64693EN/01》
Typical M Command for a machining-center
The following table provides a detailed list of the most commonly used M codes in FANUC machining centers, along with their corresponding functions:
| M Code | Function Description | Key Notes |
|---|---|---|
| M00 | Program Stop | This code brings the machining program to a complete halt. All machine movements, including spindle rotation and coolant flow, stop. It is often used for operator - performed tasks such as inspecting the workpiece, measuring dimensions, or cleaning chips during the machining process. The program can only resume when the operator presses the "Cycle Start" button. |
| M01 | Optional Stop | Similar to M00, M01 also stops the program. However, its activation depends on the setting of the "Optional Stop" switch on the machine control panel. If the switch is in the "ON" position, the program stops when M01 is encountered; if it is in the "OFF" position, the program skips M01 and continues running. This provides flexibility for operators to decide whether to stop the program at specific points. |
| M02 | End of Program | M02 marks the end of the main machining program. When this code is executed, all machine axes stop moving, the spindle stops rotating, and the coolant is turned off. Unlike M30, M02 does not rewind the program to the beginning. After M02 is executed, the machine remains in the end - of - program state, and the operator needs to manually reset the program or load a new program to start a new machining cycle. |
| M03 | Spindle on Clockwise | Executing M03 starts the spindle rotating in the clockwise direction (when viewed from the front of the spindle). Before using M03, the operator must ensure that the spindle speed (S code) has been set correctly. The spindle will rotate at the specified speed until another spindle - related M code (such as M05) is encountered. |
| M04 | Spindle on Counter - Clockwise | M04 is used to start the spindle rotating in the counter - clockwise direction (also viewed from the front of the spindle). Just like M03, a corresponding S code (spindle speed) must be specified before M04 is executed. This code is commonly used in machining operations that require reverse spindle rotation, such as certain types of threading or milling. |
| M05 | Spindle Stop | M05 stops the rotation of the spindle immediately. Once M05 is executed, the spindle will decelerate and come to a complete stop. It is typically used at the end of a machining operation or when the spindle needs to be stopped temporarily for tasks like tool changing (though M06 usually handles spindle stopping in conjunction with tool change) or workpiece handling. |
| M06 | Tool Change | M06 is the code used to initiate the automatic tool change process. When M06 is called, the machine first stops the spindle (if it is rotating), moves the spindle to the tool change position, and then exchanges the current tool in the spindle with the next tool specified by the tool number (T code). Proper tool setup and calibration are essential to ensure accurate and smooth tool changes when using M06. |
| M08 | Coolant on | M08 turns on the coolant system, which sprays coolant onto the cutting tool and workpiece during machining. Coolant serves multiple purposes, including reducing the temperature generated by the cutting process (preventing tool overheating and workpiece thermal deformation), lubricating the cutting interface (reducing friction and tool wear), and flushing away chips from the cutting area. The coolant flow rate can usually be adjusted on the machine control panel. |
| M09 | Coolant off | M09 shuts off the coolant system, stopping the flow of coolant to the cutting area. It is commonly used at the end of a machining operation, during tool changes, or when the coolant is not needed temporarily (such as during workpiece inspection). Turning off the coolant when not in use helps conserve coolant and prevent unnecessary splashing. |
| M10 | Clamp | M10 activates the workpiece clamping mechanism, securing the workpiece firmly to the machine table or fixture. A secure workpiece clamp is essential to prevent movement or vibration during machining, which can affect the accuracy of the machined part. The clamping force should be set appropriately based on the size, material, and machining requirements of the workpiece. |
| M11 | Unclamp | M11 releases the workpiece clamping mechanism, allowing the operator to remove the finished workpiece or load a new one. It is important to ensure that all machining operations have been completed and that the spindle and other moving parts are stopped before executing M11 to avoid any safety hazards. |
| M30 | End of Program and Rewind to Beginning | M30 not only marks the end of the main program (similar to M02) but also rewinds the program to the beginning. After M30 is executed, the machine resets to the initial state, and the program is ready to be run again with the press of the "Cycle Start" button. This is particularly useful for batch production, where the same machining program needs to be repeated multiple times. |
| M98 | Call Subprogram | M98 is used to call a subprogram from the main program. Subprograms are small, self - contained programs that perform specific repetitive operations (such as drilling a series of holes or milling a specific contour). By calling a subprogram with M98, the main program can be simplified, reducing programming time and the chance of errors. The format of M98 usually includes the subprogram number and the number of times the subprogram should be repeated (if applicable). |
| M99 | End Subprogram | M99 marks the end of a subprogram. When M99 is executed, the control system returns to the main program and continues running from the line immediately following the M98 code that called the subprogram. In some cases, M99 can also be used to loop the subprogram by specifying a return line number within the subprogram. |
Note:
- Sequence of Execution: M codes are typically executed after the completion of the preceding G code movements. However, some M codes (such as M03 and M08) can be set to execute simultaneously with G code movements (using the "M code execution with movement" function) to save cycle time. Operators should be familiar with the machine's specific settings regarding the sequence of M code execution.
- Compatibility with Machine Configuration: Different models of FANUC machining centers may have additional or modified M codes based on their specific configurations (such as the type of tool changer, coolant system, or workpiece clamping mechanism). Always refer to the machine's operation manual for the exact M code functions applicable to the specific machine.
- Safety First: Before executing any M code, operators must ensure that the machine is in a safe state. For example, before executing M06 (tool change), check that the spindle is at the correct tool change position and that there are no obstacles in the tool change path. Before executing M10 (clamp) or M11 (unclamp), ensure that the workpiece is properly positioned to avoid damage to the workpiece or machine.
- Testing and Verification: When using a new program or unfamiliar M codes, it is recommended to run the program in "dry run" mode (without cutting tools or workpiece) first to verify the correctness of the M code operations. This helps identify any potential errors or issues before actual machining, preventing damage to the machine, tools, or workpiece.
Typical MDI Commands for a Lathe
1. Tool Change and Spindle Control
- M06 T08;
Command Function: Performs a tool change to tool number 8
Parameter Details:
- "M06": Core command for automatic tool change, triggering the machine's tool change mechanism to operate.
- "T08": Specifies the target tool number as 8. The tool number must match the actual tool number in the tool magazine (e.g., Tool 8 can be an end mill with a diameter of 10mm).
- S1500 M03;
Command Function: Turns spindle on clockwise to 1500 rpm
Parameter Details:
- "S1500": Sets the spindle speed to 1500 revolutions per minute. The speed must match the tool material and workpiece material (e.g., this speed is commonly used when machining aluminum alloy with carbide tools).
- "M03": Starts spindle rotation in the clockwise direction. The direction is determined by viewing from the front of the spindle, and it is suitable for conventional cutting scenarios such as milling and drilling.
- G01 X18.2 F15.5;
Command Function: Moves the X axis to position 18.2 at a feedrate of 15.5
Parameter Details:
- "G01": Activates linear interpolation mode, ensuring the axis moves smoothly along a straight line, which is used for cutting operations or precise positioning.
- "X18.2": Defines the target absolute coordinate of the X axis as 18.2 mm. The coordinate unit is millimeters by default and must be consistent with the machine settings.
- "F15.5": Sets the feedrate to 15.5 mm/min. The feedrate needs to be adjusted according to the machining accuracy requirements; lower feedrates are usually used for finish machining.
2. Axis Movement Control
- G00 X25.0 Y30.5 Z40.2;
Command Function: G00 Move in rapid travel
Parameter Details:
- "G00": Enables rapid traverse mode, which is high-speed positioning in non-cutting states. The speed is preset by machine parameters, usually 3000-5000 mm/min.
- "X25.0": Target X-axis coordinate (25.0mm), used to avoid workpiece fixtures and prevent collisions.
- "Y30.5": Target Y-axis coordinate (30.5mm), close to the machining area to reduce the subsequent machining movement distance.
- "Z40.2": Target Z-axis coordinate (40.2mm), ensuring the tool is above the workpiece surface to avoid scratching the workpiece.
- G01 X32.8 Y22.6 Z15.3 F20.8;
Command Function: G01 Move in a straight line
Parameter Details:
- "G01": Linear interpolation mode, the core movement command for cutting operations.
- "X32.8/Y22.6/Z15.3": Target coordinates of the X, Y, and Z axes (32.8mm, 22.6mm, 15.3mm respectively), corresponding to the workpiece machining position (e.g., milling the side of a rectangular workpiece).
- "F20.8": Feedrate set to 20.8 mm/min, suitable for finish machining of aluminum alloy to balance efficiency and surface quality.
- G02 X45.5 Y18.9 Z8.7 I2.3 J-1.8 K0 F18.3;
Command Function: G02 Move along a clockwise circular path
Parameter Details:
- "G02": Clockwise circular interpolation, used for machining convex arcs or the clockwise segment of inner arcs.
- "X45.5/Y18.9/Z8.7": Absolute coordinates of the arc's end point (45.5mm for X, 18.9mm for Y, 8.7mm for Z), determining the end position of the arc.
- "I2.3/J-1.8/K0": Relative coordinates from the arc's start point to the center. I=2.3mm means the center is 2.3mm in the positive X-direction from the start point; J=-1.8mm means the center is 1.8mm in the negative Y-direction from the start point; K=0 means no offset in the Z-axis direction, which is used to determine the arc radius and direction.
- "F18.3": Feedrate for circular movement (18.3mm/min), preventing over-cutting or rough surfaces during arc machining.
- G03 X52.1 Y27.4 Z6.9 I-3.5 J2.1 K0 F16.7;
Command Function: G03 Move along a counter-clockwise circular path
Parameter Details:
- "G03": Counter-clockwise circular interpolation, used for machining concave arcs or the counter-clockwise segment of outer arcs.
- "X52.1/Y27.4/Z6.9": End point coordinates of the arc (52.1mm for X, 27.4mm for Y, 6.9mm for Z).
- "I-3.5/J2.1/K0": Relative offset from the start point to the arc center. I=-3.5mm is 3.5mm in the negative X-direction; J=2.1mm is 2.1mm in the positive Y-direction; K=0 means no offset in the Z-axis direction.
- "F16.7": Feedrate for counter-clockwise arc (16.7mm/min), suitable for machining cast iron materials.
- G04 X3.2;
Command Function: G04 Pause machine operation
Parameter Details:
- "G04": Dwell command, used for short stays during machining (e.g., chip removal at the bottom of holes, eliminating cutting stress).
- "X3.2": Dwell time specified with a decimal point, with the unit being seconds. The value 3.2 means a pause of 3.2 seconds.
- G04 P4800;
Command Function: G04 Pause machine operation
Parameter Details:
- "G04": Dwell command.
- "P4800": Dwell time specified without a decimal point, with the unit being milliseconds. The value 4800 means a pause of 4800 milliseconds (i.e., 4.8 seconds), which is suitable for scenarios requiring precise control of short pauses (e.g., stabilizing thread forming after tapping).
3. Reference Point Return
- G28 G90 X12.5 Y8.7;
Command Function: G28 Return to reference point; G90 Absolute positioning
Parameter Details:
- "G28": Triggers return to the machine's reference point. The reference point is the machine's preset mechanical origin, used for calibrating axis coordinates.
- "G90": Activates absolute positioning mode, where all coordinates are calculated based on the machine origin.
- "X12.5/Y8.7": Intermediate absolute coordinates before returning to the reference point (12.5mm for X, 8.7mm for Y), serving as a safe transition position for the machine to avoid collisions with components during movement.
- G28 G91 X-6.3 Y-5.9;
Command Function: G28 Return to reference point; G91 Incremental positioning
Parameter Details:
- "G91": Enables incremental positioning mode, where coordinates are calculated based on the current position.
- "X-6.3/Y-5.9": Incremental movement distances before returning to the reference point. X=-6.3mm means moving 6.3mm in the negative X-direction; Y=-5.9mm means moving 5.9mm in the negative Y-direction, used to avoid convex parts of the workpiece.
- "G28": Returns to the reference point after completing the incremental movement.
- G28 G91 X0.0 Y0.0;
Command Function: G28 Return to reference point; G91 Incremental positioning
Parameter Details:
- "G91": Incremental positioning mode.
- "X0.0/Y0.0": No incremental movement in the X and Y axes, meaning starting directly from the current position.
- "G28": Directly returns to the reference point from the current location, suitable for scenarios where the tool is unobstructed after machining.
4. Cutter Compensation Control
- G41 D05 X29.4;
Command Function: G41 Cutter Comp Left
Parameter Details:
- "G41": Activates left cutter radius compensation. The compensation value is added to the left side of the machining path, used for left contour machining.
- "D05": Calls the 5th cutter radius offset parameter. The compensation value is preset in the machine parameters (e.g., Compensation 5 corresponds to a tool radius of 5.2mm).
- "X29.4": X-axis movement to activate compensation (moving to the 29.4mm position on the X-axis). The compensation is activated during the movement to ensure smooth transition of the tool when the compensation takes effect.
- G42 D07 X37.8;
Command Function: G42 Cutter Comp Right
Parameter Details:
- "G42": Activates right cutter radius compensation. The compensation value is added to the right side of the machining path, used for right contour machining.
- "D07": Calls the 7th cutter radius offset parameter (e.g., corresponding to a ball end mill with a radius of 3.8mm).
- "X37.8": X-axis movement to trigger compensation (moving to the 37.8mm position on the X-axis), triggering the compensation to take effect, suitable for finish machining of curved contours.
- G40 X22.1;
Command Function: G40 Cancel Cutter Comp
Parameter Details:
- "G40": Cancels cutter radius compensation, preventing dimensional deviations caused by residual compensation in subsequent machining.
- "X22.1": X-axis target position for compensation cancellation (22.1mm position on the X-axis). A safe position in the non-machining area is selected to ensure the tool does not collide with the workpiece during the cancellation process.
5. Tool Length Offset Control
- G43 H12 Z19.6;
Command Function: G43 Add offset amount
Parameter Details:
- "G43": Activates positive tool length offset. The compensation value is added to the Z-axis coordinate, used to adjust the difference between the actual tool length and the standard length.
- "H12": Calls the 12th tool length offset parameter (e.g., the compensation value is 158.7mm, corresponding to the length of an extended end mill).
- "Z19.6": Z-axis target position after offset (19.6mm position on the Z-axis), ensuring the tool tip accurately contacts the workpiece machining surface.
- G44 H09 Z14.3;
Command Function: G44 Subtract offset amount
Parameter Details:
- "G44": Activates negative tool length offset. The compensation value is subtracted from the Z-axis coordinate, suitable for reverse-clamped tools.
- "H09": Calls the 9th tool length offset parameter (e.g., the compensation value is 126.5mm, corresponding to a short-edge drill).
- "Z14.3": Z-axis target position after offset subtraction (14.3mm position on the Z-axis), ensuring accurate machining depth of the tool.
- G49 H13 Z0.0;
Command Function: G49 Cancel Offset
Parameter Details:
- "G49": Cancels tool length offset, restoring the original calculation method of the Z-axis coordinate.
- "H13": Specifies the 13th tool length offset to cancel (e.g., Offset 13 corresponds to a tool length of 142.9mm).
- "Z0.0": Z-axis target position after cancellation (0.0mm position on the Z-axis, i.e., Z-axis zero return), facilitating subsequent tool changes or coordinate calibration.
6. Macro Program Call
- G65 P1002 L05;
Command Function: G65 Macro call (Modal)
Parameter Details:
- "G65": Modal macro call command. After calling, the macro program remains effective until canceled by another command.
- "P1002": Specifies the macro program number as 1002. Macro Program 1002 is preset as a repeated drilling program.
- "L05": Sets the number of macro repetitions to 5, i.e., continuously machining 5 holes of the same specification.
- G66 P2008;
Command Function: G66 Macro call (Non-Modal)
Parameter Details:
- "G66": Non-modal macro call command. It is executed only once and does not require manual cancellation.
- "P2008": Specifies the macro program number as 2008 (e.g., Program 2008 is a single-time program for special curved surface milling).
7. Machining Cycle Control
- G73 X28.6 Y19.3 Z-25.8 R5.2 Q3.6 F12.8 K04;
Command Function: G73 High speed peck drilling cycle
Parameter Details:
- "G73": High-speed peck drilling cycle. It performs segmented drilling to quickly remove chips, suitable for deep hole machining.
- "X28.6/Y19.3": Absolute coordinates of the drill hole (28.6mm for X, 19.3mm for Y), determining the position of the hole.
- "Z-25.8": Z-axis coordinate of the hole bottom (-25.8mm), i.e., the drilling depth is 25.8mm. The negative value indicates it is below the workpiece surface.
- "R5.2": Z-axis coordinate of the retract plane (5.2mm on the Z-axis). The tool retracts to this plane after drilling to avoid scratching the workpiece.
- "Q3.6": Depth of each peck stroke (3.6mm), i.e., the tool retracts once to remove chips after drilling 3.6mm.
- "F12.8": Feedrate for drilling (12.8mm/min).
- "K04": Number of repeats to drill (4 holes), i.e., repeatedly machining 4 holes of the same specification according to this parameter.
- G74 X35.9 Y24.7 Z-32.1 R4.8 P2.5 F10.5 K03;
Command Function: G74 Left handed tapping cycle
Parameter Details:
- "G74": Left-handed tapping cycle, used for machining left-handed threads.
- "X35.9/Y24.7": Absolute coordinates of the tapping hole (35.9mm for X, 24.7mm for Y), determining the hole position.
- "Z-32.1": Z-axis coordinate of the hole bottom (-32.1mm), indicating the depth of the tapped hole.
- "R4.8": Z-axis coordinate of the retract plane (4.8mm on the Z-axis). The tool retracts to this plane after tapping.
- "P2.5": Dwell time at the bottom of the hole (2.5 seconds), ensuring full thread forming.
- "F10.5": Feedrate for tapping (10.5mm/min). The feedrate must match the spindle speed (Feedrate = Spindle speed × Thread pitch).
- "K03": Number of repeats (3 holes), meaning the left-handed tapping cycle is repeated 3 times to machine 3 identical threaded holes.
- G76 X41.2 Y28.9 Z-38.5 R6.3 Q2.1 P1.8 F8.7 K02;
Command Function: G76 Fine boring cycle
Parameter Details:
- "G76": Fine boring cycle, used for high-precision hole machining. It can ensure the roundness, cylindricity and surface roughness of the hole, and is usually the final process of hole machining.
- "X41.2/Y28.9": Absolute coordinates of the boring hole (X41.2mm, Y28.9mm), determining the center position of the hole to be machined.
- "Z-38.5": Z-axis coordinate of the hole bottom (-38.5mm), meaning the fine boring depth is 38.5mm, which is set according to the workpiece thickness and hole depth requirements.
- "R6.3": Z-axis coordinate of the retract plane (6.3mm). The boring tool completes the radial tool retraction movement on this plane to avoid scratching the hole wall when retracting.
- "Q2.1": Radial offset distance (2.1mm). After fine boring to the bottom of the hole, the boring tool moves outward 2.1mm in the radial direction to prevent friction between the tool shank and the hole wall when retracting.
- "P1.8": Dwell time at the bottom of the bore (1.8 seconds), stabilizing the boring tool for cutting and reducing the impact of vibration on hole accuracy.
- "F8.7": Feedrate for fine boring (8.7mm/min). Low feedrate can improve the surface quality of the hole wall, which is suitable for fine boring of medium carbon steel such as 45# steel.
- "K02": Number of repeats (2 holes), indicating the fine boring cycle is repeated twice to machine 2 high-precision holes.
- G81 X17.5 Y31.8 Z-18.4 R3.9 F14.2 K05;
Command Function: G81 Spot drilling cycle
Parameter Details:
- "G81": Spot drilling cycle, mainly used to pre-drill positioning holes before drilling, preventing the drill bit from deviating during subsequent drilling and ensuring the position accuracy of the hole.
- "X17.5/Y31.8": Absolute coordinates of the spot hole (X17.5mm, Y31.8mm), determining the position of the positioning hole.
- "Z-18.4": Z-axis coordinate of the spot hole bottom (-18.4mm), meaning the spot drilling depth is 18.4mm, which is usually 1/3 to 1/2 of the subsequent drilling depth.
- "R3.9": Z-axis coordinate of the retract plane (3.9mm). The spot drill starts feeding on this plane to avoid wasting time on idle travel.
- "F14.2": Feedrate for spot drilling (14.2mm/min), suitable for machining cast iron with high-speed steel spot drills.
- "K05": Number of repeats (5 holes), meaning the spot drilling cycle is repeated 5 times to pre-drill 5 positioning holes for batch drilling.
- G82 X23.7 Y26.4 Z-22.6 R4.5 P3.2 F11.9 K04;
Command Function: G82 Drilling cycle counter boring cycle
Parameter Details:
- "G82": Drilling cycle counter boring cycle, which has both drilling and counter boring functions. It can directly counter bore a counter sink after drilling, suitable for scenarios where bolts and nuts need to be installed.
- "X23.7/Y26.4": Absolute coordinates of the hole (X23.7mm, Y26.4mm), determining the common center of drilling and counter boring.
- "Z-22.6": Z-axis coordinate of the drilling bottom (-22.6mm), meaning the total drilling depth is 22.6mm, including the counter boring depth.
- "R4.5": Z-axis coordinate of the retract plane (4.5mm). After the tool retracts, it does not affect the loading and unloading of the workpiece.
- "P3.2": Dwell time at the bottom of the hole (3.2 seconds). During the counter boring stage, dwelling can ensure the bottom surface of the counter sink is flat without steps.
- "F11.9": Feedrate for drilling/counter boring (11.9mm/min). The feedrate during counter boring should be slightly lower than that during drilling to avoid tool chipping.
- "K04": Number of repeats (4 holes), indicating the cycle is repeated 4 times to machine 4 holes with counter sinks.
- G83 X39.4 Y15.8 Z-42.3 R5.8 Q4.2 F9.8 K03;
Command Function: G83 Peck drilling cycle
Parameter Details:
- "G83": Peck drilling cycle, which machines deep holes by means of segmented feeding and segmented retraction. It can effectively discharge chips, prevent chips from wrapping around the tool or scratching the hole wall, and is suitable for deep hole machining where the depth exceeds 3 times the tool diameter.
- "X39.4/Y15.8": Absolute coordinates of the deep hole (X39.4mm, Y15.8mm), determining the position of the deep hole.
- "Z-42.3": Z-axis coordinate of the deep hole bottom (-42.3mm), meaning the total depth of the deep hole is 42.3mm.
- "R5.8": Z-axis coordinate of the retract plane (5.8mm). After each peck drilling, the tool retracts to this plane to discharge chips, ensuring complete chip discharge.
- "Q4.2": Depth of each peck stroke (4.2mm), meaning the tool retracts to discharge chips after feeding 4.2mm each time. The Q value should be set according to the tool rigidity and material cutting performance to avoid tool breakage due to excessive feeding depth.
- "F9.8": Feedrate for peck drilling (9.8mm/min). Low feedrate is required for deep hole machining to ensure tool heat dissipation and cutting stability.
- "K03": Number of repeats (3 holes), meaning the peck drilling cycle is repeated 3 times to machine 3 identical deep holes.
Other Articles
Related Articles
Here are some related technical resources you may also find helpful:
- FANUC G/ M Code for lathe
- How to backup SRAM file
- How to backup All data
-
Common FANUC CNC Alarms Classification
-
Fanuc Common Over Travel Alarm List
- How to Solve FANUC alarm 5523/5524
Technical Categories
Browse our full set of technical resources:
-
Common FANUC Alarms
-
G & M Code Reference
-
Technical Guides (Backup, Parameters, Settings)
- Repair Cases & Troubleshooting Examples
Back to Previous Page
Click here to return to the previous category page.
Back to Technical Support Home
Return to the Technical Support main page to explore all resources.