Posted by: davidhayden | February 28, 2012

Table of Common Turning G Codes for CNC Programming


Notes about G codes for CNC Programming.  

The following is taken from 7 Easy Steps to CNC Programming Book II, Beyond the Beginning.

There are two types of G codes, modal and non-modal.  Modal G codes remain in effect until canceled or changed by another G code.  For example G0 / G00, which initiates rapid travel, is modal.  So once programmed, the machine will remain in rapid travel mode until a G1 / G01, G2 / G02, G3 / G03 is commanded.  By contrast, G4 / G04, which causes the machine to dwell for a specified time is non-modal.  When a G4 / G04 is commanded, the machine suspends machine motions code, dwells for the programmed time, then returns to normal movements.
  
There is some degree of variation in the use of G and M codes.  The 1980 ANSI/EIA standard RS-274-D left several ranges of G and M codes unassigned.  These unassigned codes give machine tool builders more flexibility to build custom features into their machines and controls.
G codes belong to several groups.  Early NC controls did not allow combining G codes on the same line of a program.  More recent CNC controls do allow combining G codes on the same line providing the G codes are from different groups.  
  
If two G codes from the same group are put on the same line, the machine will only act on the last G code of the group.  For example, if a line read G01 X0 Y0 F3.0 G00, the control would tell the machine to rapid travel to point X0, Y0 rather than feed to the point at the programmed F3.0 feed rate.
  
The parameter column in the following table shows the required / necessary codes that may be needed to complete the command.

The following pages provide a list of the common turning G codes.

Most Common Turning G Codes

G Code 

G Code Group 

G Code Parameters 

What the G CODE does / How to Use the G Code 

G0 / G00 

01 

 

Modal. Initiates rapid travel.  Causes the machine to move the tool to the programmed coordinate at the machines maximum speed. 

G1 / G01 

01 

Modal. Initiates linear feed.  Moves the tool in a straight line at the programmed feed rate as specified by F. 

G2 / G02 

01 

I, K, R, 

Modal. Initiates clockwise interpolation.  Moves the tool to a specified endpoint in a clockwise direction.  The parameters I, J ,K and R define the size of the arc.

I, J ,K define the center of the arc and are generally used together.  These parameters allow programming of arcs from 0-360 degrees.

The R command is a shortcut for defining the arc radius and is never used on the same line with I, J, or K. The R command can be used to program arcs up to 360 degrees but not including 360 degrees. 

G3 / G03 

01 

I, K, R,

Modal. Initiates counterclockwise interpolation.  Moves the tool to a specified endpoint in a counterclockwise direction.  The parameters I, J ,K and R define the size of the arc.

I, J ,K define the center of the arc and are generally used together.  These parameters allow programming of arcs from 0-360 degrees.

The R command is a shortcut for defining the arc radius and is never used on the same line with I, J, or K. The R command can be used to program arcs up to 360 degrees but not including 360 degrees. 

G4 / G04 

00 

X, P 

Non-modal. Commands the machine to dwell or sit still for X seconds or P miliseconds.  For example G04 X3 would cause the machine to dwell for 3 seconds. 
 
To dwell for 3 seconds using the P parameter, the command would be G04 P3000 

This is useful for having the machine sit idle while coolant comes on or the spindle gets up to speed, etc. 

G17 

16 

 

Modal. Sets active plane to the X, Y plane. 

G18 

16 

 

Modal. Sets active plane to the X, Z plane (most common plane for turning). 

G19 

16 

 

Modal. Sets active plane to the Y, Z plane 

G20 / G94 

06 

 

Modal. Sets the machine to operate in inch mode. 

G21 / G95 

06 

 

Modal. Sets the machine to operate in metric mode. 

G28 

00 

 

Non-Modal.  Commands the machine to move to the machine zero-reference point through an intermediate point. 

G32 / G33 

01 

