0% found this document useful (0 votes)
6 views

Lecture 3

The document provides an overview of CNC programming, focusing on G-codes and M-codes used to control CNC machines. It details the structure of a CNC program, frequently used codes, and their functions, including tool movement, coolant control, and program management. Additionally, it explains the significance of coordinate systems and circular interpolation in CNC operations.

Uploaded by

Ahmed AL Afeefy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lecture 3

The document provides an overview of CNC programming, focusing on G-codes and M-codes used to control CNC machines. It details the structure of a CNC program, frequently used codes, and their functions, including tool movement, coolant control, and program management. Additionally, it explains the significance of coordinate systems and circular interpolation in CNC operations.

Uploaded by

Ahmed AL Afeefy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

Lecture 3

CNC Programming

G-codes
M-codes
What is G-
• Code?
Geometric code
• G-code is a language used to communicate to a
CNC machine. It tells the machine how to move
and what commands to execute.
• It is a way for a machinist to tell a CNC machine
what to do.

What is M-Code?
• Miscellaneous code
• Examples: coolant, spindle speed,
clockwise, counterclockwise and
changing to a specific tool number, etc.
Layout of a program
• % (it means the start of program)
• Program number (reference)
• Safety codes (safety codes to
cancel presets)
• Stock definition
• Tool change
• Move to position
• Spindle turns on
• Coolant turns on
• Cutting begins
• End of program
• Reset
The starting codes of
any program
%
O0000
N100 G21
N102 G0 G17 G40 G49 G80 G90
N104 G91 G28 Z0.0
N106 G91 G28 X0.0 Y0.0
N108 M06 T01
N110 G92 X….. Y…… Z…..
N112 G00 X0.0 Y0.0
N114 G43 H01
N116 G00 Z5.0
N118 M03 S…….. M07
Frequently used G Codes and their use
G00 --Rapid move to position---Quickly travels to the position specified by
X, Y, Z
G01– Move to position while cutting– Reaches position specified by X, Y, Z
while making cut
G02– Making clockwise cut– Makes arc/round cut
G03– Making anticlockwise cut--Makes arc/round cut
G17– XY plane– If the plane is changed due to previous program it will
again return to XY
G90– Absolute distance– Always considers from 0,0,0
G54– Cancel offset– Previous offset of 0,0,0 will be cancelled
G40– Cancel tool radius offset
G49– Cancel tool length offset
G94– Feed per minute
G41– tool compensation left of cut (looking from behind)– Considers the
tool radius
G42-- tool compensation right of cut (looking from behind)
G43– tool length compensation – Considers the tool length
G80-- Cancel all canned cycle– Canned cycle is used to do multiple similar
works like drilling in different positions with same parameters
G83– Pecking canned cycle– Used for peck drilling
G91– Incremental movement– Adds the given value with previous position
G04– Dwell– Stays in the specified position for given time. Its calculated as
1000th of a second. So 4000 will mean 4 second.
G20– Unit in inch
G21– Unit in mm
Frequently used M Codes and their
use

M03– Spindle start clockwise


M04-- Spindle start anticlockwise
M05– Spindle stop
M06– Tool change
M07– Flood Coolant start
M08– Mist Coolant start
M00– Program stop
M09– Coolant stop
CNC Words

N, G, X, Y , Z, A, B, C, I, J,
K, F, S, T, R, M
 F: feed rate of the tool motion
 S: cutting-speed
 T: tool number
CNC Words

N, G, X, Y , Z, A, B, C, I, J,
K, F, S, T, R, M
• X, Y, Z, A, B, C: provide the coordinate
positions of the tool. X, Y, and Z define
the three translational (Cartesian) axes of
a machine. A, B and C are used for the
three rotational axes about the X, Y, and
Z axes.
• I, J, K: specify the center for circular
motion
G codes
• Unit selection:
– G20 (inch), G21(metric)
• Coordinates selection:
– G90(absolute), G91(incremental)
• Working plane selection:
– G17(X-Y), G18(Z-X), G19(Y-Z)
G90 and G91
• G90: absolute distance;
represent positions in terms
of the currently active
coordinate system (Program
Zero)
• G91: incremental distance
mode; axis numbers
represent increments from
the current position.
G90 and G91
G90 and G91
G92
• G92 means “set an offset in
all coordinate systems”
• G92 X….. Y….. Z…. , the
values in (x, Y and Z) are the
distances between the
machine zero (home position
and the program zero)
G92
• G92 means “set an offset in
all coordinate systems”
• G92 X10.0 Y5.0 Z0.0
G92 and G43
• The program
zero at Z is the
same at home
position without
installing any
tool.
• G43 H0… makes
the
compensation
offset with the
values saved in
the tools table
G92 and G43
Tool Tool Diameter Height
Number Description
T01 Center Drill 3 -50
T02 Drill bit 10 -5
T03 End Mill 8 -30
T04 Face Mill 75 -6
T05 Tap Mill 12 -25

