Since last 25 years,CAD/CAM technology have been impacting the design,drafting and manufacturing of products significantly .CAD/CAM departments are now visible in many engineering industries like automobiles,Machine Tools ,Design etc.All mass production industries are headed towards computer integrated manufacturing which uses flexible automation including technology.Nowadays not only it is being used in industries but also DIY projects are being incorporated with the help of CAD/CAM. CNC being a part of CAD/CAM it is necessary to understand basics.In this instructables we are going to learn about CNC and its basic programming for milling operation.




Grade 9 +


Basic knowledge of Cartesian coordinate system

Basic knowledge of operation of computer

Basic knowledge of Fusion 360(optional)


  • Notebook
  • Pencil/Pen
  • Ruler
  • Personal computer with internet connection.
  • Fusion 360(optional)

Step 1: What Is CNC?

Computer Numerical Control (CNC) is a method of automating control of machine tools through the use of software embedded in a microcomputer attached to the tool.With CNC, each object to be manufactured gets a custom computer program, usually written in an international standard language called G-code, stored in and executed by the machine control unit(MCU).The program contains the instructions and parameters the machine tool will follow,such as the feed rate of materials and the positioning and speed of the tool's components.Mills,lathes,routers,laser cutters are common machine tools whose operations can be automated with CNC. It can also be used to control non-machine tools,such as welding, electronic assembly machines. CNC is considered to provide more precision, complexity and repeatability than is possible with manual machining. Other benefits include greater accuracy, speed and flexibility, as well as capabilities such as contour machining, which allows milling of contoured shapes, including those produced in 3D designs.

Step 2: History of CNC Machining

CNC machining uses a machining technique that was developed in the 18th Century. In fact, the first ‘turning the machine with a metal frame’ was invented in 1751, the first of a long series of machines aiming to create more precise operations mechanically than are possible by handcrafted techniques. This marked the beginning of industrialization.

However, it was not until the Cold War that the development of automation was addressed. At that time, the company Parsons Works was commissioned by the U.S. Navy to increase the productivity of its production line for helicopter blades. John T. Parsons then motorised the axes of the machines for making these blades. Working with IBM, he studied the possibilities of controlling these machines by computer. This was the starting point of the CNC machining method. In 1952, Richard Kegg, in collaboration with MIT, developed the first CNC milling machine: the Cincinnati Milacron Hydrotel. Five years later, in 1958, he filed a patent for a “Motor Controlled Apparatus for Positioning Machine Tool”. This was the commercial birth of this technology.

The First NC Machine Tool Manufactured in Europe 1956 which can be seen in second picture.

Step 3: Components of CNC

The main components of CNC are:

  1. Input Devices: These are the devices which are used to input the part program in the CNC machine. There are three commonly used input devices and these are punch tape reader, magnetic tape reader and computer via RS-232-C communication.
  2. Machine Control Unit (MCU): It is the heart of the CNC machine. It performs all the controlling action of the CNC machine.
  3. Machine Tool: A CNC machine tool always has a slide table and a spindle to control of the position and speed. The machine table is controlled in X and Y axis direction and the spindle is controlled in the Z axis direction.Depending upon the operation to be performed,the tool can be selected from tool turret.Major type of tools used in milling operation are shown in the second picture.
  4. Driving System: The driving system of a CNC machine consists of amplifier circuits, drive motors and ball lead screw. The MCU feeds the signals (i.e. of position and speed) of each axis to the amplifier circuits. The control signals are than augmented (increased) to actuate the drive motors. And the actuated drive motors rotate the ball lead screw to position the machine table.
  5. Feedback System: This system consists of transducers that acts like sensors. It is also called as measuring system. It contains position and speed transducers that continuously monitor the position and speed of the cutting tool located at any instant. The MCU receives the signals from these transducers and it uses the difference between the reference signals and feedback signals to generate the control signals for correcting the position and speed errors.
  6. Display Unit: A monitor is used to display the programs, commands and other useful data of CNC machine.

Step 4: Working of CNC Machine

First, the part program is inserted into the MCU of the CNC. In MCU all the data process takes place and according to the program prepared, it prepares all the motion commands and sends it to the driving system.The drive system works as the motion commands are sent by MCU. The drive system controls the motion and velocity of the machine tool.The feedback system records the position and velocity measurement of the machine tool and sends a feedback signal to the MCU. In MCU, the feedback signals are compared with the reference signals and if there are errors, it corrects it and sends new signals to the machine tool for the right operation to happen.A display unit is used to see all the commands, programs and other important data. It acts as the eye of the machine.

