List of G Codes: SR - NO. Code Function 1. 2. 3. 4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

LIST OF G CODES

SR.NO.
1.
2.
3.
4.
5.
6.
7.
8.
9
10.
11.
12.
13.
14.
15.
16.
17.
18.

CODE
G00
G01
G02
G03
G04
G20
G21
G28
G32
G70
G71
G72
G73
G74
G90
G92
G96
G97

FUNCTION
RAPID POSITIONING
LINEAR INTERPOLATION
CLOCKWISE CIRCULAR INTERPOLATION
COUNTER CLOCKWISE CIRCULAR
INTERPOLATION
DWELL IN SECONDS
INCH PROGRAMMING
METRIC PROGRAMMING
AUTO. RETURN TO REF. POINT
THREAD CUTTING CYCLE
FINISHING CYCLE
STOCK REMOVAL IN TURNING
STOCK REMOVAL IN FACING
PATTERN REPEATING CYCLE
PECK DRILLING CANNED CYCLE
DIAMETER CUTTING CYCLE
THREADING CANNED CYCLE
CONSTANT SURFACE SPEED ON
CONSTANT SURFACE SPEED OFF

LIST OF M-CODES
SR. NO.

CODE

1.
2.
3.
4.
5.
6.
7.
8.
9.
10

M01
M02
M03
M04
M05
M07
M08
M09
M13
M14

9.
10.
11.

M30
M98
M99

FUNCTION
OPTIONAL PROGRAM STOP
PROGRAM END
SPINDLE START CLOCKWISE
SPINDLE START ANTICLOCKWISE
SPINDLE STOP
COOLANT NO. 1 ON
COOLANT NO. 2 ON
COOLANTS OFF
SPINDLE CLOCKWISE & COOLANT ON
SPINDLE ANTI-CLOCKWISE & COOLANT
ON
PROGRAM END & REWIND
START OF SUBROUTINE
END OF SUBROUTINE

Characteristics of The CNC Machine

Work part machining on CNC machine requires controllable


& adjustable infeed axes which are run by Stepper motors
independent of each other. The above figure shows the X &
Z axes along with their directions of movement.

CNC Programming Basics


A CNC program comprises a series of commands with which the CNC Machine tool is
instructed to manufacture a certain profile.
For each machining process on a CNC machine, the CNC program has a
command with relevant information. These commands consists of letters, numbers &
characters.

CNC Programming Standards (ISO)


The ISO- Norm 6983 is for standardizing the CNC programming of machines. This is
however limited to standardizing certain commands as well the general structure of a
CNC program. CNC manufacturers have considerable liberty for incorporating their own
CNC commands in their control. Sequentially the general structure of a CNC program
according to ISO 6983 is illustrated.

Structure of a CNC Program


The first line of the CNC program contains the program name
( ex. G02-dia 25). This name can contain alphanumerical or numerical characters.
A CNC program consists of a sequence of blocks. They contains the relevant
geometric & technical information that the CNC control requires for each machining
step.
The program end is commanded with M30 or M02.
The comments are also allowed within the program for identifying an operation.
These, however must be set in brackets.

Structure of a Program Block


Every CNC block consists of a block number as well as specific control character, which
inform the CNC Control about the necessary action to be performed.

Structure of a Program Word


A word consists of a address letters & a number with a plus or
minus sign. The definition & sequence are designated in the
programming instructions of the CNC control system. Depending upon
the address letter, the number either have a code or a value.

Block number N :
The block number is the first word in a block. The
block number has no influence on the execution of the individual
blocks since they are invoked following the order in which they were
entered into the control.
G Function :
Together with the words for the co-ordinates. This
word essentially determines the geometrical part of the CNC program.
It consists of the address letter G & a 2 digit code.
Co-ordinates X & Z :
The co-ordinates X, Z defines the target points that
are needed to travel.
Interpolation parameters I & K :
The interpolation parameters I, K are used to
define the center of a circle for circular movements.
Feed F :
The speed at which the tool is to be moved is programmed
with the function F. This value in entered in mm/min.
Spindle Speed S :
The function S is for entering the spindle speed. It
can be directly programmed in rotations per minute.

