Are you sure you understand everything about CNC machining G code? See if there is anything you don't understand.
1. G code and its functions
G00--Quick positioning
G01--Linear interpolation
G02--Clockwise arc interpolation
G03--Counterclockwise arc interpolation
G04--Timed pause
G05--Circular interpolation through intermediate point
G06--Parabolic interpolation
G07--Z-spline interpolation
G08--Feed acceleration
G09--Feed deceleration
G10--Data settings
G16--Polar coordinate programming
G17--Processing XY plane
G18--Processing XZ plane
G19--Processing YZ plane
G20 - Imperial size (FANUC system)
G21 - Metric Dimensions (FANUC System)
G22--Radius dimension programming method
G220--Used on the system operation interface
G23--Diameter size programming method
G230--Used on the system operation interface
G24--End of subroutine
G25--Jump processing
G26--Cycle processing
G30--magnification cancellation
G31 - magnification definition
G32--Constant pitch thread cutting, inch system
G33 - Constant pitch thread cutting, metric
G34--increased pitch thread cutting
G35--Reduced pitch thread cutting
G40--Tool compensation/tool offset logout
G41--Cutter compensation left
G42--Tool compensation right
G43--Tool offset positive
G44--Tool offset negative
G45--Tool offset+/+
G46--Tool offset +/-
G47--Tool offset-/-
G48--Tool offset-/+
G49--Tool offset 0/+
G50--Tool offset 0/-
G51--Tool offset +/0
G52--Tool offset-/0
G53--Linear offset, logout
G54--Set workpiece coordinates
G55--Set workpiece coordinate two
G56--Set workpiece coordinate three
G57--Set workpiece coordinate four
G58--Set workpiece coordinate five
G59--Set workpiece coordinate six
G60--Accurate path mode (fine)
G61--Accurate path mode (middle)
G62--Exact path mode (coarse)
G63--Tapping
G68--Tool offset, inside angle
G69--Tool offset, outside corner
G70--Inch size (this is Siemens, FANUC is G21)
G71 - Metric Dimensions mm
G74--Reference point return (machine zero point)
G75--Return to programmed coordinate zero point
G76--Threading compound cycle
G80--canned cycle logout
G81--External circle fixed cycle
G331--Thread canned cycle
G90 - absolute size
G91 - relative size
G92--Prefabricated coordinates
G93--Time countdown, feed rate
G94--Feed rate, feed per minute
G95--Feed rate, feed per revolution
G96--Constant linear speed control
G97--Cancel constant linear speed control
2. Detailed explanation of G code functions
Rapid positioning
Format: G00 X(U)__Z(W)__
illustrate:
(1) This command makes the tool quickly move to the specified position according to point control mode. The workpiece must not be processed during movement.
(2) All programmed axes move at the speed defined by the parameters at the same time. When one axis reaches the programmed value, it stops, while the other axes continue to move.
(3) No programming is required for non-moving coordinates.
(4) G00 can be written as G0
example:
G00 X75 Z200
G01 U-25 W-100
First, walk X and Z at the same time for 25 seconds to reach point A, and then walk in the Z direction for 75 seconds to reach point B.
Linear interpolation
Format: G01 X(U)_Z(W)_F_(mm/min)
illustrate:
(1) This command makes the tool move to the specified position according to linear interpolation. The moving speed is commanded by F
Feed rate. All coordinates can be run in conjunction.
(2) G01 can also be written as G1
example:
G01 X40 Z20 F150
Two axes linkage from point A to point B
Arc interpolation
Format 1: G02X(u)_Z(w)_I_K_F_
illustrate:
(1) When X and Z are at G90, the arc end point coordinates are the absolute coordinate values relative to the programmed zero point. At G91,
The arc end point is the incremental value relative to the arc start point. Regardless of G90 or G91, I and K are the incremental coordinates of the arc's center relative to the starting point.
I is the X direction value, and K is the Z direction value. The circle center coordinates cannot be omitted during arc interpolation unless programmed in other formats.
(2) When programming the G02 instruction, you can directly program quadrant circles, full circles, etc.
Note: When crossing the quadrant, gap compensation will be automatically performed. If the gap compensation input at the end of the parameter area is very different from the actual reverse gap of the machine tool, obvious cuts will be produced on the workpiece.
(3) G02 can also be written as G2.
Example: G02 X60 Z50 I40 K0 F120
Format 2: G02X(u)_Z(w)_R(+-)_F_
Note: (1) Cannot be used for full circle programming
(2) R is the radius of the R arc on one side of the workpiece. R is signed, "+" means the arc angle is less than 180 degrees;
"-" means the arc angle is greater than 180 degrees. The "+" can be omitted.
(3) It is based on the coordinates of the end point. When the length value between the end point and the starting point is greater than 2R, a straight line is used instead of the arc.
Example: G02 X60 Z50 R20 F120
Format 3: G02X(u)_Z(w)_CR=_(radius)F_
Format 4: G02X(u)_Z(w)_D_(diameter)F_
These two programming formats are basically the same as format 2
Circular interpolation
Note: Except for the opposite direction of arc rotation, the format is the same as the G02 command.
timed pause
Format: G04_F_ or G04_K_
Note: The processing movement is paused. After the time is up, processing will continue. The pause time is specified by the data following F. The unit is seconds. The range is 0.01 seconds to 300 seconds.
Intermediate point arc interpolation
Format: G05X(u)_Z(w)_IX_IZ_F_
Note: X, Z are the coordinate values of the end point, IX, IZ are the coordinate values of the intermediate point. Others are similar to G02/G03
Example: G05 X60 Z50 IX50 IZ60 F120
Accelerate/Decelerate
Format: G08
Note: They occupy one line by themselves in the program section. When the program reaches this section, the feed speed will increase by 10%. If it is to increase by 20%, it needs to be written as two separate sections.
Radius programming
Format: G22
Note: If it occupies its own line in the program, the system runs in radius mode, and the following values in the program are also based on the radius.
Diameter size programming method
Format: G23
Note: If it occupies its own line in the program, the system operates in diameter mode, and the following values in the program are also based on diameter.
Jump processing
Format: G25 LXXX
Explanation: When the program executes to this program, it will transfer to the program segment specified by it. (XXX is the program segment number).
Cycle processing
Format: G26 LXXX QXX
Note: When the program executes this section of the program, the specified program section starts with this section as a loop body, and the number of loops is determined by the value after Q.
Multiple cancellation
Format: G30
Instructions: Occupy its own line in the program, use it in conjunction with G31, and cancel the function of G31.
magnification definition
G31 F_
G32: Constant pitch thread processing (imperial)
G33: Constant pitch thread processing (metric)
Format: G32/G33 X(u)_Z(w)_F_
illustrate:
(1) X and Z are the end point coordinates, and F is the pitch.
(2) G33/G32 can only process single-tool and single-start threads.
(3) Changes in X value can process tapered threads
(4) When using this command, the spindle speed cannot be too high, otherwise the tool wear will be greater.
Set workpiece coordinates/set maximum (low) spindle speed
Format: G50 S_Q_
S is the highest spindle speed, Q is the spindle lowest speed
Set workpiece coordinates
Format: G54
There can be several coordinate systems in the system. G54 corresponds to the first coordinate system, and its origin position value is set in the machine tool parameters.
G55: Set workpiece coordinate two
G56: Set workpiece coordinate three
G57: Set workpiece coordinate four
G58: Set workpiece coordinate five
G59: Set workpiece coordinate six
Exact path method
Format: G60
In the actual processing process, when several actions are connected together and programmed with accurate paths, there will be a buffering process (that is, deceleration) when performing the next section of processing.
continuous path method
Format: G64
Compared with G60, it is mainly used for rough machining.
Return to reference point (machine zero point)
Format: G74 X Z
(1) No other content may appear in this paragraph.
(2) The coordinates appearing after G74 will return to zero in order of X and Z.
(3) Before using G74, you must confirm that the machine tool is equipped with a reference point switch.
(4) Single-axis zero return can also be performed.
Return to programmed coordinate zero point
Format: G75 X Z
Return to the starting point of programming coordinates
Format: G76
Return to the position where the tool started machining.
External circle (inner circle) fixed cycle
Format: G81_X(U)_Z(W)_R_I_K_F_
illustrate:
(1) X, Z are the coordinate values of the end point, U, W are the incremental values of the end point relative to the current point.
(2) R is the diameter of the starting section to be processed.
(3) I is the rough turning feed, K is the finishing turning feed, I and K are signed numbers, and the signs of the two should be the same. The symbol convention is as follows: cutting from the outside to the central axis (turning the outer circle) is "-", and vice versa is "+".
(4) Different X, Z, R determine different switches of the outer circle, such as: with taper or no taper, forward taper or reverse taper, left cutting or right cutting, etc.
(5) F is the cutting speed (mm/min)
(6) After processing is completed, the tool stops at the end point.
Example: G81 X40 Z 100 R15 I-3 K-1 F100
Processing process:
1) G01 feeds 2 times I (the first cut is I, the last cut is I+K finishing) for deep cutting:
2) G01 two-axis interpolation, cutting to the end section, and stopping if the processing is completed:
3) G01 retracts the tool I to a safe position and performs auxiliary cut surface smoothing at the same time
4) G00 rapidly feeds outside the high working surface I, leaving I for the next step of cutting, repeating to 1.
absolute value programming
Format: G90
illustrate:
(1) When G90 is programmed, all coordinate values programmed in the future are based on the programmed zero point.
(2) After the system is powered on, the machine tool is in G state.
N0010 G90 G92 x20 z90
N0020 G01X40 Z80 F100
N0030 G03X60 Z50 I0 K-10
N0040 M02
incremental programming
Format: G91
Note: When G91 is programmed, all subsequent coordinate values use the previous coordinate position as the starting point to calculate the programmed value of motion. In the next segment of the coordinate system, the previous point is always used as the starting point for programming.
Example: N0010 G91 G92 X20 Z85
N0020 G01X20 Z-10 F100
N0030 Z-20
N0040 X20 Z-15
N0050 M02
Set workpiece coordinate system
Format: G92 X_ Z_
illustrate:
(1) G92 only changes the coordinate value currently displayed by the system, without moving the coordinate axis, to achieve the purpose of setting the coordinate origin.
(2) The effect of G92 is to change the displayed tool nose coordinates to the set value.
(3) XZ behind G92 can be programmed separately or in full.
G94-Feed rate, feed per minute
Note: This is the default startup state of the machine tool.
subroutine call
Format: G20 L_
N_
illustrate:
(1) After L is the program name after N of the subroutine to be called, but N cannot be entered.
Only numbers 1~99999999 are allowed after N.
(2) This program shall not contain content other than those described above.
Subroutine ends and returns
Format: G24
illustrate:
(1) G24 indicates the end of the subroutine and returns to the next section of the program that called the subroutine.
(2) G24 and G20 appear in pairs.
(3) No other instructions are allowed in this section of G24.
3. G code programming examples
Example: The following example illustrates the parameter passing process during subroutine calling. Please pay attention to the application.
Program name: P10
M03 S1000
G20 L200
M02
N200 G92 X50 Z100
G01 X40 F100
Z97
G02 Z92 X50 I10 K0 F100
G01 Z-25 F100
G00X60
Z100
G24
If you want to call it multiple times, please use it in the following format
M03 S1000
N100 G20 L200
N101 G20 L200
N105 G20 L200
M02
N200 G92 X50 Z100
G01 X40 F100
Z97
G02 Z92 X50 I10 K0 F100
G01 Z-25 F100
G00X60
Z100
G24
G331-Thread machining cycle
Format: G331 X_ Z_I_K_R_p_
illustrate:
(1) The diameter changes in the X direction, X=0 is a straight thread
(2) Z is the thread length, either absolute or relative programming is available
(3) I is the run-out length in the X direction after thread cutting, ± value
(4) The diameter difference between the outer diameter and the root diameter of the R thread, positive value
(5) K pitch KMM
(6) The number of cycles of p thread processing, that is, how many cuts are required to complete the cutting
hint:
(1) The depth of each cutting is R÷p and rounded to the nearest whole number. The last cutting is not carried out to smooth the thread surface.
(2) The name of the internal thread withdrawal is determined according to the positive and negative directions of X.
(3) The starting position of the thread processing cycle is to align the tool tip with the outer circle of the thread.
example:
M3
G4 f2
G0 x30 z0
G331 z-50 x0 i10 k2 r1.5 p5
G0 z0
M05
4. Supplements and Notes
1. G00 and G01
There are two types of G00 motion trajectories: straight line and polyline. This command is only used for point positioning and cannot
For cutting processing;
G01 moves to the target point specified by the instruction in a linear motion at the specified feed speed, and is generally used for cutting processing.
2. G02 and G03
G02: Clockwise arc interpolation
G03: Counterclockwise arc interpolation
3. G04 delay or pause command
Generally used for forward and reverse switching, processing blind holes, step holes, turning and grooving
4. G17, G18, G19 plane selection instructions
Specified surface processing, generally used on milling machines and machining centers
G17: X-Y plane, can be omitted, or it can be a plane parallel to the X-Y plane
G18: X-Z plane or a plane parallel to it. There is only X-Z plane in CNC lathes and does not need to be specially specified.
G19: Y-Z plane or a plane parallel to it
5. G27, G28, G29 reference point instructions
G27: Return to the reference point, check and confirm the reference point position
G28: Automatically return to the reference point (passing the intermediate point)
G29: Return from the reference point, used in conjunction with G28
6. G40, G41, G42 radius compensation
G40: Cancel tool radius compensation
G41: Left compensation
G42: Right compensation
7. G43, G44, G49 length compensation
G43: Positive length compensation
G44: Negative length compensation
G49: Cancel tool length compensation
8. G32, G92, G76
G32: Thread cutting
G92: Thread cutting fixed cycle
G76: Thread cutting compound cycle
9. Turning processing: G70, G71, 72, G73
G71: Axial rough turning compound cycle command
G70: Finishing compound cycle
G72: Face turning, radial rough turning cycle
G73: Copying rough turning cycle
10. Milling machines and machining centers:
G73: High-speed deep hole pecking drilling
G83: Deep hole pecking drilling
G81: drilling cycle
G82: Deep hole drilling cycle
G74: Left-hand thread processing
G84: Right-hand thread processing
G76: Fine boring cycle
G86: Boring processing cycle
G85: Reaming
G80: Cancel cycle command
11. Programming method G90, G91
G90: Absolute coordinate programming
G91: Incremental coordinate programming
12. Spindle setting command
G50: Setting of the maximum spindle speed
G96: Constant linear speed control
G97: Spindle speed control (cancel constant linear speed control command)
G98: Return to reference point (last hole)
G99: Return to point R (middle hole)
13. Spindle forward and reverse stop commands M03, M04, M05
M03: Spindle forward transmission
M04: Spindle reverse
M05: Spindle stops
14. Cutting fluid switch M07, M08, M09
M07: Mist cutting fluid on
M08: liquid cutting fluid on
M09: Cutting fluid off
15. Movement stop M00, M01, M02, M30
M00: program pause
M01: Plan stopped
M02: Machine tool reset
M30: The program ends and the pointer returns to the beginning
16. M98: Call subroutine
17. M99: Return to the main program




