Home> Blog> CNC machining must know the G code, are you sure you understand it?

CNC machining must know the G code, are you sure you understand it?

February 25, 2023

First, the G code and its functions


G00------ Quick positioning

G01------Linear interpolation

G02------clockwise circular interpolation

G03------clockwise circular interpolation

G04------Timed suspension

G05------Interpolation through the intermediate point

G06------Parabolic interpolation

G07------Z spline interpolation

G08------Feed acceleration

G09------Feeding deceleration

G10------ data setting

G16------ polar programming

G17------Machining XY plane

G18------Processing XZ plane

G19------Processing YZ plane

G20------Inch size (Fanaco system)

G21-----Metric size (Fanaco system)

G22------ radius size programming

G220-----Use on the system operation interface

G23------diameter size programming

G230-----Use on the system operation interface

G24------ subroutine ends

G25------ jump processing

G26------Cycle processing

G30------ rate cancellation

G31------ magnification definition

G32------ Equal pitch thread cutting, inch sizes

G33------ equal pitch thread cutting, metric

G34------ Increased pitch thread cutting

G35------ Reduced pitch thread cutting

G40------Tool compensation / tool offset logout

G41------Tool 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------Line offset, logout

G54------Set workpiece coordinates

G55------Set the 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------ accurate path mode (coarse)

G63------Tapping

G68------ tool offset, inner angle

G69------Tool offset, outer corner

G70------Inch size inch (this is Siemens, FANU is G21)

G71------Metric size mm

G74------Return to reference point (machine zero)

G75------Return to programmed coordinate zero

G76------Threaded compound cycle

G80------ fixed cycle logout

G81------Circular fixed cycle

G331-----Threaded fixed cycle

G90------Absolute size

G91------relative size

G92------Prefabricated coordinates

G93------Time reciprocal, feed rate

G94------Feed rate, feed per minute

G95------feed rate, feed per revolution

G96 ------ constant line speed control

G97------Cancel constant line speed control


Second, G code function detailed


Rapid positioning

Format: G00 X(U)__Z(W)__

Description:

(1) This command causes the tool to quickly move to the specified position according to the point control mode. The workpiece must not be machined during the move.

(2) All programmed axes move at the same speed as the parameter defines. When one axis finishes the programmed value, it stops, while the other axes continue to move.

(3) The coordinates of no motion do not need to be programmed.

(4) G00 can be written as G0

example:

G00 X75 Z200

G01 U-25 W-100

First, X and Z go to 25 points to point A at the same time, then Z to go back to point 75 and then to point B.


Linear interpolation

Format: G01 X(U)_Z(W)_F_(mm/min)

Description:

(1) This command moves the tool to the specified position in the linear interpolation mode. Movement speed is determined by the F command

Feed rate. All coordinates can be linked together.

(2) G01 can also be written as G1

example:

G01 X40 Z20 F150

Two-axis linkage from point A to point B


Circular interpolation

Format 1: G02X(u)_Z(w)_I_K_F_

Description:

(1) When X and Z are at G90, the arc end point coordinate is the absolute coordinate value of the relative programmed zero point. At G91,

The end point of the arc is the incremental value relative to the starting point of the arc. Regardless of G90, G91, I and K are the incremental coordinates of the center of the arc relative to the starting point.

I is the X direction value and K is the Z direction value. The center coordinates must not be omitted during circular interpolation unless programmed in other formats.

(2) When programming the G02 command, you can directly edit the quadrant circle, the whole circle, and so on.

Note: When the quadrant is over, the gap compensation will be automatically performed. If the input gap compensation at the end of the parameter area is different from the actual backlash of the machine, 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_

Description: (1) can not be used for programming the entire circle

(2) R is the radius of the single-sided R arc of the workpiece. R is a symbol, and "+" means that the arc angle is less than 180 degrees;

"-" means that the arc angle is greater than 180 degrees. Where "+" can be omitted.

(3) It is based on the coordinates of the end point. When the length of the end point and the starting point is greater than 2R, the arc is replaced by a straight line.

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: The format is the same as the G02 command except that the arc rotates in the opposite direction.


Timed pause

Format: G04_F_ or G04_K_

Note: The machining movement is suspended, and the processing continues after the time is up. The pause time is specified by the data following F. The unit is seconds. The range is from 0.01 seconds to 300 seconds.


Intermediate point circular interpolation

Format: G05X(u)_Z(w)_IX_IZ_F_

Description: X, Z is the end point coordinate value, IX, IZ is the intermediate point coordinate value. Other similar to G02/G03

Example: G05 X60 Z50 IX50 IZ60 F120


Acceleration/deceleration

Format: G08

Note: They are in a single line in the block. When running to this segment in the program, the feed rate will increase by 10%. If you want to increase by 20%, you need to write two separate segments.


Radius programming