Modal.  Single pass Threading. This command causes the machine to make one threading pass that ends at the X, Z coordinates specified in the G33 line.  The F or feed rate parameter controls the pitch of the thread. 

For older machines that cannot feed in inches per revolution you need to calculate the feed rate using the following formula  1/TPI x RPM.   

For example, the feed rate for a 12 pitch thread at 100 RPM would be 1/12 x 100 or 8.3333.  The F command on a machine with decimal point programming would be F8.333. 

G40 

07 

 

Modal.  Cancels cuter compensation. 

G41 

07 

Modal. Cutter compensation left. This command tells the machine to move the cutter to the left of the programmed path by the amount specified in the offset identified by the D word. 

For example G41 X-3.000 D23 commands the machine to move to X-3 but to keep the tool to the left of the programmed path by amount in offset register 23. 

Left and Right are determined by looking down the tool path from start point to end point.  As you imagine looking down that path, the compensation will be to the left. 

G42 

07 

Modal. Cutter compensation Right. This command tells the machine to move the cutter to the right of the programmed path by the amount specified in the offset identified by the D word.

  For example G41 X-3.000 D23 commands the machine to move to X-3 but to keep the tool to the right of the programmed path by amount in offset register 23. 

Left and Right are determined by looking down the tool path from start point to end point.  As you imagine looking down that path, the compensation will be to the right. 

G50 / G92 

00 

X, Z, 

Modal. Used to program the absolute zero. Additionally the G50 is used to establish the maximum spindle speed when using Constant Surface Speed spindle control.  On some machines these functions are handled by the G92 command. 

The X and Z would be programmed as the distance and direction from the desired absolute zero point to the current tool position.  The S would be programmed as direct RPM in a manner similar to this: G50 S350  The example command would insure the spindle speed never exceeded 350 RPM. 

G70 

00 

 

Modal.  The ANSI/EIA RS-274-D standard command for inch programming. 

G70 

00 

P, Q 

Non-Modal. Finishing Cycle. This is a different use of the G70 command. On the controls that use this version of G70, this command is used in conjunction with a G71, G72 or G73 command.

The part is first roughed with a G71, G72 or G73 command. Once the roughing cycle is completed, the G70 is used to perform the finish pass. 
 
P specifies the starting block of the roughing cycle. Q specifies the ending block of the roughing cycle.
 
For example suppose you roughed a part with one of the roughing cycles starting at line N100 and ending at line N125, the G70 command would look like: 

G70 P100 Q125; 

G71 

00 

 

Modal.  The ANSI/EIA RS-274-D standard command for metric programming. 

G71 

00 

P, Q, R, U, W 

Non-Modal Turning stock removal.  This command simplifies roughing by allowing you to describe the finish turn in a series of commands and defining how much stock is to be removed. This is a linear roughing command that removes stock off the diameter by cutting parallel to the center line of the part. 

The command takes 2 lines. The first line defines the depth of cut to take per pass and the amount to retract the tool for clearance. 

The second line of the command defines:

* the starting block of the finish pass (P),
* the ending block of the finish pass (Q),
* the direction and amount of stock to leave on
  the X axis (U)
* the direction and amount of stock to leave on
  the Z axis (W)

A typical G71 command set might look like: 

G71 U.125 R.03; 

G71 P100 Q125 U.015 W.015; 

This command would tell the control to look ahead to blocks 100-125, rough turn at .125 per pass, retract the tool by .031, and leave .015 stock on the X and Z axis for finishing. 

G72 

00 

P, Q, R, U, W 

Non-Modal Facing stock removal.  This command simplifies roughing by allowing you to describe the finish part in a series of commands and defining how much stock is to be removed.  This is a linear roughing command that removes stock off the faces by cutting perpendicular to the center line of the part.

The command and parameters are used as described in the G71 command.  The notable exception is that the first G72 line is a W and an R because the depth of cut is along the face rather than the diameter. 

G73 

00 

D, I, K, P,
Q, U, 

