Chapter 4
CNC Part Programming
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Reference systems
 M - Machine Zero or home: This is set by the
manufacturer as the origin of the coordinate system of the
machine.
Prepared by: Prof. Rahul Thaker (ACET)
Reference systems
W - Part zero or point of origin of the part: This is the
origin point that is set for programming the measurements of
the part. It can be freely selected by the programmer.
 R - Machine Reference point : This is a point on the
machine established by the manufacturer around which the
synchronization of the system is done. The control positions
the axis on this point.
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
CNC PROGRAMMING
CNC is the part program is a set of encoding information,
giving co-ordinates and other details to indicate how a tool
should move in a relation to a work piece in a machine
should perform desirable operation on the job. CNC controls
will be the program and execute the operations. The program
is prepared by co-ordinate values (XYZ) of the entire tool
path as suited to machine to complete the component and it
also contains the following basic information.
•Preparatory function (G code)
•Miscellaneous function (M code)
•Spindle speed (S)
•Feed rate (F)
•Tool number (T)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Programming Key Letters
O - Program number (Used for program identification)
N - Sequence number (Used for line identification)
G - Preparatory function
X - X axis designation
Y - Y axis designation
Z - Z axis designation
R - Radius designation
F – Feed rate designation
S - Spindle speed designation
H - Tool length offset designation
D - Tool radius offset designation
T - Tool Designation
M - Miscellaneous function
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Word Address 1
N – Sequence or line number
• A tag that identifies the beginning of a block of
code. It is used by operators to locate specific lines of a
program when entering data or verifying the program
operation.
G – Preparatory function
• G words specify the mode in which the milling
machine is to move along its programmed axes.
Prepared by: Prof. Rahul Thaker (ACET)
Word Address 2
• Dimension Words
X – Distance or position in X direction
Y – Distance or position in Y direction
Z – Distance or position in Z direction
• M – Miscellaneous functions
• M words specify CNC machine functions not
related to dimensions or axial movements.
Prepared by: Prof. Rahul Thaker (ACET)
Word Address 3
• F – Feed rate (inches per minute or millimeters per
minute)
The feed function F is the speed at which the tool center
point moves.
The programmed F is effective working in linear (G01) or
circular (G02, G03).
The maximum F value is limited by the machine parameters.
Rate at which cutting tool moves along an axis.
• S – Spindle speed (rpm – revolutions per minute)
Controls spindle rotation speed.
• T – Tool number
Specifies tool to be selected.Prepared by: Prof. Rahul Thaker (ACET)
Word Address 4
• I – Circular cutting reference for x axis
• J – Circular cutting reference for y axis
• K – Circular cutting reference for z axis
Prepared by: Prof. Rahul Thaker (ACET)
G Word
• G words or codes tell the machine to perform
certain functions. Most G words are modal
which means they remain in effect until
replaced by another modal G code.
Prepared by: Prof. Rahul Thaker (ACET)
Common G Codes
• G00 – Rapid positioning mode
• Tool is moved along the shortest route to
programmed X,Y,Z position. Usually NOT used
for cutting.
• G01 – Linear Interpolation mode
• Tool is moved along a straight-line path at
programmed rate of speed.
• G02 – Circular motion clockwise (cw)
• G03 – Circular motion counter clockwise (ccw)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Common G Codes, con.,
• G17 – XY plane
• G18 – XZ plane
• G19 – YZ plane
• G20 – Inch Mode
• G21 – Metric Mode
• G28 – Return to axis machine Zero (Home)
Prepared by: Prof. Rahul Thaker (ACET)
G Codes: G90, G91
G90 – Absolute Coordinate Reference
References the next position from an absolute zero
point which is set once for the entire program.
G91 – Incremental Coordinate Reference
References the next position from the previous
position.
Prepared by: Prof. Rahul Thaker (ACET)
G Codes: Cutter Compensation
• G40 – Cancel cutter diameter compensation.
• G41 – Cutter compensation left.
• G42 – Cutter compensation right.
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
M Word
• M words tell the machine to perform certain
machine related functions, such as: turn
spindle on/off, coolant on/off, or stop/end
program.
Professional Development ID Code: 6006
Prepared by: Prof. Rahul Thaker (ACET)
Common M words
• M00 – Programmed pause
• Automatically stops machine until operator pushes a button
to resume program.
• M01 – Optional stop
• A stop acted upon by the machine when operator has
signaled this command by pushing a button.
• M02 – End of program
• Stops program when all lines of code are completed. Must
be last command in program.
Prepared by: Prof. Rahul Thaker (ACET)
Common M words
• M03 – Turn spindle on
• In clockwise direction
• M04 – Turn spindle on
• In counter clockwise direction
• M05 – Stop spindle
• Usually used prior to tool change or at end of program.
• M06 – Tool change
• Stops program and calls for a tool change, either
automatically or manually.
Prepared by: Prof. Rahul Thaker (ACET)
Common M words
• M08 – Turns Accessory 1 on.
• M09 – Turns Accessory 1 off.
• M10 – Turns Accessory 2 on.
• M11 – Turns Accessory 2 off.
• M30 – End of program
• Similar to M02 but M30 will also “rewind” the
program. Must be last statement in program. If used, DO
NOT use M02.
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
N02 G21 Metric programming
N03 M03 S1000 Spindle start clockwise with 1000rpm
N04 G00 X0 Y0 Rapid motion towards (0,0)
N05 G00 Z-10.0 Rapid motion towards Z=-10 plane
N06 G01 X50.0 Linear interpolation
N07 G01 Y20.0 Linear interpolation
N08 G02 X25.0
Y45.0 R25.0 Circular interpolation clockwise(cw)
N09 G03 X-25.0
Y45.0 R25.0 Circular interpolation counter clockwise(ccw)
N10 G02 X-50.0
Y20.0 R25.0 Circular interpolation clockwise(cw)
N11 G01 Y0.0 Linear interpolation
N12 G01 X0.0 Linear interpolation
N13 G00 Z10.0 Rapid motion towards Z=10 plane
N14 M05 M09 Spindle stop and program end
EXAMPLE
Prepared by: Prof. Rahul Thaker (ACET)
N01 G91 G71 M03 S800 (incremental mode,metric, spindle start with a speed of 800 rpm)
N02 G00 X1.0 (tool away from work piece 1mm, rapid)
N03 G00 Z-1.0 (tool to left 1mm for facing)
N04 G01 X-16.0 F200 (facing cut at a feed rate 200mm/min)
N05 G00 Z1.0 (move tool to right 1mm from that position)
N06 G00 X10.0 (move 10 mm away from the centre in x direction)
N07G01 Z-36.0 (plane turning over a length of 35 mm)
N08 G01 X5.0 Z-30.0 (simultaneous movement in X and Z directions for taper turning)
N09 G00 X1.0 Z66.0 (move to the starting position)
N10 M02 (end of program) Prepared by: Prof. Rahul Thaker (ACET)
N01 G90 G71 M03 S800 (absolute, metric, start spindle at a speed 800 rpm)
N02 G00 X0.0 Y0.0 (move tool to the beginning of cut)
N03 G02 X10.0 Z-10.0 I 0.0 K-10.0 F150 (clockwise circular interpolation, I&K are
offsets, feed rate 150mm/min)
N04 G00 Z-30.0 (move from point B to point C)
N05 G03 X15.0 Z-35.0 I5.0 K0.0 (counterclockwise interpolation, I&K are
offsets, move to point D)
N06 M02 (end of program)
Prepared by: Prof. Rahul Thaker (ACET)
Subroutines
 Any frequently programmed order of instruction or
