Basic Programming Jan 2013
Basic Programming Jan 2013
Y+
X- X+
From Drawing Y-
3
Address in Program
What is ‘address’
Address is the use of alphabet characters
to regulate the functions of a machine tool.
The commands are shown on next slide.
4
Sample of Address
Function Address Meaning
Program number O O1000 ( test )
Sequence number N N10, N20, N30
Preparatory Function G G00, G01, command machine
Dimensional words X,Y,Z Axes travel command
R Arc radius
I, J, K Arc center coordinates
Feed rate F F500 ( mm/min )
Spindle function S S1000 ( rpm )
Tool function T T10 ( Tool number 10 )
Miscellaneous Function M M3, M5, on/off control m/c
Offset number H,D H1 ( tool length), D32 ( radius )
Dwell P,X Dwelling time
Program number command P Sub program number
5
Program number O & Comment
Function of program number O
%
O10000 ( HAAS)
• O xxxxx follow by four digits number
• ( ------- ) comment or message
6
Sequence Number N
Function of sequence number Nxxxx
• Use number from ( 1-99999 or 1-9999 )
• Can be used for program restart
• Use at changes in the process for easy access
7
Movement Command & Setting Units
To move machine axis command
• Axes are X, Y, Z, A, B, C, U, V, W
• Providing a decimal point
X50. • X 50 = 0.05 mm
X50.0 • X 1.23456 = X1.235
X50.00
• X1.23456789 = alarm more
X50.000
X50000 than 9 digits
8
Absolute G90
Function G90
• Thedestination of movement is specified with the
coordinate value regardless the current position.
Y+
60
Y+
10 10
X+ X+
10 60 10
G90 X60.0 Y10.0 ; G90 X10.0 Y60.0 ;
9
Incremental G91
Function G91
• The movement is specified by the direction and the
incremental value to the destination referring the
current position. Y+
60
Y+
10 10
X+ X+
10 60 10
G91 X50.0 ; G91 Y50.0 ;
10
Absolute G90 & Incremental G91
For dimensional command use G90 or G91
• Hereafter, G90 and G91 are abbreviated as ABS & INC
respectively in the text..
11
Information of ABS & INC
Which is more convenient ?
ABS is better
• when each hole position is
indicated from a reference
point, programming is made
easy by setting as origin.
INC is better
• when the pitch between the
position of each hole is
indicated.
• when position with the same
pitch is repeated.
12
G CODES
G00 : Positioning in rapid
G01 : Linear positioning in feed
G02 : Circular Interpolation CW
G03 : Circular Interpolation CCW
G04 : Dwell
G10 : Data Setting
G17 : XY Plane Selection
G18 : ZX Plane Selection
G19 : YZ Plane Selection
G20 : Input In Inch
G21 : Input In Metric
G28 : Return To Reference Position
G30 : 2nd, 3rd and 4th Reference Position Return
G31 : Skip Function
G40 : Cutter Compensation Cancel
G41 : Cutter Compensation Left
G42 : Cutter Compensation Right
13
G43 : Tool Length Compensation + Direction
G44 : Tool Length Compensation - Direction
G53 : Setting Machine Coordinate System Selection
G54 : Work Piece Coordinate System 1
G55 : Work Piece Coordinate System 2
G56 : Work Piece Coordinate System 3
G57 : Work Piece Coordinate System 4
G58 : Work Piece Coordinate System 5
G59 : Work Piece Coordinate System 6
G65 : Macro Call
G73 : Peck Drilling Cycle
G76 : Fine Boring Cycle
G80 : Canned Cycle Cancellation
G81 : Drilling Cycle
G82 : Counter Boring Cycle
G83 : Peck Drilling Cycle
G84 : Tapping Cycle
G85 : Boring Cycle
G86 : Boring Cycle
14
G90 : Absolute Command
G91 : Increment Command
G94 : Feed Per Minute
G95 : Feed Per Rotation
G98 : Return To Initial Point In Canned Cycle
G99 : Return To R Point In Canned Cycle
15
es GC
d Fo
C o es r C odes
G r Ax Cy anne
Fo otion cle d
M s
G Code
o d e s Groups G Co
GC des F
To ol or
For s Com
r en ce pens
ation
Ref e
One Shot G
Codes
16
G CODES FOR AXES MOVEMENTS
17
G CODES FOR REFERENCES
18
G CODES FOR TOOL COMPENSATION
19
What is a “CANNED CYCLE”
20
Rapid Traverse G00
Linear Interpolation G01
Rapid Traverse ( G00 )
• The cutter moves at a rapid traverse rate
with non-linear or linear interpolation.
• The rapid traverse rate depends on the
machine type.
21
Sample of Program
O1000 ( HAAS )
N1 G90 G54 G00 X0 Y0 S1000 M3 ; 200
N8 Y0 ; X- X+
N9 M30 ;
Y-
22
Circle Interpolation G02 , G03
Circle Interpolation
• Commands G02, G03 are used to cut circle or
circular arcs. G02 is specified for CW circular motion.
G03 for CCW circular motion.
23
Dimension I & J
* Command I & J specify the distance from the start point of circle arc A
to the Center. I & J must be specified incrementally irrespective of ABS /
INC mode, adding plus or minus for the direction of I & J
* I & J are the distance of center from the starting point in X & Y directions.
* Dimensions I & J are the same data regardless of ABS or INC.
Y
B (end point of the arc)
Y
60
A (start point of the arc)
Start 40
center J
X 10
Center End 50 X J+
0,0 10 20 I
I+
I-
ABS G90 G03 X20 Y60 I-40 J-30 F100 ; J-
INC G91 G03 X-30 Y20 I-40 J-30 F100 ;
24
Specifying radius of circle arc R
* The radius of circle arc can be directly specified by R instead of
specifying the center of circle arc by I, J & K.
* When the center angle of arc is 180 deg or more, the radius R
must be specified with negative (-) sign.
Y
Start
50
B (end point of the arc)
R
60 70
A (start point of the arc)
40
R30 20 End point
0,0 X 0,0 20 70
20 50
ABS G90 G03 X20 Y60 R30 F100 ABS G90 G02 X70 Y20 R-50 F100
INC G91 G03 X-30 Y20 R30 F100 INC G91 G02 X50 Y-50 R-50 F100
25
A complete circle
* With I, J & K a complete circle can be programmed by
using one block.
Y+ A
0
R4
B
J+
X+
I- I+
J-
26
Example G02 & G03
Y
O0001 (ABS);
R4
N6 G01 X-60.0; N2
0
N7 G00 X0 Y0; N7 N5
N8 M30; N6
(-60,-40) (0,-40)
27
Tool Length Compensation
28
Overview of Tool Length Compensation
29
Tool Radius Compensation G41,G42 & G40
Tool Radius Compensation, rules of G41, G42
• This
.
function is used for side cutting by end mill,
from rough, semi - finish to finishing cutting.
• G40 for Canceling G41,G42.
Follow the cutting feed direction G42
G42 G41
G41 Left G41
G42 Right
G41 G40
30
Programming Format G41,G42 & G40
G17 X_ Y_
G00 G42 D_ ;
G18 Z_ X_
G01 G41
Y_ Z_
G19
X_ Y_
G00
Canceling G40 Z_ X_
G01
Y_ Z_
31
Function of G41
G41 Tool radius offset compensation - Left
• The center of the tool is offset by
the amount referring to the
advance direction.
• G41 cause down cut.
32
Function of G42
G42 Tool radius offset compensation - Right
• the center
. of the tool is offset by
the amount referring to the
advance direction.
• G42 cause up cut.
33
Advantage of Tool Radius Compensation
Simplification of roughing to finishing program
• Any allowance can be obtained by modifying the tool
offset data actually used from the tool dimension in
spite of the same program . OFFSET
NO DATA NO DATA
H16 0.000 H25 0.000
Finishing H17 0.000 H26 0.000
H18 0.000 H27 0.000
H19 0.000 H28 0.000
Semi-Finishing Roughing C = A+B H20 0.000 H29 0.000
34
Sample of Program for G41, G42 & G40
OFFSET
O1000 (Ø20 ENDMILL ) ; NO DATA NO DATA
G90 G54 G00 X0 Y0 S1000 M03 ; H16 0.000 H25 0.000
H17 0.000 H26 0.000
G01 G41 X0 Y-50.0 D32 F100 ; H18 0.000 H27 0.000
X100.0 ; H19 0.000 H28 0.000
H20 0.000 H29 0.000
Y50.0 ; H21 0.000 H30 0.000
200
X-100.0 ; H22 0.000 H31 0.000
H23 0.000 H32 10.000
Y-50.0 ;
X0 ; ACTUAL POSITION [ RELATIVE ]
X 0.000 Y 0.000
G40 X0 Y0 ; 100 Z 0.000
35
Learning Activity
• If now we need to cut a hole is Ø20
OFFSET
- 0.250
• Your Answer for D32 = __________ . [OFFSET] [SETTING] [WORK]
36
Summary for G41 & G42
• Under the offset mode ( after specifying G41 or G42),two
block are read in advance for offset calculation. Therefore
two or more blocks, other than the specified plane, must
not be programmed because it may cause over cutting.
•
• To prevent under or over cutting do it on 90° approach to
the surface.
37
Dwell G04
What is ‘dwell’
It is a function to delay the execution of the next block.
P ______
Programming format G04
X _______
38
Automatic Reference point return G28
Automatic reference point return is a function to return
each axis to its reference position automatically.
Example :-
• G91 G28 Z0 ; The tool moves rapidly to the reference point
of the Z axis ( machine zero point ).
• G28 is usually used under G91 & without axes motion ( X0, Y0 ).
• G28 causes rapid traverse regardless of the previous mode.
• Before specifying G28, the tool radius compensation should be
cancelled in advance.
39
Second reference point G30
40
Data Setting G10
Data Setting is automatic loading of Work/Tool offset data.
Ex: G90 G10 L1 P16 R125.0 (in Tool table data no. 16 will loaded by value 125.0)
G91 G10 L1 P16 R0.5 (In Tool table data no.16 will be increased by 0.5)
G90 G10 L2 P3 X200. Y200. Z200.(In work offset no.3 (G56) X200,Y200
& Z200 will be loaded.)
G91 G10 L2 P3 X0.1 Y0.1 Z0.1 (In G56 X,Y & Z values will increase by 0.1
41
Canned Cycle
What is a ‘canned cycle’ ?
• The canned cycle can also be called the ‘hole drilling
cycle’.
• Several popular machining cycles such as boring,drilling
and tapping are specified with a fixed format which is
shortened and performed easily.
42
Programming Format for Canned Cycle
G90 G98 G_ _ X_Y_R_Z_Q_F_P_L_ ;
G91 G99
43
Programming Format for Canned Cycle
G 98 : Initial level return
G 99 : R point level return
G __ : Cycle mode ( G81, G82, G83 )
G80 : Canned cycle cancellation
44
Overview of Canned cycles
Cycle feed Operation at the Retraction
G code ( - Z direction ) bottom of a hole ( + Z direction ) Application
High speed peck drilling
G73 Intermittent feed ---- Rapid traverse cycle
G74 Cutting feed Spindle CW Cutting feed Left hand tapping cycle
Fine boring cycle
G76 Cutting feed Spindle orientation Rapid traverse ( canned cycle II only )
G80 ---- ---- ---- Cancel
Drilling cycle, spot drilling
G81 Cutting feed ---- Rapid traverse cycle
Drilling cycle, counter
G82 Cutting feed Dwell Rapid traverse boring cycle
G83 Intermittent feed ---- Rapid traverse Peck drilling cycle
G84 Cutting feed Spindle CCW Cutting feed Tapping cycle
G85 Cutting feed ---- Cutting feed Boring cycle
G86 Cutting feed Spindle stop Rapid traverse Boring cycle
Manual / Boring cycle, back boring
G87 Cutting feed Spindle stop Rapid traverse cycle
Dwell Manual /
G88 Cutting feed Spindle stop Rapid traverse Boring cycle
G89 Cutting feed Dwell Cutting feed Boring cycle
45
Drilling Cycle -G81 & G82
G98 G81 G98 G82
FEED
RAPID
O Point R O Point R
O O Point Z O O Point Z
Dwell
46
Example of Program
G98 / G99 G81 X_ Y_ R_ Z_ F_ ;
O1000 ( CANNED CYCLE ) ;
G90 G54 G00 X0 Y0 ; 100 10
Y
S1000 M3 ;
Z100.0 ;
50 Z
G98 G81 X50.0 Y25.0 R5.0 Z-10.0 F100;
X-50.0 ;
Y-25.0 ; X
X50.0 ;
G80 ;
M30 ;
47
Deep Drilling Cycle - G73 & G83
G73 / G83 X_ Y_ R_ Z_ Q_ F_ L_ ;
G98 G73 G98 G83
FEED FEED
RAPID RAPID
O O
R Point R Point
Q Q O
d d
O O O O
Q Q O
d O O
d
O O
Q Q
O O Point Z O O Point Z
G73 - HIGH SPEED PECK DRILLING CYCLE G83 - PECK DRILLING CYCLE
48
G76 Fine Boring Cycle
G98 / G99 G76 X_ Y_ R_ Z_ Q_ F_ ;
Tool
Initial point
O O O
FEED
O Point R RAPID
OSS O
Point Z
Q
OSS - oriented spindle stop M19 Shift amount Q
49
Boring Cycle G86
G98 G86 X_ Y_ R_ Z_ F_ ;
G99
OO Initial point
Spindle CW O Point R
O O Point Z
Spindle stop
50
Tapping Cycle G84
G98 G84 X_ Y_ R_ Z_ F_ ;
G99
FEED
RAPID
O Initial point
Spindle CW Point R
Point Z
Spindle CCW
51
Miscellaneous Function M code
Address M and the follow numerals control on / off of machine
function. Such as the spindle rotation start or stop .
52
M05 Spindle rotation stop.
The main spindle stops rotating.
M08 Coolant on
Flood coolant is supplied.
M99 Subprogram end (This command shows the end of the subprogram)
53
Programming Format M98 ,M99 & M30
54
Subprogram nesting up to 4 levels
Main program Sub program Sub program Sub program Sub program
M 30 M 99 M 99 M 99 M 99
55
Example of Subprogram under G91 Mode
01001 (SUB PRO ) ;
Use F100 as feedrate G91 G00 Z-95.0 ;
50 ----- Rapid traverse G41 X40.0 Y20.0
___ Cutting feed D32;
G01 Z-5.0 F100;
Y30.0 ;
50 100 150
01000 ( MAIN PRO ); X-10.0;
G90 G54 G00 X0 Y0 ; X10.0 Y30.0 ;
S1000 M03 ; X40.0 ;
Z100.0 ; X10.0 Y-30.0 ;
X-10.0 ;
M98 P1001 ;
Y-20.0 ;
G90 G00 X80.0 ;
X-50.0 ;
M98 P1001 ;
G00 Z100.0 ;
G90 G00 X0 Y0 M05 ;
G40 X-40.0 Y-30.0 ;
M30;
M99 ;
56
Example of Subprogram under G90 mode
Y
57
Feed rate F & Spindle Speed S
Function F and S code
These are given according to the tools to be used
and the material of them, workpiece to be cut.
F01 1 mm/min
F10.0 10 mm/min
F1000 1000 mm/min
S10 10 revolutions per min ( rpm )
S1500 1500 revolutions per min.
S400 400 revolutions per min.
58
RPM & Feed Formula
Cutting Speed ( m/min ) * 318
RPM =
Diameter
59
Learning Activity
Calculation RPM & Feed
• Cutting Speed = 250 m/min
• Cutting Diameter = Ø 10 mm
• No. of tooth = 2
• Feed per tooth = 0.1
• Your answer is
60
Learning Activity
Calculation Cutting Speed & Feed per tooth
61
62