0% found this document useful (0 votes)
21 views50 pages

Computer Aided Manufacturing-II

The document provides information on various G-codes used in CNC milling programming. It discusses positioning codes like G00 for rapid moves and G01 for linear cutting moves. It covers circular interpolation codes G02 for clockwise arcs and G03 for counterclockwise arcs. Additional codes covered include G04 for dwell, G17/G18/G19 for setting the machine coordinate system plane, G20/G21 for setting units, and G40/G41/G42 for cutter compensation. The document provides examples of common G-code commands and parameters used in CNC milling.

Uploaded by

elkhawad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views50 pages

Computer Aided Manufacturing-II

The document provides information on various G-codes used in CNC milling programming. It discusses positioning codes like G00 for rapid moves and G01 for linear cutting moves. It covers circular interpolation codes G02 for clockwise arcs and G03 for counterclockwise arcs. Additional codes covered include G04 for dwell, G17/G18/G19 for setting the machine coordinate system plane, G20/G21 for setting units, and G40/G41/G42 for cutter compensation. The document provides examples of common G-code commands and parameters used in CNC milling.

Uploaded by

elkhawad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 50

Computer Integrated Manufacturing

CIM

Manufacturing Engineering Department

Lecture 3– Computer Aided Manufacturing - CAM


CNC Milling Programming
G00 Positioning in Rapid
N_ G00 X_ Y_ Z_

• The G00 command is a rapid tool move. A rapid tool move is


used to move the toll linearly from position to position
without cutting any material.

• This command is not


to be used for cutting
any material

• On most CNC machine


tools, it is standard to
program a G00 rapid
for XY move only and
the Z moves separately
G00 Positioning in Rapid
• Depending on where the tool is located, there are two basic
rules to follow for safety

1. If the Z value represents a cutting


move in the negative direction, the X
and Y axes should be executed first

2. If the Z value represents a move in


the positive direction, the X and Y
should be executed last.

Example
N25 G00 X2.5 Y4.75 Rapid to X2.5 Y4.75
N30 Z0.1 Rapid down to Z0.1
G01 Linear Interpolation

N_ G01 X_ Y_ Z_ F_

• G01 command is specifically for the linear removal of


material from a workpiece, in any combination of the X, Y, or
Z axes.

• This G code provides for straight line (linear) motion from


point to point. Motion can occur in 1, 2 or 3 axes. All axis
specified will start at the same time and proceed to their
destination and arrive simultaneously at the specified feed
rate.

• Because there is contact between the cutting tool and the


workpiece, it is imperative that the proper spindle speeds and
feed rates be used.
G01 Linear Interpolation

Example
N30 G01 Z-0.125 F5 feed Down to Z-0.125 at ipm

N35 X3 Y2 F10 feed diagonally to X3, Y2 at 10 ipm


G02 Circular Interpolation (CW)
The G02 command requires an endpoint and a radius
I, J, K specify the radius

N_ G02 X_ Y_ Z_ I_ J_ K_ F_

R specifies the radius

N_ G02 X_ Y_ Z_ R_ F_

• The G02 command is used specifically for all clockwise


radial moves, whether they are quadratic arcs, partial arcs,
or complete circles, as long as long they lie in any one plane

Example
N35 G02 X2 Y2 I1 J0 F20
N45 G02 X3 Y0.5 R2 F20
G02 Circular Interpolation (CW)

• Circular interpolation commands are


used to move a tool along a circular arc
to the commanded end position. Five
pieces of information are required for
executing a circular interpolation
command:
G02 Circular Interpolation (CW)

• An easy way to determine the radius values (I and J values) is


by making a small chart:

Center Point X1 Y1
Start Point X1 Y2
__________________________
Radius I0 J-1

Result
G02 X2 Y1 I0 J-1 F5
G02 Circular Interpolation (CW)

Example
G02 CW CIRCULAR INTERPOLATION USING "I", &"J"
FOR THE X & Y AXIS
G02 CW CIRCULAR INTERPOLATION USING “R”
G03 Circular Interpolation (CCW)
The G03 command requires an endpoint and a radius

I, J, K specify the radius

N_ G03 X_ Y_ Z_ I_ J_ K_ F_

R specifies the radius

N_ G03 X_ Y_ Z_ R_ F_

• The G03 command is specifically for all


counterclockwise radial feed moves,
whether they are quadratic arcs, partial
arcs, or complete circles, as long as they
lie in any plane.