Format: G22

Note: If you are on a separate line in the program, the system runs in a radius mode. The values in the program are also based on the radius.


Diameter size programming

Format: G23

Note: If you are on a separate line in the program, the system runs in diameter. The lower values in the program are also based on the diameter.


Jump processing

Format: G25 LXXX

Description: When the program executes to this program, it transfers the block specified by it. (XXX is the block number).


Cyclic processing

Format: G26 LXXX QXX

Description: When the program executes to this program, the block specified by it starts from this segment as a loop body, and the number of loops is determined by the value after Q.


Rate cancellation

Format: G30

Description: One line in the program alone, used in conjunction with G31, to log out the function of G31.


Magnification definition

G31 F_

G32: Equal pitch thread machining (Inch)

G33: Equal pitch thread machining (metric)

Format: G32/G33 X(u)_Z(w)_F_

Description:

(1) X, Z are the coordinates of the end point, and F is the pitch

(2) G33/G32 can only process single-pole and single-start threads.

(3) Change in X value, can process taper thread

(4) When using this command, the spindle speed should not be too high, otherwise the tool wears a lot.


Set workpiece coordinate / set spindle maximum (low) speed

Format: G50 S_Q_

S is the maximum speed of the spindle, and Q is the minimum speed of the spindle.


Set the 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 parameters.

G55: Set the workpiece coordinate two

G56: Set workpiece coordinate three

G57: Set workpiece coordinate four

G58: Set the workpiece coordinate five

G59: Set the workpiece coordinate six


Accurate path

Format: G60

In the actual machining process, when several actions are connected together, when programming with an accurate path, there will be a buffering process (meaning deceleration) during the next processing.


Continuous path mode

Format: G64

Relative to the G60, it is mainly used for roughing.

Click for free to receive ☞CNC (milling), ug programming, cad drawing, CNC simulation, CNC mechanical books, etc. on 10G tutorial

Reference point (machine zero)

Format: G74 XZ

(1) No other content may appear in this paragraph.

(2) The coordinates appearing after G74 will be returned to zero by X and Z.

(3) Before using G74, you must confirm that the machine is equipped with a reference point switch.

(4) It is also possible to perform single-axis zero return.


Return to programmed coordinate zero

Format: G75 XZ


Return to the starting point of the programmed coordinates

Format: G76

Return to the position where the tool starts machining.


External circle (inner circle) canned cycle

Format: G81_X(U)_Z(W)_R_I_K_F_

Description:

(1) X, Z are the end point coordinate values, and 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 machined.

(3) I is the rough car feed, K is the fine car feed, I and K are signed numbers, and the symbols of the two should be the same.

The symbol convention is as follows: cutting from the outward central axis (outer circle) is "-", and this is "+".

(4) Different X, Z, R determine the switch with different outer circle, such as: taper or no degree, forward taper or reverse taper, left cut or right cut.

(5) F is the speed of cutting (mm/min)

(6) After the machining is finished, the tool stops at the end point.

Example: G81 X40 Z 100 R15 I-3 K-1 F100

Processing process:

1) G01 feeds twice the I (the first knife is I, and the last knife is I+K), for deep cutting:

2) G01 two-axis interpolation, cutting to the end section, if the machining is finished, stop:

3) G01 retracts the knife I to the safe position, and at the same time, the auxiliary cutting surface is smoothed.

4) G00 fast feed to the high working surface I, reserve I for the next cutting process, repeat to 1.


Absolute value programming

Format: G90

Description:

(1) When the 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 is in the 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 coordinate values are calculated from the previous coordinate position as the starting point.

The programmed value of the motion. In the next coordinate system, always use the previous point as the starting point to program.

Example: N0010 G91 G92 X20 Z85

N0020 G01X20 Z-10 F100

N0030 Z-20

N0040 X20 Z-15

N0050 M02


Set the workpiece coordinate system

Format: G92 X_ Z_

Description:

(1) G92 only changes the coordinate value currently displayed by the system, does not move the coordinate axis, and reaches the set coordinates.

The purpose of the origin.

(2) The effect of G92 is to change the displayed tool nose coordinate to the set value.

(3) The XZ behind the G92 can be programmed separately or fully.

G94—feed rate, feed per minute

Description: This is the default state of the machine's power on.


Subroutine call

Format: G20 L_

N_

Description:

(1) L is the program name after the subroutine N to be called, but N cannot be input.

Only numbers 1 to 99999999 are allowed after N.

(2) The procedures in this paragraph shall not appear beyond the above description.


Subroutine returns

Format: G24

Description:

(1) G24 indicates the end of the subroutine and returns to the next segment of the subroutine call.

(2) G24 and G20 appear in pairs.

(3) No other instructions are allowed in this paragraph of G24.


Third, G code programming examples


Example: Through the following example to illustrate the transfer process of parameters in the subroutine call process, 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

