Thursday, August 2, 2018

CNC Programming Examples - CNC Lathe Machine

  Thanh A Tran       Thursday, August 2, 2018

[CNC Programming Examples]

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.

* Top 3 Best CNC Machines
* Best ebooks for CNC programming: 
CNC Programming Basics 
G-Code and M-Code 
CNC programming 
G-Code Reference 
CNC Machine Tutorial 

CNC Turning Center Programming Example

        N10 T03 D03 M06
        N20 G97 S900 M04
        N30 G00 G42 X40 Z5
        N40 G92 S3500
        N50 G96 S250
        N60 G01 X60 Z-5 F0.1
        N70 Z-15
        N80 X56 Z-20
        N90 G02 X70 Z-30 R10
        N100 G01 X80 Z-40
        N110 X100
        N120 Z-80
        N130 X106
        N140 G03 X116 Z-85 R5
        N150 G01 X120
        N160 G00 X150 Z100 G40 G97 S900 M05
        N170 M30


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

G02 G03 Programming Example

            N50 G00 X20 Z85
            N60 G96 S200
            N70 G01 Z80
            N80 G02 X50 Z65 R15
            N90 G03 X50 Z35 I-10 K-15
            N100 G00 X80
            N110 G97 S900 M05
            N120 M30


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.


                G71 U... R...
                G71 P... Q... U... W... F... S...


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,
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
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.

Fanuc G71 Example

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

G71 Rough Turning Cycle Example
                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
                N120 X100 W-10
                G70 P80 Q120


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
  • G71 Rough Turning Cycle
  • G72 Facing Cycle
  • G70 Finish Cycle

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.

Fanuc Programming Example

Fanuc Canned Cycle Example

                    G28 U0 W0
                    G50 S1500
                    N1 T0101 M8 (OD FACING)
                    G96 S180 M3
                    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
                    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
                    N600 X50.0
                    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


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.

CNC Lathe Basic Programming Example (Turning Boring Operations)

CNC Lathe Example Turning Boring
                        N10 (ø30 DRILL) 
                        G50 T0200
                        G97 S250 M03
                        G00 X0 Z5.0 T0202 M08
                        G01 Z-5.0 F0.07
                        Z-40.0 F0.25
                        G00 Z5.0
                        G01 Z-60.0
                        G00 Z10.0
                        X200.0 Z200.0 T0200
                        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
                        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
                        G01 X60.5
                        G03 X80.5 Z-6.2 R3.8
                        G00 U2.0 Z5.0
                        X200.0 Z200.0 T0100
                        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
                        G01 Z-15.0
                        X34.5 Z-24.3
                        G00 Z10.0
                        X200.0 Z200.0 T0400
                        N40 (Out diameter finishing) 
                        G50 S1800 T0500
                        G96 S200 M03
                        G00 X63.0 Z5.0 T0505 M08
                        G01 X38.0 F0.2
                        G00 X60.0 Z3.0
                        G42 Z1.0
                        G01 Z-2.5 F0.2
                        G03 X80.0 Z-5.5 R3.0
                        G01 Z-13.5
                        G02 X83.0 Z-15.0 R1.5
                        G01 X100.0
                        G40 G00 U2.0 W1.0
                        G00 Z10.0
                        X200.0 Z200.0 T0500
                        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
                        G40 G00 Z10.0
                        X200.0 Z200.0 T0600 M09


Haas G72 Type I Rough and G70 Finish Facing Cycle Program Example – Fanuc Compatible

Haas lathe programming example to illustrate the use and programming of Haas G72 Type I Rough Facing Cycle/ G70 Finish Cycle.
The above code will also work on cnc lathe machines with Fanuc cnc control with little or no change.
All the G-code / M-code which are used in this Haas lathe programming example are given below with description.

Haas G72 Type I Rough G70 Finish Facing Cycle Program Example

Haas G72 Type I Rough and G70 Finish Facing Program Example

        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)


G00 Rapid traverse motion.
G01 Linear interpolation motion.
G03 Circular Interpolation – Counterclockwise.
G41 Tool Nose Compensation LEFT of the programmed path.
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.


M01 Optional Program Stop.
M03 Starts the Spindle FORWARD.
M30 Program End and Reset to the beginning of program.


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)

Fanuc Lathe Programming Example
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
            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


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

CNC Lathe Programming Exercise

CNC Lathe Programming Exercise Fanuc G71, G74 Cycles
N10 G40 G00
                N20 G99
                N60 T0101
                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
                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


CNC Arc Programming G02 G03 Example

CNC arc programming example this cnc program shows how two arcs G03 G02 can be joint together.

CNC Arc Programming G02 G03 Example

CNC Arc Programming G02 G03 Example
   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)



Thanks for reading CNC Programming Examples - CNC Lathe Machine

« Prev Post

No comments:

Post a Comment