CNC Programming Examples - Step Turning CNC Lathe

CNC Mill Subprogram Example Joining Multiple Arcs G02 G03 G41

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

CNC milling program to describe how two or more radii can be joint together in a cnc mill program.

CNC Mill Subprogram Example

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


        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


CNC Pocket Milling Program Example – Peck Milling

CNC milling program example which shows how a cnc program can be made to machine Pockets on a cnc mill.
This program example uses Peck milling to cut material to machine a rectangular and one round pocket.
  • CNC Pocket Milling Program Example
    • Main Program
    • Subprogram
    • Explanation

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


            N05 G1 Z-2 G91 F30
            N10 X10 F100
            N15 Y36
            N20 X-10
            N25 Y-36
            N30 M99


Although this cnc mill program is self explanatory
M98 P030035
this code mean call Subprogram No. 0035 three times.


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

Multi Start Threads with Fanuc G76 Threading Cycle
There are multiple techniques for cutting multi-start threads on cnc with Fanuc G76 threading cycle. Here is one of them.
This cnc programming example uses cnc subprogram call to cut multi-start threads on Fanuc cnc.

CNC Main program
N50 G00 X48 Z5
                N60 M98 P0034713

CNC Sub Program

N10 G76 P020000 Q100 R0.05
                N20 G76 X42 Z-15 P974 Q200 F4.5
                N30 G00 W1.5
                N40 M99
The above cnc main program calls the 4713 sub-program three times.