Example
N40 G03 X3 Y3.5 I-0.5 J0 F20
N60 G03 X3.5 Y1 R0.5 F20
G03 Circular Interpolation (CCW)

• An easy way to determine the radius values (I and J values) is


by making a small chart:

Center Point X2 Y1
Start Point X2 Y2
__________________________
Radius I0 J-1

Result
G03 X1 Y1 I0 J-1 F5
G03 Circular Interpolation (CCW)

Example
G03 CCW CIRCULAR INTERPOLATION USING "I", &"J"
FOR THE X & Y AXIS
G03 CCW CIRCULAR INTERPOLATION USING “R”
G04 Dwell
N_ G04 P_
• The G04 command is a Dwell command that halts all axis
movement for a specified time, while the spindle continuous
revolving at the specified rpm.

• A Dwell is used largely in drilling operations, which allows for


the clearance of chips

• This command requires a specified duration, denoted by the


letter P, and followed by the time in seconds.

Example
N30 G04 P2
(Dwell for 2 seconds)
Machine Tool Planes
• A typical CNC machining center has three axes. Any two axes
form a plane. A machine plane may be defined by looking at the
machine from standard operating position.
• For a vertical machining center, there are three standard views

 The top view (XY Plane) is


selected by G17.

 The front view (XZ plane) is


selected by G18.

 The right side vide (YZ plane)


is selected by G19.
Machine Tool Planes
• For machining applications using the circular interpolation
mode, with G02 or G03 commands, cutter radius offset with
G41 or G42 commands and fixed cycles mode with G81 to G89
commands. The plane selection is very critical.

• For all rapid motions (programmed with G00) and all linear
motions (programmed with G01), the plane selection
command is not needed.

• Any plane selection change is programmed as desired, prior to


actual tool path change. Plane can be changed as often as
necessary in a program, but only one plane can be active at any
time.

• Selection of one plane cancels any other plane, so the


G17/G18/G19 commands cancel each other.
G17 XY Plane
N_ G17
• G17 commands sets the system to default to the XY plane as the
main machining plane for specifying circular interpolation
moves and/or cutter compensation.
• Here the Z-axis is secondary and works perpendicular to the XY
plane
G18 XZ Plane N_ G18
• G18 command sets the system to the XZ plane as the main
machining plane for specifying circular interpolation moves
and/or cutter compensation.
• This command changes the default machining plane to the XZ
plane, where the Y axis is secondary, and works perpendicular
to the XZ plane.
• In this plane, it is possible to cut convex and concave arcs using
G02 and G03 circular interpolation commands.
G19 YZ Plane N_ G19
• G19 command sets the system to the YZ plane as the main
machining plane for specifying circular interpolation moves
and/or cutter compensation.
• This command changes the default machining plane to the YZ
plane, where the X axis is secondary, and works perpendicular
to the YZ plane.
• In this plane, it is possible to cut convex and concave arcs using
G02 and G03 circular interpolation commands.
G20 English Units (Inch Units)
N_ G20

• G20 command defaults the system to inch data units. When you
are running a program and encounter the G20 command, all
coordinates are stated in inch units

G21 SI Units (Metric Units)


N_ G21

• G21 command defaults the system to metric data units


(Millimeters). When you are running a program and encounter
the G21 command, all coordinates are stated in metric (mm)
units
G90 Absolute Positioning
N_ G90

• The G90 command defaults the system to accept all coordinates


as absolute coordinates. Remember that absolute coordinates
are those measured from a fixed origin (X0, Y0, Z0) and are
expressed in terms of X, Y, and Z distances.

• This command is found at the beginning of most programs to


default the system to absolute coordinates.
• On some machines it is possible to change between absolute
and incremental coordinates within a program

Example
N5 G90 G21 Set to absolute mode and metric units
G91 Incremental Positioning
N_ G91

• The G91 command defaults the system to accept all coordinates


as incremental coordinates. Remember that incremental
coordinates are those measured from the previous point and are
expressed in terms of X, Y, and Z distances.

• This command is found at the beginning of some programs to


default the system to incremental coordinates.
• On some machines it is possible to change between incremental
and absolute coordinates within a program

Example
N5 G91 G21 Set to incremental mode and metric units
Cutter Compensation

• Cutter compensation is used to offset the center of the cutter,


and shift it the distance of the radius, to the specified side of the
programmed path.
• Complex part geometries having angled lines, lines tangent to
arcs, and lines intersecting arcs involve substantial trigonometric
computations to determine the center of the cutter.
• Cutter compensation involves
programming the part geometry
directly instead of the tool center.

