CNC Programming Tutorials Examples G and M Codes Programming Tutorial Example Code For Beginner To Advance Level CNC Machinist PDF
CNC Programming Tutorials Examples G and M Codes Programming Tutorial Example Code For Beginner To Advance Level CNC Machinist PDF
com
CNC Programming Tutorials Examples G & M Codes
***
TABLE OF CONTENTS:
1. Advanced Level
2. Beginner Level
3. Bolt Hole Circle
4. Boring CNC Lathe
5. Chamfer Radius
6. CNC Lathe Machine
7. CNC Milling Machine
8. Drilling
9. G02 G03 I J K
10. G02 G03 R
11. G40 G41 G42
12. G81 Drilling Cycle
13. G91 Incremental Programming
14. Grooving
15. Intermediate Level
16. Pattern Drilling
17. Peck Drilling Lathe
18. Peck Drilling-Mill
19. Peck Milling
20. Ramping Milling
21. Slot Milling
22. Step Turning CNC Lathe
23. Subprogram
24. Taper Threading
25. Tapping
26. Threading
www.EngineeringBooksPDF.com
CNC Program Examples *
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Advanced Level
Fanuc G72.1 G72.2 Figure Copy Program Example
(Bolt Hole Circle)
This CNC program example shows how both G72.1 and G72.2 figure copy
functions can call one-another in one part program, read Programming
Notes below carefully.
Programming
Programming Notes
Specifying two or more commands to copy a figure
www.EngineeringBooksPDF.com
G72.1 cannot be specified more than once in a subprogram for making a
rotational copy (If this is attempted, alarm PS0900 will occur).
G72.2 cannot be specified more than once in a subprogram for making a
linear copy (If this is attempted, alarm PS0901 will occur).
In a subprogram that specifies rotational copy, however, linear copy can be
specified. Similarly, in a subprogram that specifies linear copy, rotational
copy can be specified.
Main program
O4000 ;
N10 G90 G00 G17 X240. Y230. Z100. ; (P0)
N20 G72.1 P4100 X120. Y120. L8 R45. ;
N30 G80 G00 X240. Y230. ; (P0)
N40 M30 ;
O4200 N110 G90 G81 X120. Y180. R60. Z10. F200. ; (P1)
N210 M99 ;
****************
www.EngineeringBooksPDF.com
Fanuc G72.2 Linear Copy (Figure
Copy Function CNC Mill)
Fanuc G72.2 Linear Copy
Programming
G72.2 P... L... I... J...
Parameters
Parameter Description
P Subprogram number
L Number of times the operation is repeated
I Shift along X-axis
J Shift along Y-axis
G-Code Data
Programming Notes
Notes
In the G72.2 block, addresses other than P, L, I and J are ignored.
P, I and J must always be specified.
If L is not specified, the figure is copied once.
For shifts (I, J), specify increments. The n-th geometric shift is equal to the
specified shift times (n – 1).
www.EngineeringBooksPDF.com
O00001234; and does not have a move command, movement may stop at the
start point of the figure made by the n-th (n = 1,2, 3, …) copying.
Limitation
Single block
Single-block stops are not performed in a block with G721.1 or G72.2.
****************
www.EngineeringBooksPDF.com
Main program
O3000 ;
N10 G90 G00 X-30. Y0 ;
N20 X0 ;
N30 G01 G17 G41 X30. D01 F100 ; (P0)
N40 Y20. ; (P1)
N50 X40. ; (P2)
N60 G72.2 P3100 L3 I90.0 J0 ;
N70 G90 X310. Y0 ; (P8)
N80 X0 ;
N90 G40 G00 X-30.0 ;
N100 M30 ;
Sub program
O3100 G91 G01 X20. ; (P3)
N100 Y30. ; (P4)
N200 G02 X40. I20. ; (P5)
N300 G01 Y-30. ; (P6)
N400 X30. ; (P7)
N500 M99 ;
****************
www.EngineeringBooksPDF.com
Read more Fanuc G72.1 Rotational Copy (Figure Copy Function CNC
Mill)
Main program
O2000 ;
N10 G90 G00 G17 X250. Y100. Z100. ; (P0)
N20 G72.1 P2100 L6 X100. Y50. R60. ;
N30 G80 G00 X250. Y100. ; (P0)
N40 M30 ;
Sub program
O2100 N100 G90 G81 X100. Y150. R60. Z10. F200. ; (P1)
N200 M99 ;
****************
www.EngineeringBooksPDF.com
Fanuc G68 Program Example
T1 M6
G0 G90 G40 G21 G17 G94 G80
G54 X20 Y0 S1500 M3
G43 Z100 H1
Z5
G81 R3 Z-20 F? M8
X30
X45
G68 X0 Y0 R120
X20 Y0
X30
X45
G68 X0 Y0 R240
X20 Y0
X30
X45
G69 G80
G0 G90 Z100 M30
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Beginner Level
CNC Mill Example Program G01 G02 G03
G90 G91
A cnc mill program for cnc machinists programmers, who have started to learning
basic cnc programming techniques.
CNC Program
N40 G90 G00 X0 Y0
N50 G01 X-10 Y-20 R8 (P1)
N60 G01 X-50 R10 (P2)
N70 Y10 (P3)
N80 X-19.97 Y25.01 (P4)
N90 G03 X7.97 Y38.99 R18 (P5)
N100 G01 X30 Y50 (P6)
N110 G91 X10.1 Y-10.1(P7)
N120 G90 G02 X59.9 Y20.1 R14 (P8)
N130 G01 X70 Y10 (P9)
N140 Y-20 R10(P10)
N150 X50 (P11)
N160 G03 X30 R10 (P12)
N170 G01 X10 R8 (P13)
N180 X0 Y0
G M S T Codes Explanation
Code Description
G00 Rapid traverse
www.EngineeringBooksPDF.com
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G90 Absolute command
G91 Increment command
*************
www.EngineeringBooksPDF.com
G3 X-23.46 Y18.27 R4(P5)
G2 X-23.46 Y-18.27 R50 (P6)
G3 X-18.27 Y-23.46 R4 (P7)
G2 X24.07 Y-26.18 R50 (P8)
G3 X30 Y-24.67 R4 (P9)
G1 X33
G M S T Codes Explanation
Code Description
G0 Rapid traverse
G1 Linear interpolation
G2 Circular interpolation CW
G3 Circular interpolation CCW
M30 End of program (Reset)
*************
www.EngineeringBooksPDF.com
N55 M30
G M S T Codes Explanation
Code Description
G0 Rapid traverse
G1 Linear interpolation
G2 Circular interpolation CW
G3 Circular interpolation CCW
G43 Tool length compensation + direction
M3 Spindle start forward CW
M6 Tool change
M30 End of program (Reset)
T Tool
S Speed
F Feed
*************
Haas Chamfering
To program Chamfer
N10 G01 X20 Y30 ,C3
www.EngineeringBooksPDF.com
Haas CNC Program
O1234 (Corner Rounding and Chamfering Example);
T1 M6;
G00 G90 G54 X0. Y0. S3000 M3; (P1)
G43 H01 Z0.1 M08;
G01 Z-0.5 F20.;
Y40. ,R10.;(P2)
X50. ,C5.; (P3)
Y0.; (P4)
G00 Z0.1 M09;
G53 G49 Z0.;
G53 Y0.;
M30;
Haas G M S T Codes
Code Description
G00 Rapid Motion
G01 Linear Interpolation Motion
G43 Tool Length Compensation +
G49 G43/G44 Cancel
G53 Non-Modal Machine Coordinate Selection
G54 Select Work Coordinate System l
G90 Incremental Programming
M3 Spindle On, Clockwise (S)
M6 Tool Change (T)
M08 Coolant On
M09 Coolant Off
M30 Program End and Reset
S Spindle speed
T Tool
www.EngineeringBooksPDF.com
*************
Subprogram
O0050
N10 F160 S400
N20 G0 Z-2.5 G91
N30 G1 G90 X5 Y50 G41 (P1)
N40 G2 X22 Y85.23 I45 J0 (P2)
N50 G3 X78 Y85.23 R45 (P3)
N60 G2 X78 Y14.77 R45 (P4)
N70 G3 X22 Y14.77 R45 (P5)
N80 G2 X5 Y50 R45 (P1)
N90 G0 G40 X-21
N100 M99
www.EngineeringBooksPDF.com
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G49 Tool length compensation cancel
G90 Absolute command
G91 Increment command
M03 Spindle start forward CW
M06 Tool change
M30 End of program (Reset)
M98 Subprogram call
M99 End of subprogram
T Tool
S Speed
F Feed
*************
www.EngineeringBooksPDF.com
CNC Part Program
N05 G54
N10 M6 T1 G43 H1 M3
N15 S500 F120
N20 G0 X-22 Y-22
N25 Z-3
N30 G1 X3 Y6 G41 H2 (P1)
N35 G91 X0 Y24(P2)
N40 X12 Y9(P3)
N45 X36 (P4)
N50 Y-24 (P5)
N55 X-21 (P6)
N60 G90 X3 Y6 (P1)
N65 G0 X-21 G40
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G54 Workpiece coordinate system 1 selection
G90 Absolute command
G91 Incremental command
M06 Tool change
T Tool
S Speed
F Feed
*************
www.EngineeringBooksPDF.com
This program example uses Peck milling to cut material to machine a rectangular
and one round pocket.
Main Program
Milling cutter diameter: 10mm
N05 G55
N10 M6 T2 H3 G43 M3
N15 S1000 F60
N20 G0 X9 Y9 Z1
N25 G1 Z0
N30 M98 P030035
N35 G0 Z1 G90
N40 X42 Y38
N45 G1 Z-2 F30
N50 X47 F300
N55 G3 X47 Y38 I-5 J0
N60 G0 Z100
N65 G49
N70 M30
Subprogram
O0035
N05 G1 Z-2 G91 F30
N10 X10 F100
N15 Y36
N20 X-10
N25 Y-36
N30 M99
Explanation
Although this cnc mill program is self explanatory
M98 P030035
www.EngineeringBooksPDF.com
*************
*************
www.EngineeringBooksPDF.com
Easy to understand CNC turning center/cnc lathe programming example for cnc
machinists who work on cnc turning centers/cnc lathe machines.
This cnc programming example can be used as a cnc learning programming
exercise for beginners level cnc programmers/machinists.
*************
www.EngineeringBooksPDF.com
CNC Wire Cut Introduction
Wire EDM cutting, also known as electrical discharge machining, is a process that
uses an electrically energized thin wire to slice through metal. Wire EDM cutting
uses rapid, controlled, repetitive spark discharges from the wire to the workpiece,
thereby eroding the metal away. The workpiece must be electrically conductive.
Wire EDM cutting can provide high dimensional accuracy for close fitting parts.
The process can make sharp inside corners.
*************
www.EngineeringBooksPDF.com
CNC Lathe Basic Programming
Example ID/OD Turning/Boring
Operations (No Canned Cycle Used)
A full CNC programming example with ID/OD (Turning/Boring operations) for
cnc machinists who work on a cnc lathe machine. A must to learn/practice for
those who are learning cnc programming.
The added benefit of this programming example is that no cnc lathe canned cycle
is used in this programming example.
www.EngineeringBooksPDF.com
G96 S180 M03
G00 X94.0 Z5.0 T0101 M08
G01 Z-14.8 F0.27
G00 U2.0 Z0.5
G01 X28.0 F0.23
G00 X87.0 W1.0
G01 Z-14.8 F0.27
G00 U2.0 Z1.0
X80.5
G01 Z-14.1
G02 X81.9 Z-14.8 R0.7
G00 X100.5 W1.0
G01 Z-29.8
G00 U2.0 Z-1.0
G01 X60.5 F0.23
G00 X82.0 W1.0
Z-2.4
G01 X60.5
X72.9
G03 X80.5 Z-6.2 R3.8
G00 U2.0 Z5.0
X200.0 Z200.0 T0100
M01
N30 (Inside diameter stock removal)
G50 S1500 T0400
G96 S180 M03
G00 X34.5 Z3.0 T0404 M08
G01 Z-41.8 F0.27
G00 U-0.5 Z1.0
X39.5
G01 Z-15.0
X34.5 Z-24.3
G00 Z10.0
X200.0 Z200.0 T0400
M01
N40 (Out diameter finishing)
G50 S1800 T0500
G96 S200 M03
G00 X63.0 Z5.0 T0505 M08
Z0
G01 X38.0 F0.2
G00 X60.0 Z3.0
G42 Z1.0
G01 Z-2.5 F0.2
X74.0
G03 X80.0 Z-5.5 R3.0
G01 Z-13.5
G02 X83.0 Z-15.0 R1.5
G01 X100.0
Z-30.0
X102.0
G40 G00 U2.0 W1.0
G00 Z10.0
X200.0 Z200.0 T0500
www.EngineeringBooksPDF.com
M01
N50 (Inside diameter finishing)
G50 S1800 T0600
G96 S200 M03
G00 X40.0 Z5.0 T0606 M08
G41 Z1.0
G01 Z-15.0 F0.2
X35.0 Z-24.33
Z-42.0
X29.0
G40 G00 Z10.0
X200.0 Z200.0 T0600 M09
M30
***********
www.EngineeringBooksPDF.com
G91 Incremental Programming CNC Mill Exercise
N5 G00 G54 G64 G90 G17 X-20 Y-20 Z50 ;Point 1
N10 S450 M03 F250 D01 (12.5 MM DIA)
N15 C0
N20 Z5
N25 G01 Z0
N30 Z-5
N35 G42 G91 X20 Y20 ;Point 2
N40 X10 Y10 ;Point 3
N45 X70 Y-10 ;Point 4
N50 X20 Y20 ;Point 5
N55 X-40 Y60 ;Point 6
N60 X-20 ;Point 7
N65 X-10 Y-25;Point 8
N70 X-30 Y-15;Point 9
N80 X0 Y-40 ;Point 10
N85 G40 G90 X-20 Y-20;Point 11
N90 G00 Z50
N95 Y100
N100 M30
Finished Part
After completing the machining process, your job will look like this in 3D view,
www.EngineeringBooksPDF.com
D : Tool no
**********
www.EngineeringBooksPDF.com
**********
www.EngineeringBooksPDF.com
N70 G40 X20 Y-20
N75 G00 Z50
N80 Y100
N85 M30
Finished Part
**********
www.EngineeringBooksPDF.com
Sinumerik Milling Program
Finished Part
Explanation of G-Code
G00 – Rapid traverse.
G54 – Zero Offset no 1.
G64 – Continuous-path mode.
G90 – Absolute dimensioning system.
G17 – X-Y plan selection.
G42 – Cutter radius compensation activation
www.EngineeringBooksPDF.com
G40 – Cutter radius compensation cancel
M03 – Cutter rotation clockwise
S – Spindle speed
F – Axis motion feed
D – Tool no
*********
www.EngineeringBooksPDF.com
*************
www.EngineeringBooksPDF.com
X-25.0
X-45.0 Y45.0
Y-80.0
M30
*********
**********
www.EngineeringBooksPDF.com
CNC Lathe Simple G Code Example –
G code Programming for Beginners
CNC lathe simple g code example for CNC machinists/CNC programmers who
just started their journey to learn CNC programming.
Code Explanation
N5 Clamping workpiece
N10 Changing No.1 tool and executing its offset
N15 Rapidly positioning to A point
N20 Starting the spindle with 600 r/min
N25 Cooling ON
N30 Approaching B point with 600mm/min
N40 Cutting from B point to C point
www.EngineeringBooksPDF.com
N50 Cutting from C point to D point
N60 Rapidly retracting to A point
N70 Canceling the tool offset
N80 Stopping the spindle
N90 Cooling OFF
N100 Releasing workpiece
N110 End of program, spindle stopping and Cooling OFF
**************
Explanation
N10 G02 X Z R
X – Arc end-point in X-axis
Z – Arc end-point in Z-axis
R – Arc Radius.
N10 G02 X Z I K
X- Arc end-point in X-axis.
Z – Arc end-point in Z-axis.
I – Distance from arc-start-point to arc-center-point in X-axis.
www.EngineeringBooksPDF.com
K – Distance from arc-start-point to arc-center-point in Z-axis.
*************
www.EngineeringBooksPDF.com
Sample G code program example for cnc programmers / cnc machinists who work
or want to learn cnc mill programming.
A similar G code example can be found here
Simple G Code Example Mill – G code Programming for Beginners
If you are interested in G code subroutine example (sub program) read
CNC Mill Contour Pecking – Fanuc Subprogram Repeat Example
This is the same component but this time we are machining it in taper.
G Code Example
*****************
www.EngineeringBooksPDF.com
G code Programming for Beginners
Learning G code programming is not that difficult.
Read and learn about a G code.
Understand how that G code work.
Then make a simple G code example drawing.
Make program for that example.
Run the program on your cnc machine (Safety first, keep a professional
around).
Or you can simply run a cnc program Simulation (but this always doesn’t
substitute the actual cnc machining process.)
The last thing is the most crucial which is Just practice practice and
practice.
This is a very simple G code example for beginner level cnc programmers /
cnc machinists.
This G code program example don’t use Tool radius compensation
G40/G41/G42 G code.
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Bolt Hole Circle
Programming
Fanuc G72.1 Rotational Copy
Using G72.1 Rotational Copy G-code a figure specified by a subprogram
can be repeatedly produced with Rotational movement.
Read G72.1 definition with program example Fanuc G72.1 Rotational Copy
(Figure Copy Function CNC Mill)
Programming Notes
www.EngineeringBooksPDF.com
G72.2 cannot be specified more than once in a subprogram for making a
linear copy (If this is attempted, alarm PS0901 will occur).
In a subprogram that specifies rotational copy, however, linear copy can be
specified. Similarly, in a subprogram that specifies linear copy, rotational
copy can be specified.
Main program
O4000 ;
N10 G90 G00 G17 X240. Y230. Z100. ; (P0)
N20 G72.1 P4100 X120. Y120. L8 R45. ;
N30 G80 G00 X240. Y230. ; (P0)
N40 M30 ;
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Boring CNC Lathe
Fanuc G71 G72 G70 Canned Cycle
CNC Lathe Internal Machining
Example (Boring & Facing)
Fanuc programming example which shows the use of multiple fanuc canned cycle
in cnc programming, Following canned cycle are used in this cnc lathe
programming example
www.EngineeringBooksPDF.com
G72 P100 Q200 F0.25
N100 G0 Z0 G41
G1 X-2.0 F0.18
N200 G0 Z5.0
G40
X255.0
G28 U0 W0
N2 T0404 M8 (ID ROUGH)
G96 S180 M3
G0 X50.0 Z5.0
G71 U2.0 R0.5
G71 P500 Q600 U-0.5 W0.1 F0.25
N500 G0 X202.0 G41
G1 Z0 F0.12
X200.0
Z-10.0
X100.0
Z-30.0
X60.0
Z-45.0
N600 X50.0
G40
G0 Z5.0
G28 U0 W0
N3 T0505 M8 (ID FINISH)
G96 S220 M3
G0 X50.0 Z5.0
G70 P500 Q600
G0 X50.0 Z5.0
G28 U0 W0
M5 M9
M30
**************
www.EngineeringBooksPDF.com
The added benefit of this programming example is that no cnc lathe canned cycle
is used in this programming example.
CNC Lathe Basic Programming Example (Turning
Boring Operations)
www.EngineeringBooksPDF.com
G00 X82.0 W1.0
Z-2.4
G01 X60.5
X72.9
G03 X80.5 Z-6.2 R3.8
G00 U2.0 Z5.0
X200.0 Z200.0 T0100
M01
N30 (Inside diameter stock removal)
G50 S1500 T0400
G96 S180 M03
G00 X34.5 Z3.0 T0404 M08
G01 Z-41.8 F0.27
G00 U-0.5 Z1.0
X39.5
G01 Z-15.0
X34.5 Z-24.3
G00 Z10.0
X200.0 Z200.0 T0400
M01
N40 (Out diameter finishing)
G50 S1800 T0500
G96 S200 M03
G00 X63.0 Z5.0 T0505 M08
Z0
G01 X38.0 F0.2
G00 X60.0 Z3.0
G42 Z1.0
G01 Z-2.5 F0.2
X74.0
G03 X80.0 Z-5.5 R3.0
G01 Z-13.5
G02 X83.0 Z-15.0 R1.5
G01 X100.0
Z-30.0
X102.0
G40 G00 U2.0 W1.0
G00 Z10.0
X200.0 Z200.0 T0500
M01
N50 (Inside diameter finishing)
G50 S1800 T0600
G96 S200 M03
G00 X40.0 Z5.0 T0606 M08
G41 Z1.0
G01 Z-15.0 F0.2
X35.0 Z-24.33
Z-42.0
X29.0
G40 G00 Z10.0
X200.0 Z200.0 T0600 M09
M30
www.EngineeringBooksPDF.com
*****************
www.EngineeringBooksPDF.com
N130 T0707
N140 G97 S0950 M3
N150 G00 Z3.
N160 G00 X0.
N170 G74 R1.0
N171 G74 X0.0 Z-59.0 Q12000 R0.0 F0.2
N350 G00 X150. Z150.
N360 T0505
N370 G50 S3500
N380 G96 S0200 M4
N390 G00 X23. Z2.
N400 G71 U3. R1
N410 G71 P420 Q530 U-0.5 W0.2 F0.3
N420 G41 G00 X72.
N440 G01 Z-21.
N450 G03 X66. Z-24. I-3. K0.
N460 G01 X54.
N470 G02 X48. Z-27. I0. K-3.
N480 G01 Z-41.
N490 G03 X42. Z-44. I-3. K0.
N500 G01 X30.
N510 G02 X24. Z-47. I0. K-3.
N520 G01 Z-59.
N530 G01 X23.
N540 G40
N550 G00 X150. Z150. F0.3
N560 T1111
N570 G50 S4500
N580 G96 S0380 M4
N590 G41 G00 X72. Z2.
N600 G70 P420 Q530
N610 G40
N620 G00 X23. Z2.
N630 G00 X200. Z150.
N640 M5
N650 M30
***************
www.EngineeringBooksPDF.com
CNC Lathe Programming Exercise
Fanuc G71 Turning Cycle, G74 Peck
Drilling Cycle
CNC programming exercise for cnc lathe machinists who work on Fanuc cnc
control (or similar cnc control).
This cnc programming exercise use
Fanuc G71 Turning Cycle
Fanuc G74 Peck Drilling Cycle
www.EngineeringBooksPDF.com
N260 G74 X0.0 Z-68.326 Q18000 F0.22
N380 G00 X200.
N400 G00 Z100.
N500 T0404 M7
N510 G50 S3500
N520 G96 S0240 M4
N530 G00 Z1.
N540 G00 X70.
N550 G71 U4. R1
N560 G71 P570 Q650 U0.6 W0.2 F0.35
N570 G42 G00 X24.
N580 G01 Z0.
N590 G01 X28. Z-2.
N600 G01 Z-72.
N610 G02 X32. Z-74. I2. K0.
N620 G01 X62.
N630 G01 X68. Z-77.
N640 G01 Z-90.
N650 G40
N660 G00 X150.
N680 G00 Z70.
N690 T0202 M7
N700 G50 S4500
N710 G96 S0380 M4
N720 G00 X16. Z3.
N730 G42 G01 Z0. F0.1
N740 G01 X24.
N750 G01 X28. Z-2.
N760 G01 Z-72.
N770 G02 X32. Z-74. I2. K0.
N780 G01 X62.
N790 G01 X68. Z-77.
N800 G01 Z-90.
N810 G40
N820 G00 X150. Z150.
N830 M5
N840 M9
N850 M30
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Chamfer Radius
CNC Mill Example Program G01 G02
G03 G90 G91
A cnc mill program for cnc machinists programmers, who have started to learning
basic cnc programming techniques.
CNC Program
N40 G90 G00 X0 Y0
N50 G01 X-10 Y-20 R8 (P1)
N60 G01 X-50 R10 (P2)
N70 Y10 (P3)
N80 X-19.97 Y25.01 (P4)
N90 G03 X7.97 Y38.99 R18 (P5)
N100 G01 X30 Y50 (P6)
N110 G91 X10.1 Y-10.1(P7)
N120 G90 G02 X59.9 Y20.1 R14 (P8)
N130 G01 X70 Y10 (P9)
N140 Y-20 R10(P10)
N150 X50(P11)
N160 G03 X30 R10 (P12)
N170 G01 X10 R8(P13)
N180 X0 Y0
G M S T Codes Explanation
Code Description
www.EngineeringBooksPDF.com
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G90 Absolute command
G91 Increment command
**************
Haas Chamfering
To program Chamfer
N10 G01 X20 Y30 ,C3
www.EngineeringBooksPDF.com
Haas CNC Program
O1234 (Corner Rounding and Chamfering Example);
T1 M6;
G00 G90 G54 X0. Y0. S3000 M3; (P1)
G43 H01 Z0.1 M08;
G01 Z-0.5 F20.;
Y40. ,R10.;(P2)
X50. ,C5.; (P3)
Y0.;(P4)
G00 Z0.1 M09;
G53 G49 Z0.;
G53 Y0.;
M30;
Haas G M S T Codes
Code Description
G00 Rapid Motion
G01 Linear Interpolation Motion
G43 Tool Length Compensation +
G49 G43/G44 Cancel
G53 Non-Modal Machine Coordinate Selection
G54 Select Work Coordinate System l
G90 Incremental Programming
M3 Spindle On, Clockwise (S)
M6 Tool Change (T)
M08 Coolant On
M09 Coolant Off
M30 Program End and Reset
S Spindle speed
T Tool
****************
www.EngineeringBooksPDF.com
Easy to program and understand that even a beginner level CNC machinist can
understand and program such sample codes.
Mostly works on Fanuc and similar CNC controls.
No extra G-code or technique is required. Just have to put a “C” for chamfer and
an “R” for Radius in a cnc program block with G01 G-code. Chamfer is at 45° (45
degrees).
For a brief description of how Chamfer and Corner Radius are programmed with
G01 G code read following cnc programming article Chamfer and Radius
Programming with G01 G code.
Another such program example is here G01 Chamfer and Corner Rounding a
CNC Program Example
****************
www.EngineeringBooksPDF.com
• CNC Programming for Beginners a Simple CNC Programming Example
• CNC Programming Example in Inch Simple CNC Lathe Program
• Lathe CNC Programming Example
• CNC Milling Machine Programming Example for Beginners
• CNC G02 Circular Interpolation Clockwise CNC Milling Sample Program
The following cnc program example shows how actually Chamfer and Radius are
programmed with G01 in a cnc lathe program.
G01 Chamfer and Corner Rounding
CNC Programming Example of Chamfer and Corner Rounding with G01 G Code
N5 ……
N6 G00 X0 Z3
N7 G01 Z0 F0.2
N8 X35 C2
N9 Z-40 R4
N10 X55 Z-52 F0.1
N11 X75 C2
N12 Z-76
N13 G00 X100 Z50
N14 ……
***********************
www.EngineeringBooksPDF.com
In the below cnc programming example
1 – A boring bar is used for the whole the roughing operation with G71 Rough
Turning Cycle.
2 – Same boring bar is used for finish cut with G70 Finishing Cycle.
Example of using a Haas G71 for I.D. Roughing and Finishing.
Contents
• Haas CNC Program Example
• Haas CNC Program Explanation
www.EngineeringBooksPDF.com
N15 – To send machine home for a tool change
******************
*********************
www.EngineeringBooksPDF.com
CNC Lathe Programming Example
A simple cnc lathe programming example. This cnc programming example will
show how to program contours like chamfer taper grooves and arc.
This cnc program will use two tools for machining. The first tool used in this cnc
programming example is a turning tooland the second one is a grooving tool.
Contents
• CNC Machining
• CNC Program
CNC Machining
The turning tool will first face the component then it will make a chamfer, after
that there is straight turning and then there is arc machining the arc may be
machined with R (Radius of arc) or arc can be machined with I and K values of
the arc, at the top of arc there is a chamfer, then again straight turning, now there
comes the groove but we can’t make grooves with turning tools because of
their shape so we will machine the groove with our next tool which is solely
made for grooving operations, but at the time we are machining with turning tool
so we will just skip this groove and will just machine in straight line, after that
there is a taper and again a straight line to be machined.
Now with our grooving tool the groove machining task is just easy.
if the grooving insert is of the same size as the dimension of the groove then
grooving is even more easy, we will make the groove in one go, but if
the grooving insert is of smaller width than we have to take depth more than one
time.
CNC Program
www.EngineeringBooksPDF.com
N1 T01 D01 M491
N2 G00 X0 Z1
N3 G01 G96 G41 Z0 F2 S140
N4 G01 X2 CHF=0.125 F0.2
N5 G01 Z-1.125
N6 G02 X3.5 Z-1.875 CR=0.75
N7 G01 X3.75 CHF=0.125
N8 G01 Z-3.575
N9 G01 X5 Z-3.875
N10 G01 Z-4.6
N11 G00 X20 Z20 G40
N12 T02 D02 M491
N13 G00 G97 S500 X4 Z-2.825
N14 G01 X3.85 F1
N15 G01 X3.35 F0.15
N16 G01 X3.85 F0.5
N17 G00 X4
N18 G00 X20 Z20
N19 M30
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
CNC Lathe Machine
CNC Turning Center Programming
Example
Easy to understand CNC turning center/cnc lathe programming example for cnc
machinists who work on cnc turning centers/cnc lathe machines.
This cnc programming example can be used as a cnc learning programming
exercise for beginners level cnc programmers/machinists.
www.EngineeringBooksPDF.com
***************
*******************
www.EngineeringBooksPDF.com
Depth of cut.
Retract height.
Finishing allowance in x-axis and z-axis.
Cycle cutting-feed, spindle speed.
Programming
G71 U... R...
G71 P... Q... U... W... F... S...
Parameters
First block
Parameter Description
U Depth of cut.
R Retract height.
Second block
Parameter Description
P Contour start block number.
Q Contour end block number.
U Finishing allowance in x-axis.
W Finishing allowance in z-axis.
F Feedrate during G71 cycle.
S Spindle speed during G71 cycle.
Note – The F and S given inside P Q block will not be used during G71 turning
cycle, they are used with G70 finishing cycle if later called.
www.EngineeringBooksPDF.com
G71 Turning Cycle Working
N60 G71 U10 R10
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75
When G71 turning cycle is run the whole operation will be done in following
sequence,
First-cut
1 – Tool will move in x-axis U (depth of cut) deep with programmed feed from
starting-point.
2 – Tool will travel with feed in z-axis (destination point in z-axis is given in P Q
blocks )
3 – Tool rapidly retracts R amount in both x-axis and z-axis (at 45 degrees).
4 – Tool rapidly travel in z-axis to start-point
Later-cuts
5 – Tool rapidly moves to last cut depth.
6 – Tool moves with feed in x-axis U deep (first-block U depth of cut).
7 – Tool with feed moves in z-axis (destination point given in P Q blocks).
8 – Tool rapidly retracts in x-axis and z-axis R amount (45 degrees).
9 – Tool rapidly moves to start-point only in z-axis.
This whole sequence of operation keep on going, until the destination point in x-
axis is met.
If finishing allowance is given tool will not make the exact diameter and length
given in P Q blocks but will leave that much allowance, This finishing allowance
can be later machined by calling G70 finishing cycle.
www.EngineeringBooksPDF.com
N60 G71 U10 R10
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75
In this program G71 turning cycle will keep repeating the contour given inside P
Q blocks shown below
N80 G00 X60
N90 G01 Z-75
These two cnc program blocks tell us that we want to remove material till X60
deep and in Z-75 in length.
The depth of cut is given in first-block U10 retract amount is also given R10.
Finishing allowance in x-axis is U3 but there is no finishing allowance given in z-
axis W0.
www.EngineeringBooksPDF.com
G71 Rough Turning Cycle Example
O0004
G00 X200 Z10 M3 S800
G71 U2 R1 F200
G71 P80 Q120 U0.5 W0.2
N80 G00 X40 S1200
G01 Z-30 F100
X60 W-30
W-20
N120 X100 W-10
G70 P80 Q120
M30
****************
www.EngineeringBooksPDF.com
Fanuc G71 for Boring Opertaion
This programming example also illustrate how G71 turning cycle can be used for
internal machining (boring operation). So if you want to remove extra stock from
inside of a component, you can use Fanuc G71 turning cycle for internal stock
removal as well.
www.EngineeringBooksPDF.com
N3 T0505 M8 (ID FINISH)
G96 S220 M3
G0 X50.0 Z5.0
G70 P500 Q600
G0 X50.0 Z5.0
G28 U0 W0
M5 M9
M30
*****************
www.EngineeringBooksPDF.com
G01 Z-5.0 F0.07
W1.0
Z-40.0 F0.25
G00 Z5.0
Z-39.0
G01 Z-60.0
G00 Z10.0
X200.0 Z200.0 T0200
M01
N20 (Outside diameter stock removal)
G50 S1500 T0100
G96 S180 M03
G00 X94.0 Z5.0 T0101 M08
G01 Z-14.8 F0.27
G00 U2.0 Z0.5
G01 X28.0 F0.23
G00 X87.0 W1.0
G01 Z-14.8 F0.27
G00 U2.0 Z1.0
X80.5
G01 Z-14.1
G02 X81.9 Z-14.8 R0.7
G00 X100.5 W1.0
G01 Z-29.8
G00 U2.0 Z-1.0
G01 X60.5 F0.23
G00 X82.0 W1.0
Z-2.4
G01 X60.5
X72.9
G03 X80.5 Z-6.2 R3.8
G00 U2.0 Z5.0
X200.0 Z200.0 T0100
M01
N30 (Inside diameter stock removal)
G50 S1500 T0400
G96 S180 M03
G00 X34.5 Z3.0 T0404 M08
G01 Z-41.8 F0.27
G00 U-0.5 Z1.0
X39.5
G01 Z-15.0
X34.5 Z-24.3
G00 Z10.0
X200.0 Z200.0 T0400
M01
N40 (Out diameter finishing)
G50 S1800 T0500
G96 S200 M03
G00 X63.0 Z5.0 T0505 M08
Z0
G01 X38.0 F0.2
G00 X60.0 Z3.0
G42 Z1.0
www.EngineeringBooksPDF.com
G01 Z-2.5 F0.2
X74.0
G03 X80.0 Z-5.5 R3.0
G01 Z-13.5
G02 X83.0 Z-15.0 R1.5
G01 X100.0
Z-30.0
X102.0
G40 G00 U2.0 W1.0
G00 Z10.0
X200.0 Z200.0 T0500
M01
N50 (Inside diameter finishing)
G50 S1800 T0600
G96 S200 M03
G00 X40.0 Z5.0 T0606 M08
G41 Z1.0
G01 Z-15.0 F0.2
X35.0 Z-24.33
Z-42.0
X29.0
G40 G00 Z10.0
X200.0 Z200.0 T0600 M09
M30
*******************
www.EngineeringBooksPDF.com
Haas G72 Type I Rough and G70 Finish Facing Program Example
O00096
N1 (G72 ROUGHING FACE)
N2 G53 G00 X0. Z0. T0 (Sending home for a tool change)
N3 T101 (O.D. TOOL x .031 TNR) (Select Tool 1 Offset 1)
N4 G50 S3000
N5 G97 S450 M03
N6 G54 G00 X3.1 Z0.1 M08 (Rapid to start point above part stock)
N7 G96 S370
N8 G72 P9 Q18 U0.01 W0.01 D0.06 F0.012 (G72 Rough Facing Cycle with TNC)
N9 G41 G00 Z-1.6 (Starting sequence number defined by P8 in G72 and G70)
N10 G01 X2. F0.008
N11 X1.4 Z-0.9
N12 X1.
N13 Z-0.6
N14 G03 X0.8 Z-0.5 R0.1
N15 G01 Z-0.1
N16 X0.6 Z0.
N17 X-0.062
N18 G40 G00 Z0.1 (End of part path geometry defined with P17 in G72 and G70)
N19 G97 S450 M09
N20 G53 G00 X0. Z0. T0 (Sending home for a tool change)
N21 M01 (Optional Stop)
N22 (G70 FINISHING FACE)
N23 G53 G00 X0. Z0. T0 (Sending home for a tool change)
N24 T202 (O.D. TOOL x .015 TNR) (Select Tool 2 Offset 2)
N25 G50 S3000
N26 G97 S450 M03
N27 G54 G00 X3.1 Z0.1 M08 (Rapid to start point)
N28 G96 S420
N29 G70 P9 Q18 (Finish Facing with G70 Finish Cycle)
N30 G97 S450 M09
N31 G53 G00 X0. Z0. T0 (Sending home for a tool change)
N32 M30 ( End of Program and Reset)
G-Codes
G00 Rapid traverse motion.
G01 Linear interpolation motion.
G03 Circular Interpolation – Counterclockwise.
G41 Tool Nose Compensation LEFT of the programmed path.
www.EngineeringBooksPDF.com
G40 Tool Nose Compensation CANCEL.
G50 Spindle Maximum RPM Limit.
G53 Machine Zero Positioning Coordinate Shift.
G54 Work Offset Positioning Coordinate #1 (Setting 56)
G72 End Face Stock Removal Cycle.
G70 Finishing Cycle.
G96 Constant Surface Speed On.
G97 Constant Surface Speed Cancel.
M-Codes
M01 Optional Program Stop.
M03 Starts the Spindle FORWARD.
M30 Program End and Reset to the beginning of program.
*************
www.EngineeringBooksPDF.com
Fanuc Lathe Programming Example Using G71, G70 for ID Machining
N10 G40 G00
N20 G99
N30 M5
N40 M9
N60 T0101
N70 G50 S3500
N80 G96 S0240 M4
N90 G00 X102. Z0.
N100 G01 X-2. F0.15 M7
N110 G00 X150. Z150.
N120 M9
N130 T0707
N140 G97 S0950 M3
N150 G00 Z3.
N160 G00 X0.
N170 G74 R1.0
N171 G74 X0.0 Z-59.0 Q12000 R0.0 F0.2
N350 G00 X150. Z150.
N360 T0505
N370 G50 S3500
N380 G96 S0200 M4
N390 G00 X23. Z2.
N400 G71 U3. R1
N410 G71 P420 Q530 U-0.5 W0.2 F0.3
N420 G41 G00 X72.
N440 G01 Z-21.
N450 G03 X66. Z-24. I-3. K0.
N460 G01 X54.
N470 G02 X48. Z-27. I0. K-3.
N480 G01 Z-41.
N490 G03 X42. Z-44. I-3. K0.
N500 G01 X30.
N510 G02 X24. Z-47. I0. K-3.
N520 G01 Z-59.
N530 G01 X23.
N540 G40
N550 G00 X150. Z150. F0.3
N560 T1111
N570 G50 S4500
www.EngineeringBooksPDF.com
N580 G96 S0380 M4
N590 G41 G00 X72. Z2.
N600 G70 P420 Q530
N610 G40
N620 G00 X23. Z2.
N630 G00 X200. Z150.
N640 M5
N650 M30
Tools & Oprations
T0101 Turning Tool – Facing Operation
T0707 Tip Drill Tool – Drilling
T0505 Boring Bar – Internal machining (ID machining)
T1111 Boring Bar – Internal finish machining
*****************
www.EngineeringBooksPDF.com
N70 G50 S3500
N80 G96 S0240 M4
N90 G00 X72. Z0.1
N100 G01 X-1.6 F0.12 M7
N110 G00 X150. Z150.
N120 M5
N130 M9
N140 T0303
N150 G97 S2500 M3
N160 G00 X0. Z3.
N170 G01 Z-6. F0.1 M7
N180 G00 Z2.
N190 G00 X150. Z150.
N210 T0707 M7
N220 G97 S0884 M3
N230 G00 Z3.
N240 G00 X0.
N250 G74 R1.0
N260 G74 X0.0 Z-68.326 Q18000 F0.22
N380 G00 X200.
N400 G00 Z100.
N500 T0404 M7
N510 G50 S3500
N520 G96 S0240 M4
N530 G00 Z1.
N540 G00 X70.
N550 G71 U4. R1
N560 G71 P570 Q650 U0.6 W0.2 F0.35
N570 G42 G00 X24.
N580 G01 Z0.
N590 G01 X28. Z-2.
N600 G01 Z-72.
N610 G02 X32. Z-74. I2. K0.
N620 G01 X62.
N630 G01 X68. Z-77.
N640 G01 Z-90.
N650 G40
N660 G00 X150.
N680 G00 Z70.
N690 T0202 M7
N700 G50 S4500
N710 G96 S0380 M4
N720 G00 X16. Z3.
N730 G42 G01 Z0. F0.1
N740 G01 X24.
N750 G01 X28. Z-2.
N760 G01 Z-72.
N770 G02 X32. Z-74. I2. K0.
N780 G01 X62.
N790 G01 X68. Z-77.
N800 G01 Z-90.
N810 G40
N820 G00 X150. Z150.
N830 M5
www.EngineeringBooksPDF.com
N840 M9
N850 M30
************
******************
www.EngineeringBooksPDF.com
G71 Rough Turning Cycle Example
Code – CNC Lathe Programming
Example Program
www.EngineeringBooksPDF.com
**************
Code Explanation
N5 Clamping workpiece
N10 Changing No.1 tool and executing its offset
N15 Rapidly positioning to A point
N20 Starting the spindle with 600 r/min
www.EngineeringBooksPDF.com
N25 Cooling ON
N30 Approaching B point with 600mm/min
N40 Cutting from B point to C point
N50 Cutting from C point to D point
N60 Rapidly retracting to A point
N70 Canceling the tool offset
N80 Stopping the spindle
N90 Cooling OFF
N100 Releasing workpiece
N110 End of program, spindle stopping and Cooling OFF
********************
www.EngineeringBooksPDF.com
I – Distance from arc-start-point to arc-center-point in X-axis.
K – Distance from arc-start-point to arc-center-point in Z-axis.
*****************
www.EngineeringBooksPDF.com
A basic cnc programming exercise for newbie cnc machinists / newbie cnc
programmers who have just to start their professional career.
This cnc program example shows the use of G90 rough turning cycle in a very
extensive way.
Newbie cnc machinists must learn such cnc programming techniques and then
master them.
www.EngineeringBooksPDF.com
N140 G00 X49.
N150 G90 X39. Z-14.8 F0.3
N160 X31.
N170 X25.
N430 G00 X150. Z100.
N440 T0202
N450 G50 S4500
N460 G96 S0380 M4
N470 G00 X-1.6 Z2.
N480 G42 G01 Z0. F0.1
N490 G01 X24.
N500 G01 Z-15.
N510 G01 X48.
N520 G01 Z-35.
N530 G01 X72.
N540 G01 Z-59.
N550 G01 X102.
N560 G40
N570 G00 X150. Z100.
N580 M5
N590 M9
N600 M30
*********************
www.EngineeringBooksPDF.com
Fanuc G73 Pattern Repeating Cycle Program Example
N010 G00 X260.0 Z80.0
N011 G00 X220.0 Z40.0
N012 G73 U14.0 W14.0 R3
N013 G73 P014 Q020 U4.0 W2.0 F0.3 S0180
N014 G00 G42 X80.0 Z2.0
N015 G01 W-20.0 F0.15 S0600
N016 X120.0 W-10.0
N017 W-20.0 S0400
N018 G02 X160.0 W-20.0 R20.0
N019 G01 X180.0 W-10.0 S0280
N020 G40
N021 G70 P014 Q020
N022 G00 X260.0 Z80.0
N023 M30
*****************
www.EngineeringBooksPDF.com
So from the first cut G73 pattern repeating cycle cuts the same shape as the finish
component.
www.EngineeringBooksPDF.com
Fanuc G73 Pattern Repeating Canned Cycle Basic CNC Sample Program
***************
Examples
www.EngineeringBooksPDF.com
For following exmaples suppos actual referece-point position on your machine is
X330 and Z529.
Example 1
G28 U0 W0
Example 2
G28 X100 Z100
**************
www.EngineeringBooksPDF.com
G71 Turning Cycle
For complete parameter explanation for G71 canned cycle read
CNC Fanuc G71 Turning Cycle or Stock Removal Canned Cycle
you might like G71 Rough Turning Cycle One-line Format.
Other such programming examples are here
CNC Programming Example with Fanuc G71 Rough Turning Cycle and G70
Fanuc G70 G71 Rough and Finish Turning Cycle Program Example
Programming Example
****************
www.EngineeringBooksPDF.com
If your Fanuc control use One-line format canned cycle then here is full
description of Fanuc G72 Facing Cycle
G72 Facing Cycle One-line Format for Fanuc 10T 11T 15T
Here is an example of One-line (single-line) format
Sample Program Example Fanuc G72 Facing Cycle Single-line-format
www.EngineeringBooksPDF.com
Same program example for G72 one-line format read Sample Program Example
Fanuc G72 Facing Cycle Single-line-format
**************
Program Example
www.EngineeringBooksPDF.com
N016 W10.0
N017 X80.0 W10.0
N018 W20.0
N019 X36.0 W22.0
N020 G70 P014 Q019
As above code shows machining contour is from N014 till N019 as given with
G72 P014 Q019
The G72 canned cycle will take D7000 (7mm) cut each.
Finishing allowance in X-axis is U4.0 and in Z-axis is W0.2
During the canned cycle the tool feed will be F0.3 and spindle speed will be S550
as given in block N013
After canned cycle completion G70 finishing cycle is called with the same block
numbers as P014 Q019.
The feed and spindle speed will act normally as normal cnc program,
As spindle speed will be S700 given in block N014
and tool feed will be F0.15 as given in block N015 (this feed will active
throughout G70 as no other feed-rate in given in later blocks)
*********************
www.EngineeringBooksPDF.com
Chamfer and Radius with G01 G-Code
***********************
www.EngineeringBooksPDF.com
Fanuc G94 Facing Cycle CNC Example Program
N10 G50 S2500
N20 G96 S180 M03
N30 T0100
N40 G00 X55.0 Z2.0 T0101
N50 G94 X15.0 Z-2.0 F0.2
N60 Z-4.0
N70 Z-6.0
N80 Z-8.0
N90 G00 X200.0 Z200.0 T0100
N95 M30
******************
www.EngineeringBooksPDF.com
Internal Threading on Fanuc 21i 18i
16i with G76 Threading Cycle
CNC program for the internal threading with G76 threading cycle on fanuc
controls 21i/18i/16i.
For an example of external threading with G76 threading cycle read External
Thread Cutting with G76 Threading Cycle on Fanuc 21i 18i 16i CNC
Fanuc 21i/18i/16i use two block format of G76 threading cycle.
Related: G76 Threading Cycle One Line Format for Fanuc 10/11/15T
Fanuc G76 threading cycle has multiple parameters making it difficult to
remember, but at the same time those multiple parameters of G76 thread cycle
give the cnc programmer/cnc machinist multiple options to control thread cutting,
some are listed below.
G76 thread cutting cycle allow cnc machinist to control number of idle cuts,
thread run-out, infeed angle.
Internal Threading on Fanuc 21i 18i 16i with G76 Threading Cycle
N17 T101
N18 G54
N19 G97 S800 M3
N20 G0 X25 Z6 M8
N21 G76 P010060 Q100 R0.02
N22 G76 X30 Z-40 P919 Q250 F1.5
N23 G0 X150 Z100
www.EngineeringBooksPDF.com
******************
Related: G76 Threading Cycle One Line Format for Fanuc 10/11/15T
External Thread Cutting with G76 Threading Cycle on Fanuc 21i 18i 16i CNC
N17 T101
N18 G54
N19 G97 S800 M3
www.EngineeringBooksPDF.com
N20 G0 X32 Z6 M8
N21 G76 P010060 Q100 R0.02
N22 G76 X28.161 Z-50 P919 Q250 F1.5
N23 G0 X150 Z100
*******************
www.EngineeringBooksPDF.com
N12 Z-76
N13 G00 X100 Z50
N14 ……
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
CNC Milling Machine
CNC Mill Example Program G01 G02
G03 G90 G91
A cnc mill program for cnc machinists programmers, who have started to learning
basic cnc programming techniques.
CNC Program
N40 G90 G00 X0 Y0
N50 G01 X-10 Y-20 R8 (P1)
N60 G01 X-50 R10 (P2)
N70 Y10 (P3)
N80 X-19.97 Y25.01 (P4)
N90 G03 X7.97 Y38.99 R18 (P5)
N100 G01 X30 Y50 (P6)
N110 G91 X10.1 Y-10.1(P7)
N120 G90 G02 X59.9 Y20.1 R14 (P8)
N130 G01 X70 Y10 (P9)
N140 Y-20 R10(P10)
N150 X50 (P11)
N160 G03 X30 R10 (P12)
N170 G01 X10 R8 (P13)
N180 X0 Y0
G M S T Codes Explanation
Code Description
www.EngineeringBooksPDF.com
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G90 Absolute command
G91 Increment command
----------------
CNC Program
G0 X-60 Y0
G1 X-70 (P1)
G2 X-25.02 Y25.97 R30(P2)
G1 X2.46 Y10.13 (P3)
G3 X8.5 Y10.92 R5(P4)
G1 X18.79 Y21.21 (P5)
G2 X25.13 Y-26.05 I21.21 J-21.21 (P6)
G1 X-5 Y-8.66(P7)
www.EngineeringBooksPDF.com
G3 X-12.14 Y-11.13 R5(P8)
G2 X-70 Y0 R30 (P1)
G1 X-60
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
----------------
www.EngineeringBooksPDF.com
CNC Part Program
G0 X30 Y-30 (P1)
G1 Y22.67 (P2)
G3 X24.07 Y26.18 R4 (P3)
G2 X-18.27 Y23.46 R50 (P4)
G3 X-23.46 Y18.27 R4(P5)
G2 X-23.46 Y-18.27 R50 (P6)
G3 X-18.27 Y-23.46 R4 (P7)
G2 X24.07 Y-26.18 R50 (P8)
G3 X30 Y-24.67 R4 (P9)
G1 X33
G M S T Codes Explanation
Code Description
G0 Rapid traverse
G1 Linear interpolation
G2 Circular interpolation CW
G3 Circular interpolation CCW
M30 End of program (Reset)
-------------
www.EngineeringBooksPDF.com
N10 M6 T1 G43 H1 M3
N15 S500 F120
N20 G0 X0 Y0 (P1)
N25 G1 Y20(P2)
N30 G3 X-15 Y35 I-15 J0 (P3)
N35 G2 X-45 Y35 I-15 J0 (P4)
N40 G3 X-60 Y20 I0 J-15 (P5)
N45 G1 Y0 (P6)
N50 G1 X0 (P1)
N55 M30
G M S T Codes Explanation
Code Description
G0 Rapid traverse
G1 Linear interpolation
G2 Circular interpolation CW
G3 Circular interpolation CCW
G43 Tool length compensation + direction
M3 Spindle start forward CW
M6 Tool change
M30 End of program (Reset)
T Tool
S Speed
F Feed
----------------
www.EngineeringBooksPDF.com
Haas Corner Rounding and Chamfering Example
www.EngineeringBooksPDF.com
--------------
www.EngineeringBooksPDF.com
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G49 Tool length compensation cancel
G90 Absolute command
G91 Increment command
M03 Spindle start forward CW
M06 Tool change
M30 End of program (Reset)
M98 Subprogram call
M99 End of subprogram
T Tool
S Speed
F Feed
-------------------
www.EngineeringBooksPDF.com
CNC Part Program
N05 G54
N10 M6 T1 G43 H1 M3
N15 S500 F120
N20 G0 X-22 Y-22
N25 Z-3
N30 G1 X3 Y6 G41 H2 (P1)
N35 G91 X0 Y24(P2)
N40 X12 Y9(P3)
N45 X36 (P4)
N50 Y-24 (P5)
N55 X-21 (P6)
N60 G90 X3 Y6 (P1)
N65 G0 X-21 G40
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G54 Workpiece coordinate system 1 selection
G90 Absolute command
G91 Incremental command
M06 Tool change
T Tool
S Speed
F Feed
---------------
www.EngineeringBooksPDF.com
This program example uses Peck milling to cut material to machine a rectangular
and one round pocket.
Main Program
Milling cutter diameter: 10mm
N05 G55
N10 M6 T2 H3 G43 M3
N15 S1000 F60
N20 G0 X9 Y9 Z1
N25 G1 Z0
N30 M98 P030035
N35 G0 Z1 G90
N40 X42 Y38
N45 G1 Z-2 F30
N50 X47 F300
N55 G3 X47 Y38 I-5 J0
N60 G0 Z100
N65 G49
N70 M30
Subprogram
O0035
N05 G1 Z-2 G91 F30
N10 X10 F100
N15 Y36
N20 X-10
N25 Y-36
N30 M99
Explanation
Although this cnc mill program is self explanatory
M98 P030035
this code mean call Subprogram No. 0035 three times.
----------------
www.EngineeringBooksPDF.com
CNC Milling Program Example G03
G90 G91
CNC milling program example, which illustrates how a cnc program can be easily
converted from G90 Absolute program mode to G91 Incremental program mode.
CNC Milling Program Example
--------------
Fanuc G72.1 G72.2 Figure Copy
Program Example (Bolt Hole Circle)
This CNC program example shows how both G72.1 and G72.2 figure copy
functions can call one-another in one part program, read Programming
www.EngineeringBooksPDF.com
Notes below carefully.
Programming
Fanuc G72.1 Rotational Copy
Using G72.1 Rotational Copy G-code a figure specified by a subprogram can be
repeatedly produced with Rotational movement.
Read G72.1 definition with program example Fanuc G72.1 Rotational Copy
(Figure Copy Function CNC Mill)
Fanuc G72.2 Linear Copy
Using G72.2 Linear Copy G-code a figure specified by a subprogram can be
repeatedly produced with Linear movement.
Read G72.2 definition with program example Fanuc G72.2 Linear Copy (Figure
Copy Function CNC Mill)
Fanuc G81 Drilling Cycle
G81 drilling cycle is used for simple drilling/spot drilling operations.
Read G81 drilling cycle definition with program examples Fanuc G81 Drilling
Cycle
Programming Notes
Specifying two or more commands to copy a figure
• G72.1 cannot be specified more than once in a subprogram for making a
rotational copy (If this is attempted, alarm PS0900 will occur).
• G72.2 cannot be specified more than once in a subprogram for making a
linear copy (If this is attempted, alarm PS0901 will occur).
• In a subprogram that specifies rotational copy, however, linear copy can be
specified. Similarly, in a subprogram that specifies linear copy, rotational
copy can be specified.
Fanuc G71.2 G72.2 Program Example
www.EngineeringBooksPDF.com
Main program
O4000 ;
N10 G90 G00 G17 X240. Y230. Z100. ; (P0)
N20 G72.1 P4100 X120. Y120. L8 R45. ;
N30 G80 G00 X240. Y230. ; (P0)
N40 M30 ;
Sub program_ Rotation copy_ (G72.1)
O4100 N100 G72.2 P4200 I0 J20. L3 ;
N200 M99 ;
Sub program_ Linear copy (G72.2_)
O4200 N110 G90 G81 X120. Y180. R60. Z10. F200. ; (P1)
N210 M99 ;
------------------
Programming
G72.2 P... L... I... J...
Parameters
Parameter Description
P Subprogram number
L Number of times the operation is repeated
I Shift along X-axis
J Shift along Y-axis
G-Code Data
Modal/Non-Modal G-Code Group
Non-Modal 00
Programming Notes
Notes
• In the G72.2 block, addresses other than P, L, I and J are ignored.
• P, I and J must always be specified.
• If L is not specified, the figure is copied once.
www.EngineeringBooksPDF.com
• For shifts (I, J), specify increments. The n-th geometric shift is equal to the
specified shift times (n – 1).
First block of the subprogram
Always specify a move command in the first block of a subprogram that performs
a linear copy. If the first block contains only the program number such as
O00001234; and does not have a move command, movement may stop at the start
point of the figure made by the n-th (n = 1,2, 3, …) copying.
_Example of an incorrect program_
O00001234 ;
G00 G90 X100.0 Y200.0 ;
____;
____;
M99 ;
_Example of a correct program_
O00001000 G00 G90 X100.0 Y200.0 ;
____;
____;
M99 ;
Limitation
_Specifying two or more commands to copy a figure
G72.2 cannot be specified more than once in a subprogram for making a
linear copy (If this is attempted, alarm PS0901will occur).
In a subprogram that specifies linear copy, however, rotational copy (G72.1) can
be specified. Similarly, in a subprogram that specifies rotational copy, linear copy
can be specified.
Commands that must not be specified
Within a program that performs a linear copy, the following must not be specified:
_Command for changing the selected plane (G17 to G19)
_Command for specifying polar coordinates (G16)
_Reference position return command(G28)
_Axis switching
_Coordinate system rotation (G68)
_scaling (G51)
_programmable mirror image (G51.1)
Single block
Single-block stops are not performed in a block with G721.1 or G72.2.
www.EngineeringBooksPDF.com
Main program
O3000 ;
N10 G90 G00 X-30. Y0 ;
N20 X0 ;
N30 G01 G17 G41 X30. D01 F100 ; (P0)
N40 Y20. ; (P1)
N50 X40. ; (P2)
N60 G72.2 P3100 L3 I90.0 J0 ;
N70 G90 X310. Y0 ; (P8)
N80 X0 ;
N90 G40 G00 X-30.0 ;
N100 M30 ;
Sub program
O3100 G91 G01 X20. ; (P3)
N100 Y30. ; (P4)
N200 G02 X40. I20. ; (P5)
N300 G01 Y-30. ; (P6)
N400 X30. ; (P7)
N500 M99 ;
---------------------
G2 Circular Interpolation CW
G2 X... Y... I... J...
Parameter Description
X Coordinates of the arc end point in x-axis.
Y Coordinates of the arc end point in y-axis.
I Distance from arc start-point to arc-center-point in X-
www.EngineeringBooksPDF.com
axis.
Distance from arc start-point to arc-center-point in Y-
J
axis__________________.
Program Example
Milling Arc using G2 I & J
G0 X0 Y0 (P1)
G1 X0 Y-1.493 F...(P2)
X1.939(P3)
G2 X1.5 Y-2.5 I1.061 J-1.061 (P4)
G1 X0 (P5)
--------------------
Syntax
G81 X... Y... Z... R... K... F...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Depth, tool will travel with feed to Z-depth
Z
starting from R plane.
R Position of the R plane.
Number of cycle repetitions (if
K
required)__________________.
F Feedrate.
Once G81 drilling cycle is defined, the canned cycle is repeated at every X-Y
position in sequential blocks. So G81 drilling cycle must be cancelled with G80.
Usage
www.EngineeringBooksPDF.com
N30 G81 X10 Y30 Z-17 R2 F75
N40 Y10
N50 X30
N60 Y30
N70 X90
N80 Y10
N90 G80
In the above example drilling will start with G81 drilling cycle at X10 Y30, so
first drill will be at X10 Y30, then second at Y10, third at X30, fourth at Y30,
fifth at X90 and the last one at Y10, because next block have G80 code, so
drilling cycle will no more be repeated.
Working
Here is briefly described how G81 drilling cycle operates,
1- Rapid traverse to the specified x,y axis position (drilling position).
2- Rapid traverse to the R plane position.
3- Drilling with specified Feed from R-plane position to Z-depth position.
4- Rapid traverse to Initial level or R-plane depends on G98, G99 modes.
www.EngineeringBooksPDF.com
Repeat drilling is normally used with G91 Incremental mode, and a good example
of repeated drilling is Grid-plate drilling. the example for repeat drilling is given
below.
Working Examples
www.EngineeringBooksPDF.com
Repeat drilling with G81 Drilling Cycle
T1 M6
G00 G90 G40 G21 G17 G94
G54 X0 Y0 S1000 M03
G43 H1 Z100
Z3
G81 G99 G91 X20 Y20 R3 Z-20 K3 F100 M08
G80
G00 G90 Z100
M30
OR
T1 M6
G00 G90 G40 G21 G17 G94
G54 X20 Y20 S1000 M03
G43 H1 Z100
Z3
G81 G99 R3 Z-20 F100 M08
G91 X20 Y20 K2
G80
G00 G90 Z100
M30
---------------
www.EngineeringBooksPDF.com
CNC Program Example
www.EngineeringBooksPDF.com
G80 ;
G0 G90 Z100 ;
T0 M6 ;
M30 ;
--------------
--------------
www.EngineeringBooksPDF.com
G82 Drilling Canned Cycle with Dwell
CNC Milling Example Program
G82 drilling cycle with dwell can be used for normal drilling where bottom of the
hole need more accurate machining.
Otherwise if you just want a drilling cycle without a dwell time at the bottom of
the hole G81 drilling cycle is a big time saver.
Following is a cnc programming example which illustrates the use of G82 Drill
cycle.
G82 Drilling Cycle CNC Milling Example Program
G82 Drilling Canned Cycle with Dwell CNC Milling Example Program
O10076
N10 T11 M06
N20 G90 G54 G00 X0.5 Y-0.5
N30 S1200 M03
N40 G43 H11 Z1. M08
N50 G82 G99 Z-0.375 P1 R0.1 F7.5
N60 X1.5
N70 Y-1.5
N80 X0.5
N90 G80 G00 Z1. M09
N100 G53 G49 Z0. M05
N110 M30
Note N50 – CNC machines with Fanuc cnc control will use P1000 instead of P1
which is used for Haas CNC machines
----------------
www.EngineeringBooksPDF.com
A complete cnc part-program which shows how G98 and G99 (canned cycle
return level) work with G81 drilling cycle and G83 peck drilling cycle for drilling
of a component which have different heights.
Explanation
www.EngineeringBooksPDF.com
N10- Tool change (M06) to tool no.1
N20- Rapid traverse to X10 Y30 Z12, Spindle started clockwise (M03) with
1000rpm (S1000).
N30- Drilling starts (G81) at X10 Y30 with cutting-feed (F75) drill will retract to
R-plane after drilling operation.
N40- Next drilling position Y10 (as G99 is a modal g-code drill will keep on
retracting to R-plane until G98 is given).
N50- Next drill at X30.
N60- Drill at Y30
N70- Drill at X90 & Retract to Initial-plane.
N80- Drill at Y10 & Retract to R-plane.
N90- Drill at X110
N100- Drill at Y30 & Retract to Initial-plane.
N110- Drilling cycle is cancelled (G80), return to reference point (G28) for tool
change, stop spindle (M05).
N120- Tool change (M06) to tool number 2.
N130- Rapid traverse to X60 Y28 Z12, start spindle at 750rpm (S750) clockwise
(M03).
N140- G83 Peck drilling starts at X60 Y28, drill depth is Z-17 and drill peck size
is Q6, drilling feed is F60
N150- Next deep drill at Y12 (return to initial point).
N160- G83 Peck drilling cycle cancelled with G80, tool returned to reference
point (G28), spindle stopped (M05).
N170- Part-program end with return to program start (M30)
G & M Codes
Code Description
T Tool no. used.
M06 Tool change command.
G90 Absolute programming
G00 Rapid traverse
S Cutter speed
M03 Cutter rotation Clockwise
M08 Coolant on.
G81 Fanuc drilling cycle.
G83 Fanuc peck drilling cycle.
G98 Return to initial point in canned cycle.
G99 Return to R point in canned cycle.
F Cutting feed.
G80 Canned cycle cancel.
www.EngineeringBooksPDF.com
M09 Coolant off.
G28 Return to reference position.
G91 Incremental programming.
M05 Cutter rotation stop.
M30 CNC part-program end with return to program-start.
--------------
www.EngineeringBooksPDF.com
N15 Tool travels on a straight line in space on P2
N20 Retraction in rapid traverse
N30 End of program
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Drilling
Programming
Fanuc G72.1 Rotational Copy
Using G72.1 Rotational Copy G-code a figure specified by a subprogram can be
repeatedly produced with Rotational movement.
Read G72.1 definition with program example Fanuc G72.1 Rotational Copy
(Figure Copy Function CNC Mill)
Fanuc G72.2 Linear Copy
Using G72.2 Linear Copy G-code a figure specified by a subprogram can be
repeatedly produced with Linear movement.
Read G72.2 definition with program example Fanuc G72.2 Linear Copy (Figure
Copy Function CNC Mill)
Fanuc G81 Drilling Cycle
G81 drilling cycle is used for simple drilling/spot drilling operations.
Read G81 drilling cycle definition with program examples Fanuc G81 Drilling
Cycle
Programming Notes
Specifying two or more commands to copy a figure
1 G72.1 cannot be specified more than once in a subprogram for making a
rotational copy (If this is attempted, alarm PS0900 will occur).
2 G72.2 cannot be specified more than once in a subprogram for making a linear
copy (If this is attempted, alarm PS0901 will occur).
3 In a subprogram that specifies rotational copy, however, linear copy can be
specified. Similarly, in a subprogram that specifies linear copy, rotational
copy can be specified.
www.EngineeringBooksPDF.com
Fanuc G71.2 G72.2 Program Example
Main program
O4000 ;
N10 G90 G00 G17 X240. Y230. Z100. ; (P0)
N20 G72.1 P4100 X120. Y120. L8 R45. ;
N30 G80 G00 X240. Y230. ; (P0)
N40 M30 ;
Sub program_ Rotation copy_ (G72.1)
O4100 N100 G72.2 P4200 I0 J20. L3 ;
N200 M99 ;
Sub program_ Linear copy (G72.2_)
O4200 N110 G90 G81 X120. Y180. R60. Z10. F200. ; (P1)
N210 M99 ;
--------------------
www.EngineeringBooksPDF.com
Syntax
G81 X... Y... Z... R... K... F...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Depth, tool will travel with feed to Z-depth starting from
Z
R plane.
R Position of the R plane.
Number of cycle repetitions (if
K
required)__________________.
F Feedrate.
Once G81 drilling cycle is defined, the canned cycle is repeated at every X-Y
position in sequential blocks. So G81 drilling cycle must be cancelled with G80.
Usage
N30 G81 X10 Y30 Z-17 R2 F75
N40 Y10
N50 X30
N60 Y30
N70 X90
N80 Y10
N90 G80
In the above example drilling will start with G81 drilling cycle at X10 Y30, so
first drill will be at X10 Y30, then second at Y10, third at X30, fourth at Y30,
fifth at X90 and the last one at Y10, because next block have G80 code, so
drilling cycle will no more be repeated.
Working
Here is briefly described how G81 drilling cycle operates,
1- Rapid traverse to the specified x,y axis position (drilling position).
2- Rapid traverse to the R plane position.
3- Drilling with specified Feed from R-plane position to Z-depth position.
4- Rapid traverse to Initial level or R-plane depends on G98, G99 modes.
www.EngineeringBooksPDF.com
After completing drilling depth the return is made with Rapid feed, the return
height can be controlled through using G98 or G99.
G98 Drill will return to the Initial level
G99 Drill will return to R-plane.
G98, G99 can be used multiple times during G81 drilling cycle.
Example
N30 G81 X10 Y30 Z-17 R2 F75
N40 Y10
N50 G98 X30
N60 G99 Y30
N70 X90
N80 Y10
N90 G80
Repeat Drilling
With G81 drilling cycle drilling operation can be repeated multiple times. The
drilling is repeated K times when that parameter is given with G81 drilling cycle.
Repeat drilling is normally used with G91 Incremental mode, and a good example
of repeated drilling is Grid-plate drilling. the example for repeat drilling is given
below.
Working Examples
www.EngineeringBooksPDF.com
G81 drilling cycle usage with G98 G99
N10 M06 T1
N20 G90 G00 X12.5 Y10 Z12 S1000 M03
N30 G99 G81 X12.5 Y10 Z-17 R2 F75
N40 Y30
N50 G98 X57.5
N60 G99 Y10
N70 G91 G80 G28 X0 Y0 Z0 M05
N80 M30
Repeat Drilling Example
-----------------
www.EngineeringBooksPDF.com
Fanuc G82 Drilling Cycle
G82 drilling cycle is also called G82 counter boring cycle.
G82 is a normal drilling cycle the only difference is that it dwell for specified time
at the bottom of the hole, normally used for accurate depth drilling.
Syntax
G82 X... Y... Z... R... P... F... K...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Depth, tool will travel with feed to Z-depth
Z
starting from R plane.
R Position of the R plane.
P Dwell at the bottom of hole.
Number of cycle repetitions (if
K
required)__________________.
F Feedrate.
Usage
N30 G82 X10 Y30 Z-17 R2 P1000 F75
N40 Y10
N50 X30
N60 Y30
N70 G80
Once G82 drilling cycle is specified with it’s parameters in a program block, this
will keep drilling at every axis movement, until cycle is ended with G80
Working
How G82 drilling cycle works
1- Rapid traverse to x, y position
2- Rapid traverse to R-plane position
3- Drilling with feed from R-plane to Z-depth position.
4- Dwell for specified time at hole bottom.
5- Rapid traverse to R-plane or Initial-level depends on G99, G98 mode.
www.EngineeringBooksPDF.com
G82 drilling cycle working
G98 G99 Modes
How G82 drilling cycle behaves upon G98 or G99 mode,
G98 Drill will return to the Initial level
G99 Drill will return to R-plane.
For a working example see G81 drilling cycle.
Example
N30 G82 X10 Y30 Z-17 R2 P2000 F75
N40 Y10
N50 G98 X30
N60 G99 Y30
N70 X90
N80 Y10
N90 G80
Repeat Drilling
If K parameter value is given with G82 drilling cycle, then drilling will repeat the
number of times given with K. An effective use of repeat drilling is while drilling
multiple same distance holes, this way G82 cycle is used in G91 incremental
mode. See G81 drilling cycle for repeat drilling example.
Working Example
------------------
www.EngineeringBooksPDF.com
G83 peck drilling cycle perform the drilling operation in multiple pecks, this
technique makes deep-hole drilling easy and economical.
Cutting feed is performed intermittently to the bottom of the hole while chips are
discharged.
As the drilling is performed to the bottom of the hole with feed in multiple small
steps, every time a specified depth is made and then drill retracts, then drill makes
the next peck, this operation is repeated again and again until the drill depth is
reached.
Syntax
G83 X... Y... Z... R... Q... F... K...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Depth, tool will travel with feed to Z-depth starting
Z
from R plane.
R Position of the R plane.
Q Depth of cut for each cutting feed (Peck).
Number of cycle repetitions (if
K
required)__________________.
F Feedrate.
Once given in program G83 peck drilling cycle is repeated at every axis
movement until G80 is given in program to end peck drilling cycle.
Usage
N150 M06 T02
N160 G90 G00 X60 Y28 Z12 S750 M03
N170 G99 G83 X60 Y28 Z-17 Q6 R2 F60
N180 G98 Y12
N190 G91 G80 G28 X0 Y0 Z0 M05
N200 M30
In the above example code first drill is done at X60 Y28 and second at Y12 and
then peck drilling is cycle is ended with G80.
6mm pecks are taken to complete total drilling depth of 17mm.
Working
Here is briefly described how G83 peck drilling cycle works,
1- Rapid traverse to X, Y drilling position.
2- Rapid traverse to R-plane.
3- Drilling with feed Q deep.
4- Retraction with Rapid traverse to R-plane.
www.EngineeringBooksPDF.com
5- Rapid traverse to Q-d deep (d value is specified in parameters).
6- Drilling with feed Q+d deep.
7- Retraction with Rapid traverse to R-plane
– this whole procedure is repeated until drill reaches Z-depth position,
– then drill is retracted to R-plane or Initial-level depends on G99 or G98 which
one is given in program.
www.EngineeringBooksPDF.com
G83 Peck drilling cycle Example
N10 M06 T1
N20 G90 G00 X12.5 Y10 Z12 S1000 M03
N30 G99 G83 X12.5 Y10 Z-17 R2 Q4 F75
N40 Y30
N50 G98 X57.5
N60 G99 Y10
N70 G91 G80 G28 X0 Y0 Z0 M05
N80 M30
----------------
www.EngineeringBooksPDF.com
N20 S1000 M3 F100
N25 G43 H01 Z2 M8
N30 G81 R2 Z-42
N35 X65
N40 Y85 R-13
N45 X15
N50 G80 Z50 M5
N55 M30
---------------
www.EngineeringBooksPDF.com
N120 M5
N130 M9
N140 T0303
N150 G97 S2500 M3
N160 G00 X0. Z3.
N170 G01 Z-6. F0.1 M7
N180 G00 Z2.
N190 G00 X150. Z150.
N210 T0707 M7
N220 G97 S0884 M3
N230 G00 Z3.
N240 G00 X0.
N250 G74 R1.0
N260 G74 X0.0 Z-68.326 Q18000 F0.22
N380 G00 X200.
N400 G00 Z100.
N500 T0404 M7
N510 G50 S3500
N520 G96 S0240 M4
N530 G00 Z1.
N540 G00 X70.
N550 G71 U4. R1
N560 G71 P570 Q650 U0.6 W0.2 F0.35
N570 G42 G00 X24.
N580 G01 Z0.
N590 G01 X28. Z-2.
N600 G01 Z-72.
N610 G02 X32. Z-74. I2. K0.
N620 G01 X62.
N630 G01 X68. Z-77.
N640 G01 Z-90.
N650 G40
N660 G00 X150.
N680 G00 Z70.
N690 T0202 M7
N700 G50 S4500
N710 G96 S0380 M4
N720 G00 X16. Z3.
N730 G42 G01 Z0. F0.1
N740 G01 X24.
N750 G01 X28. Z-2.
N760 G01 Z-72.
N770 G02 X32. Z-74. I2. K0.
N780 G01 X62.
N790 G01 X68. Z-77.
N800 G01 Z-90.
N810 G40
N820 G00 X150. Z150.
N830 M5
N840 M9
N850 M30
Used Tools & Operations
• T0101 Turning Tool – Rough Facing
www.EngineeringBooksPDF.com
• T0303 Center Drill – Center Drilling
• T0707 Twist Drill – Drilling
• T0404 Turning Tool – Rough Turning
• T0202 Turning Tool – Finish Contour Cutting
---------------
T1 M6
G0 G90 G40 G21 G17 G94 G80
G54 X20 Y0 S1500 M3
G43 Z100 H1
Z5
G81 R3 Z-20 F? M8
X30
X45
G68 X0 Y0 R120
X20 Y0
X30
X45
G68 X0 Y0 R240
X20 Y0
X30
X45
G69 G80
G0 G90 Z100 M30
www.EngineeringBooksPDF.com
-------------------------
www.EngineeringBooksPDF.com
Fanuc Subprogram Example
O1000 ;
N1 T1 M6 ;
N2 G0 G90 G40 G21 G17 G94 G80 ;
N3 G54 X10 Y10 S? M3 ;
N4 G43 Z100 H1 ;
N5 Z5 ;
N6 G81 R3 Z-20 F? M8 ;
N7 M98 P1001 ;
N8 G0 G90 Z100
N9 T2 M6 ;
N10 G0 G90 G40 G21 G17 G94 G80 ;
N11 G54 X10 Y10 S? M3 ;
N12 G43 Z100 H1 ;
N13 Z5 ;
N14 G84 G99 G95 R3 Z-20 F1.25 M8 ;
N15 M98 P1001 ;
N16 G0 G90 Z100 ;
N17 T0 M6 ;
N18 M30 ;
Sub Program
O1001 ;
N101 Y30 ;
N102 Y50 ;
N103 Y70 ;
N104 X30 ;
N105 X50 ;
N106 X70 ;
N107 X90 ;
N108 Y50 ;
N109 Y30 ;
N110 Y10 ;
N111 X70 ;
N112 X50 ;
N113 X30 ;
N114 G80 ;
N115 M99
-----------------
www.EngineeringBooksPDF.com
G81 Drilling Cycle G84 Tapping Cycle
CNC Program Example
CNC program which shows the use of G81 Drilling Cycle G84 Tapping Cycle.
As G81 drilling cycle has already been briefly explained here G81 Drilling
Canned Cycle – CNC Mill Programming.
G81 drilling cycle program examples http://www.helmancnc.com/fanuc/fanuc-
g81-drilling-cycle/.
G84 tapping cycle can be read here G84 Tapping Cycle – CNC Mill
Programming with multiple G84 tapping cycle examples
programs http://www.helmancnc.com/fanuc/fanuc-g84-tapping-cycle/.
CNC Program Example
www.EngineeringBooksPDF.com
T2 M6 ;
G0 G90 G40 G21 G17 G94 G80 ;
G54 X10 Y10 S? M3 ;
G43 Z100 H1 ;
Z5 ;
G84 G99 G95 R3 Z-20 F1.25 M8 ;
Y30 ;
Y50 ;
Y70 ;
X30 ;
X50 ;
X70 ;
X90 ;
Y50 ;
Y30 ;
Y10 ;
X70 ;
X50 ;
X30 ;
G80 ;
G0 G90 Z100 ;
T0 M6 ;
M30 ;
----------------
www.EngineeringBooksPDF.com
G82 Drilling Canned Cycle with Dwell CNC Milling Example Program
O10076
N10 T11 M06
N20 G90 G54 G00 X0.5 Y-0.5
N30 S1200 M03
N40 G43 H11 Z1. M08
N50 G82 G99 Z-0.375 P1 R0.1 F7.5
N60 X1.5
N70 Y-1.5
N80 X0.5
N90 G80 G00 Z1. M09
N100 G53 G49 Z0. M05
N110 M30
Note N50 – CNC machines with Fanuc cnc control will use P1000 instead of P1
which is used for Haas CNC machines.
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
G02 G03 I J K
CNC Mill Programming Example
CNC mill program example for cnc machinists.
Contents
1 CNC Mill Programming Example
CNC Program
G M S T Codes Explanation
CNC Mill Programming Example
CNC Program
G0 X-60 Y0
G1 X-70 (P1)
G2 X-25.02 Y25.97 R30(P2)
G1 X2.46 Y10.13 (P3)
G3 X8.5 Y10.92 R5(P4)
G1 X18.79 Y21.21 (P5)
G2 X25.13 Y-26.05 I21.21 J-21.21 (P6)
G1 X-5 Y-8.66(P7)
G3 X-12.14 Y-11.13 R5(P8)
G2 X-70 Y0 R30 (P1)
G1 X-60
G M S T Codes Explanation
Code Description
www.EngineeringBooksPDF.com
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
-----------------
Contents
4 G02 G03 Example CNC Mill
CNC Part Program
G M S T Codes Explanation
G02 G03 Example CNC Mill
www.EngineeringBooksPDF.com
G2 X-23.46 Y-18.27 R50 (P6)
G3 X-18.27 Y-23.46 R4 (P7)
G2 X24.07 Y-26.18 R50 (P8)
G3 X30 Y-24.67 R4 (P9)
G1 X33
G M S T Codes Explanation
Code Description
G0 Rapid traverse
G1 Linear interpolation
G2 Circular interpolation CW
G3 Circular interpolation CCW
M30 End of program (Reset)
---------------
www.EngineeringBooksPDF.com
N55 M30
G M S T Codes Explanation
Code Description
G0 Rapid traverse
G1 Linear interpolation
G2 Circular interpolation CW
G3 Circular interpolation CCW
G43 Tool length compensation + direction
M3 Spindle start forward CW
M6 Tool change
M30 End of program (Reset)
T Tool
S Speed
F Feed
------------
www.EngineeringBooksPDF.com
CNC Part Program
N10 T1 H1 M6 G43 M3
N20 F150 S250
N30 G0 X-21 Y50 Z0.5
N40 G0 Z0
N50 M98 P040050
N60 G49
N70 G0 Z50
N80 M30
Subprogram
O0050
N10 F160 S400
N20 G0 Z-2.5 G91
N30 G1 G90 X5 Y50 G41 (P1)
N40 G2 X22 Y85.23 I45 J0 (P2)
N50 G3 X78 Y85.23 R45 (P3)
N60 G2 X78 Y14.77 R45 (P4)
N70 G3 X22 Y14.77 R45 (P5)
N80 G2 X5 Y50 R45 (P1)
N90 G0 G40 X-21
N100 M99
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G49 Tool length compensation cancel
G90 Absolute command
G91 Increment command
www.EngineeringBooksPDF.com
M03 Spindle start forward CW
M06 Tool change
M30 End of program (Reset)
M98 Subprogram call
M99 End of subprogram
T Tool
S Speed
F Feed
---------------
www.EngineeringBooksPDF.com
--------------
www.EngineeringBooksPDF.com
Always specify a move command in the first block of a subprogram that performs
a linear copy. If the first block contains only the program number such as
O00001234; and does not have a move command, movement may stop at the start
point of the figure made by the n-th (n = 1,2, 3, …) copying.
_Example of an incorrect program_
O00001234 ;
G00 G90 X100.0 Y200.0 ;
____;
____;
M99 ;
_Example of a correct program_
O00001000 G00 G90 X100.0 Y200.0 ;
____;
____;
M99 ;
Limitation
_Specifying two or more commands to copy a figure
G72.2 cannot be specified more than once in a subprogram for making a
linear copy (If this is attempted, alarm PS0901will occur).
In a subprogram that specifies linear copy, however, rotational copy (G72.1) can
be specified. Similarly, in a subprogram that specifies rotational copy, linear copy
can be specified.
Commands that must not be specified
Within a program that performs a linear copy, the following must not be specified:
_Command for changing the selected plane (G17 to G19)
_Command for specifying polar coordinates (G16)
_Reference position return command(G28)
_Axis switching
_Coordinate system rotation (G68)
_scaling (G51)
_programmable mirror image (G51.1)
Single block
Single-block stops are not performed in a block with G721.1 or G72.2.
G72.2 Programming Example
Main program
www.EngineeringBooksPDF.com
O3000 ;
N10 G90 G00 X-30. Y0 ;
N20 X0 ;
N30 G01 G17 G41 X30. D01 F100 ; (P0)
N40 Y20. ; (P1)
N50 X40. ; (P2)
N60 G72.2 P3100 L3 I90.0 J0 ;
N70 G90 X310. Y0 ; (P8)
N80 X0 ;
N90 G40 G00 X-30.0 ;
N100 M30 ;
Sub program
O3100 G91 G01 X20. ; (P3)
N100 Y30. ; (P4)
N200 G02 X40. I20. ; (P5)
N300 G01 Y-30. ; (P6)
N400 X30. ; (P7)
N500 M99 ;
-----------
www.EngineeringBooksPDF.com
Quincunx a CNC Plasma Cutting
Controller Program Example
CNC program example to cut Quincunx on a CNC Plasma Cutting Controller.
This program example is programmed in G91 Incremental programming.
Contents
• What is a CNC Plasma Cutting Machine
◦ Plasma Cutting
◦ CNC Plasma Cutter
• Plasma Cutting Controller Program Example
What is a CNC Plasma Cutting Machine
Plasma Cutting
Plasma cutting is a process that is used to cut steel and other metals of different
thicknesses (or sometimes other materials) using a plasma torch. In this process,
an inert gas (in some units, compressed air) is blown at high speed out of a nozzle;
at the same time an electrical arc is formed through that gas from the nozzle to the
surface being cut, turning some of that gas to plasma. The plasma is sufficiently
hot to melt the metal being cut and moves sufficiently fast to blow molten metal
away from the cut.
www.EngineeringBooksPDF.com
Quincunx a CNC Plasma Cutting Controller Program Example
Relative coordinate programming
G92 X0 Y0(P1)
G00 X75 Y75 (P2)
G02 Y100 I0 J50 (P3)
G02 X100 I50 J0 (P4)
G02 Y-100 I0 J-50(P5)
G02 X-100 I-50 J0(P6)
G00 X-75 Y-75(P7)
M02
------------
www.EngineeringBooksPDF.com
Wire EDM Programming Example
G92 X0. Y0.
G01 Y1.25 (P1)
G02 X.5 I.25 J0.(P2)
G01 Y.75(P3)
G03 X1. I.25 J0.(P4)
G01 Y1.25 (P5)
G02 X1.5 I.25 J0. (P6)
G01 Y0. (P7)
X0. (P8)
M02
G92 command is used to assign program zero. You will include the distances and
directions from the program zero point to the wire start point in your G92
command.
--------------
www.EngineeringBooksPDF.com
CNC Program Example G03 Circular Interpolation
N1 G00 X0 Z0
N2 G01 X11
N3 G01 Z-15
N4 G03 X11 Z-27 I-8 K-6
Description
The I and K for the G03.
I Calculation for G03 Circular Interpolation
I is the distance from the arc start point to arc center point in x-axis. This value is
not given in diameter but as a radius value, so
• Find the start diameter it is 11
• Now make it radius value by dividing it by 2 such as 11 / 2 = 5.5
• This is a easy example in way that the arc center point distance from the
workpiece center point is given other wise we have to calculate it.
• So now just add 2.5 in 5.5 earlier calculated 2.5 + 5.5 = 8
• This is the value of I 8 this is the distance from the arc start point to the ace
center point.
K Calculation for G03 Circular Interpolation
K is the distance from the arc start point to arc center point in z-axis.
• In this example it is just easy as you just have to subtract 21 from 15 such
as 21 – 15 = 6.
• So the value from the arc start point to the arc center point in z-axis is 6
-----------
www.EngineeringBooksPDF.com
CNC Arc Programming Exercise
N10 GOO X0 Z0
N20 G01 X12 F0.3
N30 G01 X40 Z-25
N40 G03 X70 Z-75 I-3.335 K-29.25
N50 G01 Z-95
N60 G00 X200 Z200
--------------
www.EngineeringBooksPDF.com
N3 G96 S150 G20
N4 G00 X0 Z1
N5 G01 Z0 G95 F0.3
N6 G01 X2 R0.25
N7 G01 Z-1
N8 G02 X5 Z-2.5 I1.5 K0
N9 G01 X6
N10 G00 X10 Z10
N11 M30
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
G02 G03 R
CNC Mill Example Program G01 G02
G03 G90 G91
A cnc mill program for cnc machinists programmers, who have started to learning
basic cnc programming techniques.
Contents
2 CNC Mill Example Program
CNC Program
G M S T Codes Explanation
CNC Mill Example Program
CNC Program
N40 G90 G00 X0 Y0
N50 G01 X-10 Y-20 R8 (P1)
N60 G01 X-50 R10 (P2)
N70 Y10 (P3)
N80 X-19.97 Y25.01 (P4)
N90 G03 X7.97 Y38.99 R18 (P5)
N100 G01 X30 Y50 (P6)
N110 G91 X10.1 Y-10.1(P7)
N120 G90 G02 X59.9 Y20.1 R14 (P8)
N130 G01 X70 Y10 (P9)
N140 Y-20 R10(P10)
N150 X50 (P11)
N160 G03 X30 R10 (P12)
N170 G01 X10 R8 (P13)
N180 X0 Y0
G M S T Codes Explanation
www.EngineeringBooksPDF.com
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G90 Absolute command
G91 Increment command
-----------------
www.EngineeringBooksPDF.com
N70 G0 Z50
N80 M30
Subprogram
O0050
N10 F160 S400
N20 G0 Z-2.5 G91
N30 G1 G90 X5 Y50 G41 (P1)
N40 G2 X22 Y85.23 I45 J0 (P2)
N50 G3 X78 Y85.23 R45 (P3)
N60 G2 X78 Y14.77 R45 (P4)
N70 G3 X22 Y14.77 R45 (P5)
N80 G2 X5 Y50 R45 (P1)
N90 G0 G40 X-21
N100 M99
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G49 Tool length compensation cancel
G90 Absolute command
G91 Increment command
M03 Spindle start forward CW
M06 Tool change
M30 End of program (Reset)
M98 Subprogram call
M99 End of subprogram
T Tool
S Speed
F Feed
-----------
www.EngineeringBooksPDF.com
CNC Turning Center Programming
Example
Easy to understand CNC turning center/cnc lathe programming example for cnc
machinists who work on cnc turning centers/cnc lathe machines.
This cnc programming example can be used as a cnc learning programming
exercise for beginners level cnc programmers/machinists.
CNC Turning Center Programming Example
-----------------
www.EngineeringBooksPDF.com
CNC program example to show how two combined arc can be programmed with
G02 G03 for a cnc lathe.
First arc is programmed using G02 R, but the second arc is programmed using
G03 I K
-----------
www.EngineeringBooksPDF.com
CNC Lathe Example Turning Boring
O0000
N10 (ø30 DRILL)
G50 T0200
G97 S250 M03
G00 X0 Z5.0 T0202 M08
G01 Z-5.0 F0.07
W1.0
Z-40.0 F0.25
G00 Z5.0
Z-39.0
G01 Z-60.0
G00 Z10.0
X200.0 Z200.0 T0200
M01
N20 (Outside diameter stock removal)
G50 S1500 T0100
G96 S180 M03
G00 X94.0 Z5.0 T0101 M08
G01 Z-14.8 F0.27
G00 U2.0 Z0.5
G01 X28.0 F0.23
G00 X87.0 W1.0
G01 Z-14.8 F0.27
G00 U2.0 Z1.0
X80.5
G01 Z-14.1
G02 X81.9 Z-14.8 R0.7
G00 X100.5 W1.0
G01 Z-29.8
G00 U2.0 Z-1.0
G01 X60.5 F0.23
G00 X82.0 W1.0
Z-2.4
G01 X60.5
X72.9
G03 X80.5 Z-6.2 R3.8
G00 U2.0 Z5.0
X200.0 Z200.0 T0100
M01
www.EngineeringBooksPDF.com
N30 (Inside diameter stock removal)
G50 S1500 T0400
G96 S180 M03
G00 X34.5 Z3.0 T0404 M08
G01 Z-41.8 F0.27
G00 U-0.5 Z1.0
X39.5
G01 Z-15.0
X34.5 Z-24.3
G00 Z10.0
X200.0 Z200.0 T0400
M01
N40 (Out diameter finishing)
G50 S1800 T0500
G96 S200 M03
G00 X63.0 Z5.0 T0505 M08
Z0
G01 X38.0 F0.2
G00 X60.0 Z3.0
G42 Z1.0
G01 Z-2.5 F0.2
X74.0
G03 X80.0 Z-5.5 R3.0
G01 Z-13.5
G02 X83.0 Z-15.0 R1.5
G01 X100.0
Z-30.0
X102.0
G40 G00 U2.0 W1.0
G00 Z10.0
X200.0 Z200.0 T0500
M01
N50 (Inside diameter finishing)
G50 S1800 T0600
G96 S200 M03
G00 X40.0 Z5.0 T0606 M08
G41 Z1.0
G01 Z-15.0 F0.2
X35.0 Z-24.33
Z-42.0
X29.0
G40 G00 Z10.0
X200.0 Z200.0 T0600 M09
M30
--------------
www.EngineeringBooksPDF.com
Vertical machining centers are a vital part of a cnc machine workshop, So here is
a Vertical machining center programming example for cnc machinists who have
just started learning cnc programming.
Vertical Machining Center Programming Example
---------------
www.EngineeringBooksPDF.com
CNC Arc Programming G02 G03 Example
O0001
N001 G0 X40 Z5; (Rapid position)
N002 M03 S200; (Start spindle)
N003 G01 X0 Z0 F900ï¼› (Approach workpiece)
N005 G03 U24 W-24 R15; (Cut R15 arc)
N006 G02 X26 Z-31 R5;(Cut R5 arc)
N007 G01 Z-40; (Cutф26)
N008 X40 Z5ï¼› (Return to starting point)
N009 M30;(End of program)
-----------------
www.EngineeringBooksPDF.com
Fanuc G73 Pattern Repeating Cycle Program Example
N010 G00 X260.0 Z80.0
N011 G00 X220.0 Z40.0
N012 G73 U14.0 W14.0 R3
N013 G73 P014 Q020 U4.0 W2.0 F0.3 S0180
N014 G00 G42 X80.0 Z2.0
N015 G01 W-20.0 F0.15 S0600
N016 X120.0 W-10.0
N017 W-20.0 S0400
N018 G02 X160.0 W-20.0 R20.0
N019 G01 X180.0 W-10.0 S0280
N020 G40
N021 G70 P014 Q020
N022 G00 X260.0 Z80.0
N023 M30
------------
www.EngineeringBooksPDF.com
Contents
• Fanuc G73 Pattern Repeating Cycle Format
• Fanuc G73 Pattern Repeating Cycle Program Example
Fanuc G73 Pattern Repeating Cycle Format
G73 U W R
G73 P Q U W F
Fanuc G73 Pattern Repeating Canned Cycle Basic CNC Sample Program
N10 G50 S2000 T0300
G96 S200 M03
G00 X35.0 Z5.0 T0303
www.EngineeringBooksPDF.com
Z0
G01 X-1.6 F0.2
G00 X70.0 Z10.0
G73 U3.0 W2.0 R2
G73 P12 Q16 U0.5 W0.1 F0.25
N12 G00 G42 X20.0 Z2.0
G01 Z-10.0 F0.15
G02 X40.0 Z-20.0 R10.0
G01 Z-30.0
X60.0 Z-50.0
N16 G40 U1.0
G70 P12 Q16
G00 X200.0 Z200.0 T0300
M30
------------
www.EngineeringBooksPDF.com
N75 M30
N5 absolute positioning, metric unit
N10 tool change to T1
N15 define work zero point at A
N20 rapid traverse to A, spindle on (2500 RPM, CW)
N25 rapid plunge to 12.5 mm above Z0
N30 feed to Z-12.5, feed rate 150 MMPM
N35 cut line AB to B
N40 cut arc BC to C
N45 cut line CD to D
N50 cut arc DE to E
N55 cut line EA to A
N60 rapid retract to Z12.5
N65 reference point return in Z direction, spindle off
N70 reference point return in X and Y directions
N75 end of program
----------------
www.EngineeringBooksPDF.com
CNC Mill Programming Absolute Incremental G90 G91 Example Code
Mill Circular Interpolation G02 G03 with R
G92 X200 Y40 Z0
G90 G03 X140 Y100 R60 F300
G02 X120 Y60 R50
Mill Circular Interpolation G02 G03 with I
G92 X200 Y40 Z0
G90 G03 X140 Y100 I-60 F300
G02 X120 Y60 I-50
--------------
www.EngineeringBooksPDF.com
The below is a cnc circular interpolation tutorial which uses G02 and G03 cnc g-
code.
CNC Programming Example
-------------
www.EngineeringBooksPDF.com
Here is a cnc programming example for beginners, this cnc programming example
is a starting step for cnc learningor CNC Programming for Beginners . Here
you will find plenty of free cnc programming examples with component drawings.
This cnc programming example explains the cnc boring with cnc boring bar tool.
----------------
www.EngineeringBooksPDF.com
so we will just skip this groove and will just machine in straight line, after that
there is a taper and again a straight line to be machined.
Now with our grooving tool the groove machining task is just easy.
if the grooving insert is of the same size as the dimension of the groove then
grooving is even more easy, we will make the groove in one go, but if
the grooving insert is of smaller width than we have to take depth more than one
time.
CNC Program
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
G40 G41 G42
CNC Mill Subprogram Example
Joining Multiple Arcs G02 G03 G41
CNC milling program to describe how two or more radii can be joint together in a
cnc mill program.
Contents
3 CNC Mill Subprogram Example
CNC Part Program
Subprogram
G M S T Codes Explanation
CNC Mill Subprogram Example
www.EngineeringBooksPDF.com
N60 G2 X78 Y14.77 R45 (P4)
N70 G3 X22 Y14.77 R45 (P5)
N80 G2 X5 Y50 R45 (P1)
N90 G0 G40 X-21
N100 M99
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G49 Tool length compensation cancel
G90 Absolute command
G91 Increment command
M03 Spindle start forward CW
M06 Tool change
M30 End of program (Reset)
M98 Subprogram call
M99 End of subprogram
T Tool
S Speed
F Feed
--------------
www.EngineeringBooksPDF.com
CNC Part Program
N05 G54
N10 M6 T1 G43 H1 M3
N15 S500 F120
N20 G0 X-22 Y-22
N25 Z-3
N30 G1 X3 Y6 G41 H2 (P1)
N35 G91 X0 Y24(P2)
N40 X12 Y9(P3)
N45 X36 (P4)
N50 Y-24 (P5)
N55 X-21 (P6)
N60 G90 X3 Y6 (P1)
N65 G0 X-21 G40
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G54 Workpiece coordinate system 1 selection
G90 Absolute command
G91 Incremental command
M06 Tool change
T Tool
S Speed
F Feed
--------------
www.EngineeringBooksPDF.com
G41 G40 Cutter Radius
Compensation Example CNC Mill
Program
Cutter Radius Compensation Example program shows how G41, G40 can be used
in a cnc mill program.
Cutter Compensation code used in this program are,
• G41 Cutter Radius Compensation Left
• G40 Cutter Radius Compensation Cancel
Cutter Radius Compensation Example
www.EngineeringBooksPDF.com
Cutter Radius Compensation Example Finished Part
Explanation of CNC G-Code
G00 : Rapid traverse.
G54 : Zero Offset no. 1.
G64 : Continuous-path mode.
G90 : Absolute dimensioning system.
G17 : X-Y plan selection.
G41 : Cutter radius compensation activation (left hand side movement)
G40 : Cutter radius compensation de-active
S : Spindle speed
F : Axis motion feed
M : Cutter rotation (3=clockwise, 4=anti-clockwise)
D : Tool offset no
-------------
www.EngineeringBooksPDF.com
Sinumerik Mill Programming Example
N5 G00 G54 G64 G90 G17 X-20 Y-20 Z50
N10 S450 M03 F250 D01 (12.5 MM DIA)
N15 C0
N20 Z5
N25 G01 Z0
N30 Z-5
N35 G42 X0 Y0
N40 X30
N45 Y30
N50 X0
N55 Y0
N60 G40 X-20 Y-20
N65 G00 Z50
N70 Y100
N75 M30
Finished Part
After the machining is complete, this finished part will look like this
Finished Part
Explanation of G-Code
G00 – Rapid traverse.
G54 – Zero Offset no 1.
G64 – Continuous-path mode.
G90 – Absolute dimensioning system.
G17 – X-Y plan selection.
G42 – Cutter radius compensation activation
G40 – Cutter radius compensation cancel
M03 – Cutter rotation clockwise
S – Spindle speed
www.EngineeringBooksPDF.com
F – Axis motion feed
D – Tool no
------------
www.EngineeringBooksPDF.com
N170 G01 Z-6. F0.1 M7
N180 G00 Z2.
N190 G00 X150. Z150.
N210 T0707 M7
N220 G97 S0884 M3
N230 G00 Z3.
N240 G00 X0.
N250 G74 R1.0
N260 G74 X0.0 Z-68.326 Q18000 F0.22
N380 G00 X200.
N400 G00 Z100.
N500 T0404 M7
N510 G50 S3500
N520 G96 S0240 M4
N530 G00 Z1.
N540 G00 X70.
N550 G71 U4. R1
N560 G71 P570 Q650 U0.6 W0.2 F0.35
N570 G42 G00 X24.
N580 G01 Z0.
N590 G01 X28. Z-2.
N600 G01 Z-72.
N610 G02 X32. Z-74. I2. K0.
N620 G01 X62.
N630 G01 X68. Z-77.
N640 G01 Z-90.
N650 G40
N660 G00 X150.
N680 G00 Z70.
N690 T0202 M7
N700 G50 S4500
N710 G96 S0380 M4
N720 G00 X16. Z3.
N730 G42 G01 Z0. F0.1
N740 G01 X24.
N750 G01 X28. Z-2.
N760 G01 Z-72.
N770 G02 X32. Z-74. I2. K0.
N780 G01 X62.
N790 G01 X68. Z-77.
N800 G01 Z-90.
N810 G40
N820 G00 X150. Z150.
N830 M5
N840 M9
N850 M30
Used Tools & Operations
• T0101 Turning Tool – Rough Facing
• T0303 Center Drill – Center Drilling
• T0707 Twist Drill – Drilling
• T0404 Turning Tool – Rough Turning
• T0202 Turning Tool – Finish Contour Cutting
www.EngineeringBooksPDF.com
------------------
www.EngineeringBooksPDF.com
N023 M30
--------------
www.EngineeringBooksPDF.com
Q – End sequence No.
U – Finishing allowance in x-axis.
W – Finishing allowance in z-axis.
F – Cutting Feedrate (during G73 canned cycle).
Fanuc G73 Pattern Repeating Cycle Program
Example
Fanuc G73 Pattern Repeating Canned Cycle Basic CNC Sample Program
N10 G50 S2000 T0300
G96 S200 M03
G00 X35.0 Z5.0 T0303
Z0
G01 X-1.6 F0.2
G00 X70.0 Z10.0
G73 U3.0 W2.0 R2
G73 P12 Q16 U0.5 W0.1 F0.25
N12 G00 G42 X20.0 Z2.0
G01 Z-10.0 F0.15
G02 X40.0 Z-20.0 R10.0
G01 Z-30.0
X60.0 Z-50.0
N16 G40 U1.0
G70 P12 Q16
G00 X200.0 Z200.0 T0300
M30
-----------------
www.EngineeringBooksPDF.com
Also illustrates the use of CNC G-code G41 Cutter Radius Compensation Left.
CNC Machining Center Programming Example
---------------
www.EngineeringBooksPDF.com
navigate through different cnc programming articles.
G02 G03 G Code Example CNC Programs (G code
Arc Examples)
• CNC Circular Interpolation Tutorial G02 G03
• Fanuc CNC Lathe Programming Example
• CNC Programming Example G Code G02 Circular Interpolation Clockwise
• Fanuc G20 Measuring in Inches with CNC Program Example
• CNC Arc Programming Exercise
• CNC Programming for Beginners a CNC Programming Example
• CNC Lathe Programming Example
Here is a new cnc programming examples which shows the use of G02 G03 G
code circular interpolation.
G02 G03 G Code Example Program
www.EngineeringBooksPDF.com
G01 Z-20.0 F0.2
G02 X67.0 Z-36.0 I16.0 K0
G01 X68.0 :
G03 X100.0 Z-52.0 I0 K-16.0
G01 Z-82.0
G40 G00 X200.0 Z200.0 M09 T0300
M30
--------------------
www.EngineeringBooksPDF.com
N60 G03 X20.0 Z-10.0 R10.0
N70 G01 Z-50.0
N80 G02 X100.0 Z-74.385 I40.0 K20.615
N80 G01 Z-125.0
N90 G40 U2.0 W1.0
N100 G00 X200.0 Z200.0 M09 T0300
N110 M30
You can use R or I K with G02/G03 G-codes see N80 in both cnc program
examples
N20 G50 S2000 T0300
N30 G96 S200 M03
N40 G00 X0 Z3.0 T0303 M08
N50 G42 G01 Z0 F0.2
N60 G03 X20.0 Z-10.0 R10.0
N70 G01 Z-50.0
N80 G02 X100.0 Z-74.385 R45.0
N80 G01 Z-125.0
N90 G40 U2.0 W1.0
N100 G00 X200.0 Z200.0 M09 T0300
N110 M30
--------------
www.EngineeringBooksPDF.com
N3 G21 G96 S150
N4 G00 X0 Z5
N5 G42 G01 Z0 G95 F0.3
N6 G01 X23.293
N7 G01 X40 Z-30
N8 G01 X58.146 Z-42
N9 G01 X70
N10 G40 G00 X100 Z100 G97 S500
----------
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
G81 Drilling Cycle
Fanuc G72.1 G72.2 Figure Copy
Program Example (Bolt Hole Circle)
This CNC program example shows how both G72.1 and G72.2 figure copy
functions can call one-another in one part program, read Programming
Notes below carefully.
Programming
Fanuc G72.1 Rotational Copy
Using G72.1 Rotational Copy G-code a figure specified by a subprogram can be
repeatedly produced with Rotational movement.
Read G72.1 definition with program example Fanuc G72.1 Rotational Copy
(Figure Copy Function CNC Mill)
Fanuc G72.2 Linear Copy
Using G72.2 Linear Copy G-code a figure specified by a subprogram can be
repeatedly produced with Linear movement.
Read G72.2 definition with program example Fanuc G72.2 Linear Copy (Figure
Copy Function CNC Mill)
Fanuc G81 Drilling Cycle
G81 drilling cycle is used for simple drilling/spot drilling operations.
Read G81 drilling cycle definition with program examples Fanuc G81 Drilling
Cycle
Programming Notes
Specifying two or more commands to copy a figure
G72.1 cannot be specified more than once in a subprogram for making a
rotational copy (If this is attempted, alarm PS0900 will occur).
G72.2 cannot be specified more than once in a subprogram for making a
linear copy (If this is attempted, alarm PS0901 will occur).
In a subprogram that specifies rotational copy, however, linear copy can be
specified. Similarly, in a subprogram that specifies linear copy, rotational
copy can be specified.
Fanuc G71.2 G72.2 Program Example
Main program
O4000 ;
N10 G90 G00 G17 X240. Y230. Z100. ; (P0)
N20 G72.1 P4100 X120. Y120. L8 R45. ;
N30 G80 G00 X240. Y230. ; (P0)
N40 M30 ;
Sub program_ Rotation copy_ (G72.1)
O4100 N100 G72.2 P4200 I0 J20. L3 ;
N200 M99 ;
Sub program_ Linear copy (G72.2_)
O4200 N110 G90 G81 X120. Y180. R60. Z10. F200. ; (P1)
N210 M99 ;
-------------
www.EngineeringBooksPDF.com
Fanuc G81 Drilling Cycle
G81 drilling cycle is used for simple drilling/spot drilling operations.
Read complete article with program examples Fanuc G81 Drilling Cycle
Fanuc G72.1 Program Example
Main program
O2000 ;
N10 G90 G00 G17 X250. Y100. Z100. ; (P0)
N20 G72.1 P2100 L6 X100. Y50. R60. ;
N30 G80 G00 X250. Y100. ; (P0)
N40 M30 ;
Sub program
O2100 N100 G90 G81 X100. Y150. R60. Z10. F200. ; (P1)
N200 M99 ;
---------------
www.EngineeringBooksPDF.com
X Hole position in x-axis.
Y Hole position in y-axis.
Depth, tool will travel with feed to Z-depth starting from
Z
R plane.
R Position of the R plane.
Number of cycle repetitions (if
K
required)__________________.
F Feedrate.
Once G81 drilling cycle is defined, the canned cycle is repeated at every X-Y
position in sequential blocks. So G81 drilling cycle must be cancelled with G80.
Usage
N30 G81 X10 Y30 Z-17 R2 F75
N40 Y10
N50 X30
N60 Y30
N70 X90
N80 Y10
N90 G80
In the above example drilling will start with G81 drilling cycle at X10 Y30, so
first drill will be at X10 Y30, then second at Y10, third at X30, fourth at Y30,
fifth at X90 and the last one at Y10, because next block have G80 code, so
drilling cycle will no more be repeated.
Working
Here is briefly described how G81 drilling cycle operates,
1- Rapid traverse to the specified x,y axis position (drilling position).
2- Rapid traverse to the R plane position.
3- Drilling with specified Feed from R-plane position to Z-depth position.
4- Rapid traverse to Initial level or R-plane depends on G98, G99 modes.
www.EngineeringBooksPDF.com
Example
N30 G81 X10 Y30 Z-17 R2 F75
N40 Y10
N50 G98 X30
N60 G99 Y30
N70 X90
N80 Y10
N90 G80
Repeat Drilling
With G81 drilling cycle drilling operation can be repeated multiple times. The
drilling is repeated K times when that parameter is given with G81 drilling cycle.
Repeat drilling is normally used with G91 Incremental mode, and a good example
of repeated drilling is Grid-plate drilling. the example for repeat drilling is given
below.
Working Examples
www.EngineeringBooksPDF.com
N30 G99 G81 X12.5 Y10 Z-17 R2 F75
N40 Y30
N50 G98 X57.5
N60 G99 Y10
N70 G91 G80 G28 X0 Y0 Z0 M05
N80 M30
Repeat Drilling Example
----------------
www.EngineeringBooksPDF.com
G81 Drilling Two Step Block
N10 T4 M6 (TWIST DRILL 8”)
N15 G90 G54 G00 X15 Y15
N20 S1000 M3 F100
N25 G43 H01 Z2 M8
N30 G81 R2 Z-42
N35 X65
N40 Y85 R-13
N45 X15
N50 G80 Z50 M5
N55 M30
-------------
T1 M6
www.EngineeringBooksPDF.com
G0 G90 G40 G21 G17 G94 G80
G54 X20 Y0 S1500 M3
G43 Z100 H1
Z5
G81 R3 Z-20 F? M8
X30
X45
G68 X0 Y0 R120
X20 Y0
X30
X45
G68 X0 Y0 R240
X20 Y0
X30
X45
G69 G80
G0 G90 Z100 M30
-----------------
www.EngineeringBooksPDF.com
Fanuc Sub Programming
As the below cnc program example shows,
cnc machinist want to drill some holes and then he want to tap the same holes.
Example Without Fanuc Sub-Program Call
The simplest way to program can be read here G81 Drilling Cycle G84 Tapping
Cycle CNC Program Example.
Example with Fanuc Sub-Program Call
Below is the same program example but this time we are using Sub-programming
technique.
Fanuc Subprogram Example
www.EngineeringBooksPDF.com
Sub Program
O1001 ;
N101 Y30 ;
N102 Y50 ;
N103 Y70 ;
N104 X30 ;
N105 X50 ;
N106 X70 ;
N107 X90 ;
N108 Y50 ;
N109 Y30 ;
N110 Y10 ;
N111 X70 ;
N112 X50 ;
N113 X30 ;
N114 G80 ;
N115 M99
---------------
www.EngineeringBooksPDF.com
G81 drilling cycle working – G98 G99 return level
CNC Part Program
Explanation
N10- Tool change (M06) to tool no.1
N20- Rapid traverse to X10 Y30 Z12, Spindle started clockwise (M03) with
1000rpm (S1000).
N30- Drilling starts (G81) at X10 Y30 with cutting-feed (F75) drill will retract to
R-plane after drilling operation.
N40- Next drilling position Y10 (as G99 is a modal g-code drill will keep on
retracting to R-plane until G98 is given).
N50- Next drill at X30.
N60- Drill at Y30
N70- Drill at X90 & Retract to Initial-plane.
N80- Drill at Y10 & Retract to R-plane.
www.EngineeringBooksPDF.com
N90- Drill at X110
N100- Drill at Y30 & Retract to Initial-plane.
N110- Drilling cycle is cancelled (G80), return to reference point (G28) for tool
change, stop spindle (M05).
N120- Tool change (M06) to tool number 2.
N130- Rapid traverse to X60 Y28 Z12, start spindle at 750rpm (S750) clockwise
(M03).
N140- G83 Peck drilling starts at X60 Y28, drill depth is Z-17 and drill peck size
is Q6, drilling feed is F60
N150- Next deep drill at Y12 (return to initial point).
N160- G83 Peck drilling cycle cancelled with G80, tool returned to reference
point (G28), spindle stopped (M05).
N170- Part-program end with return to program start (M30)
G & M Codes
Code Description
T Tool no. used.
M06 Tool change command.
G90 Absolute programming
G00 Rapid traverse
S Cutter speed
M03 Cutter rotation Clockwise
M08 Coolant on.
G81 Fanuc drilling cycle.
G83 Fanuc peck drilling cycle.
G98 Return to initial point in canned cycle.
G99 Return to R point in canned cycle.
F Cutting feed.
G80 Canned cycle cancel.
M09 Coolant off.
G28 Return to reference position.
G91 Incremental programming.
M05 Cutter rotation stop.
M30 CNC part-program end with return to program-start.
----------------
www.EngineeringBooksPDF.com
G81 Drilling Cycle – Repeat Drilling
in G91 Incremental Mode Example
Code
This cnc program example explains the use of G81 Drilling cycle but this time the
tool is not positioned in the usual way (G90 absolute programming mode) but this
time G91 Incremental Programming Mode is used.
This programming example code also explains the use of G81 drilling cycle
parameter K (number of repeats), which is not normally used.
Contents
• G81 Drilling Cycle Format
• CNC Code G81 Drilling Cycle with G91 Inremental Programming
◦ Explanation
G81 Drilling Cycle Format
G81 X_ Y_ Z_ R_ F_ K_ ;
X_ Y_: Hole position data
Z_ : Z-depth (tool will travel with feed to Z-depth starting from R plane)
R_ : The distance from the initial level to point R level
F_ : Cutting feedrate
K_ : Number of repeats (if required)
G81 drilling cycle parameter K (number of repeats). On different cnc controls this
parameter has different letter assign to it such as on,
• Fanuc uses letter K for number of repeats.
• Haas CNC uses letter L for number of repeats.
• Fagor CNC Control uses letter N for number of repeats.
Incremental motion in canned cycle is often useful as a loop count, which can be
used to repeat the operation with an incremental X or Y move between each cycle.
CNC Code G81 Drilling Cycle with G91 Inremental
Programming
www.EngineeringBooksPDF.com
G81 Drilling Cycle – Repeat Drilling in G91 Incremental Mode Example Code
N10 T1 M6
N20 G00 G90 X0 Y0 Z0
N30 S1450 M03
N40 G81 G99 G91 X50 Y50 Z-120 R-98 K3 F350
N50 G98 G90 G00 X500 Y500
N60 G80
N70 G90 X0 Y0
N80 M30
Explanation
N40 G81 G99 G91 X50 Y50 Z-120 R-98 K3 F350
K3 means that the G81 drilling cycle will repeat three times.
G91 Incremental mode makes the tool to move every time X50 and Y50
So first hole will be at X50 Y50
Second hole will be at X100 Y100 because
X100 = X50(previous value) + X50 (increment)
Y100 = Y50(previous value) + Y50 (increment)
Third hole will be at X150 Y150 because
X150 = X100(previous value) + X50 (increment)
Y150 = Y100(previous value) + Y50 (increment)
N50 G98 G90 G00 X500 Y500
The fourth hole position is given with G90 Absolute Programming Mode.
The above code is only possible if you use G91 Incremental Programming Mode
with G81 Drilling cycle, but if you try to use G90 Absolute Programming Mode
with G81 as above you will see the tool will repeat drilling at the same position.
---------------
www.EngineeringBooksPDF.com
Fanuc G81 drilling cycle is used for simple drilling operations, so here is a cnc
program example which demonstrates how G81 drilling cycle can be used.
Contents
• CNC Program
• Explanation
• G & M Codes
CNC Program
Explanation
Once G81 drilling canned cycle is defined, the canned cycle is repeated at every
X-Y position in sequential blocks, G80 code is used to cancel G81 drilling cycle.
N1- Tool change to tool no.1
N2- Tool rapidly moves to first drilling position X0.3 Y1.2 while taking into
account Zero-offset-no. 1
N3- Drill starts rotating clockwise with 1200 rpm.
N4- Drill takes depth Z1. taking into account tool length compensation (G43
H01), coolant is turned on.
N5- Drilling cycle parameters, drill depth and cutting feed are given, with this
command first drill is made at current position (X0.3 Y1.2).
N6- As drilling cycle continues it’s work with every axis movement so next drill
is done at X1.2 Y0.3
N7- Drilling cycle is canceled with G80 command, Coolant is turned off.
N8- As operation for this component is finished, so cutting tool is taken to
reference position, and cutter rotation is stopped.
www.EngineeringBooksPDF.com
N9- CNC part-program is ended.
G & M Codes
Code Description
T Tool no. used.
M06 Tool change command.
G90 Absolute programming
G54 Zero offset no.1
G00 Rapid traverse
S Cutter speed
M03 Cutter rotation Clockwise
G43 Tool length compensation.
M08 Coolant on.
G81 Fanuc drilling cycle.
F Cutting feed.
G80 Canned cycle cancel.
M09 Coolant off.
G28 Return to reference position.
G91 Incremental programming.
M05 Cutter rotation stop.
M30 CNC part-program end with return to program-start.
-------------
www.EngineeringBooksPDF.com
Sample Program
Explanation
O10075 Program number (there are many programs in cnc memory so they are
distinguished by their number).
N1- Tool change (M06) to tool no.16
N2- Tool rapidly moves (G00) to first drilling position X0.5 Y-0.5 while taking
into account Zero-offset-no. 1 (G54)
N3- Drill starts rotating clockwise (M03) with 1450 rpm (S1450).
N4- Drill takes depth Z1. taking into account tool length compensation (G43
H16), coolant is turned on (M08).
N5- Drilling cycle (G81) parameters, drill depth (Z) and cutting feed (F) are
given, with this command first drill is made at current position (X0.5 Y-0.5).
N6- As drilling cycle continues it’s work with every axis movement so next drill
is done at X1.5
N7- Third drilling hole at Y-1.5
N8- Fourth drill at X0.5
N9- Drilling cycle is canceled (G80), Coolant is turned off (M09).
N10- Taking Machine-coordinate-system (G53) into account the drill is taken to
Z0 position. Tool length compensation is canceled (G49), cutter rotation is
stopped (M05).
N11- CNC part-program is ended.
G & M Codes
www.EngineeringBooksPDF.com
Code Description
T Tool no. used.
M06 Tool change command.
G90 Absolute programming
G54 Zero offset no.1
G00 Rapid traverse
S Cutter speed
M03 Cutter rotation Clockwise
G43 Tool length compensation.
M08 Coolant on.
G81 Fanuc drilling cycle.
F Cutting feed.
G80 Canned cycle cancel.
M09 Coolant off.
G53 Machine coordinate system selection.
G49 Tool length compensation cancel.
M05 Cutter rotation stop.
M30 CNC part-program end.
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
G91 Incremental Programming
Face Grooving with G74 Peck Drilling
Cycle CNC Programming Tutorial
G74 Peck Drilling Cycle
G74 peck drilling cycle be used in variety of ways, from peck drilling to face
grooving.
The G74 Peck drilling in already discussed here Simple CNC Lathe Drilling with
Fanuc G74 Peck Drilling Cycle.
The cnc programming example below shows how face grooving can be machined
with the help of G74 peck drilling canned cycle.
With face grooving operations the tool is fed axially rather than radially toward
the end surface of the workpiece.
Face Grooving with G74 Peck Drilling Cycle
-------------
www.EngineeringBooksPDF.com
G75 is the grooving cycle in x-axis.
For a full description of G75 canned cycle grooving read this G75 Grooving
Cycle.
For one-line format (one-block format) of Fanuc G75 read Fanuc G75
Grooving Cycle One-Line Format.
You might find another G75 grooving cycle cnc programming example
here Fanuc G75 Grooving Cycle CNC Program Example.
Contents
7 Explanation of Parameters of Fanuc G75 Grooving Cycle
8 G75 Canned Cycle Grooving CNC Programming Example
Explanation of Parameters of Fanuc G75 Grooving
Cycle
N10 G75 R
N20 G75 X Z P Q R
G75 First CNC Programming Block
R = Return amount
G75 Second CNC Programming Block
X = Groove Depth.
Z = Last groove position in z-axis.
P = Peck increment in x-axis
Q = Stepping in z-axis.
R = Relief amount at end of the cut.
G75 Canned Cycle Grooving CNC Programming
Example
www.EngineeringBooksPDF.com
N70 G00 X90.0
N80 X200.0 Z200.0 T0
-----------
-------------
www.EngineeringBooksPDF.com
CNC Lathe Programming Example
A simple cnc lathe programming example. This cnc programming example will
show how to program contours like chamfer taper grooves and arc.
This cnc program will use two tools for machining. The first tool used in this cnc
programming example is a turning tooland the second one is a grooving tool.
Contents
• CNC Machining
• CNC Program
CNC Machining
The turning tool will first face the component then it will make a chamfer, after
that there is straight turning and then there is arc machining the arc may be
machined with R (Radius of arc) or arc can be machined with I and K values of
the arc, at the top of arc there is a chamfer, then again straight turning, now there
comes the groove but we can’t make grooves with turning tools because of
their shape so we will machine the groove with our next tool which is solely
made for grooving operations, but at the time we are machining with turning tool
so we will just skip this groove and will just machine in straight line, after that
there is a taper and again a straight line to be machined.
Now with our grooving tool the groove machining task is just easy.
if the grooving insert is of the same size as the dimension of the groove then
grooving is even more easy, we will make the groove in one go, but if
the grooving insert is of smaller width than we have to take depth more than one
time.
CNC Program
www.EngineeringBooksPDF.com
N7 G01 X3.75 CHF=0.125
N8 G01 Z-3.575
N9 G01 X5 Z-3.875
N10 G01 Z-4.6
N11 G00 X20 Z20 G40
N12 T02 D02 M491
N13 G00 G97 S500 X4 Z-2.825
N14 G01 X3.85 F1
N15 G01 X3.35 F0.15
N16 G01 X3.85 F0.5
N17 G00 X4
N18 G00 X20 Z20
N19 M30
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Grooving
G02 G03 Programming Example
CNC program example to show how two combined arc can be programmed with
G02 G03 for a cnc lathe.
First arc is programmed using G02 R, but the second arc is programmed using
G03 I K
------------
www.EngineeringBooksPDF.com
Plasma Cutting
Plasma cutting is a process that is used to cut steel and other metals of different
thicknesses (or sometimes other materials) using a plasma torch. In this process,
an inert gas (in some units, compressed air) is blown at high speed out of a nozzle;
at the same time an electrical arc is formed through that gas from the nozzle to the
surface being cut, turning some of that gas to plasma. The plasma is sufficiently
hot to melt the metal being cut and moves sufficiently fast to blow molten metal
away from the cut.
-----------------
www.EngineeringBooksPDF.com
Cutting feed is performed intermittently to the bottom of the hole while chips are
discharged.
As the drilling is performed to the bottom of the hole with feed in multiple small
steps, every time a specified depth is made and then drill retracts, then drill makes
the next peck, this operation is repeated again and again until the drill depth is
reached.
Syntax
G83 X... Y... Z... R... Q... F... K...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Z Depth, tool will travel with feed to Z-depth starting from R plane.
R Position of the R plane.
Q Depth of cut for each cutting feed (Peck).
K Number of cycle repetitions (if required)__________________.
F Feedrate.
Once given in program G83 peck drilling cycle is repeated at every axis
movement until G80 is given in program to end peck drilling cycle.
Usage
N150 M06 T02
N160 G90 G00 X60 Y28 Z12 S750 M03
N170 G99 G83 X60 Y28 Z-17 Q6 R2 F60
N180 G98 Y12
N190 G91 G80 G28 X0 Y0 Z0 M05
N200 M30
In the above example code first drill is done at X60 Y28 and second at Y12 and
then peck drilling is cycle is ended with G80.
6mm pecks are taken to complete total drilling depth of 17mm.
Working
Here is briefly described how G83 peck drilling cycle works,
1- Rapid traverse to X, Y drilling position.
2- Rapid traverse to R-plane.
3- Drilling with feed Q deep.
4- Retraction with Rapid traverse to R-plane.
5- Rapid traverse to Q-d deep (d value is specified in parameters).
6- Drilling with feed Q+d deep.
7- Retraction with Rapid traverse to R-plane
– this whole procedure is repeated until drill reaches Z-depth position,
www.EngineeringBooksPDF.com
– then drill is retracted to R-plane or Initial-level depends on G99 or G98 which
one is given in program.
www.EngineeringBooksPDF.com
N30 G99 G83 X12.5 Y10 Z-17 R2 Q4 F75
N40 Y30
N50 G98 X57.5
N60 G99 Y10
N70 G91 G80 G28 X0 Y0 Z0 M05
N80 M30
----------------
www.EngineeringBooksPDF.com
G0 X255.0 Z5.0
G72 W2.0 R0.5
G72 P100 Q200 F0.25
N100 G0 Z0 G41
G1 X-2.0 F0.18
N200 G0 Z5.0
G40
X255.0
G28 U0 W0
N2 T0404 M8 (ID ROUGH)
G96 S180 M3
G0 X50.0 Z5.0
G71 U2.0 R0.5
G71 P500 Q600 U-0.5 W0.1 F0.25
N500 G0 X202.0 G41
G1 Z0 F0.12
X200.0
Z-10.0
X100.0
Z-30.0
X60.0
Z-45.0
N600 X50.0
G40
G0 Z5.0
G28 U0 W0
N3 T0505 M8 (ID FINISH)
G96 S220 M3
G0 X50.0 Z5.0
G70 P500 Q600
G0 X50.0 Z5.0
G28 U0 W0
M5 M9
M30
-----------------
www.EngineeringBooksPDF.com
give the cnc programmer/cnc machinist multiple options to control thread cutting,
some are listed below.
G76 thread cutting cycle allow cnc machinist to control number of idle cuts,
thread run-out, infeed angle.
CNC Program of Internal Threading with G76
Threading Cycle
Internal Threading on Fanuc 21i 18i 16i with G76 Threading Cycle
N17 T101
N18 G54
N19 G97 S800 M3
N20 G0 X25 Z6 M8
N21 G76 P010060 Q100 R0.02
N22 G76 X30 Z-40 P919 Q250 F1.5
N23 G0 X150 Z100
You might like other cnc threading options on cnc machines with fanuc control
--------------
www.EngineeringBooksPDF.com
Explanation of Parameters of Fanuc G75 Grooving
Cycle
N10 G75 R
N20 G75 X Z P Q R
G75 First CNC Programming Block
R = Return amount
G75 Second CNC Programming Block
X = Groove Depth.
Z = Last groove position in z-axis.
P = Peck increment in x-axis
Q = Stepping in z-axis.
R = Relief amount at end of the cut.
G75 Canned Cycle Grooving CNC Programming
Example
------------
www.EngineeringBooksPDF.com
Fanuc cnc controls has no direct threading cycle for cutting multi start
threads on cnc. But you can cut multi start threads on a cnc with fanuc control by
using Fanuc G76 Threading Cycle.
Related: Fanuc G76 Thread Cycle for Dummies
-------------
www.EngineeringBooksPDF.com
Fanuc G76 Thread Cycle for Dummies explains Fanuc G76 threading cycle
briefly. Fanuc G76 gives cnc machinist full control over thread turning.
Fanuc G76 threading cycle has multiple parameters but the same way Fanuc G76
gives full flexibility in thread cutting.
This article is actually to help cnc machinists to easily navigate through multiple
articles explaining Fanuc G76 threading cycle.
Below are quick links,
• Fanuc G76 Threading Cycle
• G76 Threading Cycle One Line Format for Fanuc 10/11/15T
• Tapered Threading with Fanuc G76 threading cycle
• Multi-Start Threading with Fanuc G76 threading cycle
• Controlling Thread Infeed with Fanuc G76 threading cycle
• How to Fully Control G76 Threading Cycle Number of Pass and Depth of
Cut
For explanation of all the variations of Fanuc G76 see below
Contents
• CNC Fanuc G76 Threading Cycle
• One Line Format for Fanuc 10/11/15T
• Tapered Threading
• Multi Start Threads
• Controlling Threading Infeed Angle
• Controlling Number of Pass and Depth of Cut
CNC Fanuc G76 Threading Cycle
CNC Fanuc G76 Threading Cycle this article briefly explains all the
parameters of Fanuc G76 threading cycle, like the following cnc programming
code for fanuc g76 threading cycle
N5 G76 P010060 Q100 R0.05
N6 G76 X30 Z-20 P1024 Q200 F2
One Line Format for Fanuc 10/11/15T
G76 Threading Cycle One Line Format for Fanuc 10/11/15T, Fanuc control
models 10/11/15 use a single-block format for G76 threading cycle.
G76 X.. Z.. I.. K.. D.. A.. F.. P..
Tapered Threading
Tapered Threading with Fanuc G76 Threading Cycle this post explained how a
cnc machinist can cut Tapered Threadswith Fanuc G76 threading cycle.
www.EngineeringBooksPDF.com
Tapered Threading with Fanuc G76 Threading Cycle
The following cnc programming code is explained in the above post.
N5 G00 X50 Z5
N6 G76 P010060 Q100 R0.05
N7 G76 X43 Z-45 P1024 Q200 R-14.5 F2
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Intermediate Level
Fanuc G81 Drilling Cycle
G81 drilling cycle is used for simple drilling/spot drilling operations.
Syntax
G81 X... Y... Z... R... K... F...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Depth, tool will travel with feed to Z-depth starting from R
Z
plane.
R Position of the R plane.
Number of cycle repetitions (if
K
required)__________________.
F Feedrate.
Once G81 drilling cycle is defined, the canned cycle is repeated at every X-Y
position in sequential blocks. So G81 drilling cycle must be cancelled with G80.
Usage
N30 G81 X10 Y30 Z-17 R2 F75
N40 Y10
N50 X30
N60 Y30
N70 X90
N80 Y10
N90 G80
In the above example drilling will start with G81 drilling cycle at X10 Y30, so
first drill will be at X10 Y30, then second at Y10, third at X30, fourth at Y30,
fifth at X90 and the last one at Y10, because next block have G80 code, so
drilling cycle will no more be repeated.
Working
Here is briefly described how G81 drilling cycle operates,
1- Rapid traverse to the specified x,y axis position (drilling position).
2- Rapid traverse to the R plane position.
3- Drilling with specified Feed from R-plane position to Z-depth position.
www.EngineeringBooksPDF.com
4- Rapid traverse to Initial level or R-plane depends on G98, G99 modes.
www.EngineeringBooksPDF.com
N80 M30
www.EngineeringBooksPDF.com
M30
----------
Drilling Grid Plate with G81 Drilling
Cycle – Sample CNC Program
CNC machine workshops deal with variety of components, of course cnc
machinists program and machine them.
But a cnc machinists also should understand and practice new and economical
ways to machine a component.
The following cnc programming example can be programmed in variety of ways,
the method of cnc programming used in this cnc program sample uses G81
drilling cycle with G91 Incremental Programming mode, which makes
programming easy.
Fanuc cnc control uses K with G81 drilling cycle to repeat drilling cycle.
Haas cnc controls use L to repeat G81 drilling cycle.
Following cnc program is written for haas cnc machine but can easily be
converted for Fanuc cnc controls.
You might read other cnc programming example which shows the same technique
for Fanuc cnc controls
G81 Drilling Cycle – Repeat Drilling in G91 Incremental Mode Example
Code
Repeat Drilling with G81 Drilling Cycle and G91 Example Program
CNC Program of Drilling Grid Plate
www.EngineeringBooksPDF.com
T1 M06
G00 G90 G54 X1.0 Y-1.0 S2500 M03
G43 H01 Z.1 M08
G81 Z-1.5 F15. R.1
G91 X1.0 L9
G90 Y-2.0 (Or stay in G91 and repeat Y-1.0)
G91 X-1.0 L9
G90 Y-3.0
G91 X1.0 L9
G90 Y-4.0
G91 X-1.0 L9
G90 Y-5.0
G91 X1.0 L9
G90 Y-6.0
G91 X-1.0 L9
G90 Y-7.0
G91 X1.0 L9
G90 Y-8.0
G91 X-1.0 L9
G90 Y-9.0
G91 X1.0 L9
G90 Y-10.0
G91 X-1.0 L9
G00 G90 G80 Z1.0 M09
G28 G91 Y0 Z0
M30
In above cnc program G90 Absolute programming mode is used while starting a
new row for drilling. Although G91 Incremen0tal programming can be used but
using G90 there makes this program easy to read understand and debug (if
anything goes wrong).
-----------
www.EngineeringBooksPDF.com
Repeat Drilling with G81 Drilling Cycle and G91
O1000
T1 M6
G00 G90 G40 G21 G17 G94
G54 X20 Y10 S1000 M03
G43 H1 Z100
Z3
G81 G99 R3 Z-20 F350 M08
G91 X10 Y10 K4
G80
G00 G90 Z100
M30
---------
www.EngineeringBooksPDF.com
G81 drilling cycle parameter K (number of repeats). On different cnc controls this
parameter has different letter assign to it such as on,
• Fanuc uses letter K for number of repeats.
• Haas CNC uses letter L for number of repeats.
• Fagor CNC Control uses letter N for number of repeats.
Incremental motion in canned cycle is often useful as a loop count, which can be
used to repeat the operation with an incremental X or Y move between each cycle.
CNC Code G81 Drilling Cycle with G91 Inremental
Programming
G81 Drilling Cycle – Repeat Drilling in G91 Incremental Mode Example Code
N10 T1 M6
N20 G00 G90 X0 Y0 Z0
N30 S1450 M03
N40 G81 G99 G91 X50 Y50 Z-120 R-98 K3 F350
N50 G98 G90 G00 X500 Y500
N60 G80
N70 G90 X0 Y0
N80 M30
Explanation
N40 G81 G99 G91 X50 Y50 Z-120 R-98 K3 F350
K3 means that the G81 drilling cycle will repeat three times.
G91 Incremental mode makes the tool to move every time X50 and Y50
So first hole will be at X50 Y50
Second hole will be at X100 Y100 because
X100 = X50(previous value) + X50 (increment)
Y100 = Y50(previous value) + Y50 (increment)
Third hole will be at X150 Y150 because
X150 = X100(previous value) + X50 (increment)
Y150 = Y100(previous value) + Y50 (increment)
N50 G98 G90 G00 X500 Y500
The fourth hole position is given with G90 Absolute Programming Mode.
www.EngineeringBooksPDF.com
The above code is only possible if you use G91 Incremental Programming Mode
with G81 Drilling cycle, but if you try to use G90 Absolute Programming Mode
with G81 as above you will see the tool will repeat drilling at the same position
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Pattern Drilling
Fanuc Lathe Programming Example
Using G70, G71, G74 for ID
Machining
Fanuc lathe programming example which uses Fanuc canned cycle
G71 Turning Cycle
G70 Finish Cycle
G74 Peck Drilling Cycle
This Fanuc lathe programming example illustrates who to use G71 Turning cycle,
G70 Finish cycle, G74 Peck drilling cycle for ID machining (Inside machining,
boring operations)
www.EngineeringBooksPDF.com
N110 G00 X150. Z150.
N120 M9
N130 T0707
N140 G97 S0950 M3
N150 G00 Z3.
N160 G00 X0.
N170 G74 R1.0
N171 G74 X0.0 Z-59.0 Q12000 R0.0 F0.2
N350 G00 X150. Z150.
N360 T0505
N370 G50 S3500
N380 G96 S0200 M4
N390 G00 X23. Z2.
N400 G71 U3. R1
N410 G71 P420 Q530 U-0.5 W0.2 F0.3
N420 G41 G00 X72.
N440 G01 Z-21.
N450 G03 X66. Z-24. I-3. K0.
N460 G01 X54.
N470 G02 X48. Z-27. I0. K-3.
N480 G01 Z-41.
N490 G03 X42. Z-44. I-3. K0.
N500 G01 X30.
N510 G02 X24. Z-47. I0. K-3.
N520 G01 Z-59.
N530 G01 X23.
N540 G40
N550 G00 X150. Z150. F0.3
N560 T1111
N570 G50 S4500
N580 G96 S0380 M4
N590 G41 G00 X72. Z2.
N600 G70 P420 Q530
N610 G40
N620 G00 X23. Z2.
N630 G00 X200. Z150.
N640 M5
N650 M30
Tools & Oprations
T0101 Turning Tool – Facing Operation
T0707 Tip Drill Tool – Drilling
T0505 Boring Bar – Internal machining (ID machining)
T1111 Boring Bar – Internal finish machining
-------------
www.EngineeringBooksPDF.com
Drilling Cycle
CNC programming exercise for cnc lathe machinists who work on Fanuc cnc
control (or similar cnc control).
This cnc programming exercise use
Fanuc G71 Turning Cycle
Fanuc G74 Peck Drilling Cycle
www.EngineeringBooksPDF.com
N540 G00 X70.
N550 G71 U4. R1
N560 G71 P570 Q650 U0.6 W0.2 F0.35
N570 G42 G00 X24.
N580 G01 Z0.
N590 G01 X28. Z-2.
N600 G01 Z-72.
N610 G02 X32. Z-74. I2. K0.
N620 G01 X62.
N630 G01 X68. Z-77.
N640 G01 Z-90.
N650 G40
N660 G00 X150.
N680 G00 Z70.
N690 T0202 M7
N700 G50 S4500
N710 G96 S0380 M4
N720 G00 X16. Z3.
N730 G42 G01 Z0. F0.1
N740 G01 X24.
N750 G01 X28. Z-2.
N760 G01 Z-72.
N770 G02 X32. Z-74. I2. K0.
N780 G01 X62.
N790 G01 X68. Z-77.
N800 G01 Z-90.
N810 G40
N820 G00 X150. Z150.
N830 M5
N840 M9
N850 M30
Used Tools & Operations
• T0101 Turning Tool – Rough Facing
• T0303 Center Drill – Center Drilling
• T0707 Twist Drill – Drilling
• T0404 Turning Tool – Rough Turning
• T0202 Turning Tool – Finish Contour Cutting
---------------
www.EngineeringBooksPDF.com
G74 peck drilling cycle be used in variety of ways, from peck drilling to face
grooving.
The G74 Peck drilling in already discussed here Simple CNC Lathe Drilling with
Fanuc G74 Peck Drilling Cycle.
The cnc programming example below shows how face grooving can be machined
with the help of G74 peck drilling canned cycle.
With face grooving operations the tool is fed axially rather than radially toward
the end surface of the workpiece.
Face Grooving with G74 Peck Drilling Cycle
-------------
www.EngineeringBooksPDF.com
If we can drill with the above method them why use a peck drilling cycle.
Actually peck drilling (Fanuc G74) gives us some hidden benefits like
• Longer drill life
• Proper chip breaking
• Proper chip removal
• Prevents component from heating
• Smooth drilling
• Easy to program
So here is the simple cnc program example which shows simple cnc peck drilling
(Fanuc G74) on a cnc lathe machine
Simple CNC Lathe Drilling with Fanuc G74 Peck Drilling Cycle
N10 T5
N20 G97 S500 M03
N30 G00 X0 Z2
N40 G74 R1
N50 G74 Z-60 Q30000 F0.1
N60 G00 X100 Z100
N70 M30
The above cnc program code shows that the tool no.5 which is a drill, will drill
the component with the peck drilling cycle G74.
The R in first block shows the amount ( 1mm) the drill will get back after it drills
30 mm every time.
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Peck Drilling Lathe
Fanuc G83 Peck Drilling Cycle
G83 peck drilling cycle perform the drilling operation in multiple pecks, this
technique makes deep-hole drilling easy and economical.
Cutting feed is performed intermittently to the bottom of the hole while chips are
discharged.
As the drilling is performed to the bottom of the hole with feed in multiple small
steps, every time a specified depth is made and then drill retracts, then drill makes
the next peck, this operation is repeated again and again until the drill depth is
reached.
Syntax
G83 X... Y... Z... R... Q... F... K...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Depth, tool will travel with feed to Z-depth starting
Z
from R plane.
R Position of the R plane.
Q Depth of cut for each cutting feed (Peck).
Number of cycle repetitions (if
K
required)__________________.
F Feedrate.
Once given in program G83 peck drilling cycle is repeated at every axis
movement until G80 is given in program to end peck drilling cycle.
Usage
N150 M06 T02
N160 G90 G00 X60 Y28 Z12 S750 M03
N170 G99 G83 X60 Y28 Z-17 Q6 R2 F60
N180 G98 Y12
N190 G91 G80 G28 X0 Y0 Z0 M05
N200 M30
www.EngineeringBooksPDF.com
In the above example code first drill is done at X60 Y28 and second at Y12 and
then peck drilling is cycle is ended with G80.
6mm pecks are taken to complete total drilling depth of 17mm.
Working
Here is briefly described how G83 peck drilling cycle works,
1- Rapid traverse to X, Y drilling position.
2- Rapid traverse to R-plane.
3- Drilling with feed Q deep.
4- Retraction with Rapid traverse to R-plane.
5- Rapid traverse to Q-d deep (d value is specified in parameters).
6- Drilling with feed Q+d deep.
7- Retraction with Rapid traverse to R-plane
– this whole procedure is repeated until drill reaches Z-depth position,
– then drill is retracted to R-plane or Initial-level depends on G99 or G98 which
one is given in program.
Repeat Drilling
G83 peck drilling cycle, drilling operation can be repeated multiple times. The
drilling is repeated K times if K value is given with G83.
Repeat drilling is normally used with G91 Incremental mode, and a good example
of repeated drilling is Grid-plate drilling. For working example see G81 drilling
www.EngineeringBooksPDF.com
cycle.
Working Example
------------
www.EngineeringBooksPDF.com
G83 Peck Drilling Cycle Example
N1 T1 M06
N2 G90 G54 G00 X.3 Y.3
N3 S1200 M03
N4 G43 H01 Z1. M08
N5 G83 Z-1.5 Q.5 R.1 F10.
N6 X1.2 Y1.2
N7 G80 G00 Z1. M09
N8 G91 G28 Z0. M05
N9 M30
------------
www.EngineeringBooksPDF.com
G81 drilling cycle working – G98 G99 return level
CNC Part Program
www.EngineeringBooksPDF.com
N90- Drill at X110
N100- Drill at Y30 & Retract to Initial-plane.
N110- Drilling cycle is cancelled (G80), return to reference point (G28) for tool
change, stop spindle (M05).
N120- Tool change (M06) to tool number 2.
N130- Rapid traverse to X60 Y28 Z12, start spindle at 750rpm (S750) clockwise
(M03).
N140- G83 Peck drilling starts at X60 Y28, drill depth is Z-17 and drill peck size
is Q6, drilling feed is F60
N150- Next deep drill at Y12 (return to initial point).
N160- G83 Peck drilling cycle cancelled with G80, tool returned to reference
point (G28), spindle stopped (M05).
N170- Part-program end with return to program start (M30)
G & M Codes
Code Description
T Tool no. used.
M06 Tool change command.
G90 Absolute programming
G00 Rapid traverse
S Cutter speed
M03 Cutter rotation Clockwise
M08 Coolant on.
G81 Fanuc drilling cycle.
G83 Fanuc peck drilling cycle.
G98 Return to initial point in canned cycle.
G99 Return to R point in canned cycle.
F Cutting feed.
G80 Canned cycle cancel.
M09 Coolant off.
G28 Return to reference position.
G91 Incremental programming.
M05 Cutter rotation stop.
M30 CNC part-program end with return to program-start.
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Peck Drilling-Mill
CNC Mill Subprogram Example
Joining Multiple Arcs G02 G03 G41
CNC milling program to describe how two or more radii can be joint together in a
cnc mill program.
www.EngineeringBooksPDF.com
N100 M99
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G49 Tool length compensation cancel
G90 Absolute command
G91 Increment command
M03 Spindle start forward CW
M06 Tool change
M30 End of program (Reset)
M98 Subprogram call
M99 End of subprogram
T Tool
S Speed
F Feed
---------------
www.EngineeringBooksPDF.com
Main Program
Milling cutter diameter: 10mm
N05 G55
N10 M6 T2 H3 G43 M3
N15 S1000 F60
N20 G0 X9 Y9 Z1
N25 G1 Z0
N30 M98 P030035
N35 G0 Z1 G90
N40 X42 Y38
N45 G1 Z-2 F30
N50 X47 F300
N55 G3 X47 Y38 I-5 J0
N60 G0 Z100
N65 G49
N70 M30
Subprogram
O0035
N05 G1 Z-2 G91 F30
N10 X10 F100
N15 Y36
N20 X-10
N25 Y-36
N30 M99
Explanation
Although this cnc mill program is self explanatory
M98 P030035
this code mean call Subprogram No. 0035 three times.
-------------
www.EngineeringBooksPDF.com
Fanuc G68 Coordinate Rotation –
Subprogram Example
CNC program example code to show how Fanuc G68 Coordinate rotation g-code
can be used in a subprogram to take most benefit from it’s functionality.
Main-program
N5 G54
N10 G43 T10 H10 M6
N15 S2000 M3 F300
M98 P030100 ; Subprogram call
N25 G0 Z50
N30 M30
Subprogram
O0100
N10 G91 G68 X10 Y10 R22.5
N15 G90 X30 Y10 Z5
N20 G1 Z-2
N25 X45
N30 G0 Z5
N35 M17
-------------------
www.EngineeringBooksPDF.com
What is Fanuc Sub programming read Fanuc Sub Programming
www.EngineeringBooksPDF.com
M99
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Peck Milling
CNC Milling Machine Programming
Example for Beginners
CNC Mill Program Example
A very simple cnc milling machine programming tutorial for beginner level cnc
machinists.
An easy to understand cnc mill programming code. This is a cnc g code example
without the use of any cnc canned cycle.
Related cnc mill program examples
CNC G02 Circular Interpolation Clockwise CNC Milling Sample
Program
CNC Milling Circular Interpolation G02 G03 G-Code Program Example
Beginner level cnc program examples for CNC Lathe
Fanuc CNC Program Example
CNC Programming for Beginners a Simple CNC Programming Example
CNC Programming for Beginners a CNC Programming Example
www.EngineeringBooksPDF.com
N30 End of program
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Ramping Milling
CNC Mill Subprogram Example
Joining Multiple Arcs G02 G03 G41
CNC milling program to describe how two or more radii can be joint together in a
cnc mill program.
www.EngineeringBooksPDF.com
N80 G2 X5 Y50 R45 (P1)
N90 G0 G40 X-21
N100 M99
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G49 Tool length compensation cancel
G90 Absolute command
G91 Increment command
M03 Spindle start forward CW
M06 Tool change
M30 End of program (Reset)
M98 Subprogram call
M99 End of subprogram
T Tool
S Speed
F Feed
------------
www.EngineeringBooksPDF.com
Slot Milling Sample CNC Program
N10 G00 G90 X70 Y25 Z1 S800 M3
N20 Z-5
N30 G01 X20 F150
N40 G00 Z100
N50 X-25 Y50
N60 M30
N10 Spindle on clockwise rotation at 800 rev/min, tool rapid traverse to P01.
N20 Infeed in Z.
N30 Tool traverse P01 to P02, feedrate 150 mm/min.
N40/N50 Rapid traverse retraction.
N60 End of program.
-------------
www.EngineeringBooksPDF.com
CNC Milling Machine Programming Example for Beginners
N05 G0 G90 X40 Y48 Z2 S500 M3
N10 G1 Z-12 F100
N15 X20 Y18 Z-10
N20 G0 Z100
N25 X-20 Y80
N30 M2
N05 The tool traverses in rapid traverse on P1, three axes concurrently,
spindle speed = 500 rpm, clockwise
N10 Infeed on Z-12, feed 100 mm/min
N15 Tool travels on a straight line in space on P2
N20 Retraction in rapid traverse
N30 End of program
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Slot Milling
Fanuc G71 Turning Cycle
Fanuc G71 Turning Cycle
G71 turning cycle is used for rough-material removal from a cnc lathe
component. G71 turning cycle makes large diameter cutting easy. Cutting can be
done in simple straight line or a complex contour can also be machined very
easily.
Through G71 turning cycle parameters cnc machinists can control
Depth of cut.
Retract height.
Finishing allowance in x-axis and z-axis.
Cycle cutting-feed, spindle speed.
Programming
G71 U... R...
G71 P... Q... U... W... F... S...
Parameters
First block
Parameter Description
U Depth of cut.
R Retract height.
Second block
Parameter Description
P Contour start block number.
Q Contour end block number.
U Finishing allowance in x-axis.
W Finishing allowance in z-axis.
F Feedrate during G71 cycle.
S Spindle speed during G71 cycle.
G71 Turning Cycle Overview
• G71 turning cycle cuts the whole contour repeatedly which is given in P Q
blocks.
• Depth of every cut can be controlled by first-block U value.
• Second-block U W are the finishing allowances which can be given if you
want to make a finish cut with G70 finishing cycle.
• F is cutting feed and S is spindle speed (given in second-block) which are
used during G71 turning cycle.
Note – The F and S given inside P Q block will not be used during G71 turning
cycle, they are used with G70 finishing cycle if later called.
G71 Turning Cycle Working
N60 G71 U10 R10
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75
When G71 turning cycle is run the whole operation will be done in following
sequence,
First-cut
1 – Tool will move in x-axis U (depth of cut) deep with programmed feed from
starting-point.
2 – Tool will travel with feed in z-axis (destination point in z-axis is given in P Q
blocks )
3 – Tool rapidly retracts R amount in both x-axis and z-axis (at 45 degrees).
4 – Tool rapidly travel in z-axis to start-point
Later-cuts
5 – Tool rapidly moves to last cut depth.
6 – Tool moves with feed in x-axis U deep (first-block U depth of cut).
7 – Tool with feed moves in z-axis (destination point given in P Q blocks).
8 – Tool rapidly retracts in x-axis and z-axis R amount (45 degrees).
9 – Tool rapidly moves to start-point only in z-axis.
This whole sequence of operation keep on going, until the destination point in x-
axis is met.
If finishing allowance is given tool will not make the exact diameter and length
given in P Q blocks but will leave that much allowance, This finishing allowance
can be later machined by calling G70 finishing cycle.
www.EngineeringBooksPDF.com
Here is a cnc part-program which shows how G71 turning cycle can be used, this
is the program for the drawing given above
N50 G00 X106 Z5 M3 S800
N60 G71 U10 R10
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75
In this program G71 turning cycle will keep repeating the contour given inside P
Q blocks shown below
N80 G00 X60
N90 G01 Z-75
These two cnc program blocks tell us that we want to remove material till X60
deep and in Z-75 in length.
The depth of cut is given in first-block U10 retract amount is also given R10.
Finishing allowance in x-axis is U3 but there is no finishing allowance given in z-
axis W0.
G70 Finishing Cycle
If you programmed G71 turning cycle with finishing allowances then that finish
allowances can be removed with G70 finishing cycle.
G70 finishing cycle repeats the whole contour the G71 way, but in just one-cut
removing the finishing allowances.
Why Use G70 Finishing Cycle
As material can be removed with G71 turning cycle, but if you want a different
cutting-feed and spindle speed for the last cut, then it is recommended that you
use G70 finishing cycle.
G70 finishing cycle use F and S values which are given inside P Q programmed
blocks. (G71 use F S values which are given inside G71 second block.)
Fanuc G70 Example
N50 G00 X106 Z5 M3 S800
N60 G71 U10 R10
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75 F0.15
N100 G00 X200 Z100
N110 G92 S1200
N120 T3 G96 S150 M03
N130 G00 X106 Z5
N140 G70 P80 Q90
N150 G00 X200 Z100
N160 M30
www.EngineeringBooksPDF.com
G71 Rough Turning Cycle Example
O0004
G00 X200 Z10 M3 S800
G71 U2 R1 F200
G71 P80 Q120 U0.5 W0.2
N80 G00 X40 S1200
G01 Z-30 F100
X60 W-30
W-20
N120 X100 W-10
G70 P80 Q120
M30
------------
www.EngineeringBooksPDF.com
inside of a component, you can use Fanuc G71 turning cycle for internal stock
removal as well.
Fanuc Programming Example
www.EngineeringBooksPDF.com
M5 M9
M30
---------------
www.EngineeringBooksPDF.com
N021 G70 P014 Q020
N022 G00 X260.0 Z80.0
N023 M30
-------------
CNC Programming Example with Fanuc G71 Rough Turning Cycle and G70
N10 G00 G90 X142 Z171
N20 G71 U4 R1
www.EngineeringBooksPDF.com
N30 G71 P40 Q110 U4 W2 F0.3
N40 G00 X40
N50 G01 Z140 F0.2
N60 G01 X60 Z110
N70 G01 Z90
N80 G01 X100 Z80
N90 G01 Z60
N110 G01 X140 Z40
N120 G70 P40 Q110
N130 G00 X200 Z220
N140 M30
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Step Turning CNC Lathe
www.EngineeringBooksPDF.com
N90 G0 G40 X-21
N100 M99
G M S T Codes Explanation
Code Description
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation CW
G03 Circular interpolation CCW
G40 Cutter compensation cancel
G41 Tool nose radius compensation left
G43 Tool length compensation + direction
G49 Tool length compensation cancel
G90 Absolute command
G91 Increment command
M03 Spindle start forward CW
M06 Tool change
M30 End of program (Reset)
M98 Subprogram call
M99 End of subprogram
T Tool
S Speed
F Feed
-------------
www.EngineeringBooksPDF.com
CNC Pocket Milling Program Example
Main Program
Milling cutter diameter: 10mm
N05 G55
N10 M6 T2 H3 G43 M3
N15 S1000 F60
N20 G0 X9 Y9 Z1
N25 G1 Z0
N30 M98 P030035
N35 G0 Z1 G90
N40 X42 Y38
N45 G1 Z-2 F30
N50 X47 F300
N55 G3 X47 Y38 I-5 J0
N60 G0 Z100
N65 G49
N70 M30
Subprogram
O0035
N05 G1 Z-2 G91 F30
N10 X10 F100
N15 Y36
N20 X-10
N25 Y-36
N30 M99
Explanation
Although this cnc mill program is self explanatory
M98 P030035
this code mean call Subprogram No. 0035 three times.
------------
www.EngineeringBooksPDF.com
Multi Start Threads with Fanuc G76
Threading Cycle
Fanuc cnc controls has no direct threading cycle for cutting multi start
threads on cnc. But you can cut multi start threads on a cnc with fanuc control by
using Fanuc G76 Threading Cycle.
Related: Fanuc G76 Thread Cycle for Dummies
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Subprogram
www.EngineeringBooksPDF.com
Taper Threading with G32 a CNC Programming Example
N10 G50 S800 T0100
N20 G97 S800 M03
N30 G00 X90.0 Z5.0
N40 X22.026
N50 G32 X49.562 Z-71.5 F3.0
N60 G00 X90.0
N70 Z5.0
N80 X21.052
N90 G32 X48.588 Z-71.5
N100 G00 X90.0
N110 Z5.0
N120 X150.0 Z150.0
N130 M30
Here are just two passes of taper threading in this cnc programming example, but
you can repeat the thread passes as much you require.
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Taper Threading
Fanuc G84 Tapping Cycle
G84 tapping cycle performs tapping operation, tapping is performed by rotating
the spindle clockwise, when bottom of the hole has been reached, the spindle is
rotated in the reverse direction for retraction. This whole operation creates
threads.
Syntax
G84 X... Y... Z... R... P... F... K...
Parameter Description
X Hole position in x-axis.
Y Hole position in y-axis.
Z Depth, tapping from R-plane to Z-depth.
R Position of the R plane.
P Dwell time.
Number of cycle repetitions (if
K
required)__________________.
F Feedrate.
Once given in program G84 tapping cycle is repeated at every axis movement
until G80 is given in program to end tapping cycle.
Notes
Feedrate override is ignored during tapping.
Feed-hold does not stop the machine until the return operation is completed.
Usage
N150 M6 T2
N160 G90 G00 X60 Y28 Z12 S100 M03
N170 G99 G84 X60 Y28 Z-17 P300 R2 F120
N180 G98 Y12
N190 G91 G80 G28 X0 Y0 Z0 M05
N200 M30
Working
Brief description of how G84 tapping cycle works,
www.EngineeringBooksPDF.com
G84 tapping cycle working
0- CW Spindle rotation command (M03) must be given in part-program.
1- Rapid traverse to X, Y position (pre-drill hole position).
2- Rapid traverse to R-plane.
3- Tapping operation is done till Z-depth (with tapping feed given with G84).
4-1- Dwell for time specified with P
4-2- Spindle is rotated CCW
5- Tap is Retracted with the specified feed.
At R-plane spindle is rotated CW.
If G99 is specified then tapping for this hole ends here,
6- if G98 is given in program then tap is moved to Initial-level.
G98 G99 Modes
After completing tapping the return height can be controlled by using G98 or
G99.
G98 Tap will return to the Initial level
G99 Tap will return to R-plane.
G98, G99 can be used multiple times during G84 tapping cycle.
Repeat Drilling
G84 tapping cycle can be repeated multiple times if K value is given.
For working example see G81 drilling cycle.
Working Example
www.EngineeringBooksPDF.com
N30 S100 M03
N40 G43 H01 Z5 M08
N50 G84 Z-20 R2 F1.25
N60 X80 Y50
N70 G80 G00 Z100 M09
N80 M30
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Tapping
Internal Threading on Fanuc 21i 18i 16i with G76 Threading Cycle
N17 T101
N18 G54
N19 G97 S800 M3
N20 G0 X25 Z6 M8
N21 G76 P010060 Q100 R0.02
N22 G76 X30 Z-40 P919 Q250 F1.5
N23 G0 X150 Z100
www.EngineeringBooksPDF.com
-----------
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com
Threading
www.EngineeringBooksPDF.com
• Depth of every cut can be controlled by first-block U value.
• Second-block U W are the finishing allowances which can be given if you
want to make a finish cut with G70 finishing cycle.
• F is cutting feed and S is spindle speed (given in second-block) which are
used during G71 turning cycle.
Note – The F and S given inside P Q block will not be used during G71 turning
cycle, they are used with G70 finishing cycle if later called.
G71 Turning Cycle Working
N60 G71 U10 R10
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75
When G71 turning cycle is run the whole operation will be done in following
sequence,
First-cut
1 – Tool will move in x-axis U (depth of cut) deep with programmed feed from
starting-point.
2 – Tool will travel with feed in z-axis (destination point in z-axis is given in P Q
blocks )
3 – Tool rapidly retracts R amount in both x-axis and z-axis (at 45 degrees).
4 – Tool rapidly travel in z-axis to start-point
Later-cuts
5 – Tool rapidly moves to last cut depth.
6 – Tool moves with feed in x-axis U deep (first-block U depth of cut).
7 – Tool with feed moves in z-axis (destination point given in P Q blocks).
8 – Tool rapidly retracts in x-axis and z-axis R amount (45 degrees).
9 – Tool rapidly moves to start-point only in z-axis.
This whole sequence of operation keep on going, until the destination point in x-
axis is met.
If finishing allowance is given tool will not make the exact diameter and length
given in P Q blocks but will leave that much allowance, This finishing allowance
can be later machined by calling G70 finishing cycle.
www.EngineeringBooksPDF.com
Here is a cnc part-program which shows how G71 turning cycle can be used, this
is the program for the drawing given above
N50 G00 X106 Z5 M3 S800
N60 G71 U10 R10
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75
In this program G71 turning cycle will keep repeating the contour given inside P
Q blocks shown below
N80 G00 X60
N90 G01 Z-75
These two cnc program blocks tell us that we want to remove material till X60
deep and in Z-75 in length.
The depth of cut is given in first-block U10 retract amount is also given R10.
Finishing allowance in x-axis is U3 but there is no finishing allowance given in z-
axis W0.
G70 Finishing Cycle
If you programmed G71 turning cycle with finishing allowances then that finish
allowances can be removed with G70 finishing cycle.
G70 finishing cycle repeats the whole contour the G71 way, but in just one-cut
removing the finishing allowances.
Why Use G70 Finishing Cycle
As material can be removed with G71 turning cycle, but if you want a different
cutting-feed and spindle speed for the last cut, then it is recommended that you
use G70 finishing cycle.
G70 finishing cycle use F and S values which are given inside P Q programmed
blocks. (G71 use F S values which are given inside G71 second block.)
Fanuc G70 Example
N50 G00 X106 Z5 M3 S800
N60 G71 U10 R10
N70 G71 P80 Q90 U3 W0 F0.25
N80 G00 X60
N90 G01 Z-75 F0.15
N100 G00 X200 Z100
N110 G92 S1200
N120 T3 G96 S150 M03
N130 G00 X106 Z5
N140 G70 P80 Q90
N150 G00 X200 Z100
N160 M30
G70 G71 Example
www.EngineeringBooksPDF.com
G71 Rough Turning Cycle Example
O0004
G00 X200 Z10 M3 S800
G71 U2 R1 F200
G71 P80 Q120 U0.5 W0.2
N80 G00 X40 S1200
G01 Z-30 F100
X60 W-30
W-20
N120 X100 W-10
G70 P80 Q120
M30
www.EngineeringBooksPDF.com
www.EngineeringBooksPDF.com