How do I learn CNC programming?


Believe me… Learning CNC is quite easy. Only that, mastering takes more time.
To start with, being good at mathematics (especially Coordinate Geometry) is enough for coding. The G codes and M codes can be found in internet easily. You don’t need to by-heart them. Just start coding by looking at the codes. The more you practice, the easier it will be.

A program contains

  1. Definition statements. They contains program number, defining the origin, selecting tool etc.,
  2. Machining statements. Based on the coordinates, you move the tool using commands like G 0, G01, G02, G03…
  3. Closing statements to tell the machine that the program is ended, bringing the tool and workpiece back to origin, stopping coolant…
    The defining and closing statements will be same for most of the programs. So master the machining statements first.
    First take simple shapes. For example consider the following: We will try to write the code in steps. Imagine the tool is of dia 10 mm (i.e radius = 5)


  1. Once the workpiece/ drawing is given, identify the origin from where you want to start cutting. Select the origin, such that it will be easier to find the coordinates of remaining points (P1, P2…).
  2. Now find the coordinates of other corner points.
  3. Use the codes to define the program.

// Defining statements:
N001 G21 (metric)
N002 G91 (incremental)
N003 G94 (Feed rate in mm/min)
N004 G28 Z0 (Home Position)
N005 G28 X0 Y0 M19
N006 M06 T01 (Tool selection)
N007 G90 M03 S2000 (Spindle CW)
// Machining statements:
N008 G00 X0 Y0 Z5 (Start Point X & Y Work zero point and 5 mm above the Z 0 point) {Rapid traverse}
G00 X75 (Move to P1)
N010 M07 (Coolant ON)
N011 G01 Z-10 F150 (Depth of cut)(Linear interpolation and Feed)
N012 G01 X185 (Move to P2)
G01 Y70 (Move to P3)
N014 G01 X145 (Move to P4)
N015 G02 X115 Y70 R15 (Move to P5)
N016 G01 X75 (P6)
N017 G01 Y0 (P1)
N018 G00 Z5 (Move tool 5 mm above the Work zero for safety)
// Closing statements:
N019 G91 G28 Z0 (Home Position)
N020 G28 X0 Y0
N021 M05 M09 (Spindle off , Coolant off)


Thanks for the info!