• The cutter compensation commands are:


 Cutter Compensation Left (G41),
 Cutter Compensation Right (G42), and
 Cutter Compensation Cancel (G40).
G41 Cutter Compensation Left
N_ G41 D_
• G41 will select cutter compensation left; that is the tool is
moved to the left of the programmed path to compensate for
the radius of the tool.
• A Dnn must also be programmed to select the correct tool size
from the DIAMETER/RADIUS offset display register.
G42 Cutter Compensation Right
N_ G42 D_
• G42 will select cutter compensation right; that is the tool is
moved to the right of the programmed path to compensate for
the radius of the tool.
• A Dnn must also be programmed to select the correct tool size
from the DIAMETER/RADIUS offset display register.
G40 Cutter Compensation Cancel
N_ G40
• G40 will cancel the G41 or G42 cutter compensation
commands.

• A tool using cutter compensation will change from a


compensated position to an uncompensated position.

• Be sure to cancel cutter compensation, when you're done with


each milling cut series that's using compensation.
Cutter Compensation
• Understanding cutter compensation can be simplified if one has a basic
understanding of manual machining. There are two common types of cutting
conditions associated with milling machines. They are CLIMB and
CONVENTIONAL cutting.

Two common rules for these types of cuts are:


• If the programmed cutter path • If the programmed cutter path
needs to mill CLIMB cutting, needs to mill with CONVENTIONAL
and if it's a standard right cutting, and it's a standard right
handed tool, it will then be handed tool, it will then be
programmed with G41 cutter programmed with G42 cutter
LEFT of the programmed path. RIGHT of the programmed path.
Cutter Compensation Example
Some Restrictions with Cutter Compensation
• A cutter compensation command (G41, G42 or G40) must be on the
same block with an X and/or Y linear command when moving onto or
off of the part using cutter compensation

• You cannot turn on or off cutter compensation with a Z axis move.

• You cannot turn ON or OFF cutter compensation in a G02 or G03


circular move, it must be in a linear G00 or G01 straight line move.
Tool Length Compensation
• During the setup process, each tool point was touched-off to
the part zero surface. From this position a TOOL LENGTH
DISTANCE offset was recorded for that tool with the TOOL
OFSET MESUR key. This TOOL LENGTH is referred to as the
"Z" axis origin move to the part zero surface.
• It is important to realize that different tools will have varying
lengths, and when tools are changed in a program, any
variation in tool length will through the origin out of zero.
• To prevent this, the tools can now be compensated for the
difference in length for either shorter or longer tools
G43 Tool Length Compensation (Plus)
N_ G43 H_
• This code selects tool length compensation in a positive
direction. That is; the tool length offsets are added to the
commanded axis positions.
• An Hnn must be programmed to select the correct offset
register from the offset display for that tool being used.
G44 Tool Length Compensation (Minus)
N_ G44 H_
• This code selects tool length compensation in a negative
direction. That is; the tool length offsets are subtracted from
the commanded axis positions.

• A Hnn must be programmed to select the correct entry from


offsets memory.

G49 Tool Length Compensation Cancels


N_ G49

• This G code cancels tool length compensation.


M-Codes
• M-codes are miscellaneous functions that include actions
necessary for machining but not those that are actual tool
movements. That is, they are auxiliary functions

• Only one M code may be programmed per block of a program.


All M codes are effective or cause an action to occur at the end
of the block.

M00 Program Stop


N_ M00
• The M00 code is used to stop a program. It also stops the
spindle and turns off the coolant and stops interpretation
lookahead processing. The program pointer will advance to
the next block and stop.
• A cycle start will continue program operation from the next
block.
M01 Optional Program Stop
N_ M01

• The M01 code is identical to M00 except that it only stops if


OPTIONAL STOP is turned on from the front panel.
• A cycle start will continue program operation from the next
block.

M02 Program End


N_ M02
• The M01 code is identical to M00 except that it only stops if
OPTIONAL STOP is turned on from the front panel. A cycle
start will continue program operation from the next block.
• This command appears on the last line of the program.
M03 Spindle On Clockwise
N_ M03

• The M03 code will start the spindle


moving is a clockwise direction at
whatever speed was previously set.

M04 Spindle On Counterclockwise

N_ M04

• The M04 code will start the spindle


moving is a counterclockwise direction at
whatever speed was previously set.
M05 Spindle Stop
N_ M05