Non-Modal Contour roughing / pattern repeating.  This cycle is similar to the previous G71 and G72 in that it removes stock based on the finish profile as defined by the P and Q parameters.  The command is different in that it removes the stock in cuts parallel to the finish pass rather than in straight lines. 

G73
contd. 

00 

D, I, K, 
P, Q, U, 

The P, Q, U and W parameters are the same as described above.  D specifies depth of cut per side, I specifies total displacement along the X axis, and K specifies total displacement along the Z axis.

A typical G73 command might look like: 

G73 P185 Q205 U.015 W.015 I.3 K.25 D.1; 

G90 

03 

 

Modal. The ANSI/EIA RS-274-D standard command for absolute programming.  

On some controls, the use of X and Z coordinate commands implies absolute programming and the use of U and W coordinate commands implies incremental programming. 

G91 

03 

 

Modal. The ANSI/EIA RS-274-D standard command for incremental programming. 

On some controls, the use of U and W coordinate commands implies incremental programming and the use of X and Z coordinate commands implies absolute programming. 

G96 

02 

S, U, X 

Modal. Constant Surface speed control.  As you know when turning a piece on lathe, as you face to the center, the surface speed of the cutting drops. 

The G96 command insures that the cutting surface speed (CSS) remains constant as set by the parameter S.  For example, an S350 parameter setting on the G96 command line tells the machine to keep the machine cutting at a constant 350 surface feet per minute. 

The other important parameters to include are the U or X.  For the machine to calculate the proper spindle speed to maintain the programmed CSS, you must tell the machine the current tool location with respect to the centerline of the part. 

A couple of notes about G96 programming: 

Clearly, as the tool moves closer to the center of the part you reach a theoretical infinite spindle speed.  Programming CSS will not enable the machine to reach a spindle speed greater than the machine’s limitations. 

G96
contd. 

02 

S, U, X 

Depending on the rigidity of your set up, the condition of your machine or any safety considerations, you may not want the spindle speed to exceed a particular RPM.  On a separate line, you can program a maximum allowable RPM while in CSS mode.  Depending on your machine control, the command to control the maximum RPM will either be a G50 or a G92.  

For example, if you program a G50 S200.  The spindle speed would never exceed 200 RPM while in G96 mode, even if towards the center of the part, the surface speed drops below the programmed CSS. 

Another point to remember. If you are programming a roughing cycle and the tool is quickly and frequently moving from a cutting diameter to a clearance diameter, the spindle RPM will rise and fall with each move.  This is not good for the machine.  So, in a situation like this, it is best to program a G97 on the retract, then reprogram the G96 on the block prior to engaging the part. 

G97 

02 

 

Modal. CSS cancel.  Returns the machine to direct RPM spindle speed programming. 

G98 

10 

 

Modal. Instructs the control to interpret the feed rate commands in inches/mm per minute. 

G99 

10 

 

Modal. Instructs the control to interpret the feed rate commands in inches/mm per revolution. 

Look to future posts that will list some Common Milling G Codes for CNC Programming excerpted from 7 Easy Steps to CNC Programming . . . A Beginner’s Guide.

About these ads

Responses

  1. [...] For the list of CNC Programming G codes for turning applications see previous post. [...]

  2. [...] Most Common G Codes for CNC Milling Applications This is the thrid post in a series about common G & M codes that started with the common G codes for CNC turning / CNC lathe work.   [...]

  3. [...] Most Common M Codes for Programming CNC Mills This is the fourth post in a series about common G & M codes that started with the common G codes for CNC turning / CNC lathe work. [...]

  4. thanks for the tuto

  5. It is very useful for who have doubts on G Codes and very very useful.Thank you

  6. Can you provide the service,by using that list of the codes can be downloaded?

    i think it should be available for download.

    thank you…

    • I emailed you a copy of the more common G & M codes. I hope that helps.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

Join 377 other followers

%d bloggers like this: