0% found this document useful (0 votes)
1K views

Slide01 Introduction CNC

This document discusses CAD/CAM/CAE and CNC programming. It provides an overview of how a manufacturing company processes a job for a CNC machine. It then explains the process of preparing a CNC program, including writing the code, using programming sheets, and different types of tool motion like rapid moves and linear/arc feed moves. It also covers canned cycles which simplify programming standard operations.

Uploaded by

alexiskandar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Slide01 Introduction CNC

This document discusses CAD/CAM/CAE and CNC programming. It provides an overview of how a manufacturing company processes a job for a CNC machine. It then explains the process of preparing a CNC program, including writing the code, using programming sheets, and different types of tool motion like rapid moves and linear/arc feed moves. It also covers canned cycles which simplify programming standard operations.

Uploaded by

alexiskandar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 149

CAD/CAM/CAE

Computer Aided Design/Computer Aided


Manufacturing/Computer Aided
Manufacturing
INTRODUCTION
Before you can fully understand CNC, you must first
understand how a manufacturing company processes a
job that will be produced on a CNC machine. The
following is an example of how a company may break
down the CNC process .
FLOW OF CNC PROCESSING
1. Obtain or develop the part drawing.
2. Decide what machine will produce the part.
3. Decide on the machining sequence.
4. Choose the tooling required.
5. Do the required math calculations for the program
coordinates.
6. Calculate the speeds and feeds required for the
tooling and part material.
7. Write the NC program.
8. Prepare setup sheets and tool lists.
9. Send the program to machine.
10. Verify the program.
11. Run the program if no changes are required
PREPARING A PROGRAM

A program is a sequential list of machining


