CNC Part Programming
PRPC17-Computer Numerical Control (CNC) Systems
Part program and its elements- methods of programming – manual part programming,
formats. codes and cycles –computer-assisted part programming - custom macro – APT and its
variations - FMS
1
Computer Numerical Control (CNC)
In CNC (Computer Numerical Control), the instructions are stored as a program in a micro-
computer attached to the machine.
CNC Lathe Machine
CNC APPLICATIONS
• Machining
Turning ~ Lathes, Turning Centre
Milling ~ Machining Centres
• Forming
➢ 2D
Plasma and Laser Cutting
Blanking and punching
➢ 3D
Rapid Prototyping CNC Vertical Machining Centre 2
INTRODUCTION
Programming languages
First systems developed and use a programming language similar to
FORTRAN or BASIC
Automatically Programmed Tools (APT) and its many variants
COMPACT II
CAD/CAM systems Dedicated CAM systems
Major CAD systems have integrated manufacturing In these systems a dedicated CAM system helps in
systems for better interfacing and translation developing the CNC part programs
Examples are: May be linked to a major CAD system such as
Pro engineer – Pro Manufacture AutoCAD, Solidworks, CADKEY,….
Unigraphics Examples
I-DEAS – Solids machining Mastercam
CATIA Virtual Gibbs
Intergraph Smartcam
Edgecam
Alphacam
CNC manufacturers
3
CNC Controller
The software which controls the program in different interface languages is known as the
controller.
FANUC
SINUMERIK
HEIDENHAIN
MAZATROL
MAZAK
4
AXIS NOMENCLATURE
RIGHT HAND RULE
Vertical Machine Horizontal Machine
5
CNC-Introduction-Axis nomenclature
6
CNC-Introduction-Axis nomenclature
7
CNC-Introduction-Multi-axis nomenclature
8
AXIS NOMENCLATURE
Turning machine Three-axes milling machine
The axes are named
according to DIN 66217. B+
Axis and motion nomenclature for numerically
controlled machines (German National Standard)
A+
C+
Six-axis milling machine
VIDO VIDEO
9
AXIS NOMENCLATURE
Reference systems
M - Machine Zero or home: This is set by the manufacturer as the origin of the coordinate
system of the machine.
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.
10
AXIS NOMENCLATURE
Reference systems
11
CNC MACHINE SETUP AND OPERATION
Check coolant and air supply levels,
ensure work area is clean, …
Fill the tool carousel.
Define Tool Length & Radius Offsets
Once he workholding device is properly
installed and aligned, set part X,Y&Z zero
datum.
12
CNC-REFERENCE SYSTEMS
Machine Reference (R) setting T1 T2 T3 T4
R R R R
TOOL LENGTH
COMPENSATION OFF
G44 L1 L2 L3 L4
OFFSET TABLE
TOOL TOOL RADIUS LENGTH
OFFSE
T
T1 D1 55.234
T2 D1 72.345
T3 D1 61.098
T4 D1 66.683
… … ... …
TOOL LENGTH
COMPENSATION ON
G43
R R R R
13
BASIC ISO PART PROGRAMMING
14
BASIC ISO PROGRAMMING
Block structure
N**** G** X****.*** Y****.*** Z****.*** A****.*** B****.*** C****.*** F****.** S****.**
Linear and angular
positioning data Feed function
Preparatory
functions
or G-codes
Speed function
Block identification
Identifies the block of information.
T** D** M** N** ; *****
Not ISO,
Block comment
= corresponds to
Number of block repetitions FAGOR 8055M
Miscellaneous or auxiliary functions
Tool offset number
Tool number 15
BASIC ISO PROGRAMMING
Feed function (F) Speed function (S)
The feed function F is the speed at which the tool The speed function S is the speed at which the
center point moves. tool (in milling) or part (in turning) rotates.
The programmed F is effective working in linear The maximum S value is limited by the machine
(G01) or circular (G02, G03). parameters.
The maximum F value is limited by the machine
parameters.
16
BASIC ISO PROGRAMMING
Tool number (T)
The "T" code identifies the tool position in the tool magazine.
Tool offset number (D)
The tool offset contains the tool dimensions.
Each tool may have several offsets associated with it.
TOOL TOOL RADIUS LENGTH … TOOL TOOL RADIUS LENGTH …
OFFSE OFFSE
T T
T1 D1 8.002 55.234 … T2 D1 4.000 72.345 …
D2 7.502 55.234 … D2 11.990 60.036 … …
D3 8.002 55.026 … D3 7.500 33.110 …
… … … … … … … …
17
BASIC ISO PROGRAMMING
Auxiliary or Miscellaneous (M) functions
M functions DESCRIPTION
M00 Program STOP / Spindle STOP / Coolant OFF
M03 Spindle ON clockwise
M04 Spindle ON counterclockwise
M05 Spindle STOP
M06 Tool change
M08 Coolant ON
M09 Coolant OFF
M30 End of program
18
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
M functions MODAL DESCRIPTION
G00 * Rapid traverse
G01 * Linear interpolation
G02 * Clockwise circular interpolation
G03 * Counterclockwise circular interpolation
G05 * Controlled corner rounding
G07 * Square corner
G36 * Automatic radius blend
G39 * Chamfer
G40 * Cancellation of tool radius compensation
G41 * Left-hand tool radius compensation
G42 * Right-hand tool radius compensation
G43 * Tool length compensation
G44 * Cancellation of tool length compensation
MODAL = Once programmed, it remains active until
G90 * Absolute programming
another incompatible G function is
G91 * Incremental programming programmed or until M30 / EMERGENCY
or RESET.
… … …
19
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Rapid traverse (G00) Linear interpolation (G01)
It is a positioning linear movement at maximum It is a working linear movement at the
F value defined in the machine parameters. programmed F value.
Not valid for cutting. It can be programmed as G01 or G1.
It can be programmed as G00, G0 or G.
G00 X Y G01 X Y
TP TP
(TP) (TP)
(SP) (SP)
… …
N80 G00 X500 Y300 N120 G01 X500 Y300 F400
… …
20
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Rapid traverse (G00) Linear interpolation (G01)
EXERCISE 1
= SP
21
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Clockwise circular interpolation (G02)
Counterclockwise circular interpolation (G03)
It is a working circular movement at the programmed F value.
It can be programmed as G02 or G2 / G03 or G3.
G02 X Y I J G03 X Y I J
TP Distance from the SP to TP Distance from the SP to
CARTESIAN COORDINATES
the Circle Center (CC). the Circle Center (CC).
WITH ARC CENTER
CC
TP TP
J J
CC
SP I I
SP
… …
N60 G02 X300 Y300 I200 J0 N60 G03 X300 Y300 I0 J200
… …
22
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Clockwise circular interpolation (G02)
Counterclockwise circular interpolation (G03)
A complete circle cannot be programmed.
G02 X Y R G03 X Y R
TP R + : Arc < 180º TP R + : Arc < 180º
CARTESIAN COORDINATES
WITH ARC RADIUS
TP
SP
TP
SP
… …
R+ N40 G02 X400 Y150 R150 R+ N40 G03 X400 Y300 R150
… …
… …
N40 G02 X400 Y150 R-150 N40 G03 X400 Y300 R-150
… …
23
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Clockwise circular interpolation (G02)
Counterclockwise circular interpolation (G03)
EXERCISE 2 EXERCISE 3
SP SP
w w
EXERCISE 4 EXERCISE 5
SP SP
w w
24
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Clockwise circular interpolation (G02)
Counterclockwise circular interpolation (G03)
EXERCISE 6
SP
25
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Absolute programming (G90)
Incremental programming (G91)
G90: The positioning data refers to the part zero (default).
G91: The positioning data corresponds to the distance to be travelled from the point where the
tool is situated.
= SP
Absolute programming (G90) Incremental programming (G91)
… …
N70 G01 G90 X70 Y15 F350 ; P2 N70 G01 G91 X50 Y0 F350; P2
N80 G01 X70 Y30 ; P3 N80 G01 X0 Y15 ; P3
N90 G01 X45 Y45 ; P4 N90 G01 X-25 Y15 ; P4
N100 G01 X20 Y45 ; P5 N100 G01 X-25 Y0 ; P5
N110 G01 X20 Y15 ; P6 N110 G01 X0 Y-30 ; P6
… …
26
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Absolute programming (G90)
Incremental programming (G91)
EXERCISE 7 EXERCISE 8
SP
SP
27
Profile Milling: BASIC ISO PROGRAMMING
%0606
N00 G54 D1 T1;
N01 G00 X0 Y0 Z5;
N02 M03 S1000 M08;
N03 G01 X0 Y0 Z-2 F50;
N04 G01 X70 Y0;
N05 G02 X90 Y0 U10;
N06 G01 X140 Y0;
N07 G03 X140 Y50 U25;
N08 G01 X80 Y50;
N09 G01 X50 Y80;
(Profile: Depth of cut: 2 mm)
N10 G01 X20 Y80;
N11 G01 X20 Y60;
N12 G03 X20 Y40 U10;
N13 G01 X20 Y20;
N14 G01 X0 Y0;
N15 G00 X0 Y0 Z5;
N16 M05;
N17 M02;
28
Part Programming-SINUMERIK System 810
M53 - M58 Mirror Functions
M53 No mirror axis X
M54 Mirror axis X
M55 No mirror axis Y
M56 Mirror axis Y
M57 No mirror axis Z
M58 Mirror axis Z
M17-End of Subroutine
29
Part Programming-SINUMERIK System 810
Mirror Images
Mirroring the X values
Mirroring the Y values
Mirroring the Z values
30
Part Programming-SINUMERIK System 810
Mirror Images
Write the Manual Part Programming using SINUMERIK 810 M.
31
Part Programming-SINUMERIK System 810
Mirror Images
L201
N00 G42 G00 X5 Y5 Z5
N02 G01 Z-10 F10
N03 X45 Y5
N04 G02 X85 Y5 U20
N05 G01 X125 Y5
N06 X125 Y125 Profile Milling
N07 X85 Y125
N08 G02 X45 Y125 U20
N09 G01 X5 Y125
N10 G01 X5 Y5
N11 G40 G00 Z5
N13 M17
32
Part Programming-SINUMERIK System 810
Mirror Images
M53 No mirror axis X
M54 Mirror axis X
L200
N01 L201
N02 M54 P1
N03 L201 Mirroring the X values
N04 M53 P1
N05 G00 Z5
N06 M17
33
Part Programming-SINUMERIK System 810
Mirror Images
M55 No mirror axis Y
M56 Mirror axis Y
%2875
N01 G54 D1 T1 M03 S1000
N05 L200
N06 M56 P1 Mirroring the Y
N07 L200 values
N08 M55 P1
N09 G00 Z5
N10 M30
34
Part Programming-SINUMERIK System 810
Mirror Images
%2875
N01 G54 D1 T1 M03 S1000
N05 L200
N06 M56 P1 Mirroring the Y R20
N07 L200 values
N08 M55 P1
R20
N09 G00 Z5
N10 M30
L200
N01 L201
N02 M54 P1
Mirroring the X
N03 L201
values
N04 M53 P1
N05 G00 Z5
N06 M17
L201
N00 G42 G00 X5 Y5 Z5
N02 G01 Z-10 F10
N03 X45 Y5
N04 G02 X85 Y5 U20
N05 G01 X125 Y5
N06 X125 Y125 Profile Milling
N07 X85 Y125
N08 G02 X45 Y125 U20
N09 G01 X5 Y125
N10 G01 X5 Y5
N11 G40 G00 Z5
N13 M17
35
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Cancellation of tool radius compensation (G40)
Left-hand tool radius compensation (G41)
Right-hand tool radius compensation (G42)
The CNC automatically calculates the path the tool should follow based on the contour of the part and the tool
radius value stored in the tool offset table.
36
BASIC ISO PROGRAMMING
Face milling
70
100
80
60
60
SP
40
Security
20
distance ~ 2 mm
20 40 60 80 100
N00 G54 T1 D1 ; Ø28mm end-mill, assign tool 1
value D1
N10 M06 ; Tool change action
N20 G00 X14 Y40 Z100 F400 S1500 M03
N30 G00 Z58
N40 G01 X116 Y40
N50 G00 X116 Y54
N60 G01 X14 Y54
N70 G00 X14 Y68
N80 G01 X116 Y68
N90 G00 X116 Y82
N100 G01 X14 Y82
N110 G00 X14 Y96
N120 G01 X116 Y96
N130 G00 Z100
N130 M30 ; End of program
37
BASIC ISO PROGRAMMING
Preparatory functions or G-codes
Cancellation of tool radius compensation (G40)
Left-hand tool radius compensation (G41)
Right-hand tool radius compensation (G42)
Tool entry & exit should always be perpendicular to the workpiece contour.
Tool entry & exit should be avoided to be from a workpiece edge may produce burr.
SP G41
…
22.5
30 N50 G01 G41 X77.5 Y70 F400
N60 G01 X100 Y70
70 • N70 G01
N80 G03
X100 Y60
X85 Y45 I0 J-15
60 N90 G02 X70 Y30 I-15 J0
N100 G01 X50 Y30
45 N110 G01 X20 Y20
N120 G01 X25 Y70
30 N130 G03 X55 Y70 I15 J0
N140 G01 X77.5 Y70
20
N150 G01 G40 X77.5 Y100
…
20 25 50 55 70 85 100
38