G & M CODES IN DETAIL


Part Programming codes that are available with this machine are according to the
latest ISO standards and adopted by the Industrial CNC controller manufacturers
worldwide. Following G,M,F,T,S commands are included in this controller.

G - CODES
G00 - RAPID TRAVERSE ( Rapid Positioning )
This motion type is used to command motion at the machine's fastest possible rate. It is
used to minimize non-productive time during the machining cycle. Common uses for
rapid motion include positioning the tool to and from cutting positions, moving to clear
clamps and other obstructions, and in general, any non-cutting motion during the
program.
The command almost all CNC machines use to initiate rapid motion is G00. Within the
G00 command, the end point for the motion is given.
The G00 command moves the tool to the position in the work piece coordinate system
with an absolute or incremental format at a rapid traverse rate.
In the Absolute format command, Coordinate value of the end point is programmed. In
Incremental format command, the distance the tool is to be moved is programmed.
In this case last command for respective axis will be considered. i.e. X command will be
ignored and U command will be executed. No Feedrate (F Word) is
required to be programmed as it is taken from internally set values.

Format : G00 X __ Z __

NOTE : The rapid traverse rate in the G00 command is set internally for each axis
drive. In the Positioning mode actuated by G00, the tool is accelerated to a
predetermined speed at the start of block and it is then decelerated at the end of the
block.

G01 - LINEAR INTERPOLATION


A G01 word is commonly used to specify straight line motion. This is the most common
code used for almost all the cutting operations. In this code single axis (individual) as
well as double axis movement is possible. Double axis movement is used for taper
turning operation.
The G01 command moves the tool to the position in the work piece coordinate system
with an absolute or incremental format at a programmed feed rate in the straight line.
In the Absolute format command, Coordinate value of the end point is programmed. In
Incremental format command the distance the tool is to be moved is programmed.
The tool moves from the current position at the specified feed rate (F) to the final position
.The tool path is a direct straight line joining current position to final position. This code
is useful for OD/ID/face turning ,also for taper turning.

Format : G01 X__ Z__ F__

Here F is feed rate (tool movement speed) given in mm/min. As this code is used for
cutting operation the value of F is very less that has to be decided according to the
material of job.

G02 - CIRCULAR INTERPOLATION (CLOCKWISE)


The G02 command is utilized to move the tool in the circular arc profile. With G02 the
movement will be in the Clockwise direction. The movement taken will be at the
programmed feed rate
.

Format : G02 X__ Z__ I__ K__ F__


G02 X__ Z__ R__ F__

Here in first syntax,


I = Distance between start point & center point of arc along X-axis.
K= Distance between start point & center point of arc along Z-axis.
& in second syntax
R = Radius of the arc.

G03 - CIRCULAR INTERPOLATION (ANTI-CLOCKWISE)


The G03 command is used to move the tool in the anti circular arc profile.
movement taken will be at the programmed feed rate.
Format : G03 X__ Z__ I__ K__ F__
G03 X__ Z__ R__ F__
Here ,
I = Distance between start point & center point of arc along X-axis.
K= Distance between start point& center point of arc along Z-axis.

The

G04 - PROGRAMMED DWELL


G04 Command will delay the execution of next block by given time.

Format : G04 X__


G04 U__
X & U specifies dwell in seconds.
This code is used mainly after the spindle ON command, as the spindle will
require some time to reach to the specified speed, before that the cutting operation
should not start.

G20 - INCH PROGRAMMING


This is the modal command which commands the controller that the dimensions
specified in blocks following the current block is in the INCH system.
Format : G20
G21 - METRIC PROGRAMMING
This is the modal command which commands the controller that the dimensions
specified in blocks following the current block is in the METRIC system. i.e. in
millimeter format. METRIC format is the default format of dimensioning.
Format :

G21

NOTE : The definition of dimensioning system is to be done only once in the part
program in first block. If it is specified more than one time the preprocessor will
invoke the ERROR ALARM showing that this is the violation of programming
code. It is not possible to switch from G20 to G21 in the program.

