Slide01 Introduction CNC
Slide01 Introduction CNC
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
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.
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
Depending on where the tool is located, there are two basic rules to
follow for safetys sake:
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)
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)
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