Step 5: Part Program

The part program is a sequence of instructions, which describe the work, which has to be done on a part, in the form required by a computer under the control of computer numerical control (CNC) software. It is the task of preparing a program sheet from a drawing sheet. All data is fed into the CNC system using a standardized format. Programming is where all the machining data are compiled and where the data are translated into a language which can be understood by the control system of the machine tool.The part program is usually written in an international standard language called G-code.

Before the invention of part programming punched tapes were used to program NC machine.Punched tape or perforated paper tape is a form of data storage, consisting of a long strip of paper in which holes are punched to store data. Now effectively obsolete, it was widely used during much of the twentieth century for teleprinter communication, for input to computers of the 1950s and 1960s, and later as a storage medium for minicomputers and CNC machine tools.

Step 6: What Are G and M Codes?

G-code was first established in the 1960s by the Electronics Industry Association (EIA). While the official language was documented as RS-274D, you’ll hear everyone refer to it as G-code. Why? Many of the words, or individual pieces of code, that make up this machine-based language start with the letter G.

M codes are machine codes that might differ between CNC machines. These codes control functions on your CNC machine like coolant and spindle directions.

A line of g-code is commonly called a “Block”.

The sequence of a G-code block is shown below:

G01 X1 Y1 F20 T01 M03 S500

Multiple line of G-code combine together to form a complete CNC program.

Step 7: Codes


Codes and Description:

G00:-Rapid positioning

G01:-Linear interpolation

G02:-Circular interpolation, clockwise

G03:-Circular interpolation, counterclockwise

G17:-XY plane selection

G18:-ZX plane selection

G19:-YZ plane selection

G20:-Programming in inches

G21:-Programming in millimeters (mm)

G28:-Return to home position

G40:-Tool radius compensation off

G41:-Tool radius compensation left

G42:-Tool radius compensation right

G43:-Tool height offset compensation negative

G44:-Tool height offset compensation positive

G49:-Tool length offset compensation cancel

G50:-Scaling function cancel

G80:-Cancel canned cycle

G90:-Absolute programming

G91:-Incremental programming

G92:-Position register

M Codes:

Codes and Description:

M00:-Compulsory stop

M02:-End of program

M03:-Spindle on (clockwise rotation)

M04:-Spindle on (counterclockwise rotation)

M05:-Spindle stop

M06:-Automatic tool change (ATC)

M07:-Coolant on (mist)

M08:-Coolant on (flood)

M09:-Coolant off

M30:-End of program

Additional codes:

Codes and Description:

T:-Tool selection

F:-Feed rate

S:-Spindle speed

R:-Radius of curve

D:-Diameter of tool

Step 8: Difference Between Absolute and Incremental Programming

Before proceeding further to part programming let us understand the difference between absolute and incremental programming.

Absolute programming:-

In Cartesian coordinate geometry system using absolute measurement, each point is always specified using same zero established for a given coordinate system, as shown in first figure.

Incremental programming:-

In Cartesian coordinate geometry system using incremental measurement, each point is specified using the reference of the preceding point position, as shown in second figure.

Step 9: Zero Points and Reference Points

1.Machine zero point:

  • The machine zero point (M) is the machine reference position or the origin of machine coordinate system.
  • Machine zero is also the position in which all tool changes take place. Therefore,for tool changing operation machine must be positioned at machine zero.

2. Workpiece zero point:

  • Starting point for the dimensions in the part program.It can be freely established by the programmer and moved as desired within the part program.

3.Machine reference point:

  • The machine reference point (R) of the machine is determined by measuring systems. It is essential to know the distance between R and M in order to relate the position of the axis to that of the reference point.

Step 10: Part Programming Example

lets take an example to understand properly how the program is written.

The question is shown in the first and second picture with specified dimensions when viewed from top and front respectively.

Note:(I am using metric measuring system you can use inch if you are accustomed with imperial measuring system.)

Now before starting the part program let us assign the coordinates of the points in the geometry given,which can be seen in figure 3,this will help us while writing the X and Y coordinates in the part program.

We will be using absolute programming method for this example.

STEP i:Setting the starting parameters

G00 G90 G21 G17 G94 G42 Z10 D10 (comments)

G00 X0 Y0 S500 M3

We are going to proceed in anticlockwise direction.

The surface of the workpiece acts as origin for z-axis.

Comments can be written in brackets which will not affect the code.

The tool is set to a height of 100mm from the surface of the workpiece to avoid any interference by assigning Z10.

Now,G00 in first and second block represents rapid linear interpolation.

