Sunteți pe pagina 1din 59

CNC Programming

Parts of a CNC program


• Just like a written letter to a friend or business
contact is comprised of three main parts
• salutation,
• body, and
• closing,

a CNC program is essentially broken into three similar


main parts:
• the salutation “program safe-start,”
• the body “material removal,”
• and the closing “program ending.”
CNC Programming
• There is no standardized format for writing a CNC
program that is compatible with all machine control
models.
• Each MCU manufacturer has developed its own
unique programming format.
• Each one has minor differences, but the principles
contained in the context of a program are the same
among them all.
• The programming examples provided in these slides
will relate the most closely to Fanuc-type controllers;
however, the principles may be applied to any
manufacturer’s programming format (see the
specific machine’s programming manual).
CODES

• Along with telling the machine what position to go to, the


programmer must also provide the machine with instructions
telling it what to do at that position.
CODES

Preparatory codes

G codes

M codes
Miscellaneous codes
CODES

Establish machine Carry out machining


settings operations

G codes

M codes
Control the machine
functions other than
tool movements
CODES

Establish machine Carry out machining


settings operations

G codes
G Codes - Axial Movements

Moves the tool at a very fast rate to a


G00 Rapid traverse
specified point
Linear Machining in a straight line at a feed
G01
interpolation rate
Clockwise Circular Machining in a clockwise circular arc
G02
interpolation at a given feed rate
Counter-clockwise
Machining in a counter-clockwise
G03 Circular
circular arc at a given feed rate
interpolation
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position
Coordinate positioning : Radial
We will NOT use Radial
system for this course

+X

+Z
-Z

-X
Coordinate positioning : Diametral
We will use Diametral
system for this course

+X

+Z
-Z

-X
G Codes - Axial Movements

Moves the tool at a very fast rate to a


G00 Rapid traverse
specified point

G00 X30 Z5

Tool
Home Position

+X X30 Z5

40 -Z
+Z

-X
G Codes - Axial Movements

Linear Machining in a straight line at a feed


G01
interpolation rate (one or more axes)

G00 X30 Z5
G01 X30 Z-20 F40 Feed rate

Tool

X30 Z-20
+X X30 Z5

40 -Z
+Z

-X
G Codes - Axial Movements
G00 X30 Z5 (Home  1)
G01 X30 Z00 F40(1  2)
X40 Z-35 (2  3)

3 Home
Position
2 1
+X

Ø40 Ø30 -Z
+Z

-X

35
G Codes - Axial Movements
Clockwise Circular
G02 Machining in a clockwise circular arc
interpolation

G00 X20 Z5

G01 X20 Z-15 F40

3 G02 X40 Z-25 R10


2 1
+X Radius
R10 Clockwise
Ø40 Ø20 -Z +Z

-X

15

25
G Codes - Axial Movements
Counter-clockwise
Machining in a counter-clockwise
G03 Circular
circular arc
interpolation

G00 X20 Z5

G01 X20 Z-15 F40


3
G03 X40 Z-25 R10
2 1
R10 +X Radius

Ø40
Ø40 Ø20
Ø20 -Z +Z Counter-
clockwise
-X

15

25
G Codes – Machine Setup
For Milling ONLY
All coordinates are relative to the
G90 Absolute positioning reference position
(i.e. Workpiece Origin)
All coordinates are relative to the
G91 Incremental positioning current position

For Turning ONLY


No need to write G code for the following in Turning
Machine will run on Absolute Mode by
Absolute positioning default
U Incremental mode in X axis
Incremental positioning W Incremental mode in Z axis
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position

G28 U00 W00

Incremental Incremental
mode in mode in
X axis Z axis
Home Position Important point
+Z
Tool will
-X +X • move 00 in the X direction
and 00 in the Z direction
-Z (incremental mode)
40
• and then will return to the
Home position
60
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position

G28 X00 Z00

Tool will
• move to the workpiece
origin : X00 Y00
(absolute mode)
Home Position
+Z
• and then will return to the
-X +X Home position

-Z
40

60
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position

G28 X00 Z00

Tool will
• move to the workpiece
origin : X00 Y00
(absolute mode)
Home Position
+Z
• and then will return to the
-X +X Home position