G28 - AUTO. RETURN TO REF. POINT


This command will move the tool to the specified reference point. In this command the
tool movement will be rapid.

Format : G28 U___ W___


No Feedrate (F Word) is required to be programmed as it is taken from internally set
values.

G70 - FINISHING CYCLE


After roughing operation this cycle is used to achieve the final dimensions.
Finish allowance has to be kept before starting this cycle. The tool path is same as the
roughing operation.

Format : G70 P __ Q __

Here ,
P= starting block of the roughing cycle.
Q= end block of roughing cycle.

This cycle is used after G71,G72 & G73 codes. The finishing
allowances values are taken from the above codes.

G71 STOCK REMOVAL IN TURNING


This code is used to do turning as well as taper operation. The program by this code
becomes very simple. You will have to write the program for the final profile & when the
program is executed the depth of cut is taken in X direction. The total profile is
achieved in steps, decided by depth of cut. Please refer the example given after the
syntax.

Format : G71 U(d) R(e)


G71 P__ Q__ U(u) W(w) F__
Here ,
U(d) = Depth of Cut
R(e) = Escaping amount ( After depth of cut, this is the return path
for the tool in X + Direction)
P
= Starting block no. of the program for the required shape
Q
= Final block no. of the program for the required shape
U(u) = Finishing allowance in X direction.
W(w) = Finishing allowance in Z direction.
F
= Feed-rate for cutting.

G72 STOCK REMOVAL IN FACING


This cycle is same as G71. The only difference is that the cutting
operation is done parallel to X axis i.e. the depth of cut is in Z direction.
Format : G72 W(d) R(e)
G71 P__ Q__ U(u) W(w) F__

Here ,
W(d) = Depth of Cut ( For trainer machine it is 1mm).
R(e) = Escaping amount ( After depth of cut, this is the return path
for the tool in X + Direction)
P
= Starting block no. of the program for the required shape
Q
= Final block no. of the program for the required shape
U(u) = Finishing allowance in X direction.
W(w) = Finishing allowance in Z direction.
F
= Feed-rate for cutting.

G73 PATTERN REPEATING CYCLE:


This cycle allows cutting a fixed pattern repeatedly, with a pattern
being displaced bit by bit.

Format :

G73 U(i) W(k) R(d)


G73 P__ Q__ U(u) W(w) F__

Where ,
U(i) = Distance of relief in X direction
This U(i) = (Job. Diameter Min. Diameter in the program) / 2
W(k) = Distance of relief in Z direction
R(d) = No. of divisions for the pattern.
This R = ( U(i) / Max. Depth of Cut) + 1
P
= Starting block no. of the program for the required shape
Q
= Final block no. of the program for the required shape
U(u) = Finishing allowance in X direction.
W(w) = Finishing allowance in Z direction.
F
= Feed-rate for cutting.

G74-PECK DRILLING CYCLE


This cycle is designed for deep hole drilling .The drill entering the work piece by a
predetermined amount then backing off by another set amount to provide breaking &
allowing chips to clear the drill flutes.

Format : G74 X__ Z__ Q__ R__ F__

Where,
X&Z = Final respective coordinates
Q = Depth of cut.
R = Return amount .
F = Feed in mm/min

G90 Diameter Cutting Cycle


This cycle is used to reduce the diameter of the job. In this cycle the tool will be back to
the starting position after cutting the diameter. In this machine the depth of cut is 1mm.
So if you want to reduce the diameter of the job from 22mm to 18 mm you will have to
use 4 G90 codes.

Format : G90 X___ Z___ F__

G92 -THREAD CUTTING CANNED CYCLE


This canned cycle is suitable for External thread cutting operation. This cycle is same
to that of G32 except that in G92 the tool is returned to the starting position.

Format : G92 X___ Z___ F__

where,
X = Threading diameter.
Z = Thread length.
F = Thread Pitch.
NOTE :
While the execution of thread cutting cycle, Spindle Speed is
nonprogrammable, Controller will automatically adjust it to proper value and
after completing the threading operation the original Spindle Speed will be
restored.