unchanging sequences can benefit by becoming a subprogram.
Typical applications for subprogram applications in CNC
programming are :
• Repetitive machining motions
• Functions relating to tool change
• Hole patterns
• Grooves and threads
• Machine warm-up routines
• Pallet changing
• Special functions and others
Prepared by: Prof. Rahul Thaker (ACET)
Subroutines
 Structurally, subprograms are similar to standard programs. They use the same
syntax rules. The benefits of subroutines involve the reduction in length of
program, and reduction in program errors. There is a definition statement and
subroutine call function.
Standard sub-routine
N10
N20
N30
….
N70 G22 N5
N80
N90
….
N100 G24
….
N160 G20 N5
 In the above example G22 statement defines the start block of the sub-routine and G24
marks the end of the sub-routine statement. The subroutine is called by another code
G20 identified by the label N5.Prepared by: Prof. Rahul Thaker (ACET)
Canned Cycles
A canned cycle is a preprogrammed sequence of events
/ motions of tool / spindle stored in memory of
controller. Every canned cycle has a format. Canned
cycle is modal in nature and remains activated until
cancelled. Canned cycles are a great resource to make
manual programming easier. Often underutilized,
canned cycles save time and effort.
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)
Prepared by: Prof. Rahul Thaker (ACET)

Chapter 4 cnc part programming

  • 1.
    Chapter 4 CNC PartProgramming Prepared by: Prof. Rahul Thaker (ACET) Prepared by: Prof. Rahul Thaker (ACET)
  • 2.
    Reference systems  M- Machine Zero or home: This is set by the manufacturer as the origin of the coordinate system of the machine. Prepared by: Prof. Rahul Thaker (ACET)
  • 3.
    Reference systems W -Part zero or point of origin of the part: This is the origin point that is set for programming the measurements of the part. It can be freely selected by the programmer.  R - Machine Reference point : This is a point on the machine established by the manufacturer around which the synchronization of the system is done. The control positions the axis on this point. Prepared by: Prof. Rahul Thaker (ACET)
  • 4.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 5.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 6.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 7.
    CNC PROGRAMMING CNC isthe part program is a set of encoding information, giving co-ordinates and other details to indicate how a tool should move in a relation to a work piece in a machine should perform desirable operation on the job. CNC controls will be the program and execute the operations. The program is prepared by co-ordinate values (XYZ) of the entire tool path as suited to machine to complete the component and it also contains the following basic information. •Preparatory function (G code) •Miscellaneous function (M code) •Spindle speed (S) •Feed rate (F) •Tool number (T) Prepared by: Prof. Rahul Thaker (ACET)
  • 8.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 9.
    Programming Key Letters O- Program number (Used for program identification) N - Sequence number (Used for line identification) G - Preparatory function X - X axis designation Y - Y axis designation Z - Z axis designation R - Radius designation F – Feed rate designation S - Spindle speed designation H - Tool length offset designation D - Tool radius offset designation T - Tool Designation M - Miscellaneous function Prepared by: Prof. Rahul Thaker (ACET)
  • 10.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 11.
    Word Address 1 N– Sequence or line number • A tag that identifies the beginning of a block of code. It is used by operators to locate specific lines of a program when entering data or verifying the program operation. G – Preparatory function • G words specify the mode in which the milling machine is to move along its programmed axes. Prepared by: Prof. Rahul Thaker (ACET)
  • 12.
    Word Address 2 •Dimension Words X – Distance or position in X direction Y – Distance or position in Y direction Z – Distance or position in Z direction • M – Miscellaneous functions • M words specify CNC machine functions not related to dimensions or axial movements. Prepared by: Prof. Rahul Thaker (ACET)
  • 13.
    Word Address 3 •F – Feed rate (inches per minute or millimeters per minute) The feed function F is the speed at which the tool center point moves. The programmed F is effective working in linear (G01) or circular (G02, G03). The maximum F value is limited by the machine parameters. Rate at which cutting tool moves along an axis. • S – Spindle speed (rpm – revolutions per minute) Controls spindle rotation speed. • T – Tool number Specifies tool to be selected.Prepared by: Prof. Rahul Thaker (ACET)
  • 14.
    Word Address 4 •I – Circular cutting reference for x axis • J – Circular cutting reference for y axis • K – Circular cutting reference for z axis Prepared by: Prof. Rahul Thaker (ACET)
  • 15.
    G Word • Gwords or codes tell the machine to perform certain functions. Most G words are modal which means they remain in effect until replaced by another modal G code. Prepared by: Prof. Rahul Thaker (ACET)
  • 16.
    Common G Codes •G00 – Rapid positioning mode • Tool is moved along the shortest route to programmed X,Y,Z position. Usually NOT used for cutting. • G01 – Linear Interpolation mode • Tool is moved along a straight-line path at programmed rate of speed. • G02 – Circular motion clockwise (cw) • G03 – Circular motion counter clockwise (ccw) Prepared by: Prof. Rahul Thaker (ACET)
  • 17.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 18.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 19.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 20.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 21.
    Common G Codes,con., • G17 – XY plane • G18 – XZ plane • G19 – YZ plane • G20 – Inch Mode • G21 – Metric Mode • G28 – Return to axis machine Zero (Home) Prepared by: Prof. Rahul Thaker (ACET)
  • 22.
    G Codes: G90,G91 G90 – Absolute Coordinate Reference References the next position from an absolute zero point which is set once for the entire program. G91 – Incremental Coordinate Reference References the next position from the previous position. Prepared by: Prof. Rahul Thaker (ACET)
  • 23.
    G Codes: CutterCompensation • G40 – Cancel cutter diameter compensation. • G41 – Cutter compensation left. • G42 – Cutter compensation right. Prepared by: Prof. Rahul Thaker (ACET)
  • 24.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 25.
    M Word • Mwords tell the machine to perform certain machine related functions, such as: turn spindle on/off, coolant on/off, or stop/end program. Professional Development ID Code: 6006 Prepared by: Prof. Rahul Thaker (ACET)
  • 26.
    Common M words •M00 – Programmed pause • Automatically stops machine until operator pushes a button to resume program. • M01 – Optional stop • A stop acted upon by the machine when operator has signaled this command by pushing a button. • M02 – End of program • Stops program when all lines of code are completed. Must be last command in program. Prepared by: Prof. Rahul Thaker (ACET)
  • 27.
    Common M words •M03 – Turn spindle on • In clockwise direction • M04 – Turn spindle on • In counter clockwise direction • M05 – Stop spindle • Usually used prior to tool change or at end of program. • M06 – Tool change • Stops program and calls for a tool change, either automatically or manually. Prepared by: Prof. Rahul Thaker (ACET)
  • 28.
    Common M words •M08 – Turns Accessory 1 on. • M09 – Turns Accessory 1 off. • M10 – Turns Accessory 2 on. • M11 – Turns Accessory 2 off. • M30 – End of program • Similar to M02 but M30 will also “rewind” the program. Must be last statement in program. If used, DO NOT use M02. Prepared by: Prof. Rahul Thaker (ACET)
  • 29.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 30.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 31.
    N02 G21 Metricprogramming N03 M03 S1000 Spindle start clockwise with 1000rpm N04 G00 X0 Y0 Rapid motion towards (0,0) N05 G00 Z-10.0 Rapid motion towards Z=-10 plane N06 G01 X50.0 Linear interpolation N07 G01 Y20.0 Linear interpolation N08 G02 X25.0 Y45.0 R25.0 Circular interpolation clockwise(cw) N09 G03 X-25.0 Y45.0 R25.0 Circular interpolation counter clockwise(ccw) N10 G02 X-50.0 Y20.0 R25.0 Circular interpolation clockwise(cw) N11 G01 Y0.0 Linear interpolation N12 G01 X0.0 Linear interpolation N13 G00 Z10.0 Rapid motion towards Z=10 plane N14 M05 M09 Spindle stop and program end EXAMPLE Prepared by: Prof. Rahul Thaker (ACET)
  • 32.
    N01 G91 G71M03 S800 (incremental mode,metric, spindle start with a speed of 800 rpm) N02 G00 X1.0 (tool away from work piece 1mm, rapid) N03 G00 Z-1.0 (tool to left 1mm for facing) N04 G01 X-16.0 F200 (facing cut at a feed rate 200mm/min) N05 G00 Z1.0 (move tool to right 1mm from that position) N06 G00 X10.0 (move 10 mm away from the centre in x direction) N07G01 Z-36.0 (plane turning over a length of 35 mm) N08 G01 X5.0 Z-30.0 (simultaneous movement in X and Z directions for taper turning) N09 G00 X1.0 Z66.0 (move to the starting position) N10 M02 (end of program) Prepared by: Prof. Rahul Thaker (ACET)
  • 33.
    N01 G90 G71M03 S800 (absolute, metric, start spindle at a speed 800 rpm) N02 G00 X0.0 Y0.0 (move tool to the beginning of cut) N03 G02 X10.0 Z-10.0 I 0.0 K-10.0 F150 (clockwise circular interpolation, I&K are offsets, feed rate 150mm/min) N04 G00 Z-30.0 (move from point B to point C) N05 G03 X15.0 Z-35.0 I5.0 K0.0 (counterclockwise interpolation, I&K are offsets, move to point D) N06 M02 (end of program) Prepared by: Prof. Rahul Thaker (ACET)
  • 34.
    Subroutines  Any frequentlyprogrammed order of instruction or unchanging sequences can benefit by becoming a subprogram. Typical applications for subprogram applications in CNC programming are : • Repetitive machining motions • Functions relating to tool change • Hole patterns • Grooves and threads • Machine warm-up routines • Pallet changing • Special functions and others Prepared by: Prof. Rahul Thaker (ACET)
  • 35.
    Subroutines  Structurally, subprogramsare similar to standard programs. They use the same syntax rules. The benefits of subroutines involve the reduction in length of program, and reduction in program errors. There is a definition statement and subroutine call function. Standard sub-routine N10 N20 N30 …. N70 G22 N5 N80 N90 …. N100 G24 …. N160 G20 N5  In the above example G22 statement defines the start block of the sub-routine and G24 marks the end of the sub-routine statement. The subroutine is called by another code G20 identified by the label N5.Prepared by: Prof. Rahul Thaker (ACET)
  • 36.
    Canned Cycles A cannedcycle is a preprogrammed sequence of events / motions of tool / spindle stored in memory of controller. Every canned cycle has a format. Canned cycle is modal in nature and remains activated until cancelled. Canned cycles are a great resource to make manual programming easier. Often underutilized, canned cycles save time and effort. Prepared by: Prof. Rahul Thaker (ACET)
  • 37.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 38.
    Prepared by: Prof.Rahul Thaker (ACET)
  • 39.
    Prepared by: Prof.Rahul Thaker (ACET)