G43 H01 will compensate 50mm which is the distance between


the tip of the center drill to top surface of the work piece
G00 and G01
G00: Rapid linear move to
position---Quickly (at the highest
speed of axis motors) travels to
the position specified by X, Y, Z.
Note that the motion here
must be at +Z (above the
surface of the work piece)
G00 X50.0 Y20.0 Z15.0
G00 and G01
G01: Linear interpolation; Move
to position while cutting– Reaches
position specified by X, Y, Z while
making cut.
The speed of the motion must be
specified by the F word which is
the federate (mm/min)
Note that the motion here
must be at -Z (below the
surface of the work piece)
G01 X50.0 Y20.0 Z15.0 F300.0
Plane Selection
Circular interpolation:
G02, G03
• G02, G03:
– For circular interpolation, the tool
destination and the circle center are
programmed in one block
– G02 is clockwise interpolation, G03 is
counterclockwise interpolation
G 02  R 
G17   X __ Y __   F __;
G 03  I __ J __ 
G 02  R 
G18  X __ Z __   F __;
 G 03   I __ K __ 
G 02  R 
G19 Y __ Z __   F __;
G 03  J __ K __ 
End point Circle center, radius
Circular interpolation:
G02, G03
Y End • Specify Center with
I, J, K
– I, J, K are the
X incremental
distance from
Start the start of the
j arc;
Center
– Viewing the start
i of arc as the
origin, I, J, K have
positive or
negative signs.
Circular
interpolation: G02,
G03
N0010 G92 X200.0 Y40.0 Z0.0 ;
N0020 G90 G03 X140.0 Y100.0 R60.0
F300 ;
N0030 G02 X120.0 Y60.0 R50.0 ;
G92:
To define working
coordinate

G90: Y
absolute 100 R50
coordinates 60 R60
40
X
O 90 120 140 200
Circular interpolation:
G02, G03
Circular
interpolation: G02,
G03
Annotation for Circular
Interpolation
– I0.0, J0.0, and K0.0 can be omitted.
– If X,Y,Z are all omitted in the
program, that means start and end
of arc are same points.
N0020 G02 I20.0 (a full circle)
– If I, J, K, and R all appears in
circular interpolation instruction, R
is valid and I, J, and K are invalid
Circular interpolation:
G02, G03
N0020 G02 I20.0 (a full circle)
Circular interpolation:
G02, G03
(a full circle)
M code
• miscellaneous word
• miscellaneous functions:
– turn the spindle on/off
– start/stop the machine
– turn on/off the coolant
– change the tool
– rewind the program (tape)
M code
M00 Program stop M06 Tool change

Flood coolant
M01 Optional stop M07
on

M02 End of program M08 Mist coolant on

M03 Spindle CW M09 Coolant off

M04 Spindle CCW M30 End of tape

modal groups
M code: M00, M01

• M00 and M01 both stop the


machine in the middle of a
program.
• M01 is effective only when the
optional stop button on the
control panel is depressed. The
program can be resumed
through the control panel.
M code: M03, M04,
M05
• M03 turns on the spindle
clockwise.
• M04 turns the spindle on
counterclockwise.
(The spindle rpm must be
specified in the same line or in a
previous line. )
• M05 turns off the spindle.
M code: M07, M08,
M09
• M07 and M08 turn on different
modes of coolant.
– M07: flood coolant on
– M08: mist coolant on
• M09 turns off the coolant.
M code: M06
• M06 signals the tool-change
operation.
• On a machine equipped with an
automatic tool changer, it stops
the spindle, retracts the spindle to
the tool-change position, and then
changes the tool to the one
specified in the T-code.
M code: M02, M30
• M02 marks the end of the
program.
• M30 marks the end of the tape. It
stops the spindle and rewinds the
program (tape)
Example 1
Write the CNC Program for the
following using a 4mm end mill
at depth Z-3.0 mm
Example1.pdf
Automatic Part Programming
Software programs can automatic generation of CNC
data

Define Tool

CNC data

Make 3D model
Simulate
cutting

You might also like