G96 - CONSTANT SURFACE SPEED ON


G97 - CONSTANT SURFACE SPEED OFF_
With this command active the constant surface speed can be achieved while cutting
operation takes place. This is the modal command and will not have any effect on the
spindle speed while thread cutting operation.

Format : G96 S__


G97

Where,
S = Surface speed in meter/min.
G97= This command will cancel the Constant surface speed option
set by the G96 command.

M CODES
M00 PROGRAM HAULT
This command is useful to check the job in between the program. With this
command the axis & the spindle will be stopped. After checking the job parameters rest
program will be executed by pressing the ENTER key. The spindle will be automatically
started with the previous speed.

Format : M00

M01 - OPTIONAL PROGRAM STOP


The M01 is used to STOP the Operation in Auto Mode. This code is only effective when
the Optional Stop is Enabled. This can be set from Setup menu.

Format : M01
In this case Auto. Mode Operation will be Stopped. User can continue the Operation
after Pressing the <Enter> Key.
M02 - PROGRAM END
The M02 is used to END the Operation in Auto. Mode. After a block specifying the
end of program is executed, control returns to the start of program.

Format : M02

M03 - SPINDLE ON CLOCKWISE


This command is used to start the Spindle in Clockwise Direction. Spindle speed can
be specified with this command as follows,

Format : M03 S__

In this case spindle will start rotating in Clockwise direction with S speed in rpm. Speed
of rotation is specified in S word (i.e. S600). But S word is not mandatory. If not
specified, default maximum speed set internally is used for operation.
M04 - SPINDLE ON ANTICLOCKWISE
This command is used to start the Spindle in anticlockwise Direction.

Format :M04 S__

In this case spindle will start rotating in anticlockwise direction with the S speed..
M05 - SPINDLE STOP
This command is used to STOP the Spindle rotation.

Format : M05

Spindle rotation can also be stopped by M30 command.

M08 - COOLANT ON
This command is used to ON the Coolant Pump provided. If two pumps are provided,
M08 command will start the Pump

Format : M08

M09 - COOLANT PUMP OFF


This command is used to STOP the Coolant Pumps. If both pumps are ON, M09
command will STOP the Pump.

Format : M09

Coolant Pumps can also be stopped by M30 command.

M13 SPINDLE CLOCKWISE & COOLANT ON


This command is used to move the spindle in clockwise direction & coolant ON.

Format : M13 S__

S = spindle speed in rpm.


M14 SPINDLE ANTICLOCKWISE & COOLANT ON
This command is used to move the spindle in anticlockwise direction & coolant ON.

Format : M14 S__

S = spindle speed in rpm.

M30 - END OF PROGRAM


M30 command must be the last command in the program. This command indicates the
END OF PROGRAM. If not specified, ERROR ALARM will be displayed. The M30
command will stop all the Auxiliary functions like, Spindle & Coolant. After the
execution of this command program will be reset to first Block.

M98 SUBROUTINE CALL


M99 - END OF SUBROUTINE
When a program contains certain fixed sequences or frequently repeated patterns, these
sequences or patterns may be entered into memory as a subprogram to simplify
programming. A subprogram can call another subprogram .When the main program call a
subprogram, it is regarded as a one-loop subprogram call.
When a command calling a subprogram is encountered in the main program control is
passed to the subprogram. And control returns to the main program when returning
command is encountered in the program.

Format :

M98 P__ R__


M99

Where,
P = subroutine repetitions.
R = subroutine label ( alphabetical as well as numerical).

M98 is followed by P i.e. No. of repetitions & then by label which can
be either name or no.
N001 G21
|
|
|
|
|
N040 M98 P1 ABC
N041 G00 X30
|
|
|
N100 M30

ABC
N105 G00 U40 W0

|
|
N135 M98 P1 XYZ
N140 G00 W1
|
|

|
N150 M99

XYZ
N155 G01 U20
|

|
|
|

|
N170 M99

Each subroutine is terminated by M99 & a subroutine can have another


subroutine in it as shown above. The subroutines has to be written in
Incremental format only.

You might also like