Introduction
A CNC program is a set of
instructions written in G-code and M-code that tells a CNC machine what to do,
how to do it, and in what sequence to be done. Every CNC program follows a fixed
structure so that the machine can read and execute it correctly without errors.
If the program is not written properly, then it ends up with an accident. That means
the turret might hit the chuck.
The following are the parts of the
program structure.
1. Program Number (Program Identification)
Every CNC program starts with a program number, which helps
the machine and operator identify the program.
Example:
O0001
- O
means program
- 0001
is the program number
- Each
program must have a unique number
2. Safety Block (Initial Setup Block)
The safety block prepares the machine for safe operation and
avoids accidental movement.
Example:
G21 G17 G90 G40 G49 G80
Explanation:
- G21
– Metric system (mm)
- G17
– XY plane selection
- G90
– Absolute programming
- G40
– Cancel cutter radius compensation
- G49
– Cancel tool length compensation
- G80
– Cancel canned cycles
This block ensures
the machine starts in a known and safe condition.
3. Work Coordinate System Selection
This tells the machine where the job zero is located.
Example:
G54
- G54
to G59 are work offsets
- Helps
in accurate machining
4. Tool Selection and Tool Change
The machine is instructed to select and change the required
tool. The turret rotates and points out the required tool towards the workpiece
in the chuck.
Example:
T01 M06
- T01
– Tool number 1
- M06
– Tool change command
5. Spindle Speed and Direction
This block controls the rotation of the spindle.
Example:
S1200 M03
- S1200
– Spindle speed (RPM)
- M03
– Spindle ON clockwise
- M04
– Counter-clockwise
- M05
– Spindle stop
6. Feed Rate Command
Feed rate defines how fast the tool moves while cutting.
Example:
F150
- F150
– Feed rate in mm/min
- Correct
feed rate ensures good surface finish and tool life
7. Rapid Positioning (Non-Cutting Movement)
Used to move the tool quickly without cutting.
Example:
G00 X0 Y0 Z5
- The
tool moves fast to the specified position
- Used
for approach and retract
8. Cutting Movement (Linear Interpolation)
Actual cutting is done using linear movement.
Example:
G01 X50 Y0 Z-2 F150
- G01
– Linear cutting movement
- Tool
moves at feed rate
- Used
for straight cuts
9. Circular Interpolation (Arc Cutting)
Used for machining circles and arcs.
Example:
G02 X40 Y40 I20 J0
- G02
– Clockwise arc
- G03
– Counter-clockwise arc
- I
and J define arc centre
10. Coolant Control
Coolant helps in cooling the tool and removing chips.
Example:
M08
- M08
– Coolant ON
- M09
– Coolant OFF
11. Program Repetition
Used when the same machining operation is repeated.
Example:
M98 P0100
- Calls
subprogram
- Saves
programming time
12. Tool Retraction and Spindle Stop
After machining, the tool is safely moved away.
Example:
G00 Z50
M05
- Tool
moves up
- Spindle
stops
13. Program End and Reset
Marks the end of the CNC program.
Example:
M30
- Ends
the program
- Resets
for next cycle
Complete Sample CNC Program (Structure)
O0001;
G21 G17 G90 G40 G49 G80;
G54;
T0101;
S1200 M03
F150;
G00 X0 Y0 Z5;
G01 Z-2;
G01 X50;
G01 Y50;
G00 Z5;
M05;
M30;
Summary of CNC Program Structure
- Program
number
- Safety
block
- Work
coordinate selection
- Tool
selection
- Spindle
and feed commands
- Rapid
movement
- Cutting
movements
- Coolant
control
- Tool
retraction
- Program
end
Conclusion:
A proper CNC programming
structure makes machining easier and safer. When the program is written step by
step in order, the machine works correctly and gives accurate parts. It also
helps operators understand the program quickly and easily correct mistakes.
Overall, a well-structured CNC program saves time, reduces errors, and improves
work quality.
