Basic Programming of CNC Milling Machine
Basic Programming of CNC Milling Machine
BASIC PROGRAMMING OF
CNC MILLING MACHINE
1
FANUC INDIA FA & ROBOT
Course contents
2
FANUC INDIA FA & ROBOT
A workpiece co-ordinate
system is also called as
work reference zero or work
datum
Structure of Program
Structure of Program 13
FANUC INDIA FA & ROBOT
Structure of Program 14
FANUC INDIA FA & ROBOT
Structure of Program 15
FANUC INDIA FA & ROBOT
Block
Structure of Program 16
FANUC INDIA FA & ROBOT
Basic G codes
- Preparatory function
- Tool movement related functions
Basic G codes 17
FANUC INDIA FA & ROBOT
Basic G codes 18
FANUC INDIA FA & ROBOT
Basic G codes 19
FANUC INDIA FA & ROBOT
Basic G codes 20
FANUC INDIA FA & ROBOT
Basic G codes 21
FANUC INDIA FA & ROBOT
Basic G codes 22
FANUC INDIA FA & ROBOT
Basic G codes 23
FANUC INDIA FA & ROBOT
Basic G codes 24
FANUC INDIA FA & ROBOT
ijk values
Basic G codes 25
FANUC INDIA FA & ROBOT
Basic M codes
- Miscellaneous function
- Machine operations related
functions
• M01 – Optional stop
• M02 – Program stop
• M03 – Spindle on, CW
• M04 – Spindle on, CCW
• M05 – Spindle stop
• M06 – Turret indexing
• M07 – Coolant on
• M08 – Coolant on
• M09 – Coolant off
• M30 – Program stop and rewind
Basic M codes 26
FANUC INDIA FA & ROBOT
1) If the actual tool length is more than the assumed tool, the difference
should be mentioned as follows
G43 H01
H01 – here 01 specifies the address where the difference
of tool will be mentioned
2) If the actual tool length is less than the assumed tool, the difference
should be
mentioned as follows
G44 H01
H01 – here 01 specifies the address where the difference
of tool will be mentioned
G41 D07;
Here, D specifies the address of
offset at which the radius of tool
will be mentioned
G41 D07;
Side cutting
Hole machining
Face cutting
Programming Examples
SQ 150
2 3
1 4
G54
SQ 200
thickness
20mm
Programming Examples 35
FANUC INDIA FA & ROBOT
Programming example
Assumptions
Work offset = G54
Tool length compensation = H01
Programming Examples 36
FANUC INDIA FA & ROBOT
Point X Y 5
1 0 25 2
2 0 50
1 6
3 45 150
4 105 150 G55
8 7
5 150 50
6 150 25
7 125 0
8 25 0
Programming Examples 38
FANUC INDIA FA & ROBOT
Programming Examples 39
FANUC INDIA FA & ROBOT
Programming Examples 40
FANUC INDIA FA & ROBOT
Point X Y 5
1 0 25 2
2 0 50
1 6
3 45 150
4 105 150 G55
8 7
5 150 50
6 150 25
7 125 0
8 25 0
Programming Examples 41
FANUC INDIA FA & ROBOT
Programming Examples 42
FANUC INDIA FA & ROBOT
Programming Examples 43
FANUC INDIA FA & ROBOT
4 125 200 1 8 7 6
G57
5 200 200
6 200 0
7 125 0
8 75 0
Programming Examples 44
FANUC INDIA FA & ROBOT
Programming Examples 45
FANUC INDIA FA & ROBOT
Programming Examples 46
FANUC INDIA FA & ROBOT
Programming Example
BLANK SIZE
100*100*20
DIA. 8, FIVE HOLES
HOLE1 (20,20)
HOLE2 (20,80)
HOLE3 (80,80)
HOLE4 (80,20)
HOLE5 (50,50)
PROGRAMMING EXAMPLE
O1005
N1 G91 G28 X0 Y0 Z0
N2 T01 M06
N3 G21
N4 G17 G90 G54 G00 X20 Y20
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G81 Z-4. R5 F300
N8 X80
N9 Y80
N10 X20N11 X50 Y50
N12 G80 G00 Z100
N13 G91 G28 X0 Y0 Z0
N14 M05
N15 M30
1 Rapid motion to hole position G82 X…. Y…. R…. Z…. P….F….
2 Rapid motion to safety level/reference level X = Hole position in X axis
Y = Hole position in Y axis
3 Feed rate motion to Z depth R = Reference position (Z axis st. point)
Z = Final depth (abs.)
4 Dwell at the depth in millisecond P = Dwell time in milliseconds
F = Federate specification
5 Rapid retract to initial/reference level
PROGRAMMING EXAMPLE
BLANK SIZE
100*100*20
DIA. 8, FIVE HOLES
HOLE1 (20,20)
HOLE2 (20,80)
HOLE3 (80,80)
HOLE4 (80,20)
HOLE5 (50,50)
O1006
N1 G91 G28 X0 Y0 Z0
N2 T02 M06
N3 G21
N4 G17 G90 G54 G00 X20 Y20
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G82 Z-15. R5 P2000 F300
N8 X80
N9 Y80
N10 X20
N11 X50 Y50
N12 G80 G00 Z100 M05
N13 G91 G28 X0 Y0 Z0
N14 M30
Canned cycles - Drilling 53
FANUC INDIA FA & ROBOT
6 Steps 3,4, and 5 repeat until the 6 Steps 4 and 5 repeat until the
programmed Z depth is reached programmed Z depth is reached
Programming Example
BLANK SIZE
100*100*20
DIA. 8, FIVE HOLES
HOLE1 (20,20)
HOLE2 (20,80)
HOLE3 (80,80)
HOLE4 (80,20)
HOLE5 (50,50)
O1007
N1 G91 G28 X0 Y0 Z0
N2 T03 M06
N3 G21
N4 G17 G90 G54 G00 X20 Y20
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G83 Z-30. R5 Q8000 F300 or G73 Z-30 R5 Q8000 F300
N8 X80
N9 Y80
N10 X20
N11 X50 Y50
N12 G80 G00 Z100 M05
N14 G91 G28 X0 Y0 Z0
N15 M30
PROGRAMMING EXAMPLE
BLANK SIZE
100*100*20
DIA. 8, FIVE HOLES
HOLE1 (20,20)
HOLE2 (20,80)
HOLE3 (80,80)
HOLE4 (80,20)
HOLE5 (50,50)
O1008
N1 G91 G28 X0 Y0 Z0
N2 T03 M06
N3 G21
N4 G17 G90 G54 G00 X20 Y20
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G84 Z-15. R5 F300 or G74 Z-30 R5 F300 (Feed = RPM * Pitch)
N8 X80
N9 Y80
N10 X20
N11 X50 Y50
N12 G80 G00 Z100 M05
N13 G91 G28 X0 Y0 Z0
N14 M30
PROGRAMMING EXAMPLE
DIMNSION OF
BLANK
100*100*20
HOLE DIA. 10 mm
HOLE (50,50)
PROGRAMMING EXAMPLE
O1009
N1 G91 G28 X0 Y0 Z0
N2 T01 M06
N3 G21
N9 G91 G28 X0 Y0 Z0
N10 M30
66
FANUC INDIA FA & ROBOT
PROGRAMMING EXAMPLE
O1009
N1 G91 G28 X0 Y0 Z0
N2 T01 M06
DIMNSION OF
BLANK 100*100*20 N3 G21
HOLE (50,50) N4 G17 G90 G54 G00 X50 Y50
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G86 Z-20. R5 F300
N8 G80 Z100
N9 G91 G28 X0 Y0 Z0
N10 M05
N11 M30
This cycle is rare. Its use is limited to boring operations with special tools
that require manual interference at the bottom of a hole. This cycle may be used by
some tool manufacturers for certain operations.
PROGRAMMING EXAMPLE
DIMNSION OF
BLANK
100*100*20
HOLE (50,50)
O1010
N1 G91 G28 X0 Y0 Z0
N2 T01 M06
N3 G21
N4 G17 G90 G54 G00 X50 Y50
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G88 Z-20. R5 P2000 F300
N8 G80 G00 Z100 M05
N9 G91 G28 X0 Y0 Z0
N10 M30
STEP Description of the cycle G89 X…. Y…. R…. Z…. P…F….
1 Rapid motion to XY position X = Hole position in X axis
2 Rapid motion to safety level/reference Y = Hole position in Y axis
level R = Reference position (Z axis st.
point)
3 Feed rate motion to Z depth Z = Final depth (abs.)
P = dwell time in milliseconds
4 Dwell at the depth F = Federate specification
5 Feed rate motion back to safety/R level
PROGRAMMING EXAMPLE
DIMNSIONS OF BLANK
100*100*20
HOLE DIA. 10 mm
HOLE (50,50)
O1011
N1 G91 G28 X0 Y0 Z0
N2 T01 M06
N3 G21
N9 G91 G28 X0 Y0 Z0
N10 M30
Pattern of holes 73
FANUC INDIA FA & ROBOT
PATTERN OF HOLES
BLANK SIZE =
100*100*20
DIA. 8, FIVE HOLES
HOLE1 (28,16)
HOLE2 (60,32)
HOLE3 (88,40)
HOLE4 (104,48)
Pattern of holes 74
FANUC INDIA FA & ROBOT
O1012
N1 G91 G28 X0 Y0 Z0
N2 T01 M06
N3 G21
N4 G17 G90 G54 G00 X28 Y16
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G83 Z-30. R5 Q8000 F300
N8 X60 Y32
N9 X88 Y40
N10 X104 Y 48
N11 G80 G00 Z100 M05
N13 G91 G28 X0 Y0 Z0
N14 M30
Pattern of holes 75
FANUC INDIA FA & ROBOT
Pattern of holes 76
FANUC INDIA FA & ROBOT
O1014
N1 G91 G28 X0 Y0 Z0
N2 T01 M06
N3 G21
N4 G17 G90 G54 G00 X15 Y10
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G83 Z-30. R5 Q8000 F300
N8 G91 X20.0 K5
N9 G80 G00 Z100 M05
N10 G28 X0 Y0 Z0
N11 M30
Pattern of holes 77
FANUC INDIA FA & ROBOT
Pattern of holes 78
FANUC INDIA FA & ROBOT
O1015
N1 G21 G94
N2 G91 G28 X0 Y0 Z0
N3 T01 M06
N4 G17 G90 G54 G00 X20 Y20
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G83 Z-30. R5 Q8000 F300
N8 G91 X38.6370 Y10.3527 K5
N9 G80 G00 Z100 M05
N10 G28 X0 Y0 Z0
N11 M30
Pattern of holes 79
FANUC INDIA FA & ROBOT
PROGRAMMING EXAMPLE
O1016
N1 G21 G94
N2 G91 G28 X0 Y0 Z0
N3 T01 M06
N4 G17 G90 G54 G00 X20 Y30
N5 G43 H01 Z100
N6 M03 S1000 Z20
Pattern of holes 80
FANUC INDIA FA & ROBOT
Pattern of holes 81
FANUC INDIA FA & ROBOT
2
3
1
4 6
Pattern of holes 82
FANUC INDIA FA & ROBOT
Hole # 1
X = 75 + 50 * cos30 = 118.30127
Y = 60 + 50 * sin30 = 85.0
Hole # 2
X = 75 + 50 * cos90 = 75.0
Y = 60 + 50 * sin90 = 110.0
Hole # 3
X = 75 + 50 * cos150 = 31.6987298
Y = 60 + 50 * sin150 = 85.0
Hole # 4
X = 75 + 50 * cos210 = 31.6987298
Hole # 5
X = 75 + 50 * cos270 = 75.0
Y = 60 + 50 * sin270 = 100.0
Hole # 6
X = 75 + 50 * cos330 = 118.30127
Y =holes
Pattern of 60 + 50* sin330 = 35.0 83
FANUC INDIA FA & ROBOT
O1017
N1 G91 G28 X0 Y0 Z0
N2 T03 M06
N3 G21
N4 G17 G90 G54 G00 X118.3012 Y85.0
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G99 G83 Z-30. R5 Q8000 F300
N8 X75.0 Y110.0
N9 X31.6987 Y85.0
N10 X31.6987 Y35.0
N11 X75.0 Y10
N12 X118.301 Y35.0
N13 G80 G00 Z100 M05
N14 G91 G28 X0 Y0 Z0
N15 M30
Pattern of holes 84
FANUC INDIA FA & ROBOT
4 6
Pattern of holes 85
FANUC INDIA FA & ROBOT
O1018
N1 G91 G28 X0 Y0 Z0
N2 T03 M06
N3 G21
N4 G17 G90 G54 G00 X75.0 Y60.0
N5 G43 H01 Z100
N6 M03 S1000 Z20
N7 G16; POLAR SYSTEM ON
N8 G99 G83 X50 Y30 Z-30. R5 Q8000 F300
N9 X50 Y90
N10 X50 Y150
N11 X50 Y210
N12 X50 Y270
N13 X50 Y330
N14 G15 ; POLAR SYSTEM OFF
N15 G80 G00 Z100 M05
N16 G91 G28 X0 Y0 Z0
N17 M30
Pattern of holes 86
FANUC INDIA FA & ROBOT
Custom Macro
Macro call
G66