CNC Programming
(S.S. BISWAL)
What is CNC ?
CNC which stands for Computer Numerical Control refers to the
automation of machine tools using pre-programmed computer software.
It is a technology used in manufacturing where computers control
machine tools such as lathes, mills, routers, and grinders. CNC
machines follow programmed instructions (called G-code & M-code)
to perform precise cutting, shaping, drilling, or milling tasks on
materials like metal, plastic, or wood.
Where CNC Machines Are Used?
CNC machines are widely used across various industries for precision machining,
mass production, and custom part manufacturing. Here are the key areas and
industries where CNC machines are commonly used:
🏭 1. Manufacturing Industry
🚗 2. Automotive Industry
✈️ 3. Aerospace Industry
🏥 4. Medical Industry
🧰 5. Tool and Die Making
🧰 6. Furniture and Woodworking
📱 7. Electronics Industry
🏗️ 8. Construction & Architecture
🎓 9. Education & Research
✅Difference Between Conventional Machine and
CNC Machine.
Feature Conventional Machine CNC Machine
Operation Operated manually Controlled by computer program (G-code)
Accuracy Depends on operator skill (LOW Accuracy) High precision, Accuracy and repeatability
Production Speed Slower, especially for complex parts Faster, especially for repetitive tasks
Complex Shapes Easily produces complex and 3D shapes
Difficult to achieve
Skill Requirement Requires high manual skills Requires programming knowledge
Setup Time Takes more time to set manually Faster setup using saved programs
Automation Fully or semi-automated
No automation – fully manual
Cost Lower Machine cost & Maintenance cost Higher Machine & Maintenance cost, but
better long-term value
Maintenance Easier and cheaper Requires skilled maintenance and diagnostics
Types of CNC Machines
1. CNC Lathe Machine
Rotates the workpiece while cutting tools shape it. Used for
cylindrical or round parts.
2. CNC Milling Machine
Uses rotary cutters to remove material from a workpiece. Ideal
for drilling, slotting, and shaping.
3. CNC Router
Similar to milling machines but mostly used for cutting wood,
plastics, and soft metals. Common in furniture and signage.
4. CNC Plasma Cutter
Uses a high-temperature plasma torch to cut metal sheets. Fast
and efficient for cutting thick materials.
5. CNC Laser Cutter
Uses a laser beam to cut or engrave materials like metal, wood,
acrylic, or plastic with high precision.
6. CNC EDM (Electrical Discharge Machine)
Uses electric sparks to remove material from hard metals. Ideal
for mold and die making.
7. CNC Grinding Machine
Uses a rotating grinding wheel to finish the surface of a
workpiece with high accuracy.
8. CNC Drilling Machine
Specializes in drilling holes at precise depths and angles. Often
part of a multi-function CNC setup.
9. CNC 3D Printer (Additive CNC)
Builds objects layer by layer using materials like plastic or resin.
Mostly used for prototyping.
10. CNC Waterjet Cutter
Uses high-pressure water (sometimes with abrasive) to cut
through materials like stone, metal, and glass.
CNC Lathe
What is a CNC Lathe?
A CNC Lathe is a Computer Numerical Control machine used to perform
turning operations on a workpiece. It spins the material (usually cylindrical) on
a rotating spindle, while computer-controlled cutting tools remove material to
create precise shapes and dimensions.
🛠️ Key Features:
The workpiece rotates, while the cutting tool moves in linear directions
(X and Z axes).
Controlled by G-code instructions programmed into the CNC system.
Ideal for making round / cylindrical, conical, or threaded parts.
Operations on a CNC Lathe Machine
1. . Facing
Cutting the end of the workpiece to make it flat and smooth.
2. Turning
Reducing the diameter of the workpiece along its length. Can be
straight, taper, or contour turning.
3. Parting (Cut-off)
Cutting a part off from the remaining material using a parting tool.
4. Drilling-
Creating a hole at the center of the rotating workpiece using a drill
bit.
5. Boring-
Enlarging an existing hole with better accuracy.
6. Threading
Cutting external or internal threads (e.g., for bolts or nuts).
7. Grooving
Cutting a narrow groove or recess on the surface or inside a hole.
8. Knurling
Producing a textured pattern on the surface for grip (often seen on
handles).
9. Taper Turning
Creating a conical shape by gradually reducing the diameter.
10. Chamfering
Cutting a beveled edge at the end of the workpiece, usually at 45°.
What is G-code and M-code?
G-code (Geometric codes) and M-code (Miscellaneous codes)
are programming languages used in Computer Numerical Control (CNC)
machining to control the movements and functions of machines. G-code
primarily controls the machine's movements (e.g., linear, circular
interpolation) and path, while M-code manages miscellaneous functions
(e.g., spindle start/stop, coolant control). Think of G-code as the
"geometry" and M-code as the "machine" or "miscellaneous" commands.
G-code Functions
G00 rapid positioning
(Rapid non-cutting movement)
G01 Linear interpolation
(cutting straight lines at set feed rate)
G02 Circular interpolation
(clockwise arc)
G03 Circular interpolation
(counter-clockwise arc)
G20 Programming in inches
G21 Programming in millimeters
G28 Return to machine home position
G54-G59 Refers to work origin position
G70 Finishing Cycle used after
G71, G72, G73
G71 Roughing cycle/ Step Turning
G72 Facing cycle
G73 Pattern repeating cycle
G74 Drilling Cycle
G75 Grooving / Parting Cycle
G76 Threading cycle
G90 Absolute positioning mode
(coordinates measured from fixed origin)
G91 Incremental positioning mode
(relative to current position)
G94 Feed in mm/min
G95 Feed in mm/rev
G97 Cancel Constant surface speed (CSS)
M-code Functions
M00 Program Stop
M01 Optional Program Stop
M02 Program End
M03 Spindle Start Clockwise (CW)
M04 Spindle Start Counterclockwise (CCW)
M05 Spindle Stop
M06 Tool Change (T)
M08 Coolant ON
M09 Coolant OFF
M30 Program End and Reset
Structure of a CNC program
1. Program Header
Starts with the Program Number.
Name Optional
Example – O0001(Name) Start in (O)
2. Start-up Program
Sets up a safe starting condition.
Tool Call & Offset Setting.
Cancels previous offsets, modes, Units and spindle commands.
Example –
G0 G28 U0.0 W0.0
T00202
G97 G21 M04 S1500
3. Profile Program
Machining Operations is based on the given part drawing.
Canned Cycles (Optional)
Example –
G0 Z1
G0 X12
G01 Z-15
G01 X16
G01 Z-30
G01 X20
G01 Z-45
G01 X24
G01 Z-60
G01 X27
4. End of the Program
Return to Safe Position & End
Example –
G00 x40.0
M05
G28 U0 W0
M30
Programming Examples
O0001
G0 G28 U0 W0
T0202
G97 G21 M04 S1300
G0 Z1
G0 X27
G71 U0.3 R2
G71 P10 Q20 U0.5 W0.0 F90
N10 G01 X0 Y0
G03 X8 Z-8 R8
USER ADDRESS
G01 Z-10
G71 U0.3 R5
G03 X12 Z-12 R2
U0.3 = Each Depth of cut
G01 Z-20
R= Retract distance
G01 X14
G71 P10 Q20 U0.5 W0.0 F60
G01 Z-30
P1= Start Line
G01 X16
Q= End Line
G01 Z-40
U= Stock in X- axis
N20 G01 X27
W= Stock in Z- axis
G00 X35
F= Feed
M05
G71= Roughing cycle
G0 G28 U0 W0
G70= Finishing Cycle
M30
(G70) Finishing cycle
G0 G28 U0 W0
T0202
G97 G21 M04 S1700
G0 X30 Z1.0
G70 P10 Q20 F50
G0 X35.0
M05
G0G28 U0 W0
M30
EXPERIMENTS- 1
EXPERIMENTS- 2