-Z
40

60
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position

Incremental G28 U00 W00

Figure shows how the tool


could collide with the billet
Home Position when manoeuvring towards
+Z the home position.
-X +X

-Z
40

60
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position

Incremental G28 U00 W00

To avoid this collision, the


tool is sent on a path which
includes the additional, or
intermediate point . The
Home Position
+Z intermediate point is used to
allow the tool to move
-X +X completely clear from the
billet, before continuing onto
-Z the home position.
40

60
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position

Incremental G28 U00 W30

Tool will
• move 00 in the X direction
and 30 in the Z direction
(incremental mode)
Home Position
+Z
• and then will return to the
-X +X Home position in a rapid
traverse mode
-Z
40

60
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position

Incremental G28 U00 W30

Tool will
• move 00 in the X direction
and 30 in the Z direction
(incremental mode)
Home Position
+Z
• and then will return to the
-X +X Home position in a rapid
traverse mode
-Z
40

60
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position

Absolute G28 X60 Z35

Tool will
• move to the intermediate
point : X60 Z35
X60 Z35 (absolute mode)
Home Position
+Z
• and then will return to the
-X +X Home position in a rapid
traverse mode
-Z
40

60
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position

Absolute G90 G28 X60 Z35

Tool will
• move to the intermediate
point : X60 Z35
X60 Z35 (absolute mode)
Home Position
+Z
• and then will return to the
-X +X Home position in a rapid
traverse mode
-Z
40

60
G Codes – Machine Setup

G20 Imperial input Inch programming units

Millimetre programming units


G21 Metric input

G98 Feed per minute inches/millimetres per minute

G99 Feed per revolution inches/millimetres per rev


D X Y

C
A
B
A B

C
0
+Y
D

0
-X +X

-Y
CODES

M codes
Control the machine
functions other than
tool movements
M codes : Group 1

M00 Program Stop utility stop for operator actions

M01 Optional Program Stop operator selected or ignored

needs manual reset to start


M02 Program End
again from the beginning
Program End and
M30 stop and automatic reset
Rewind
M00 : Program Stop
• M00 is used to stop the CNC program in the middle
when it is executed by a CNC machine.

• M00 stops following CNC functions.


• Motion of all axes
• Rotation of the spindle
• Coolant function
• Further program execution

• M00 doesn’t reset the CNC machine program.


• If Cycle Start button is pressed again, the machine will
continue to run by the program blocks after M00 block.
M00 : Program Stop
• M00 normally is used for manual intervention, such
as
• Component Inspection while the component is still in
machine.
• Tool Condition can be checked.
• Chip-removal from the workpiece.

• M00 is also called as “Compulsory Program Stop”


M01 : Optional Program Stop
• M01 optional program stop is very similar to M00,
but the CNC operator does have a choice to use it
or not to use it.

• By turning the Optional Stop switch ON (located on


the operation panel), any encounter of M01 in the
part program will force the program processing
(execution) to stop until the Cycle Start button is
pressed.
M01 : Optional Program Stop
Optional Stop Switch Settings

Processing will Processing will


STOP NOT stop

Optional Stop Optional Stop

OFF OFF
M01 M01

ON ON
M02 : Program End
Program 1 Program 2
• The M02 code is
used to end a
program.
• But the Program
won’t reset to the
beginning of the
program for the
next cycle.
M02 M02
• The Operator
must manually
press the Reset
button to start the
program again.
M30 : Program End and Rewind
Program 1 Program 2
• M30 can be used
anywhere in the
program.
• For example, we may
have a need to run the
first half of an existing
program.
• Rather than deleting
part of the program, we M30 M30

could simply insert the


M30 code wherever we
wish to terminate the
execution.
M codes : Group 2

M03 Spindle ON (CW) Clockwise

M04 Spindle ON (CCW) Anti-Clockwise

M05 Spindle OFF

M06 Tool Calling

M08 Coolant ON

M09 Coolant OFF


+X G00 X20 Z5

G01 X20 Z-10 F40


E X40 Z-30
D C X40 Z-45
B A
-Z G02 X50 Z-50 R5
+Z
Ø50 Ø40
Ø20

10
30
45
50