G00 X60

Z100

G24

If you want to call multiple times, please use 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

G00 X60

Z100

G24


G331 - threading cycle

Format: G331 X_ Z_I_K_R_p_

Description:

(1) X-direction diameter change, X=0 is straight thread

(2) Z is the length of the thread, either absolute or relative programming

(3) I is the length of the tail in the X direction after the thread is cut, ± value

(4) The diameter difference between the outer diameter of the R thread and the root diameter, positive value

(5) K pitch KMM

(6) The number of cycles of p-threading, that is, a few cuts

prompt:

1. Each infeed depth is R÷p and rounded, and the last knife does not enter the knife to smooth the thread surface.

2, the internal thread retreat according to the positive and negative direction of X to determine the value of the I value.

3. The starting position of the threading cycle is to align the tool tip with the outer circumference of the thread.

example:

M3

G4 f2

G0 x30 z0

G331 z-50 x0 i10 k2 r1.5 p5

G0 z0

M05


Fourth, supplementary and precautions


1, G00 and G01

There are two kinds of G00 motion trajectories: straight line and polyline. This command is only used for point positioning and cannot be used for cutting.

G01 moves in the linear motion to the target point specified by the command at the specified feedrate, and is generally used for cutting.


2, G02 and G03

G02: Clockwise circular interpolation

G03: counterclockwise circular interpolation


3, G04 delay or pause command

Generally used for forward and reverse switching, machining blind holes, stepped holes, turning and grooving


4, G17, G18, G19 plane selection command

Designated plane machining, generally used in milling machines and machining centers

G17: XY plane, which can be omitted or a plane parallel to the XY plane

G18: XZ plane or plane parallel to it, only XZ plane in CNC lathe, no special designation

G19: YZ plane or plane parallel to it


5, G27, G28, G29 reference point command

G27: Return to the reference point to check and confirm the reference point position

G28: Automatically return to the reference point (via the middle point)

G29: Return from reference point, use 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: Length negative compensation

G49: Cancel tool length compensation


8, G32, G92, G76

G32: thread cutting

G92: thread cutting canned cycle

G76: Thread cutting compound cycle


9, turning processing: G70, G71, 72, G73

G71: Axial roughing compound cycle instruction

G70: Finishing compound cycle

G72: face turning, radial roughing cycle

G73: Profile roughing cycle


10. Milling machine and machining center:

G73: High speed deep hole drilling

G83: Deep hole 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 the loop instruction


11, programming mode G90, G91

G90: Absolute coordinate programming

G91: incremental coordinate programming


12, spindle setting instructions

G50: setting of maximum spindle speed

G96: Constant line speed control

G97: Spindle speed control (cancel constant line speed control command)

G98: Return to reference point (last hole)

G99: Return to point R (middle hole)


13. Spindle forward and reverse stop command M03, M04, M05

M03: Spindle forward transmission

M04: Spindle reversal

M05: Spindle stop


14, cutting fluid switch M07, M08, M09

M07: Mist cutting fluid is on

M08: Liquid cutting fluid is on

M09: Cutting fluid off


15. Sports stop M00, M01, M02, M30

M00: Program pause

M01: Plan to stop

M02: Machine reset

M30: The program ends and the pointer returns to the beginning.


16, M98: call subroutine


17, M99: return to the main program

Contact Us

Author:

Ms. Mirada Kuo

Phone/WhatsApp:

+86886 48946412

Popular Products
You may also like
Related Information
How to Choose Customized CNC Hexagon Lock Flange Nut ?

Steel Cnc Machining Parts Display When choosing customized CNC hexagon lock flange nuts for a specific application, several factors should be considered to ensure the selection meets the requirements...

The Advantage of Customized CNC Hexagon Lock Flange Nut

Steel Precision Machining Components Display The advantages of customized CNC hexagon lock flange nuts stem from their tailored design and specific features, which address the unique requirements of...

The Specification of Customized CNC Hexagon Lock Flange Nut

Cnc Precision Machined Components Display Specifications for Cnc Machining Steel Parts hexagon lock flange nuts can vary based on the specific requirements of the application and the standards of the...

The Application of Customized CNC Hexagon Lock Flange Nut

Steel Cnc Machining Parts Display The application of customized CNC hexagon lock flange nuts is wide-ranging and can be found in various industries and scenarios where secure fastening and resistance...

Related Categories

Email to this supplier

Subject:
Email:
Message:

Your message must be betwwen 20-8000 characters

Contact Us

Author:

Ms. Mirada Kuo

Phone/WhatsApp:

+86886 48946412

Popular Products
We will contact you immediately

Fill in more information so that we can get in touch with you faster

Privacy statement: Your privacy is very important to Us. Our company promises not to disclose your personal information to any external company with out your explicit permission.

Send