• The M05 command turns the spindle off. Although other M-


cods turn off all functions (for example, M00 and M01), this
command is dedicated to shutting the spindle off directly.
• The M05 command appears at the end of a program.

Example
%
:1010
N5 G90 G20
N10 M06 T12
……………………………………………….
N65 M05 (Spindle stop)
M06 Tool Change
N_ M06 T_
• The M06 code is used to initiate a tool change. The previously
selected tool (T_) is put into the spindle. If the spindle was
running, it will be stopped.
The Z-axis will automatically move up to the machine zero

position and the selected tool will be put into the spindle. The Z-
axis is left at machine zero.
• The T_ must be in the same block or in a previous block. The
coolant pump will be turned off during a tool change.
Example
%
:1010
N5 G90 G20
N10 M06 T12 (Tool change to tool #12)
……………………………………………….
N65 M05
M07/M08 Coolant On
N_ M07 OR N_ M08
• The M07 and M08 commands switch on the coolant flow.

M09 Coolant Off


N_ M09
• The M09 command shuts off the coolant flow. The coolant
should be shut off prior to tool changes or when you are
rapiding the tool over long distances.
M10 Clamps On
N_ M10
• The M10 command turns on the automatic clamps to secure
the workpiece.
• Not all CNC machines have automatic clamps, but the option
exists and the actual code will vary by the machine tool make
and model.
• This command is normally in the program setup section of a
CNC Program.

Example
%
:1010
N5 G90 G20
N10 M06 T12
N15 M10 (clamp workpiece)
N20 M03 S1000
M11 Clamps Off

N_ M11

• The M11 command releases the automatic clamps so that the


workpiece may be removed and the next blank inserted.
• This command is normally in the system shutdown section of a
CNC Program.

Example
%
:1010
N5 G90 G20
………………………….
N80 M05
N85 M11 (Unclamp workpiece)
N90 M30
M30 Program End, Reset to Start

N_ M30

• The M30 code is used to stop a program. It also stops the spindle and
turns off the coolant. The program pointer will be reset to the first
block of the program and stop.

Example
%
:1012
N5 G90 G20
………………………….
N65 X0 Y0
N85 M05
N90 M30 (program end; reset to start)
M98 Call Subprogram
N_ M98 P_

• The M98 function is used to call a subroutine or subprogram.


Execution is halted in the main program and started on the
program referenced by The letter P_ address value.
• For example,
N15 M98 P1003 would call program:1003

M99 Return from Subprogram


N_ M99

• The M99 function is used to end or terminate the subprogram


and return to the main calling program.
• Execution is continued at the line immediately following the
subprogram call. It is used only at the end of the subprogram.
Block Skip
/ N_

• If turned on, upon execution of a CNC program and


encountering a block skip “/”, the program will ignore and CNC
code on that block.

Example
%
:1012
N5 G90 G20
/N10 M06 T03
/N20 G00 X0 Y0
……………………………………..
N85 M05
N90 M30
Comments
N_ (Comment statement)

• Comments help the CNC machine operator to set up and run a


job.
• Comments are defined by the use of round brackets. Anything
between them is ignored by the controller.
• Remember that comments are just aids to help in reading and
understanding a program. Their text is totally ignored even it
contains valid CNC code.

Example
N 10 G00 Z0.5 (Rapid to Z0.5)
Example
% (program start flag)
:1087 (program number)
N5 G90 G20 G40 (Absolute, Inches, and compensation canceled)
N10 M06 T04 (Tool change to toll #4)
N15 M03 S2000 (Spindle on clockwise at 2000 rpm)
N20 G00 X2 Y-0.375 M08 (Rapid to X2, Y-0.375), coolant 2 on)
N25 Z-0.25 (Rapid down to Z-0.25)
N30 G01 Y0 F15 (Feed move to point #1 at 15 ipm)
N35 X0.5 Y0.5 (Feed move to point #2)
N40 Y3.0 (Feed move to point #3)
N45 G02 X2 I0.75 J0 (Circular feed move to point #4)
N50 G01 X3.5 (Feed move to point #5)
N55 G01 Y0.5 (Feed move to point #6)
N60 G02 X3 Y0 I-0.5 J0 (Circular feed move to point #7)
N65 G01 X2 (Feed move to point #1)
N70 G00 Z1 (Rapid to Z1)
N75 X0 M09 (Rapid to X0, coolant off)
N80 M05 (Spindle off)
N85 M30 (End of program)

You might also like