-X
+X

-Z
+Z

-X
+X

Roughing depth of
Cut
-Z
+Z

-X
+X

-Z
+Z

-X
+X

-Z
+Z

-X
+X

-Z
+Z

-X
+X

-Z
+Z

-X
+X

-Z
+Z

-X
+X

-Z
+Z

Material to be left
for finish pass

-X
+X

Material being
removed by
finishing pass

-Z
+Z

-X
+X

Roughing depth of
Cut

-Z
+Z

Material to be left
for finish pass

-X
Canned Cycles
• Many turning operations require tedious and
redundant motions, such as the multiple passes
performed during a rough turning operation or
multiple pecks required for deep hole-drilling
operations.
• Machine control manufacturers have equipped the
controls with features that make these tedious
operations easier and faster to program.
• These machining routines can be packaged or
“canned” into one or two blocks of code and are
called canned cycles.
Stock Removal Turning Cycle : G71
• Function G71 is the stock removal cycle for turning
that removes metal along the direction of the Z axis.
In a case where there is a lot of material to be
removed, this cycle provides an easy method for
programming.

• There are two program blocks required for function


G71.

Block 1 G71 U R

Block 2 G71 P Q U W F
Stock Removal Turning Cycle : G71
depth of
roughing cut amount of retract, along
(no sign) the X axis, for each cut

Block 1 G71 U R

Block 2 G71 P Q U W F

block number where the amount of material for roughing feed rate
code for the contour finishing to be left on
begins all diameters
(X axis)

amount of material for


block number where the finishing to be left on
code for the contour all faces
ends (Z axis)
Stock Removal Turning Cycle : G71
+X
Rough Stock
finish amount to be left diameter
on Z-axis faces W

Depth of Cut U
R12.5
Retract amount R

finish amount to be left


90 50 on the diameter U

-Z +Z
10

25
62.5
75

-X
Stock Removal Turning Cycle : G71

N10 G00 X95 Z5

Block 1 N20 G71 U5 R0.5

Block 2 N30 G71 P40 Q80 U1 W1 F30

N40 G00 X10 Z5

N50 G01 X10 Z-25


Cycle Blocks

N60 X50 Z-62.5

N70 G02 X75 Z-75

N80 G01 X95 Z-75


Finishing Cycle : G70

G70 P Q F S

block number where the


feed rate, effective for
code for the finishing contour
blocks P through Q
begins
spindle speed,
effective for blocks P
through Q

block number where the


code for the finishing contour
ends
Stock Removal Turning Cycle : G71 and Finishing
Cycle G70
N10 G00 X95 Z5

Block 1 N20 G71 U5 R0.5

Block 2 N30 G71 P40 Q80 U1 W1 F30

N40 G00 X10 Z5


Cycle Blocks

N50 G01 X10 Z-25

N60 X50 Z-62.5

N70 G02 X75 Z-75

N80 G01 X95 Z-75


Finishing Cycle G70 P40 Q80 F10 S1500
Peck Drilling Canned Cycle G74
block number where the
code for the finishing contour
begins amount of retract

G74 R

G74 X Z Q F

X-axis hole location Feed rate


(part centerline) peck increment
or
total absolute Z-depth depth of cut in Z axis
Micrometre (µm)
Clearance

G74 R
Z
G74 X Z Q F

Micrometre (µm)
R

Q Micrometre (µm)

Clearance
Clearance

G74 R1
20
G74 X0 Z-20 Q5000 F50

Micrometre (µm)
1

5000 Micrometre (µm)

Clearance
Threading Cycle : G76 angle of Micrometre (µm) in
software
Relief angle (to the thread mm in machine
number of
retract it may be minimum cut
finishing cuts
require some depth for rough
angle) cut

depth of the final


pass
(finishing
Block 1 G76 P000000 Q R allowance)

Block 2 G76 X Z P Q F

minor diameter Height of thread in feed rate (normally


Major Dia - 2*Pitch micron equal
(= 0.613*Pitch) to the thread pitch).
Micrometre (µm) in software
mm in machine

First pass depth of cut


Final end position of the
Micrometre (µm) in software
thread along the Z axis mm in machine
Threading

S-ar putea să vă placă și