since we are using absolute programming method with metric measurement system G90 and G21 are assigned respectively. G17 is used to assign XY plane .G94 to provide feed rate per minute.

It is necessary to calculate the cutter path by offsetting the contour by an amount equal to the radius of the cutter.

G42 is used when when the cutter is on the right side of the programmed tool path when looking in the direction of the tool movement.

let us assume the cutter radius to be 5 mm. Hence D10 will be used to denote the cutter tool with radius of 5 mm

In the second block the cutter tool is rapid interpolated on the origin of the geometry with the use of G00 code by assigning X0 Y0 as the position of the cutter.

S500 is used to assign the speed of spindle in r.p.m(rotation per minute) now to start the spindle in clockwise direction M3 is used.

STEP ii:linear interpolation

G00 X20 Y0

G01 Z-20 F100

G01 X80 Y0

G01 X100 Y20

The cutter tool is now rapid interpolated to the first point i.e. intersection of curve of radius 20 mm and horizontal line.

G01 is used for controlled rate interpolation which depends on feed rate (F).

Since the thickness of the workpiece is 20mm,the cutter is now moved in vertical downward direction at a distance of 20mm.

The cutting process has now started.

The cutter us now interpolated to the second point i.e. at he intersection of horizontal line and slant line.

Now you must be wondering that there might be a different G-code for slant interpolation well there isn't the same linear interpolation can be used for slant lines.

After the slant interpolation the cutter now proceeds in a vertical direction till the intersection of a curve and vertical line.

STEP iii:Circular interpolation

G03 X80 Y100 R20 F40

G03 is used for anticlockwise interpolation.Note here that the X Y coordinates in part program after G03 are the end point of curve with R as radius of the curve.

Some CNC software might not recognize the above block then try the block written below:

G03 X80 Y100 I20 J0 F40

Here I denotes the distance between the center of the curve and the starting point of the curve in horizontal direction and J denotes the distance between the center of the curve and the starting point of the curve in vertical direction.Since the distance between the center and start point is only in vertical direction J will be equal to zero.

While interpolating in circular direction make sure to reduce the feed rate.

STEP iv:Linear interpolation

G01 X0 Y100

GO1 X0 Y20

This will be same as explained above

STEP v:Circular interpolation

G02 X20 Y0 R20 F40

This will be same as explained in step iii.Here the I value will be zero and J value will be 20 if we are using the alternate method.

STEP vi:End

G01 Z5


Moving the tool away from the work piece.

M30 is used to end the program.

STEP vii:Compiled program

G00 G90 G21 G17 G94 G42 Z10 D10

G00 X0 Y0 S500 M3

G01 X20 Y0 F100

G01 Z-20

G01 X80 Y0

G01 X100 Y20

G01 X100 Y80

G03 X80 Y100 R20 F40

G01 X0 Y100

G01 X0 Y20

G02 X20 Y0 R20 F40

GO1 Z10


STEP viii:Simulation

The above program can be simulated in the web browser click the link given below:

Erase the program that comes typed on the left-hand window.Copy the program written in step vii paste it in the left-hand window the output will be simulated on the right hand pane when simulate button is pressed.

Step 11: Simulation in Fusion 360(optional)

STEP i: Creating model in fusion 360

Create the model with dimensions same as example question we did in part programming step and extrude to a height of 20mm.

Now click on the model tab on left side of the interface and then click on the cam option

STEP ii: New setup

Click on setup scroll down option and select new setup.

STEP iii: Setting origin point

A series of dots will appear on the surface of the model select the dot which will act as origin and click ok.

STEP iv:Selecting the type of operation and tool

Select 2D contouring option from 2D scroll down option

Now click on tool select option and select the tool.Since selection of tool is out of scope for our syllabus,select any Flat Endmill tool with diameter less than 12mm and overall length greater than 40 mm(I am selecting 3/8" Flat Endmill cutter) and then click ok.

STEP v:Selecting the contour Geometry

Select upper and lower edge of the model and then select ok.

STEP vi:Simulating

Click on the simulate icon as shown in the picture and press the play button to play the simulation video.

Disclaimer:The above steps should not be used to do the actual machining since various parameters are being assumed to do the simulation.A depth field study must be done before proceeding to machining operation.


Cover image

CNC history image

What is cnc

CNC history

Components of CNC

Milling cutter tools


Farazdak Haideri(2008).CAD/CAM and Automation.Maharashtra:NIRALI PRAKASHAN.

R.B.Patil,Neha Patil.(2019).CAD/CAM/CAE.Maharashtra:TechKnowledge Publications.

CNC Contest

Participated in the
CNC Contest