05 CNC Milling Programming 4 in 1 Page
05 CNC Milling Programming 4 in 1 Page
دا ه ﯽ اراک
milling machines, a programmer has to
master the following five categories of
وه ﺳﺎ ﺖ و ﻮ ﯿﺪ-دا ه ﻣ ﮑﺎ ﯿﮏ
programming command codes and
techniques:
1. Basic programming commands.
5 6
7
G54-G59 Workpiece coordinate settings Modal 8
CNC MILLING G-CODES CNC MILLING G-CODES
G73 High-speed peck drilling Modal
G94 Feed per minute
G80 Cancel canned cycles Modal
G95 Feed per revolution
G81 Drilling cycle Modal G98 Set initial plane default
G82 Counter boring cycle Modal G99 Return to retract (rapid) plane
G83 Deep hole drilling cycle Modal
G84 Tapping cycle
G85 Boring cycle Modal
G90 Absolute positioning Modal
G91 Incremental positioning Modal
G92 Reposition origin point
9 10
The G00 rapid move should have two distinct As this diagram shows, if the basic rules are not
movements to ensure that vertical moves are always followed, an accident can result. Improper use of
separate from horizontal moves. In a typical rapid move
G00 often occurs because clamps are not taken
toward the part, the tool first rapids in the flat,
horizontal XY plane. Then, it feeds down in the Z axis. into consideration. Following the basic rules will
When rapiding out of a part, the G00 command always reduce any chance of error.
goes up in the Z axis first, then laterally in the XY plane.
15 16
Sample Program :
Workpiece Size: X6,Y4,Z1
EXAMPLE: Tool: Tool #2, 1/4" Slot Drill
N25 G00 X2.5 Y4.75 (Rapid to X2.5,Y4.75) Tool Start Position: X0,Y0,Z1
N30 Z0.1 (Rapid down to Z0.1) % (Program start flag)
:1001 (Program number 1001)
Depending on where the tool is located, there are two basic rules to N5 G90 G20 (Absolute and inch programming)
N10 M06 T2 (Tool change, Tool #2)
follow for safety’s sake:
N15 M03 S1200 (Spindle on CW, at 1200 rpm)
N20 G00 X1 Y1 (Rapid over to X1,Y1)
• If the Z value represents a cutting move in the negative direction, N25 Z0.1 (Rapid down to Z0.1)
the X and Y axes should be executed first. N30 G01 Z-0.25 F5 (Feed move down to a depth of 0.25 in.)
N35 Y3 (Feed move to Y3)
• If the Z value represents a move in the positive direction, the X N40 X5 (Feed to X5)
and Y axes should be executed last. N45 X1 Y1 Z-0.125 (Feed to X1,Y1,Z–0.125)
N50 G00 Z1 (Rapid up to Z1)
N55 X0 Y0 (Rapid over to X0,Y0)
N60 M05 (Spindle off)
17
N65 M30 (End of program) 18
27 28
G03 Circular Interpolation (cont'd)
EXAMPLE: G03 X1 Y1 R1
You can also specify G03 by entering the X and Y endpoints and then R for the The G03 command requires an
radius.
endpoint and a radius in order to
Note: The use of an R value for the radius of an arc is limited to a maximum cut the arc. The start point of this
movement of 90°. An easy way to determine the radius values (the I and J values) is arc is (X4,Y1) and the endpoint
to make a small chart as follows.
is(X1,Y4). To find the radius,
Center point X2 Y1 simply measure the incremental
Start point X2 Y2 distance from the start point to the
Radius I0 J-1
Finding the I and J values is easier than it first seems. Follow these steps:
center point. This radius is written
1. Write the X and Y coordinates of the arc’s center point. in terms of the X and Y distances.
2. Below these coordinates, write the X and Y coordinates of the arc’s start point. To avoid confusion, these values
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 arc’s start point and
are assigned variables I and J,
center point in the X direction. In this case, both X values are 2. Hence there is no respectively.
difference between them, so the I value is 0. To find the J value, calculate the
difference between the arc’s 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.
29 30
Result: G03 X1 Y1 I0 J-1
33 34
G04 DWELL
Format: N_ G04 P_
39 40
G17 = XY plane G20 or G70 Inch Units
G18 = XZ plane Format: N_ G20 or G70
G19 = YZ plane 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.
41 42
for.
67 68
G92 Reposition Origin Point G98 Set Initial Plane Rapid Default
Format: N_ G92 X_ Y_ Z_ Format: N_ G98
The G92 command is
The G98 command
used to reposition the
forces the tool to return
origin point. The origin
to the Z initial plane a
point is not a physical
drilling operation. This
spot on the machine tool,
forces the tool up and
but rather a reference
out of the workpiece.
point to which the
This setting is normally
coordinates relate.
used when a workpiece
Generally, the origin
has clamps or other
point is located at a
obstacles that could
prominent point or object
interfere with tool
(for example, front top
movement. The G98
left corner of the part) so
command is also the
that it is easier to measure
system default.
from. 69 70
77 78
79 80
M10 CLAMPS ON
M08 Coolant On or M09 Coolant Off Format: N_ M10
Format: N_ M08 or N_ M09 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.
81 82
N5 X2
N20 Y2
N25 X1
91 92
N30 M99 (Return from subprogram)
Workpiece Size: X5, Y4, Z1 EXAMPLE 2: I-part2.mil
Tool: Tool #3, 3/8" End Mill
Tool Start Position: X0, Y0, Z1 (Relative to workpiece) This next program introduces you to diagonal linear feed moves,
% where both the X axis and the Y axis are traversed
: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
93 94
97 98