instructions for the CNC machine to execute.
These instructions are CNC code that consists of
blocks (also called lines). Each block contains
an individual command for a movement or
specific action. As with conventional machines,
one movement is made before the next one. This
is why CNC codes are listed sequentially in
numbered blocks.
The following is a sample CNC milling program. Note how each
block is numbered and usually contains only one specific
command. The blocks are numbered in increments of 5 (this is the
software default on startup). Each block contains specific
information for the machine to execute in sequence.
Workpiece Size: X4, Y3, Z1
Tool: Tool #3, 3/8" Slot Drill
Tool Start position: X0, Y0, Z1.0
% (Program Start Flag)
:1002 (Program #1002)
N5 G90 G20 G40 G17 (Block #5, Absolute in Inches)
N10 M06 T3 (Tool Change to Tool #3)
N15 M03 S1250 (Spindle on CW at 1250 RPM)
N20 G00 X1.0 Y1.0 (Rapid over to X1.0, Y1.0)
N25 Z0.1 (Rapid down to Z0.1)
N30 G01 Z-0.125 F5 (Feed down to Z-0.125 at 5ipm)
N35 X3.0 Y2.0 F10.0 (Feed diagonally to X3.0, Y2.0 at 10ipm)
N40 G00 Z1.0 (Rapid up to Z1.0)
N45 X0 Y0 (Rapid over to X0, Y0)
N50 M05 (Spindle Off)
N55 M30 (Program End)
CNC CODES
There are two major types of CNC codes, or letter addresses,
in any program. The major CNC codes are called G-codes and
M-codes.

G-codes are preparatory functions, which involve actual tool


moves (for example, control of the machine). These include
rapid moves, feed moves, radial feed moves, dwells, roughing,
and profiling cycles.

M-codes are miscellaneous functions, which include actions


necessary for machining but not those that are actual tool
movements (for example, auxiliary functions). These include
actions such as spindle on and off, tool changes, coolant on
and off, program stops, and related functions.
Each designation used in CNC programming is called a letter
address. The letters used for programming are as follows:
N Block Number: Specifies the start of a block
G Preparatory function, as previously explained
X X Axis Coordinate
Y Y Axis Coordinate
Z Z Axis Coordinate
I X Axis location of Arc center
J Y Axis location of Arc center
K Z Axis location of Arc center
S Sets the spindle speed
F Assigns a feedrate
T Specifies tool to be used
M Miscellaneous function, as previously explained
THREE MAJOR PHASES OF A CNC
PROGRAM
The three phases of a CNC program are:
(1) Program setup: contains all the instructions that
prepare the machine for operation
(2) Material removal: deals exclusively with the
actual cutting feed moves
(3) System shutdown: contains the G- and M-codes
that turn off all the options that were turned on in the
setup phase.
The following shows the three major phases of a CNC
program.
%
:1001
N5 G90 G20
Program setup N10 M06 T2
N15 M03 S1200
N20 G00 X1.00 Y1.00
Material removal N25 Z0.125
N30 G01 Z-0.125 F5.0
N35 G01 X2.0 Y2.0
N40 G00 Z1.0
N45 X0 Y0
System shutdown N50 M05
N55 M30
Examine the following program to see
how it was written.
% Program Start Flag
:1001 Program Number
N5 G90 G20 Use Absolute Coordinates and inch programming
N10 M06 T1 Tool change, use Tool #1.
N15 M03 S1200 Turn spindle on CW at 1200 RPM
N20 G00 X1 Y1 Z0.125 Rapid move to X1 Y1 Z0.125
N25 G01 Z-0.125 F5.0 Feed down into the part 0.125" at 5 ipm
N30 G01 X3.0 Feed to X3 (still at 5 ipm)
N35 G01 Y2.0 Feed to Y2 (still at 5 ipm)
N40 G01 X1 Feed back to X1
N45 G01 Y1 Feed back to Y1
N50 G01 Z-0.25 Feed down to Z-0.25" (still at 5 ipm)
N55 G01 X3 Feed across to X3
N60 Y2 Feed to Y2 (The G01 is MODAL)
N65 X1 Feed back to X1 (G01 is still MODAL)
N70 Y1 Feed to start point at Y1
N75 G00 Z0.050 Rapid to Z0.05
N80 G00 Z1 Rapid tool up to Z1 or clearance plane
N85 X0 Y0 Rapid to home position
N85 M05 Turn spindle off
N90 M30 End of program
USING A PROGRAMMING SHEET
You use the CNC program sheet to prepare the CNC program. Doing so
simplifies the writing of the CNC program

EQUIVALENT CNC BLOCKS --> N5 G20 G90


N10 T02 M06
N15 M03 S1200
N20 G00 X0 Y0
N25 Z0.1
N30 G01 Z-0.1 F2.0
N35 G01 X1.5
BLOCK FORMAT
Block format is often more important than program format. It is vital that each
block of CNC code be entered into the CPU correctly. Each block comprises
different components, which can produce tool moves on the machine.

Following is a sample block of CNC code. Examine it closely and note how it is
written.
N135 G01 X1.0 Y1.0 Z0.125 F5.0
N135 Block Number Shows the current CNC block number.
G01 G-Code The G-code is the command that tells the machine what it is to
do in this case, a linear feed move.
X1.0 Y1.0 Z0.125 Coordinate. This gives the machine an endpoint for its move.
X designates an X axis coordinate. Y designates a Y coordinate. Z
designates a Z coordinate.
F5.0 Special Function. Any special function or related parameter is to be
included here. In this case, a feed rate of 5 inches per minute is
programmed.
There are some simple restrictions to CNC blocks:
Each may contain only one tool move.
Each may contain any number of nontool move G-codes, provided they do not
conflict with each other (for example, G42 and G43).
Each may contain only one feedrate per block.
Each may contain only one specified tool or spindle speed.
The block numbers should be sequential.
Both the program start flag and the program number must be independent of all
other commands.
The data within a block should follow the sequence shown in the above sample
block, N-block number, G-code, any coordinates, and other required functions.
Each may contain only one M-code per block.
PREPARING TO
PROGRAM
Before you write a CNC program, you
must first prepare to write it. The
success of a CNC program is
directly related to the preparation
that you do before you write the
CNC program. You should do three
things before you begin to write a
program:
1. Develop an order of operations.
2. Do all the necessary math and
complete a coordinate sheet.
3. Choose your tooling and calculate
speeds and feedrates.
The CNC operator can also use coordinate and setup sheets. Using
them as references makes generation of the CNC program easier.
Program zero allows you to specify a position from which to start or to
work. Once program zero has been defined, all coordinates used in a program
will be referenced from this point. When you work from a constant program
zero, you are using absolute programming. In incremental programming, you
have in effect a floating program zero that changes at all times

To specify absolute positions in


the X direction, use the X-
address word. To specify
absolute positions in the Y and
Z directions, use the Y- and Z-
address words, respectively.
The position selected for
milling is always the lower left-
hand corner and top surface of
the workpiece. The position
used for the lathe is always the
center of the part in X and the
right-hand end of the finished
workpiece in Z.
TOOL MOTION

Generally, three types of tool motion are used on a CNC


machine:
G00 Rapid tool move. Nonmachining command. Each
axis trajectory is exhausted as fast as the motor can drive
the axes.
G01 Straight-line feed move. Linear interpolation.
Coordinated moves at a controlled feedrate.
G02/G03 Two-dimensional arc feed moves. Circular
interpolation.
TOOL MOTION
USING CANNED CYCLES

Canned, or fixed program, cycles are aids that simplify


programming. Canned cycles combine many standard
programming operations and are designed to shorten the
program length, minimize math calculations, and optimize
cutting conditions to improve the efficiency of the machine.

Examples of canned cycles on a mill are drilling, boring, spot


facing, tapping, and so on; on a lathe, threading, rough facing
and turning, and pattern repeating cycles. On the lathe,
canned cycles are also referred to as multiple repetitive
cycles. You will find examples of these cycles as you work
through the milling and turning sections.
USING CANNED CYCLES
Tooling Not all cutting operations can
be performed with a single
tool. Separate tools are used
for roughing and finishing,
and tasks such as drilling,
slotting, and thread cutting
require their own specific
tools. The correct cutting tool must
be used at all times. The size and
shape of the cutting tools that you can
use depend on the size and shape of
the finished part. A tool
manufacturer's catalog will give
Remember: The depth of cut that can be you a complete list of the
taken depends on the workpiece material, various types of tools
the coolant, the type of tool, and the available and the applications
machine tool itself.
of each
Tooling
The tool most often used to
make holes is the fluted
drill. Drills are made with
two, three, or four cutting
lips. The two-lip drill is
used for drilling solid
stock. The three- and four-
lip drills are used for
enlarging holes that have
been previously drilled.
Modern drills can also
have coolant holes for
direct delivery of coolant
through the end of the
drill.
Tooling
The rotating cutter, termed the
milling cutter, has almost an
unlimited variety of shapes and
sizes for milling regular and
irregular forms. The most common
milling cutter is the end mill. Other
tools that are often used are shell
mills, face mills, and roughing
mills. When milling, care must be
taken not to take a cut that is
deeper than the milling cutter can
handle. End mills come in various
shapes and sizes, each designed to
perform a specific task. The three
basic shapes of standard end mills
are flat, ballnose, and bullnose.
Tooling
In lathe operations, the tool is driven
through the material to remove chips
from the workpiece in order to leave
geometrically true surfaces. The type
of surface produced by the cutting
operation depends on the shape of the
tool and the path it follows through the
material. When the cutting edge of the
tool breaks down, the surface finish
becomes poor and the cutting forces
rise. Vibration and chatter are definite
signs of tool wear, although many
forces such as depth of cut, properties
of materials, friction forces, and
rubbing of the tool nose also affect tool
vibration.
FEEDRATES AND SPINDLE SPEEDS
It is very important to fully understand the value of the correct
feedrate and spindle speed. Too fast a speed or feedrate will
result in early tool failure or poor surface finish. Too slow a
speed or feedrate will lead to increased machining time and,
possibly, greater part cost. New tool technology has produced
a wide range of tools that can be used at greater speeds and feed
rates for longer periods.

For milling, the correct speeds and feed rates are determined in
part by the diameter of the cutter, spindle RPM, number of teeth
on the cutter, chip load per tooth, and surface feet per minute for
a particular material. For turning, the diameter of the workpiece
and the surface feet per minute for the material are factors in
determining the proper speeds and feed rates.
CUTTING FLUIDS
There are three main reasons for using cutting fluid
To remove or reduce the heat being produced
To reduce cutting tool wear
To help clear chips from the workpiece area
End of Part -10
CAD/CAM/CAE
Computer Aided Design/Computer Aided
Manufacturing/Computer Aided Manufacturing

CNC Fundamentals
CNC Fundamentals
All CNC machine tools follow the same standard for
motion nomenclature and the same coordinate system.
This is defined as the EIA 267-C standard. The standard
defines a machine coordinate system and machine
movements so that a programmer can describe
machining operations without worrying about whether
a tool approaches a workpiece or a workpiece
approaches a tool.
Machine coordinate system
The direction of each finger
represents the positive direction of
motion.
The axis of the main spindle is
always Z, and the positive
direction is into the spindle.
On a mill the longest travel slide
is designated the X axis and is
always perpendicular to the Z axis.
If you rotate your hand looking
into your middle finger, the
forefinger represents the Y axis.
The base of your fingers is the
start point or (X0, Y0, Z0).
Axis and motion nomenclature Rotary motion
designation
The right-hand rule for determining the correct axis on a
CNC machine may also be used to determine the
clockwise rotary motion about X, Y, and Z.

To determine the positive, or clockwise, direction about


an axis, close your hand with the thumb pointing out.
The thumb may represent the X, Y, or Z direction and the
curl of the fingers may represent the clockwise, or
positive, rotation about each axis.
These are known as A, B, and C and represent the rotary
motions about X, Y, and Z, respectively.
Axis and motion nomenclature CNC mill

On this gantry mill the spindle travels along the X Axis. The
travel direction of the table designates the Y Axis. The Z Axis is
designated by the stationary vertical column.
Axis and motion nomenclature CNC lathe

On most CNC lathes the Z Axis is parallel to


the spindle and longer than the X Axis.
Axis and motion nomenclature 5-axis CNC
contour mill

On this five-axis horizontal contour milling machine, note the


orientation of the X and Y axes in relation to the Z Axis. The
rotary axes for both the X and Y axes are designated by the A and
B rotary tables.
Axis and motion nomenclature vertical CNC knee
mill

On a common vertical knee CNC mill the spindle is


stationary while the rest of the components move
according to their axis designations (X, Y, and Z).
Axis and motion nomenclature CNC punch
machine

On a CNC punch press the part is moved in the X


and Y directions while the punch is stationary.
CNC milling fundamentals The three
Cartesian planes

The three planes in the Cartesian coordinate system are XY,


XZ, and YZ. These are referred to as G17, G18, and G19,
respectively, on the mill.
CNC milling fundamentals The part reference
zero
The video illustrates the two reference points on a
CNC Machine: Machine Reference Zero (MRZ) and
the Part Reference Zero (PRZ). All coordinates are
based on these two points.

All CNC machine tools require a reference point


from which to base coordinates.
It is generally easier to use a point on the
workpiece itself for reference, because the
coordinates apply to the part anyway thus the
PRZ designation.
The PRZ is defined as the lower left-hand corner
and the top of the stock of each part.
The advantages of having the PRZ at the lower left top
corner are:
1.Geometry creation is in the positive XY plane for
CAD/CAM systems.
2.The corner of the workpiece is easy to find.
3.All negative Z depths are below the surface of the
workpiece.
The Cartesian graph
Cartesian coordinates were
invented by Ren Descartes,
who is famous for the phrase
"I think, therefore I am."
Most Cartesian graphs for
milling and turning use a
three-axis coordinate system,
denoted by the X, Y, and Z
axes. These coordinates are
used to instruct the machine
tool where to move on the
workpiece.
CNC milling fundamentals Absolute coordinates

Absolute coordinates use the


origin as the reference point.
This means that any point on
the Cartesian graph can be
plotted accurately by
measuring the distance from
the origin to the point, first in
the X direction, then in the Y
direction, and then, if
applicable, in the Z direction.
CNC milling fundamentals Incremental
coordinates

Incremental coordinates use


the present position as the
reference point for the next
movement. This means that
any point in the Cartesian
graph can be plotted
accurately by measuring the
distance between points,
generally starting at the
origin.
EXERCISE 1: Absolute Coordinates
Fill in the X and Y blanks with the appropriate absolute coordinates
for points A through H.
A: X_____, Y_____ B: X_____, Y_____
C: X_____, Y_____ D: X_____, Y_____
E: X_____, Y_____ F: X_____, Y_____
G: X_____, Y_____ H: X_____, Y_____
EXERCISE 2: Incremental Coordinates
Fill in the X and Y blanks with the appropriate incremental
coordinates for points A through H.
A: X_____, Y_____ B: X_____, Y_____
C: X_____, Y_____ D: X_____, Y_____
E: X_____, Y_____ F: X_____, Y_____
G: X_____, Y_____ H: X_____, Y_____
CAD/CAM/CAE
Computer Aided Design/Computer Aided
Manufacturing/Computer Aided
Manufacturing

CNC Milling Programming


To maximize the power of modern CNC
milling machines, a programmer has to
master the following five categories of
programming command codes and
techniques:
1. Basic programming commands.
2. Compensating an offset.
3. Fixed cycles.
4. Macro and subroutine programs.
5. Advanced programming features.
1. Basic programming commands.
Motion commands (G00, G01, G02, G03)
Plane selection (G17, G18, G19)
Positioning system selection (G90, 091)
Unit selection (G70 or G20, G71 or G21)
Work coordinate setting (G92)
Reference point return (G28, G29, G30)
Tool selection and change (Txx M06)
Feed selection and input (Fxxx.xx, G94, 095)
Spindle speed selection and control (Sxxxx, M03, M04,
M05)
Miscellaneous functions (M00, M01, M02, M07, M08, M09,
M30)
2. Compensation and offset. The use of
compensation and offset functions in defining work
coordinate systems, performing tool diameter
compensations, and accommodating tool length differences
often results in reduced programming effort. The main
compensation and offset functions are
Work coordinate compensation (G54-G59)
Tool diameter (radius) compensation (G40, G41, G42)
Tool length offset (G43, G44, G49)
3. Fixed cycles. The purpose of a fixed cycle is to
execute a series of repetitive machining operations with a
single block command. Fixed cycles may be classified into
the following three categories:
Standard fixed cycles (G80-G89)
Special fixed cycles
User-defined fixed cycles
4. Macro and subroutine programming. Most
modem CNC controls furnish the power of computer
programming to define variables, perform arithmetic
operations, execute logical decisions, and so on. These
features allow easy implementation of repetitive
machining patterns and complex workpiece shapes that
can be defined mathematically.
5. Advanced programming features. These
commands are dependent on user control. They are
used to simplify programming effort and reduce
programming time and program size. Typical features
include scaling, rotation, and mirror image.
CNC Milling G-Codes

G-codes are preparatory functions that involve actual


tool moves (for example, control of the machine). These
include rapid moves, feed moves, radial feed moves,
dwells, and roughing and profiling cycles.

Most G-codes described here are modal, meaning that


they remain active until canceled by another G-code.
The following codes are described in more detail in the
following sections.
CNC Milling G-Codes
G00 Positioning in rapid Modal
G01 Linear interpolation Modal
G02 Circular interpolation (CW) Modal
G03 Circular interpolation (CCW) Modal
G04 Dwell
G17 XY plane Modal
G18 XZ plane Modal
G19 YZ plane Modal
G20/G70 Inch units Modal
CNC Milling G-Codes
G21/G71 Metric units Modal
G28 Automatic return to reference point
G29 Automatic return from reference point
G40 Cutter compensation cancel Modal
G41 Cutter compensation left Modal
G42 Cutter compensation right Modal
G43 Tool length compensation (plus) Modal
G44 Tool length compensation (minus) Modal
G49 Tool length compensation cancel Modal
G54-G59 Workpiece coordinate settings Modal
CNC Milling G-Codes
G73 High-speed peck drilling Modal
G80 Cancel canned cycles Modal
G81 Drilling cycle Modal
G82 Counter boring cycle Modal
G83 Deep hole drilling cycle Modal
G90 Absolute positioning Modal
G91 Incremental positioning Modal
G92 Reposition origin point
G98 Set initial plane default
G99 Return to retract (rapid) plane
CNC Milling M-CODES
M-codes are miscellaneous functions that include actions necessary fo
machining but not those that are actual tool movements. That is, they are
auxiliary functions, such as spindle on and off, tool changes, coolant on
and off, program stops, and similar related functions. The following
codes are described in more detail in the following sections.

M00 Program stop


M01 Optional program stop
M02 Program end
M03 Spindle on clockwise
M04 Spindle on counterclockwise
CNC Milling M-CODES
M05 Spindle stop
M06 Tool change
M08 Coolant on
M09 Coolant off
M10 Clamps on
M11 Clamps off
M30 Program end, reset to start
M98 Call subroutine command
M99 Return from subroutine command
Block Skip Option to skip blocks that begin with /
Comments Comments may be included in blocks with
round brackets ( )
Tool Motion Command - G00 Positioning in Rapid
Format: N_ G00 X_ Y_ Z_
The G00 command is a rapid
tool move. A rapid tool move
is used to move the tool
linearly from position to
position without cutting any
material. This command is
not to be used for cutting any
material, as to do so would
seriously damage the tool and
ruin the workpiece. It is a
modal command, remaining
in effect until canceled by
another G-Code command
The G00 command is used to move the tool
quickly from one point to another without cutting,
thus allowing for quick tool positioning.
The G00 rapid move should have two distinct movements to
ensure that vertical moves are always separate from
horizontal moves. In a typical rapid move toward the part,
the tool first rapids in the flat, horizontal XY plane. Then, it
feeds down in the Z axis. When rapiding out of a part, the
G00 command always goes up in the Z axis first, then
laterally in the XY plane.
As this diagram shows, if the basic rules are not
followed, an accident can result. Improper use of
G00 often occurs because clamps are not taken
into consideration. Following the basic rules will
reduce any chance of error.
EXAMPLE:
N25 G00 X2.5 Y4.75 (Rapid to X2.5,Y4.75)
N30 Z0.1 (Rapid down to Z0.1)

Depending on where the tool is located, there are two basic rules to
follow for safetys sake:

If the Z value represents a cutting move in the negative direction,


the X and Y axes should be executed first.

If the Z value represents a move in the positive direction, the X


and Y axes should be executed last.
Sample Program :
Workpiece Size: X6,Y4,Z1
Tool: Tool #2, 1/4" Slot Drill
Tool Start Position: X0,Y0,Z1
% (Program start flag)
:1001 (Program number 1001)
N5 G90 G20 (Absolute and inch programming)
N10 M06 T2 (Tool change, Tool #2)
N15 M03 S1200 (Spindle on CW, at 1200 rpm)
N20 G00 X1 Y1 (Rapid over to X1,Y1)
N25 Z0.1 (Rapid down to Z0.1)
N30 G01 Z-0.25 F5 (Feed move down to a depth of 0.25 in.)
N35 Y3 (Feed move to Y3)
N40 X5 (Feed to X5)
N45 X1 Y1 Z-0.125 (Feed to X1,Y1,Z0.125)
N50 G00 Z1 (Rapid up to Z1)
N55 X0 Y0 (Rapid over to X0,Y0)
N60 M05 (Spindle off)
N65 M30 (End of program)
G01 Linear Interpolation
Format: N_ G01 X_ Y_ Z_ F_
The G01 command is
specifically for the
linear removal of
material from a
workpiece, in any
combination of the X,
Y, or Z axes. The
machine tool follows a
linear trajectory.
The G01 is modal and
requires a user
variable feedrate
(designated by the letter
F followed by a
number).
Linear Interpolation,
or straight-line feed
moves, on the flat XY
plane (no Z values
are specified).

G01 command,
using multi-axis feed
moves. All diagonal
feed moves are a
result of a G01
command, where
two or more axes
are used at once.
Sample Program (G01):
Workpiece Size: X4, Y3, Z1
Tool: Tool #3, 3/8" Slot Drill
Tool Start Position: X0, Y0, Z1
% (Program start flag)
:1002 (Program #1002)
N5 G90 G20 (Block #5, absolute in inches)
N10 M06 T3 (Tool change to Tool #3)
N15 M03 S1250 (Spindle on CW at 1250 rpm)
N20 G00 X1.0 Y1.0 (Rapid over to X1,Y1)
N25 Z0.1 (Rapid down to Z0.1)
N30 G01 Z-0.125 F5 (Feed down to Z0.125 at 5 ipm)
N35 X3 Y2 F10 (Feed diagonally to X3,Y2 at 10 ipm)
N40 G00 Z1.0 (Rapid up to Z1)
N45 X0.0 Y0.0 (Rapid over to X0,Y0)
N50 M05 (Spindle off)
N55 M30 (Program end)
G02 Circular Interpolation (clockwise)
Format: N_ G02 X_ Y_ Z_ I_ J_ K_ F_
or N_ G02 X_ Y_ Z_ R_ F_
Circular Interpolation is
more commonly known as
radial (or arc) feed moves.
The G02 command is
specifically used for all
clockwise radial feed
moves, whether they are
quadratic arcs, partial
arcs, or complete circles,
as long as they lie in any
one plane.
The G02 command is
modal and is subject to a
user-definable feed rate.
G02 Circular Interpolation (cont'd.) The G02 command requires
an endpoint and a radius in
order to cut the arc. The start
point of this arc is (X1,Y4)
and the endpoint is (X4,Y1).
To find the radius, simply
measure the incremental
distance from the start point
to the center point. This
radius is written in terms of
the X and Y distances. To
avoid confusion, these
values are assigned
variables, called I and J,
respectively.
EXAMPLE: G02 X2 Y1 I0 J-1
The G02 command requires an endpoint and a radius in order to cut the
arc. The start point of this arc is (X1, Y2) and the end-point is (X2, Y1). To
find the radius, simply measure the relative, (or incremental), distance
from the start point to the center point. This radius is written in terms of the
X and Y distances. To avoid confusion, these values are assigned variables
called I and J, respectively.
EXAMPLE: G02 X2 Y1 R1
You can also specify G02 by entering the X and Y endpoints and then R for the
radius.

Note: The use of an R value for the radius of an arc is limited to a maximum
movement of 90.
An easy way to determine the radius values (the I and J values) is by making a small
chart:
Center point X1 Y1
Start point X1 Y2
Radius I0 J-1

Finding the I and J values is easier than it first seems. Follow these steps:
1. Write the X and Y coordinates of the arcs center point.
2. Below these coordinates, write the X and Y coordinates of the arcs start
point.
3. Draw a line below this to separate the two areas to perform the subtraction.
Result: G02 X2 Y1 I0 J-1 F5
4. To find the I value, calculate the difference between the arcs start point and
center point in the X direction. In this case, both X values are 1. Hence there is no
difference between them, so the I value is 0. To find the J value, calculate the
difference between the arcs start point and center point in the Y direction. In this
Sample Program (G02):
Workpiece Size: X4, Y3, Z1
Tool: Tool #2, 1/4" Slot Drill
Tool Start Position: X0, Y0, Z1
%
:1003
N5 G90 G20
N10 M06 T2
N15 M03 S1200
N20 G00 X1 Y1
N25 Z0.1
N30 G01 Z-0.1 F5
N35 G02 X2 Y2 I1 J0 F20 (Arc feed CW, radius I1,J0 at 20 ipm)
N40 G01 X3.5
N45 G02 X3 Y0.5 R2 (Arc feed CW, radius 2)
N50 X1 Y1 R2 (Arc feed CW, radius 2)
N55 G00 Z0.1
N60 X2 Y1.5
N65 G01 Z-0.25
N70 G02 X2 Y1.5 I0.25 J-0.25 (Full circle arc feed move CW)
N75 G00 Z1
N80 X0 Y0
N85 M05
N90 M30
G03 CIRCULAR INTERPOLATION (CCW)
Format: N_ G03 X_ Y_ Z_ I_ J_ K_ F_ (I, J, K specify the radius)

The G03 command is


used for all
counterclockwise radial
feed moves, whether
they are quadratic arcs,
partial arcs, or complete
circles, as long as they
lie in any one plane.
The G03 command is
modal and is subject to a
user-definable feed rate
EXAMPLE: G03 X1 Y1 I0 J-1
The G03 command requires an endpoint and a radius in order to cut the arc. (See
Fig. 5.7.) The start point of this arc is (X2, Y2) and the end-point is (X1, Y1). To
find the radius, simply measure the incremental distance from the start point to
the center point of the arc. This radius is written in terms of the X and Y
distances. To avoid confusion, these values are assigned variables called I and J,
respectively.
EXAMPLE: G03 X1 Y1 R1
You can also specify G03 by entering the X and Y endpoints and then R for the
radius.

Note: The use of an R value for the radius of an arc is limited to a maximum
movement of 90. An easy way to determine the radius values (the I and J values) is
to make a small chart as follows.

Center point X2 Y1
Start point X2 Y2
Radius I0 J-1
Finding the I and J values is easier than it first seems. Follow these steps:
1. Write the X and Y coordinates of the arcs center point.
2. Below these coordinates, write the X and Y coordinates of the arcs start point.
3. Draw a line below this to separate the two areas to perform the subtraction.
4. To find the I value, calculate the difference between the arcs start point and
center point in the X direction. In this case, both X values are 2. Hence there is no
difference between them, so the I value is 0. To find the J value, calculate the
difference between the arcs start point and center point in the Y direction. In this
case, the difference between Y2 and Y1 is down 1 inch, so the J value is 1.
Result: G03 X1 Y1 I0 J-1
G03 Circular Interpolation (cont'd)

The G03 command requires an


endpoint and a radius in order to
cut the arc. The start point of this
arc is (X4,Y1) and the endpoint
is(X1,Y4). To find the radius,
simply measure the incremental
distance from the start point to the
center point. This radius is written
in terms of the X and Y distances.
To avoid confusion, these values
are assigned variables I and J,
respectively.
NOTE: Programming the G02 and G03 commands
with an R value is reserved only for arcs less than or
equal to 90 degrees. The more common method
involves the use of trigonometry to solve for the I, J,
or K values.
Sample Program (G03).
Workpiece Size: X4, Y4, Z0.25
Tool: Tool #2, 1/4" Slot Drill
Tool Start Position: X0, Y0, Z1
%
:1004
N5 G90 G20
N10 M06 T2
N15 M03 S1200
N20 G00 X2 Y0.5
N25 Z0.125
N30 G01 Z-0.125 F5
N35 X3 F15
N40 G03 X3.5 Y1 R0.5 (G03 arc using R value)
N45 G01 Y3
N50 G03 X3 Y3.5 I-0.5 J0 (G03 arc using I and J)
N55 G01 X2
N60 G03 X2 Y1.5 I0 J-1 (180 arc using I and J)
N65 G01 Y0.5
N70 G00 Z0.1
N75 X1.5 Y2.5
N80 G01 Z-0.25 F5
N85 G03 X1.5 Y2.5 I0.5 J0 (Full circle using I and J)
N90 G00 Z1
N95 X0 Y0
N100 M05
N105 M30
Command Format with IJK Method
(GI7) G02 (or G03) Xx Yy li Ji Ff on XY-plane
(G18) G02 (or G03) Xx Zz li Kk Ff on ZX-plane
(G19) G02 (or G03) Yy Zz Jj Kk Ff on YZ-plane

Command Format with R Method


(GI7) G02 (or G03) Xx Yy Rr Ff on XY-plane
(G18) G02 (or G03) Xx Zz Rr Ff on ZX-plane
(G19) G02 (or G03) Yy Zz Rr Ff on YZ-plane
G04 DWELL
Format: N_ G04 P_

The G04 command is


a nonmodal dwell
command that halts
all axis movement for
a specified time while
the spindle continues
revolving at the
specified rpm. A dwell
is used largely in
drilling operations and
after plunge moves,
which allows for the
clearance of chips .
Sample Program (G04):
Workpiece Size: X3.5, Y2, Z0.5
Tool: Tool #1, 1/8" Slot Mill
Tool Start Position: X0, Y0, Z1
% (Program start flag)
:1005 (Program #1005)
N5 G90 G20 (Absolute programming in inch mode)
N10 M06 T1 (Tool change to Tool #1)
N15 M03 S1300 (Spindle on CW at 1300 rpm)
N20 G00 X3 Y1 Z0.1 (Rapid to X3,Y1,Z0.1)
N25 G01 Z-0.125 F5.0 (Feed down to Z0.125 at 5 ipm)
N30 G04 P2 (Dwell for 2 seconds)
N35 G00 X2 Z0.1 (Rapid up to 0.1)
N33 X2 (Rapid to X2)
N40 G01 Z-0.125 F5.0 (Feed down to Z0.125)
N45 G04 P1 (Dwell for 1 second)
N50 G00 Z1.0 (Rapid out to Z1)
N55 X0. Y0. (Rapid to X0, Y0)
N60 M05 (Spindle off)
N65 M30 (Program end)
G17 XY Plane
Format: N_ G17
G18 XZ Plane
Format: N_ G18
G19 Y Z Plane
Format: N_ G19
G17 = XY plane
G18 = XZ plane
G19 = YZ plane
G20 or G70 Inch Units
Format: N_ G20 or G70
The G20 or G70 command defaults the
system to inch units. When a program is
being run and the G20 command is
encountered, all coordinates are stated as
inch units. This command is usually found
at the beginning of a program. However,
on some controllers it can be used to
switch from metric units in the middle of a
program.
G21 or G71 Metric, or SI, Units
Format: N_ G21 or G71
The G21 or G71 command defaults the
system to metric units. When a program is
being run and the G21 command is
encountered, all coordinates are stated in
as millimeter units. This command is
usually found at the beginning of a
program. However, it can be used to
switch between metric and inch units in
the middle of a program.
G28 Automatic Return to Reference
Format: N_ G28 X_ Y_ Z_

The G28 command is


primarily used before
automatic tool
changing. It allows
the existing tool to be
positioned to the
predefined reference
point automatically
via an intermediate
position. This ensures
that when the tool
changer is engaged, it NOTE: When this command is being used, it is
is properly aligned advisable for safety reasons to cancel any tool offset
with the spindle head. or cutter compensation.
G29 Automatic Return from Reference
Format: N_ G29 X_ Y_ Z_
The G29 command
can be used
immediately after an
automatic tool
change. It allows the
new tool to be
returned from the
predefined reference
point to the specified
point via an
intermediate point
specified by the
previous G28 NOTE: When this command is being used, it is
command. advisable for safety reasons to cancel any tool offset
or cutter compensation.
G40 Cutter Compensation Cancel
Format: N_ G40
Usually, CNC programs are written so that the tool center
follows the toolpath. Cutter compensation is used whenever tool
centerline programming is difficult. It is also used to
compensate for significant tool wear or tool substitution. The
G40 command cancels any cutter compensation that was
applied to the tool during a program and acts as a safeguard to
cancel any cutter compensation applied to a previous program
or G-codes.

NOTE: Cutter compensation is modal, so it must be canceled


when it is no longer needed. This is the sole function of the G40
command
G41 Cutter Compensation Left
Format: N_ G41 D_
The G41 command
compensates the cutter a
specified distance to the
left-hand side of the
programmed tool path. It is
used to compensate for
excessive tool wear or
substitute a tool to profile a
part.

The G41 command is


modal, so it compensates
each successive tool move
the same specified distance
until it is overridden by a
G40 command or receives a
different offset.
G41 Cutter Compensation Left
Format: N_ G41 D_
Sample program (G41): N55 G01 X0.5
Workpiece Size: X5, Y4, Z1 N60 Y0.5
N65 G00 Z1
Tool: Tool #1, 1/4" Slot Drill N70 X0 Y0
Tool #4, 1/2" End Mill N75 M06 T04
Register: D11 is 0.25" N80 M03 S1000
Tool Start Position:X0, Y0, Z1 N85 G00 X0.75 Y1
N90 Z0.125
% N95 G01 Z-0.25 F5
:1012 N100 G41 X0.5 Y0.5 D11 F20
N5 G90 G20 G40 G17 G80 N105 X2
N10 T01 M06 N110 X2.5 Y1
N15 M03 S2000 N115 Y2
N20 G00 X0.5 Y0.5 N120 G03 X2 Y2.5 R0.5
N25 Z0.1 N125 G01 X0.5
N30 G01 Z-0.25 F5 N130 Y0.5
N135 G40 X0.75 Y0.75
N35 X2 F15 N140 G00 Z1
N40 X2.5 Y1 N145 X0 Y0
N45 Y2 N150 M05
N50 G03 X2 Y2.5 R0.5 N155 M30
G42 CUTTER COMPENSATION RIGHT
Format: N_ G42 D_
The G42 command
compensates the cutter a
specified distance to the
right-hand side of the
programmed tool path. It
is used to compensate for
excessive tool wear or
substitute a tool to profile
a part. The G42 command
is modal, so it
compensates each
successive tool move the
same specified distance
until it is overridden by a
G40 command or receives
a different offset.
G42 CUTTER COMPENSATION RIGHT
Format: N_ G42 D_
Sample Program (G42): N65 G00 Z1
Workpiece Size: X4, Y4, Z1 N70 X0 Y0
Tool: Tool #1, 1/4" Slot Drill N75 T04 M06
Tool #4, 1/2" End Mill N80 M03 S1000
Register: D11 is 0.25" N85 G00 X-0.5
Tool Start Position: X0, Y0, Z1 N90 Z-0.5
% N95 G01 G42 X0.5 Y0.5 Z-0.5 D11 F15
:1013 N100 X2
N5 G90 G20 G40 G17 G80
N105 X2.5 Y1
N10 T01 M06
N110 Y2
N15 M03 S2000
N20 G00 X0.5 Y0.5 N115 G03 X2 Y2.5 R0.5
N25 Z0.1 N120 G01 X0.5
N30 G01 Z-0.25 F5 N125 Y0
N35 X2 F15 N130 G01 G40 Z0.25
N40 X2.5 Y1 N135 G00 Z1
N45 Y2 N140 X0 Y0
N50 G03 X2 Y2.5 R0.5 N145 M05
N55 G01 X0.5 N150 M30
N60 Y0.5
G43 Tool Length Compensation (Plus)
Format: N_ G43 H_
The G43 command
compensates for tool
length in a positive
direction. 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 throw the origin out
of zero. To prevent this,
the difference in tool
length should be
compensated for.
G43 Tool Length Compensation (Plus)
Format: N_ G43 H_
G44 Tool Length Compensation (Minus)
Format: N_ G44 H_
The G44 command
compensates for tool
length in a minus
direction. 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 throw the origin out
of zero. To prevent this,
the difference in tool
length should be
compensated for.
G44 Tool Length Compensation (Minus)
Format: N_ G44 H_
G49 Tool Length Compensation Cancel
Format: N_ G49

The G49 command cancels all previous cutter


length offset commands. Because the G43 and
G44 commands are modal, they will remain
active until canceled by the G49 command. It is
important to keep this in mind; forgetting that a
tool has been offset can cause the cutter to crash
into the workpiece.
G54G59 Workpiece Coordinate System
Format: N_ G54 through G59
The G54 G59 commands
are used to reposition the
origin per a user- defined
working coordinate system.
In CNCez six register sets in
the controller hold the values
for the working coordinate
systems. The G54 G59
commands are very useful
when multiple workpiece
fixtures are used. On real
CNC controllers these values
are held in parameter fields
which are normally set in the
parameters entry screen of
the controller.
G73 High-Speed Peck Drilling Cycle
Format: N_ G73 X_ Y_ Z_ R_ Q_ F_
During a G73 high-speed
peck drilling cycle, the tool
feeds in to the peck distance
or depth of cut, then retracts
a small pre-determined
distance, which is the chip-
breaking process, and then
feeds to the next peck, which
takes the tool deeper. This
process is repeated until the
final Z depth is reached.
Because the tool doesn't
retract fully from the hole, as
in the G83 cycle, it minimizes
cycle time and improves total
part machining time.
G80 Cancel Canned Cycles
Format: N_ G80
The G80 command cancels all previous canned
cycle commands. Because the canned cycles are
modal (refer to the canned cycles on the
following pages), they will remain active until
canceled by the G80 command. Canned cycles
include tapping, boring, spot facing, and
drilling.

Note: On most controllers the G00 command


will also cancel any canned cycles.
G81 Drilling Cycle
Format: N_ G81 X_ Y_ Z_ R_ F_
The G81 command
invokes a drill cycle at
specified locations. This
cycle can be used for
bolt holes, drilled
patterns, and mold
sprues, among other
tasks. This command is
modal and so remains
active until overridden
by another move
Invoking the G81 command requires
command or canceled
invoking the Z initial plane, Z depth
by the G80 command. and Z retract plane parameters.
G82 Spot Drilling or Counter Boring Cycle
Format: N_ G82 X_ Y_ Z_ R_ P_ F_
This cycle follows the same
operating procedures as the
G81 drilling cycle, with the
addition of a dwell. The
dwell is a pause during
which the Z axis stops
moving but the spindle
continues rotating. This
pause allows for chip
clearing and a finer finish on
the hole. The dwell time is
measured in seconds.
The dwell is specified by the The same Z levels apply to the G82
P letter address, followed by
cycle as to the G81 cycle: Z initial
the dwell time in seconds.
plane, Z depth and Z retract.
G83 Deep Hole Drilling Cycle
Format: N_ G83 X_ Y_ Z_ R_ Q_ F_
The G83 command involves
individual peck moves in each
drilling operation. When this
command is invoked, the tool
positions itself as in a
standard G81 drill cycle. The
peck is the only action that
distinguishes the deep hole
drilling cycle from the G81
cycle. When pecking, the tool
feeds in the specified distance
(peck distance or depth of
cut), then rapids back out to
the Z Retract plane. The next
peck takes the tool deeper,
and then it rapids out of the
hole. This process is repeated In the G83 cycle, Q is the
until the final Z depth is
reached.
incremental depth of cut.
G90 Absolute Positioning
Format: N_ G90
The G90 command defaults the system to
accept all coordinates as absolute
coordinates. These coordinates are
measured from a fixed origin (X0, Y0, Z0)
and expressed in terms of X, Y, and Z
distances.
G91 Incremental Positioning
Format: N_ G91

The G91 command defaults the system to


accept all coordinates as incremental, or
relative, coordinates.
G92 Reposition Origin Point
Format: N_ G92 X_ Y_ Z_
The G92 command is
used to reposition the
origin point. The origin
point is not a physical
spot on the machine tool,
but rather a reference
point to which the
coordinates relate.
Generally, the origin
point is located at a
prominent point or object
(for example, front top
left corner of the part) so
that it is easier to measure
from.
G98 Set Initial Plane Rapid Default
Format: N_ G98
The G98 command
forces the tool to return
to the Z initial plane a
drilling operation. This
forces the tool up and
out of the workpiece.
This setting is normally
used when a workpiece
has clamps or other
obstacles that could
interfere with tool
movement. The G98
command is also the
system default.
G99 Set Rapid to Retract Plane
Format: N_ G99
The G99 command forces the
tool to return to the retract
plane after a drilling
operation. This forces the
tool up and out of the
workpiece to the retract plane
specified in the drilling cycle,
overriding the system default.
This command is usually
used on drilling cycles within
a pocket, or on workpieces
that do not have surface
obstacles. It is quicker than
the G98 command because
the tool moves only to the
retract plane.
CNC Milling M- Codes

M-codes are miscellaneous functions that include actions


necessary for machining but not those that are actual tool
movements (for example, auxiliary functions). They include
actions such as spindle on and off, tool changes, coolant on
and off, program stops, and similar related functions.
M-Codes
M00 Program stop
M01 Optional program stop
M02 Program end
M03 Spindle on clockwise
M04 Spindle on counterclockwise
M05 Spindle stop
M06 Tool change
M08 Coolant on
M09 Coolant off
M10 Clamps on
M11 Clamps off
M30 Program end, reset to start
M98 Call subroutine command
M99 Return from subroutine command
Block Skip Option to skip blocks that begin with /
Comments Comments may be included in blocks with round
brackets ( )
M00 - Program stop
Format: N_ M00
The M00 command is a temporary program stop function. When
it is executed, all functions are temporarily stopped and will not
restart unless and until prompted by user input.

This command can be used in lengthy programs to stop the


program in order to clear chips, take measurements, or adjust
clamps, coolant hoses, and so on.

M01 Optional Program Stop


Format: N_ M01
If the Optional Stop switch is set to ON, the program will stop
when it encounters in an M01command. Both real CNC
controllers and the CNCez simulators have this feature.
M02 PROGRAM END
Format: N_ M02
The M02 command indicates an end of the main program cycle operation. Upon
encountering the M02 command, the MCU switches off all machine operations (for
example, spindle, coolant, all axes, and any auxiliaries), terminating the program.
This command appears on the last line of the program.
Sample Program (M02):
Workpiece Size: X4, Y3, Z1
Tool: Tool #2, 1/4" Slot Drill
Tool Start Position: X0, Y0, Z1
%
:1003
N5 G90 G20
N10 M06 T2
N15 M03 S1200
N20 G00 X1 Y1
N25 Z0.1
N30 G01 Z-.125 F5
N35 X3 F15
N40 G00 Z1
N45 X0 Y0
N50 M05
N55 M02 (Program end)
M03 SPINDLE ON CLOCKWISE
Format: N_ M03 S_
The M03 command switches the spindle on in a clockwise rotation. The spindle
speed is designated by the S letter address, followed by the spindle speed in
revolutions per minute
M04 SPINDLE ON COUNTERCLOCKWISE
Format: N_ M04 S_
The M04 command switches the spindle on in a counterclockwise
rotation. The spindle speed is designated by the S letter address,
followed by the spindle speed in revolutions per minute.
M05 SPINDLE STOP
Format: N_ M05
The M05 command turns the spindle off. Although other M-codes
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.

M06 TOOL CHANGE


Format: N_ M06 T_
The M06 command halts all program operations for a tool
change. It is actually a two-fold command. First, it stops all
machine operationsfor example, the spindle is turned off and
oriented for the tool change, and all axes motion stopsso that it
is safe to change the tool. Second, it actually changes the tool
M06 TOOL CHANGE
Format: N_ M06 T_
M07/M08 COOLANT ON
Format: N_ M07 or N_ M08
The M07 and M08 commands switch on the coolant flow.

M09 COOLANT OFF


Format: 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.
M08 Coolant On or M09 Coolant Off
Format: N_ M08 or N_ M09
M10 CLAMPS ON
Format: N_ M10
The M10 command turns on the automatic clamps to secure
the workpiece. Automatic clamps can be pneumatic,
hydraulic, or electromechanical. Not all CNC machines have
automatic clamps, but the option exists and the actual code
will vary by machine tool make and model.
M11 CLAMPS OFF
Format: N_ M11
The M11 command releases the automatic clamps so that the
work-piece may be removed and the next blank inserted. The
automatic clamps may be pneumatic, hydraulic, or
electromechanical, depending on the application.
Sample Program M11EX10:
Workpiece Size: X4, Y3, Z1
Tool: Tool #12, 1" End Mill
Tool Start Position: X0, Y0, Z1
%
:1011
N5 G90 G20
N10 M06 T12
N15 M10 (Clamp workpiece)
N20 M03 S1000
N25 G00 X-0.75 Y1
N30 Z-0.375
N35 G01 X0 F10
N40 G03 Y2 I0 J0.5
N45 G01 X2 Y3
N50 X4 Y2
N55 G03 Y1 I0 J-0.5
N60 G01 X2 Y0
N65 X0 Y1
N70 G00 Z1
N75 X0 Y0
N80 M05
N85 M11 (Unclamp workpiece)
N90 M30
M30 PROGRAM END, RESET TO START
Format: N_ M30
The M30 command indicates the end of the program data. In
other words, no more program commands follow it. This is a
remnant of the older NC machines, which could not
differentiate between one program and the next, so an End of
Data command was developed. Now the M30 is used to end
the program and reset it to the start.
M98 CALL SUBPROGRAM
Format: 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 P letter address value. For example,
N15 M98 P1003 would call program :1003, either from within
the current CNC program file or from an external CNC program
file. Machine status is maintained when a sub-program is called.
This is especially useful in family parts programming or when
several operations are required on the same hole locations. In the
following sample program the subprogram is used to drill a hole
pattern, using several calls to different drill cycles. The main
program positions the machine tool at the starting location to
invoke the cycle; the subprogram then continues the pattern
Sample Program M98EX9:
Workpiece Size: X5, Y5, Z1
Tool: Tool #1, 3/32" Spot Drill
Tool #2, 1/4 HSS Drill
Tool #3, 1/2 HSS Drill
Tool Start Position: X0, Y0, Z1
%
:1010
N5 G90 G20
N10 M06 T1
N15 M03 S1500
N20 M08 (Coolant on)
N25 G00 X1 Y1
N30 G82 X1 Y1 Z-.1 R.1 P0.5 F5 (Start of cycle)
N35 M98 P1005 (Call subprogram to do rest)
N40 G80
N45 G28 X1 Y1
N50 M09
N55 M06 T02
N60 G29 X1 Y1
N65 M03 S1200
N70 M08
N75 G83 X1 Y1 Z-1 R0.1 Q0.1 F5.0 (Start of cycle)
N80 M98 P1005 (Call subprogram to do rest)
N85 G80
N90 G28 X1 Y1
N95 M09
N100 M06 T03
N105 G29 X1 Y1
N110 M03 S1000
N115 M08
N120 G73 X1 Y1 Z-1 R0.1 Q0.1 F5.0 (Start of cycle)
N125 M98 P1005 (Call subprogram to do
rest)
N130 G80
N135 G00 Z1
N140 X0 Y0
N145 M09
N150 M05
N155 M30
O1005 (Subprogram)
N5 X2
N10 X3
N15 X4
N20 Y2
N25 X3
N30 X2
N35 X1
N40 M99 (Return from sub-
program)
M99 RETURN FROM SUBPROGRAM
Format: 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.

Sample Program M99EX10:


Workpiece Size: X5, Y5, Z1
Tool: Tool #1, 3/32" Spot Drill
Tool #2, 1/4 HSS Drill
Tool Start Position: X0, Y0, Z1
%
:1011
N5 G90 G20
N10 M06 T1
N15 M03 S1500
N20 M08 (Coolant on)
N25 G00 X1 Y1
N30 G82 X1 Y1 Z-.1 R.1 P0.5 F5 (Start of cycle)
N35 M98 P1005 (Call subprogram to do rest)
N40 G80
N45 G28 X1 Y1
N50 M09
N55 M06 T03
N60 G29 X1 Y1
N65 M03 S1200
N70 M08
N75 G83 X1 Y1 Z-1 R0.1 Q0.1 F5.0 (Start of cycle)
N80 M98 P1006 (Call subprogram to do rest)
N85 G80
N135 G00 Z1
N140 X0 Y0
N145 M09
N150 M05
N155 M30

O1006 (Subprogram to drill rest of square pattern)

N5 X2
N20 Y2
N25 X1
N30 M99 (Return from subprogram)
Examples
This program introduces you to the Cartesian coordinate
system and absolute coordinates. Only single-axis, linear-feed
moves show the travel directions of the X, Y, and Z axe
Workpiece Size: X5, Y4, Z1
Tool: Tool #3, 3/8" End Mill
Tool Start Position: X0, Y0, Z1 (Relative to workpiece)
%
:1001
N5 G90 G20
N10 M06 T3
N15 M03 S1200
N20 G00 X1 Y1
N25 Z0.125
N30 G01 Z-0.125 F5
N35 X4 F20
N40 Y3
N45 X1
N50 Y1
N55 G00 Z1
N60 X0 Y0
N65 M05
N70 M30
EXAMPLE 2: I-part2.mil
This next program introduces you to diagonal linear feed moves,
where both the X axis and the Y axis are traversed
Workpiece Size: X5, Y4, Z1
Tool: Tool #2, 1/4" End Mill
Tool Start Position: X0, Y0, Z1 (Relative to workpiece)
%
:1002
N5 G90 G20
N10 M06 T2
N15 M03 S1200
N20 G00 X1 Y1
N25 Z0.125
N30 G01 Z-0.125 F5
N35 X4 F10
N40 Y3
N45 X1 Y1
N50 Y3
N55 X4 Y1
N60 G00 Z1
N65 X0 Y0
N70 M05
N75 M30
Example 3:
This program introduces arcs: G02 (clockwise) and G03
(counterclockwise). These are all simple quarter quadrant arcs
with a 1-in. radius
Workpiece Size: X5, Y4, Z1
Tool: Tool #2, 0.25" Slot Mill
Tool Start Position: X0, Y0, Z1 (Relative to workpiece)
%
:1003
N5 G90 G20
N10 M06 T2
N15 M03 S1200
N20 G00 X0.5 Y0.5
N25 Z0.25
N30 G01 Z-0.25 F5
N35 G02 X1.5 Y1.5 I1 J0 F10
N40 X2.5 Y2.5 R1
N45 X3.5 Y1.5 I0 J-1
N50 X4.5 Y0.5 R1
N55 G01 Y1.5
N60 G03 X3.5 Y2.5 R1
N65 X2.5 Y3.5 I-1 J0
N70 X1.5 Y2.5 R1
N75 X0.5 Y1.5 I0 J-1
N80 G01 Y0.5
N85 G00 Z1
N90 X0 Y0
N95 M05
N100 M30
EXAMPLE 4: This program cuts several G02 and G03 arcs
(clockwise and counterclockwise) in semicircles and full
circles
Workpiece Size: X4, Y4, Z2
Tool: Tool #4, 0.5" Slot Mill
Tool Start Position: X0, Y0, Z1 (Relative to workpiece)
%
:1004
N5 G90 G20
N10 M06 T4
N15 M03 S1200
N20 G00 Z0.25
N25 G01 Z0 F5
N30 G18 G02 X4 Z0 I2 K0
N35 G19 G03 Y4 Z0 J2 K0
N40 G18 G03 X0 Z0 I-2 K0
N45 G19 G02 Y0 Z0 J-2 K0
N50 G00 Z0.25
N55 X1 Y2
N60 G01 Z-0.25
N65 G17 G02 I1 J0 F10
N70 G00 Z1
N75 X0 Y0
N80 M05
N85 M30
EXAMPLE 5:
This program involves a simple drilling cycle with a defined
retract plane. Once the G-code for the drill cycle has been
executed, only the X and/or Y location of the remaining holes
need to be defined
Workpiece Size: X5, Y4, Z1
Tool: Tool #7, 3/8" HSS Drill
Tool Start Position: X0, Y0, Z1 (Relative to
workpiece)
% N55 Y1
:1005 N60 X3
N5 G90 G20 N65 X4
N10 M06 T7
N70 Y2
N15 M03 S1000
N75 Y3
N20 G00 X1 Y1
N25 Z0.25 N80 X3
N30 G98 G81 X1 Y1 Z-0.25 R0.25 F3 N85 Y2
N35 Y2 N90 G00 Z1
N40 Y3 N95 X0 Y0
N45 X2 N100 M05
N50 Y2 N105 M30
EXAMPLE 6: I-part6.mil
This program involves a drilling cycle with a dwell and
incremental coordinates
Workpiece Size: X5, Y4, Z1
Tool: Tool #8, 3/4" HSS Drill
Tool Start Position: X0, Y0, Z1 (Relative to workpiece)
%
:1006
N5 G90 G20
N10 M06 T8
N15 M03 S500
N20 G00 X1 Y1
N25 Z0.25
N30 G91 G98 G82 Z-0.5 R0.25 P1
N35 X1
N40 X2
N45 Y1
N50 Y1
N55 X-2
N60 X-1
N65 Y-1
N70 X1
N75 G80 G90 G00 Z1
N80 X0 Y0
N85 M05
N90 M30
The End of Part 11

You might also like