G Code For Fanuc System
| Address | Details |
|---|---|
| G00 | Rapid Linear Interpolation |
| G01 | Linear Interpolation |
| G02 | Clockwise Circular Interpolation |
| G03 | Counter Clockwise Circular Interpolation |
| G04 | Dwell |
| G05 | High Speed Machining Mode |
| G10 | Offset Input By Program |
| G17 | X-Y Plane Selection |
| G18 | Z-X Plane Selection |
| G19 | Y-Z Plane Selection |
| G20 | |
| G21 | |
| G22 | |
| G23 | |
| G24 | |
| G25 | |
| G26 | |
| G27 | |
| G28 | Return To Reference Point |
| G29 | |
| G30 | |
| G38 | |
| G39 | |
| G40 | Tool Radius Compensation Cancel |
| G41 | Tool Radius Compensation Left |
| G42 | Tool Radius Compensation Right |
| G43 | Tool Length Compensation |
| G44 | Tool Length Compensation Cancel |
| G45 | Tool Offset Increase |
| G46 | Tool Offset Decrease |
| G47 | |
| G48 | |
| G49 | |
| G50 | |
| G51 | |
| G52 | Local Coordinate Setting |
| G53 | Machine Co-ordinate |
| G54 | Work Coordinate Registers 1 |
| G55 | Work Coordinate Registers 2 |
| G56 | Work Coordinate Registers 3 |
| G57 | Work Coordinate Registers 4 |
| G58 | Work Coordinate Registers 5 |
| G59 | Work Coordinate Registers 6 |
| G60 | Unidirectional Positioning |
| G61 | Exact Stop Check Mode |
| G62 | |
| G63 | |
| G64 | |
| G65 | Macro Call (Non Modal) |
| G66 | Macro Call (Modal) |
| G67 | |
| G68 | Programmed Coordinate Rotation |
| G69 | Coordinate Rotation Cancel |
| G70 | |
| G71 | |
| G72 | |
| G73 | Fixed Cycle (Step) |
| G74 | Fixed Cycle (Reverse Tapping) |
| G75 | |
| G76 | Fixed Cycle (Fine Boring) |
| G77 | |
| G78 | |
| G79 | |
| G80 | Fixed Cycle Cancel |
| G81 | Fixed Cycle (Drilling / Spot Drilling) |
| G82 | Fixed Cycle (Drilling / Counter Boring) |
| G83 | Fixed Cycle (Deep Hole Drilling) |
| G84 | Fixed Cycle (Tapping) |
| G85 | Fixed Cycle (Boring) |
| G86 | Fixed Cycle (Boring) |
| G87 | Fixed Cycle (Back Boring) |
| G88 | Fixed Cycle (Boring) |
| G89 | Fixed Cycle (Boring) |
| G90 | Absolute Value Command |
| G91 | Incremental Value Command |
| G92 | Work Offset Set |
G00(Rapid Positioning / Traverse)
The G00 code executes a non cutting movement, at a rapid feedrate, to a specific co-ordinate position in the working area (operating under absolute co-ordinate movement) or when a certain distance from a previously stated position (under incremental co-ordinate movement) is programmed.
Format
G00 X* Y* Z*;
where,
G00 is the Rapid Positioning/ Traverse code.
X* Y* Z* are the X, Y and Z axis co-ordinate values.
The axis co-ordinate moves following a G00 command can be programmed as either absolute values(G90) or incremental values(G91).
G01(Linear Interpolation)
The G01 code executes a cutting movement following a straight line, at a set feedrate.
Format
G01 X* Y* Z*;
where,
G01 is the Linear Interpolation code.
X* Y* Z* are the X, Y and Z axis co-ordinate values.
The feedrate value programmed into the G01 command is the actual feedrate along the proposed tool path, not the feedrate of each axis/slide.
On single axis moves (ie, the tool moves exactly parallel to the X, Y or Z axis direction), the slide will feed at the rate stated in the G01 command.
On two or three axis moves (ie, the tool is moving in a straight diagonal line), all the slides have to operate exactly the same length of time, in order to produce a single diagonal (vector) move. The machine controller will calculate the separate feedrates for the X, Y and Z slides, enabling the actual vector feedrate to equal that stated in the G01 command.
The axis co-ordinate moves following a G00 command can be programmed as either absolute values(G90) or incremental values(G91).
G02(Circular Interpolation-Clockwise)
The G02 code executes a cutting movement following a clockwise circular path, at a set feedrate.
G03 (Circular Interpolation-Counter Clockwise)
The G03 code executes a cutting movement following a counterclockwise circular path, at a set feedrate.The definitions of clockwise (G02) and counterclockwise (G03) are fixed according to the system of co-ordinates in the diagram below.
When programming arcs using absolute values (G90), the X and Y values describe the end point of the arc, in relation to the datum position of the workpiece. The arc end point is sometimes referred to as the target position.
When programming arcs using incremental values (G91), the X and Y values relate to the distance moved along the X and Y axes, from the start point of the arc to the end point of the arc. The sign of the X and Y axis moves (+/-) will depend on the movement of the machine slides in relation to their start position.
The above tool path can be programmed as follows (In absolute mode, G90):
G02/03 Circular Interpolation Example.
G01 X100 Y40 F125 ;
G03 X80 Y60 I-20 ;
G01 X60 ;
G02 X40 Y40 I-20 ;
or,
G01 X100 Y40 F125 ;
G03 X80 Y60 R20 ;
G01 X60 ;
G02 X40 Y40 R20 ;
The above tool path can be programmed as follows (In incremental mode, G91):
G03 X-20 Y20 I-20 ;
G01 X-20 ;
G02 X-20 Y-20 I-20 ;
or,
G03 X-20 Y20 R20 ;
G01 X-20 ;
G02 X-20 Y-20 R20 ;
G04(Dwell):
The G04 code is used to enter a set time delay into the program (called a "dwell").
A G04 command is written in the following format:
G04 X_ ;
or G04 P_;
where,
The dwell value is programmed using the address letters X (time in seconds) or P (time in 1/1000 seconds), followed by a number indicating this dwell value.
For example,
G04 X1.5 ;
This command is read perform a dwell of 1.5 seconds duration.
For example,
G04 P2500 ;
This command is read perform a dwell of 2.5 seconds duration.
G20 /G21(Imperial/Metric Data Input):
The machine controller can be programmed in either Imperial (inch) unit input (G20) or Metric (millimetre) unit input (G21). The standard format for a CNC part program is to write the G20 or G21 code in the first block of the program.
| G code. | Type. | Units. | Lowest input value. |
|---|---|---|---|
| G20 | Imperial | Inch | 0.0001 inch |
| G21 | Metric | Millimetre | 0.001 mm |
The unit systems of the following items are changed depending on whether G20 or G21 is set
1) Positioning commands (X, Y and Z).
2) Incremental movement distances.
3) Feedrates commanded by the F code.
4) Offset values.
G40/ G41 / G42 (Cutter Compensation):
The collection of G40, G41 and G42 codes allow the machine controller to produce very accurate arcs and tapers on the billet, by compensating for the tool radius.
Complex workpiece shapes are therefore programmed with cutter compensation mode active. The radius of the tool (the offset amount) is measured, then entered into the offset file in the machine controller. Once set, the tool path can be offset by this value, regardless of the program.
Work Position and Movement Command.
When tool nose radius compensation is required in a CNC program, the position of the billet in respect to the tool must be specified using the table below:
G code Direction Tool Path
G40 Cancel Movement along programmed path
G41 Left hand Movement on the left hand side of the programmed path
G42 Right hand Movement on the right hand side of the programmed path
The operation instructing a machine to switch to cutter compensation mode is called the start-up block, or ramping on block. The start-up block is used to allow the tool time to change from moving along the programmed path line to following either side of the programmed path line.
The start-up block should satisfy the following points:
1) A G41 or G42 code must contained in the block, or specified in the previous block.
2) A G01 X, Y, or X and Y move is specified in the block and the distance of the linear move must be greater than the tool radius.
3) The tool radius value, "R", entered into the tool offsets table must not be 00.
A G02 or G03 circular interpolation command cannot be specified in the start-up block.
In cutter compensation start-up, two blocks are read into the machine controller. The first block is performed and the second block is entered and held in memory.
In subsequent compensation moves, two blocks are read in advance, so the machine controller has the block currently being performed and the next two blocks in memory.
This is because cutter compensation always needs to know what happens in the move following the one being currently performed. The machine controller can plan ahead to calculate the correct end position for the current move, that will also be the correct start position allowing for cutter compensation, for the next move.
The codes G40, G41 and G42 are modal, belonging to the same modal family. They are incompatible with each other on the same block.
Direction of compensation codes G41 and G42.
The two diagrams below illustrate the direction of compensation codes G41 and G42, in relation to your eye level:
G41 - Left hand Compensation:
The tool is positioned on the left hand side of the part, as seen following the direction of movement, from behind the tool.
G42 - Right hand Compensation:
The tool is positioned on the right hand side of the part, as seen following the direction of movement, from behind the tool.
Cutter Compensation Cancel (G40).
The G40 code is used to cancel cutter compensation.
A G40 command can only be performed in a block in which a linear move (ie, G00, G01, G28) is programmed.
Following the machining of an internal pocket, it is recommended that the Z axis is withdrawn by using the G01 command, to a position clear of the workpiece, before the cutter compensation mode is cancelled.
The machine controller enters compensation cancel mode automatically when:
1) the machine power is first switched on.
2) the reset button on the CRT/MDI controller panel is pressed.
3) a program is forced to end by performing an M02 or M30 command.
G40/41/42 Cutter Compensation Example.
The following part program for a finishing pass shows the recommended method for start-up and cancellation of cutter compensation:
O 0010
N0010 G00 X-15 Y-15 ;
N0020 G41 X0 Y0 F100 ; (Start-Up Move)
N0030 Y40 ;
N0040 X30 Y80 ;
N0050 X60 ;
N0060 G02 X100 Y40 R40 ;
N0070 G01 Y30 ;
N0080 G03 X70 Y0 R30 ;
N0090 X0 ;
N0100 X-15 Y-15 ; (Cancellation Move)
G73- G89 (Canned Cycles):
A canned cycle simplifies the program by replacing complex machining sequences, programmed by several blocks of information, with just one or two blocks.
Generally, a canned cycle consists of a sequence of six operations, as shown below:
Operation 1 - Positioning of the X and Y axes.
Operation 2 - Rapid traverse in the Z axis to the "R" point.
Operation 3 - Hole machining procedure.
Operation 4 - Operation at bottom of hole.
Operation 5 - Retraction to R point.
Operation 6 - Rapid traverse in the Z axis to the Initial level
.
Data Format Command Modes.
The data format used in canned cycles is specified by the codes G90 and G91, as shown below:
G90 - Absolute Data Format. G91 - Incremental Data Format.
Text Box:
Return Point Level Command Modes.
The return point position of the tool (ie, to the Initial Level, or the R Level) is specified by the codes G98 and G99, as shown below:
The Initial level refers to the absolute value of the Z axis, at the time of change from the positioning mode top the canned cycle mode.
G98 - Initial Point Level Return.
G99 - R Point Level Return.
Canned Cycle Format.
The format for machining data in a canned cycle is written as follows:
(G90 or G91) (G98 or G99) G.... X.... Y.... Z.... R.... P.... Q.... K.... F.... ;
where,
G.... is defined as the canned cycle.
X.... Y.... is defined as the hole position, in absolute or incremental value.
Z.... is defined as the distance from the R point to the bottom of the hole in incremental mode, or the position of the hole bottom in absolute mode.
R.... is defined as the distance from the initial level to the R point level in incremental mode, or the position of the Z datum in relation to the R point level in absolute mode.
P.... is defined as the dwell time to be performed at the bottom of the hole (see the G04 code for more details).
Q.... is defined as the cut-in distance value or shift value (Note - this is always specified as an incremental value).
K.... is defined as the number of repeats, for a series of holes. When not specified, K=1.
F.... is defined as the feedrate for machining.
The addresses P and Q are omitted within some canned cycles.
Once the drilling data has been specified and read into the machine controller, it is retained until it is either changed, or the canned cycle cancelled. All the required data must be specified when the canned cycle is started and only the data to be changed has to be specified during the cycle.
Canned Cycle Example Programs.
The following example shows a canned cycle for drilling 4 holes, where the third hole is to be machined 10mm deeper:
G90 G99 G81 X10 Y10 Z-15 R2 F100 ;
X20 ; (X axis move)
X30 Z-25 ; (X and Z change)
X40 Z-15 ; (X and Z change)
G80 ; (Cancel)
The following example shows a repeat canned cycle:
G91 G99 G81 X10 Y6 Z-10 R-8 K4 F100 ;
G73(High Speed Peck Drilling):
A G73 (High Speed Peck Drilling) command is written in the following format:
(G90 or G91) (G98 or G99) G73 X.... Y.... Z.... Q.... F.... ;
When machining, the drill is positioned at the co-ordinate point of the first hole, for the X and Y axes and at the initial level, for the Z axis. The G73 command is then read into the machine controller and the cycle begins.
The drill will rapid traverse to the R point level and begin to feed in, until a cut-in distance of Q is attained. At this point, the drill will retract a small distance (set within the machine controller). A cut-in distance of Q at the same feedrate will begin again, followed by a similar retraction. These movements will continue until the total Z depth has been reached.
The drill will rapid traverse out to the Initial level, if a G98 code is programmed within the cycle, or to the R point level, if a G99 code is programmed within the cycle. At this point the next block is read into the machine controller. If this block contains an X, Y or X and Y co-ordinate the drill will position itself at that point and the high speed peck drilling cycle will begin again.
G74(Counter Tapping):
A G74 (Counter/Left Hand Tapping) command is written in the following format:
(G90 or G91) (G98 or G99) G74 X.... Y.... Z.... P.... R.... F.... ;
Text Box: Sequence of moves:
- Rapid position to X, Y and Z (the Initial level).
- Rapid traverse to R point level.
- Feed to Z depth.
- Dwell P (time for spindle stop and start CW direction).
- Feed to R point level.
- Dwell P (time for spindle stop and start CCW direction).
If the G98 code is programmed within the cycle, the next move will be a rapid traverse to the Initial level. If the G99 code is programmed within the cycle, there will be no movement.
F (Feed) = RPM x Pitch.
G76(Fine Boring):
A G76 (Fine Boring) command is written in the following format:
( G90 or G91) (G98 or G99) ( G76 X.... Y.... Z.... R.... P… Q… F….,
Text Box: .
Sequence of moves:
Op 1) Rapid position to X, Y and Z (the Initial level).
Op 2) Rapid traverse to R point level.
Op 3) Feed to Z depth.
Op 4) Dwell P (time for spindle stop and move Q value).
Op 5) Feed to R point level.
Op 6) Move back Q value.
The above moves vary depending on the setting of the codes G98 and G99.
THIS CYCLE CAN ONLY BE USED ON A MACHINE FITTED WITH A SPINDLE CAPABLE OF ORIENTATION. BECAUSE THE TOOL MOVES WITHIN THE HOLE AFTER SPINDLE STOP TO FACE THE OPPOSITE DIRECTION.
G80-Fixed Cycle Cancel
Cancel the Fixed Cycle
Some of the addresses used within a canned cycle are modal (Z, P, Q and R), so their respective values are retained in the machine controller memory after the cycle has finished. The canned cycle must be cancelled, automatically removing these modal values, before the next canned cycle can be programmed into the machine controller.
This is achieved by programming a G80 code, following the last block of the canned cycle within the part program.
The G80 code is active when:
1) the machine power is first switched on.
2) the reset button on the CRT/MDI controller panel is pressed.
3) the Emergency Stop button is pressed.
G81(Drilling - Spot Boring):
Format
(G90 or G91) (G98 or G99) G81 X* Y* Z* R* F*;
- X*,Y*-Positions of Hole
- Z*-Depth to be drilled
- R*-Initial point of drill hole starting
- F*-Feedrate
Sequence of moves:
- Rapid position to X, Y and Z (the Initial level).
- Rapid traverse to R point level.
- Feed to Z depth.
- Rapid traverse to Initial level (G98) or R point level (G99).
G82(Drilling - Counter Boring):
Format
(G90 or G91) (G98 or G99) G82 X* Y* Z* P* R* F*;
- X*,Y*-Positions of Hole
- Z*-Depth to be drilled
- R*-Initial point of drill hole starting
- P*-Dwell time at the bottom of hole
- F*-Feedrate
Sequence of moves:
- Rapid position to X, Y and Z (the Initial level).
- Rapid traverse to R point level.
- Feed to Z depth.
- Dwell for value P.
- Rapid traverse to Initial level (G98) or R point level (G99).
G83(Deep Hole Peck Drilling):
G83 என்பது peck drilling or Deep Hole Drilling-ற்கு பயன்படுத்தும் Code ஆகும்.
A G83 (Deep Hole Peck Drilling) command Format
(G90 or G91)(G98 or G99)G83 X* Y* Z* I* J* K* Q* R* F* P* L*;
G90/G91-Absolute or increment
G98/G99-Initial or Return Point
X,Y-Position Of Hole
Z-Depth of hole to be drill
I
J
K
L-No of Repeat(Optional)
Q-Pecking Depth
R-Initial Level of drill Starting above the workpiece
F-Feedrate of drilling
P-Dwell Time(See G04) in Milli Seconds(Optional)
எ.கா G83 Z-20.0 R1.0 Q5.0 L0 F100;
Z-20.0 என்பது Drill ஆனது எவ்வளவு Depth செல்ல வேண்டும் என்பதாகும்.
R1.0 என்பது Tool ஆனது Z ல் எங்கிருந்து துளையிட துவங்க வேண்டும் என்பதாகும். இங்கு Work Offset ற்கு மேல் 1.0 mm ஆகும்.
Q5.0 ஒவ்வொரு முறையும் எவ்வளவு Depth செல்ல வேண்டும் என்பதைக் குறிக்கும்.
L0
F100 Feedrate for drilling.
In new Fanuc Machine with the following Format
G83 X10.0 Y10.0 Z-15.0 I5.0 J1.0 K1.0 R5.0 P500 F50.0 L2;
X-X position of hole
Y-Y position of hole
Z-Final Hole Depth
I-Size of first pecking
J-Amount to reduce peck depth each pass
K-Minium Peck Depth
R-Retract Point
P-Pause at the end of last peck
F-Feedrate
L-Loop No or No of holes
Sequence of moves:
- Rapid position to X, Y and Z (the initial level).
- Rapid traverse to R point level.
- Feed in to the value of Q.
- Rapid traverse out to R point. Rapid traverse back to within 1mm of depth of Q cut.Operation moves 2 and 4 are repeated until Z depth is reached.
- Rapid traverse to Initial level (G98) or R point level (G99).
K.... is defined as the number of repeats, for a series of holes. When not specified, K=1.
G84(Tapping):
A G84 (Tapping) command is written in the following format: (G90orG91)(G98orG99)G84 X* Y* Z R P F*;
Sequence of moves:
- Rapid position to X, Y and Z (the initial level).
- Rapid traverse to R point level.
- Feed to Z depth.
- Dwell P (time for spindle stop and start CCW direction).
- Feed to R point level.
- Dwell P (time for spindle stop and start CW direction).
Note
If the G98 code is programmed within the cycle, the next move will be a rapid traverse to the Initial level. If the G99 code is programmed within the cycle, there will be no movement.
F (Feed) = RPM x Pitch.
G85(Boring):
A G85 (Boring) command is written in the following format:
(G90or G91) (G98 or G99) G85 X.... Y.... Z.... R.... F.... ;
Sequence of moves:
Op 1) Rapid position to X, Y and Z (the initial level).
Op 2) Rapid traverse to R point level.
Op 3) Feed in to the Z depth.
Op 4) Feed back to R point level.
If the G98 code is programmed within the cycle, the next move will be a rapid traverse to the Initial level. If the G99 code is programmed within the cycle, there will be no movement.
G86(Boring):
A G86 (Boring) command is written in the following format:
(G90 or G91) (G98 or G99) G86 X.... Y.... Z.... R.... F.... ;
Sequence of moves:
Op 1) Rapid position to X, Y and Z (the initial level).
Op 2) Rapid traverse to R point level.
Op 3) Feed to Z depth and spindle stop.
Op 4) Rapid traverse to the initial level and spindle CW for G98, or rapid traverse to R point level and spindle CW for G99.
G90(Absolute Zero Command):
When G90 is active, all co-ordinates are relative to the workpiece datum (the zero position).
The G90 code is active when:
1) the machine power is first switched on.
2) the reset button on the CRT/MDI controller panel is pressed.
3) the Emergency Stop button is pressed.
1) absolute values (relative to a set datum point) following setting of the G90 code, or,
2) incremental values (relative to the last stated co-ordinate in the program) following setting of the G91 code
G91(Incremental Command):
When G91 is active, all movement command values are distance moved (including the +/- sign) from last known programmed position.
G92-Work Offset Shift
Example
%
O60921 (G92 SHIFT WORK OFFSETS) ;
(G54 X0 Y0 Z0 is at the center of mill travel) ;
G00 G90 G54 X0 Y0 (Rapid to G54 origin) ;
G92 X2. Y2. (Shifts current G54) ;
G00 G90 G54 X0 Y0 (Rapid to G54 origin) ;
G92 X-2. Y-2. (Shifts current G54 back to original) ;
G00 G90 G54 X0 Y0 (Rapid to G54 origin) ;
M30 (End program) ;
%
G94(Feed per Minute).
When G94 is active, all feedrates stated within the program are defined in either millimetres per minute when operating in G21 Metric Mode, or inches per minute when operating in G20 Imperial Mode.
For example,
(G20) F6 = 6 in/min.
(G21) F150 = 150 mm/min.
G95(Feed per Revolution):
When G95 is active, all feedrates stated within the program are defined in either millimetres per revolution when operating in G21 Metric Mode, or inches per revolution when operating in G20 Imperial Mode.
THE G95 CODE IS ONLY AVAILABLE WHEN THE MACHINE IS FITTED WITH A SPINDLE ENCODER. SEE YOUR MACHINE SPECIFICATION.