m.nazmi ‹#› general 1- composition of a part programs. 2- block configuration. 3- part...

36
M.nazmi 1 General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number): • Each block of information must be allocated a number. • Ex: N0010, N0020, • It is recommended that the blocks are programmed in increments of 10 to allow for further block insertion. G (code for preparatory function): • A G code is a command to the control unit to perform some specific task or function. •G code is made from the G address letter and a two digit number: G00, G01 • Some G codes remain active till replaced or cancelled. These are called modal (retained) G codes. • G code from group 0 are non-modal. XYZ (position co-ordinate data): • These letters refer to movement along the designated axes. • Use XYZ when absolute mode is intended. • Use U,W when incremental mode is intended. F (feed function): • The movement of the tool at a specified speed for cutting is called the feedrate. • The feedrate is defined using the F address letter followed by a numerical value: F256 • Feedrates can be specified as either millimetre or inches movement per minute or revolution. • Incorrect feedrates may result in damage to the

Upload: amberly-clark

Post on 16-Dec-2015

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 1

General1- Composition of a part programs.2- Block Configuration.3- Part programming Block format:

N G X(u) Y(w) Z F M S TN (block number):• Each block of information must be allocated a number.• Ex: N0010, N0020,• It is recommended that the blocks are programmed in increments of 10 to

allow for further block insertion.

G (code for preparatory function):• A G code is a command to the control unit to perform some specific task

or function.• G code is made from the G address letter and a two digit number:

G00, G01• Some G codes remain active till replaced or cancelled. These are called

modal (retained) G codes.• G code from group 0 are non-modal.

XYZ (position co-ordinate data):• These letters refer to movement along the designated axes.• Use XYZ when absolute mode is intended.• Use U,W when incremental mode is intended.

F (feed function):• The movement of the tool at a specified speed for cutting is called the

feedrate.• The feedrate is defined using the F address letter followed by a numerical

value: F256• Feedrates can be specified as either millimetre or inches movement per

minute or revolution.• Incorrect feedrates may result in damage to the cutting tool or the work

piece.

Page 2: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 2

M code (miscellaneous functions):•are (non-standard) commands to the control unit to perform special tasks.•M codes are defined using the M address letter and a two digit number EX: M03 spindle forward

S (spindle speed function):•The rotational speed of the tool with respect to the work piece being cut is called the spindle speed.

•Four digit number following the S code specifies the speed in RPM.•When a move command and a S code is specified in the same block a simultaneous execution of the command is performed.

T (tool function):•A tool from the ATC is selected using the address letter T followed by a number in ATC magazine position.

•To command a tool change the M06 code would precede the number of the “new” tool required. Ex: M06 T01

4- Tool Movement

Point-to-PointThis is a rapid traverse movement that moves the slide to the next position required.Axes movements are not co-ordinated with each other so care must be taken to avoid collision with clamps.This is used for tool positioning and no cutting should be undertaken.

Line Motion (Linear interpolation)Tool moves along the specified straight line with a given feed rate.Line motion is used when the tool is to cut in a straight line under co-ordinated axis movement.

ContouringThis involves programming that is similar to line motion in that the next position is specified and a feed rate is given but an arc movement is achieved.

Page 3: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 3

De to the great cutting forces that these machines are capable of producing and the increased feed rates over conventional machines, great care must be taken at all times as any fault in the program may have disastrous effects on the machine and the operator.

Safety Rules:

•Make sure you know how to stop the machine in case of an emergency.

•Make sure that the machine guards are in position when machining.

•If you suspect something is going wrong, STOP the machine immediately.

•Isolate the machine before any adjustments.•Do not attempt to use the machine until you are sure you can use it correctly.

•Part programs should be proved prior to machining using a dry run or computer simulation.

6- Program Proving

5- SAFETY

Page 4: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 4

Methods of checking/verification

Graphical simulation: computer graphics are used to simulate the workipece and the cutting tool movements. Any errors in the program will be highlighted prior to the program being entered into the machine and therefore the programmer is able to edit/correct his program.

Page 5: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 5

DATUM:

•Machine datum: defines the zero point of all axes which is fixed by the manufacturer. We can use zero offset facility to move this datum.

•Program/work datum is specified by the programmer when the program is written. All subsequent measurements are then made relative to this new “program” datum.

Dry Run: this method of program proving is done on the machine tool but the component or billet to be cut is not installed. As the tool or cutter moves in air the operator looks to see that the cutting tool will not collide with proposed clamping and fixture arrangements or the part.A dry run can be done in single step mode which means that the part program can be run block by block under the control of the operator. All CNC machine controllers have this facility.

YZ

X

Page 6: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 6

Co-Ordinate Dimensioning:

There are two types of co-ordinate dimensioning systems used in CNC programming:

•Incremental: where next position measurements are taken relative to the current position.

- an error made in one dimension will effect subsequent measurements - if a dimension changes then the rest of dimension will have to be changed

•Absolute: Dimensions are always measured from the same datum position therefore there are no build-up or accumulation of errors between dimensions.

XY12

34

56

Absolute Incremental

Page 7: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 7

Page 8: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 8

G&N programming for CNC lathe6- Absolute and Incremental Co-ordinates

• The addresses X and Z within a program relate to a co-ordinate position from the workpiece datum.

• The address U and W within a program relate to the individual axis movements required to reach the new position, from the last position reached by the tool. The address U refers to the X axis and the address W refers to the Z axis.

Dia 20

Dia 30

50

Z axis

X a

xis

• Four different ways can be used to write a block within a program:

Absolutes/ absolutes G01 X30 Z-50;

Incremental/incremental G01 U10 W-50;

Absolutes/incremental G01 X30 W-50;

Incremental/absolutes G01 U10 Z-50;

Page 9: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 9

List of G Codes (Turning machine)

G00 positioning (rapid traverse)G01 liner interpolation (feed)G02 circular interpolation CWG03 circular interpolation CCWG04 dwellG20 inch data inputG21 metric data inputG28 reference point returnG40 tool nose radius compensation cancelG41 tool nose radius compensation leftG42 tool nose radius compensation rightG50 work coordinate change/Max spindle speed settingG70 finish cycleG71 stock removal in turning –XG72 stock removal in facing-ZG73 pattern repeatingG74 Peck drilling in Z axisG75 Grooving in X axisG76 multiple thread cutting cycleG81 deep hole drillingG90 diameter cutting cycle A (outer/inner)G92 thread cutting cycleG94 cutting cycle B (end face cycle)G96 assessed surface speed controlG97 Assessed surface speed control cancelG98 feed per minuteG99 feed per revolution

Page 10: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 10

G Codes

G00 /Rapid positioning & traverse (modal)• Executes a non cutting movement at a rapid feedrate to a specific

coordinate position in the working area (absolutes mode) or a certain distance from previous position (increment mode).

• The two axes move completely independent off each other at the maximum feedrate along a non vector path.

P1

2.0Dia.X 30

Z 0.0

G00 X30 Z2

Non vector movement

2.0 G00 Z2 X30G00 is modal

G01 /Linear interpolation (modal)• The G01 executes a cutting movement following a straight line at a set

feedrate. G01 X(or U) Z(or W) F• The feedrate value programmed into the G01 command is the actual

feedrate along the proposed tool path, not the feed rates of the slide.• On two axis movements, the machine controller will calculate the

separate feedrates for both the X and Z slides, enabling the actual vector feedrate to equal that stated in the G01 command.

• The coordinates can be programmed in absolutes values as X and Y, or incremental values as U and W.

• The coordinates may be programmed in mixed modes.to

Page 11: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 11

25

5040 Dia

P1P2

P3

25 D

ia

Absolute:G01 Z-25 F0.1;

X40 -Z50;

Incremental:G01 W-25 F0.1;

U15 W-25;Mixed:G01 W-25 F0.1;

X40 W-25;

Feedrate values are modal.

G02/G03 circular interpolation (modal)• G02 executes a cutting movement following a clockwise circular path at

a set feedrate.• G03 executes the cutting movement following an anticlockwise circular

path at a set feedrate.

• When using absolute position, X & Z values are the dimensions of the end point of the arc in relation to the datum position of the component.

• In incremental mode, U & W are the distance the tool moves from the start position of the arc. This can either be a plus value or a minus value depending on the direction of the movement relative to the start position.

G02 X Z R Absolute G03 X Z RG02 +/-U +/-W R Incremental G03 U W R

+Z

+XR

Start

End

30 Dia

20

G02 X30 Z-30 R F

G02 X30 W-20 R F

10

Page 12: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 12

When you do not know the radius: A case for I and K

To program an arc when only the arc center is given use the address letter I and K.

• I relates to the address X and is the incremental value and direction from the start point of the arc in the X axis to the arc center.

• K relates to the address Z and is the incremental value and direction from the start point of the arc in the Z axis to the arc center.

End

Start

Center of ARC

I

K

+Z

+X

Absolute G02 X Z I K F;Incremental G02 U W I K F;

Start

Finish

I

Z

G04 /Dwell

G04 X-- (Integer time in seconds) G04 X10G04 U- (Real time in seconds) G04 X10.5G04 P-- (time in milliseconds) G04 P2500

• Used to enter a set time delay into the program.• No decimal points can be used with address P• Dwell is performed at the start of the block in which it is programmed.• G04 is non-modal

Page 13: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 13

G20-G21 / Inch-Metric Data input unit• The machine controller can be programmed in either inch unit input or

metric unit input.

G20 Imperial/Inch lowest value 0.0001G21 Metric/Millimeter lowest value 0.001

• Do not switch between G20/G21 during a program• The offsets must be set according to the units of measurement being

used.

Offsets !!!!!!!!!!!????!!

• There are two parameters that are different from tool to tool. These are radius and length.

• The offset compensation table is a useful means of overcoming this problem.

40

10

10060

100-60-10100-40-10

50

G28 /Reference point return

G28 X(U) Y(W)

• The reference point is a fixed position on the machine to which the tool can be moved. (home position)

• G28 instructs the tool to automatically move to this reference point.• X/Y/ can be used to indicate an intermediate point through which the tool

will pass before continuing to the reference point.

Page 14: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 14

• G28 moves are performed at rapid traverse rates (non-vector tool path)

Reference PointCollisionPoint

P1

P2

G28 U0 W0

when no intermediate points are required U&W are set to zero.

P1

P2P3Reference Point

G28 X100 Z-40

To avoid this collision the tool is sent on a path through the intermediate point P2.

Dia

80

40

G50 / 1- Clamping maximum spindle speed.2- Coordinate system setting.3- Coordinate system shift.

1- Clamping maximum spindle speed. G50 S____• The value in word address S specifies the maximum spindle speed measured in

RPM.• this command can be used in conjunction with G96 (Constant surfaces speed

control) to clamp the spindle speed to the given value.

2- Coordinate system setting.• This command can be used to specify a user coordinate value to register as the

current position of the tool. The tool will think it is at the specified coordinates although it has not actually moved.

Page 15: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 15

10

10

20

3040

20 30 40 +Z

G50 X10 Z10

10

10

20

200

3- Coordinate system shift.• If incremental word addresses are used to specify the values then this

command shifts the coordinate axes by the specified values.

10

10

20

3040

20 30 40 +Z

G50 U10 W10

10

10

20

200

G71 / Stock removal in X axis.

• G71 is a canned cycle that generates the roughing cuts needed to make a component profile.

U1F

rF

R

U2

W

ProgrammedPath

R = retract escaping amount.

F= feedrate for roughing.

U1= depth of cut in X axis (Radius value)

U2=finishing allowance in X axis (sign & Mag)

W=finishing allowance in Z axis (sign & Mag)

A

B

Page 16: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 16

Prior to writing this command the tool is positioned at the start point. The sequence of tool moves are as follows:

A- roughing cycle.1- From the start position, the tool moves a distance U2 along the X axis and W

along the Z axis at a rapid feed rate.2- the tool moves the distance U1 along the X axis towards the billet centerline at a

feed rates corresponding to the G code in the ns block.3- the tool moves along the Z axis towards the spindle. The feedrate used is a stated

in the second block of G71.4- at this point the tool retracts in the X and Z axis away from the work at an angle of

45 degrees at a rapid traverse. feedrates. The amount R is stated in the first block of the G71.

5- the tool then retracts along the Z axis at a rapid feedrate until it reaches the start point of that same diameter.

6- from this point the above cycle is repeated until the programmed shape between ns and nf has been roughed out.

7- after all the roughing passes are completed a singled roughing profile pass is performed at G71stated feedrate. when this single pass is complete the tool will retract to the original starting position of the G71.

B-finishing cycle.8- if the next block contains G70 the same tool will be used to perform the finishing

pass at feedrate and spindle speed contained between ns and nf.

• should a different tool be required to perform the finishing pass:a) The block after nf would instruct the machine to move to a tool change

position.b) The next block would instruct the machine to change to the tool required for

the finishing pass.c) The next block would move the tool back to the original G71 starting

position.d) At this point the finishing pass block would be read into the machine and

executed.

9- When the finishing pass ends the tool will retract to original G71 start position.

G71 command is written in the following format: N ns …………F…..; G71 U(1) R__; ……….; G71 P ns Q nf U(2) W_ F_; F …….;

S …….;Any F or S commands between ns to nf block N nf ……………….;numbers will only be effective on the finishing pass. M

ove

com

man

ds a

re

spec

ifie

d be

twee

n pr

ogra

m b

lock

num

bers

ns

to n

f.

Page 17: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 17

• In canned cycle G71 only an X axis move is permitted in the first block of the finished profile.

• Only G00, G01, G02, G03 and G04 can be programmed between ns and nf blocks.

38 Dia 30 Dia 25 Dia 20 Dia

12 35 30

3 Rad

1 Rad1.5 Chamfer

N0050 G00 X38 Z2; start & finished positionN0060 G71 U1.5 R0.5;N0070 P80 Q170 U2 W0.1 F0.15;N0080 G01 X16 F0.3; (ns)N0090 Z0.5;N0100 X20 Z-1.5 F0.05;N0110 Z-30 F0.075;N0120 X23;N0130 G03 X25 Z-31 R1;N0140 G01 X30 Z-65;N0150 Z-74;N0160 G02 X36 Z-77 R3;N0170 G01 X38.5; (NF)N0180 G70 P80 Q170; Finish pass

G70 /Finishing Cycle G70 Pns Qnf

• After part profile rough cutting has been competed using G71-G72-G73 codes the G70 can be used to perform a finishing pass/cut.

• ns = the sequence number of the start block for the finishing pass.• nf = the sequence number of the last block for the finishing pass.• When the finished pass is ended the tool returns to the position it was originally at

before G70 was commanded.• F and S between the sequence numbers ns and nf will be effectively in the G70

operation.

Page 18: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 18

15 1515

1.5 Rad

20 Dia

32 Dia 1.5 Chamfer

N0070 G00 X16 Z2;N0080 G71 U1.25 R0.5;N0090 G71 P100 Q170 U-1.5 W0.07 F0.075;N0100 G01 X36 F0.3;N0110 Z0.5;N0120 X32 Z-15 F0.05;N0130 Z-15 F0.07;N0140 X20 Z-30;N0150 Z-43.5;N0160 G03 X17 Z-45 R1.5 F0.05;N0170 G01 X15.8;N0180 G70 P100 Q170;

G72 /Stock removal in Z axis• similar to G71except that the cut is applied in the Z axes.

G72 W(1) R__;G72 Pns Qnf U__ W(2) F__;

W1

W(2)

UProgrammedPath

F

R

A

B

r

F= feedrate.r= rapid traverse.W1= depth of cut.U= finishing cut allowance in X axis.R=escaping amount.ns= sequence number of the first block of the programmed finished shape.nf= sequence number of the last block of the programmed finished shape.U= distance and direction of the finished allowance in the X axis.W(2)= finishing cut allowance in Z axis.F=feedrate for roughing.

Page 19: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 19

• Only a Z axis move is allowed in the ns block.

• If the finishing pass is required to block G70 Pns Qnf is placed after the G72 command has been completed.

80Dia

60Dia

60Dia

40Dia

10 10 10 1020

20Dia

U

N0050 G00 X81 Z2;N0060 G72 W2 R0.5;N0070 G72 P80 Q150 U0.5 W1 F0.1;N0080 G00 Z-60;N0090 G01 X80 F0.2;N0100 X60 W10 F0.075;N0110 W10;N0120 X40 W10;N0130 W20;N0140 X180 W11;N0150 W1;N0160 G70 P80 Q150;

Page 20: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 20

G75 / grooving cycle.

• G75 permits grooving in the X axis.

G75 R(1);G75 X(U) Z(W) P__ Q__ R(2) F__;

R1 peck return amount.X(U) the diameter of the depth of the

groove.Z(W) the width of the groove.P stepover in the X axis measured in

microns.Q pecking debt in the Z axis

measured in microns.

• The retract amount R(2) at the base of the groove may be impossible unless a clearance amount has been provided. If no clearance amount has been left the R(2) value must be set to zero or omitted from the block.

Q

z(w)

R(2)

P

R(1)

X(U

)Star position X52 Z-10.5

3mm wide grooving tool

20 Dia

50 Dia 405

N0060 G00 X52 Z-8;N0070 G01 X20 F0.075;N0080 G00 X52;N0090 W-2.5;N0100 G75 R0.5;N0110 G75 X20 Z-40 P5000 Q2500 R0.5 F0.075;

Page 21: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 21

G90 /outer diameter cutting cycle

• The command G90 performs the one pass cutting cycle where the cut is applied in the x axis.

• G90 is modal.

• G90 can also be used to cut tapers.

• To sign of R depends on thedirection of path P1. In this exampleİt is entered as a minus value.

Z

X/2

U/2

W

P1(R)P2(F)P3

(F) P4(R)

G90 X(U)_ Z(W)_ F_;

• In this example both U and W are minus.

Z

X/2

U/2

W

P1(R)

P2(F)

P3(F

) P4(R)

G90 X(U) Z(W) R_ F_;

R

40Dia

25 Dia

20 25

20 D

ia

8

N0060 G00 X41 Z2;N0070 G90 X35 Z-45 F0.1;N0080 X30;N0090 X25 Z-25;N0100 X20;N0110 X20 R-3.512;

Page 22: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 22

G94 /end face turning cycle

• This command performs a one pass face cutting cycle.

• The cut is applied in the Z axis.

• G94 can also be used for cutting taper profiles.

• If repetition of the move is required only the values that changed needs to be entered into the next block.

W

P1(R)

P3(F)

P2(

F)

P4(

r)

XU

/2

ZG94 X(U) Z(W) F_

W

R

Z

XU

/2G94 X(U) Z(W) R_ F_

To sign of R depends on the direction of path P1. In this example It is entered as a minus value.

P1(R)

P2(F)P3(F) R

5 5 5

10 D

ia

20 D

ia

60 D

ia

N0060 G00 X61 Z2;N0070 G94 X20 Z-2.5 F0.1;N0080 Z-5;N0090 Z-7.5;N0100 Z-10;N0110 Z-12.5;N0120 Z-15;N0130 G00 X21 Z5;N0140 Z-2.5;N0150 Z-5;N0160 G94 X10 Z-7.5 R-2.5;N0150 Z-11 R-6;

Page 23: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 23

Spindle speed

• this spindle speed specified by the word address S in any block of a program may be interpreted in two ways depending on the mode selected. these are:

G96 / constant surface speed G96 S___;

• The spindle speed is calculated so that the surface speed is always the specified value (in S) in relation to the tool position.

• The units used will depanned on whether the machine is operating using metric or Imperial measurements.

• G96 units can therefore be meters pair minutes, or feet per min.• When using G96, the work datum point must be set so that the center of rotation

meets the Z axis.• G50 code defining clamping off maximum spindle speed must be used in

conjunction with G96, so as not to overrun the safe maximum spindle speed off the chuck.

• G96 is modal.

G97 / spindle speed in Rev Per Minute G97 S__;

• Once G97 is entered all subsequent spindle speeds are defined in revolution per minutes.

• G97 is the default mode at power up.

G98 / Fee per Minute G98 F__;• This command allows a feedrate written in the units, millimeters per minute or

inches per minute to be entered into the machine controller.• G98 is modal therefore if a change to the feedrate is required within a program,

only the F value needs to be entered.• G98 is the default condition at power up.

G99 / Per Revolution Feed G99 F__;• G99 results in feed rate of millimeters or inches per revolution depending on the

previously selected units.• G99 is modal

Page 24: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 24

M Codes: M??

• Miscellaneous functions, called M codes, are used by the CNC control to command on/off signals to the machine functions.

• The functions allocated are constant in most CNC machines however some can vary from one make of the machine to the next.

• Only one M code can be programmed within each block.

M00 program stopM01 optional stopM02 end of programM03 spindle forward (clockwise)M04 spindle reverse (counter clockwise)M05 spindle stopM06 automatic tool changeM08 coolant onM09 coolant offM10 chuck openM11 chuck closeM13 spindle forward and coolant onM14 spindle reverse and coolant onM25 tailstock quill extendM26 tailstock quill retractM30 program stop and resetM38 door openM39 door closeM40 parts catcher extendM41 parts catcher retractM98 sub program callM99 sub program end and return

Main prog.

O0001N0020 ……;N0030 ……;N0040 M98 P1000;N0090 ……;N0100 ……;N0110 M30;

Sub prog. 1

O1000N0020 ……;N0030 ……;N0040 M98 P2000;N0090 ……;N0100 ……;N0110 M99;

Sub prog. 2

O2000N0020 ……;N0030 ……;N0040 ……;N0090 ……;N0100 ……;N0110 M99;

Page 25: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 25

DATUM:

•Machine datum: Sometimes referred to as the zero datum defines the zero point of all axes which is fixed by the manufacturer.

We can use zero offset facility to move this datum.

•Program datum is specified by the programmer when the program is written. All subsequent measurements are then made relative to this new “program” datum.

7- G&N programming for CNC Milling Machine

X

YZ

Page 26: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 26

Co-Ordinate Dimensioning:

There are two types of co-ordinate dimensioning systems used in CNC programming:

•Incremental: where next position measurements are taken relative to the current position.

- an error made in one dimension will effect subsequent measurements - if a dimension changes then the rest of dimension will have to be changed

•Absolute: Dimensions are always measured from the same datum position therefore there are no build-up or accumulation of errors between dimensions.

XY12

34

56

Absolute Incremental

Page 27: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 27

2 holes on CL, 8 Dia x 10 deep

98

147

11

8

825

8

12

20

20

30X8X5 deep

Page 28: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 28

O0001N0010 G21; metric measure[BILLET X98 Y147 Z36; size of work piece[TOOLDEF T3 D8 Z20; define tool[EDGEMOVE X0 Y0 Z0; force billet datum to be at workpiece datum/ for simulation set X datum to 20/ this means we have room to move to the left the billetN0015 M6 T3; pick toolN0020 G90; Go home - absoluteN0040 G00 X-4 Y4 Z-25; 1st moveN0050 M03 S1500; Spindle onN0060 G01 X94 F120; 2nd cutN0070 Y143; 3nd cutN0080 X-4; make sure no corner remainsN0090 Y139;N0100 X93; 4rd cut completeN0110 G00 Y140;N0120 X4; ready for last cutN0130 G01 Y4; last cut round/N0140 G00 Z10; lift clearN0150 X49 Y20; position over 1st holeN0150 G01 Z-10;N0160 G00 Z10;N0170 Y127; Over 2nd holeN0180 G01 Z-10;N0190 G00 Z10; Retract/N0200 Y73.5; Over the slot centerN0210 G01 Z-5;N0220 G91; incremntalN0230 X30;N0240 X-60;N0250 G00 z10;N0260 G90;N0270 M02;N0280 M30

Page 29: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 29

G00 /Rapid positioning & traverse

G00 X10 Y20 Z30

• Executes non cutting movement (point-to-point) at a rapid feed rate.• Axis co-ordinate moves can be absolute or incremental• G00 freezes tool radius compensation and axis movement are

independent of each other.• G00 is modal

G01 /Linear interpolation G90 G01 X100 Y50 F170

• Executes cutting movement along a straight line at a given feed rate• Axis co-ordinate moves can be absolute or incremental• G01 is modal• F is modal and is specified as inches per minute (G20) or

millimeters per minute (G21)

G02-G03 /Circular interpolation

•G02 (CW) and G03(CCW) executes a cutting movements in circular path.•There are four ways to program a CW/CCW circular path:

G90 G02/03 X-- Y-- R-- F-- [can use G91]arc end point in X&Y (absolute/incremental). R length of arc radius. F feed rate.

G90 G02/G03 X-- Y-- I-- J-- F-- [can use G91]I-- J-- defines the signed distance of the arc start point from the centre point of the arc.

•For arcs exceeding 180 degree the radius value R-- must be specified as negative.•When X or Y are omitted the arc end point is located at the same position as the arc start point and the arc center is commanded by I or J, an arc of 360 degree is assumed.

Page 30: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 30

G04 /Dwell

G04 X-- (time in seconds) G04 X1.5G04 P-- (time in 1 milliseconds) G04 P2500

• Used to enter a set time delay into the program.• No decimal points can be used with address P• Dwell is performed at the start of the block in which it is

programmed.• G04 is non-modal

G20-G21 /Data input unit

G20 Imperial/Inch lowest value 0.0001G21 Metric/Millimeter lowest value 0.001

• Do not switch between G20/G21 during a program

G28 /Reference point return

G28 X-- Y-- Z--

• the reference point is a fixed position on the machine to which the tool can be moved. (home position)

• X/Y/Z can be used to indicate an intermediate point through which the tool will pass before continuing to the reference point.

• G28 is non-modal

G40-G41-G42 /Cutter compensation

• G41/42 the tool is positioned on the left/right hand side of the part (programmed path) as seen following the direction of movement from behind the tool.

• G40 cancels cutter compensation• The radius of the tool (amount compensated by) should have been

set in the machine controller.

Page 31: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 31

G40-G41-G42 /Cutter compensation

• G41/42 the tool is positioned on the left/right hand side of the part (programmed path) as seen following the direction of movement from behind the tool.

• G40 cancels cutter compensation• The radius of the tool (amount compensated by) should have been set

in the machine controller.• A start-up or ramping on block must be used to allow the tool time to change

from moving along he programmed path line to following either side of the path line. Therefore:

G41/42 must be contained in the block or specified in the previous block and A G01 is specified in the block and the distance of the linear move must be greater than the tool compensation

• The tool offset store in the table must not be 00

G02 or G03 can not be specified in the start-up blockG40/41/42 are modalG40 can only be performed in a block in which a linear move (G00-G01-G28) is

performed

2 holes on CL, 8 Dia x 10 deep

98

147

11

88

25

8

12

20

20

30X8X5 deep

Page 32: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 32

Caned cycles (G73-G89) simplifies the program by replacing a number of complex machine sequence blocks with just one block.

G98 - initial point returnG99 - R point level return

G81 /Drilling- spot boring

G90/G91 G98/G99 G81 X-- Y-- Z-- R-- K-- F--;

G90 G81 X10 Y30 Z-17 R2 F75;G91 G99 G81 X10 Y6 Z-10 R-8 K4 F100;

• Rapid position to XY (initial level)• Rapid traverse to R point level• Feed to depth Z• Rapid traverse to initial Z level (G98) or R point (G99).• K defines the number or repeats

G90-G91-G42 /Absolute/incremental data format

• Z defines the distance from the R point to the bottom of the hole in incremental mode or the position of the hole bottom in absolute mode.

• R defines the distance from the initial level to the R point level in incremental mode or the position of the R point level in absolute mode.

XY

Z=0

Z

RG99

G98XY

Z=0

Z

RG99

G98

Page 33: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 33

G82 /Drilling- counter boring

G90/G91 G98/G99 G82 X-- Y-- Z-- P-- R-- K-- F--;

• Rapid position to XY (initial level)• Rapid traverse to R point level• Feed to depth Z• Dwell for value P• Rapid traverse to initial Z level (G98) or R point (G99).• K defines the number or repeats

G80 /Canned cycle cancel

• The data specified (ZPQR) is retained until it is either changed or the canned cycle cancelled.

G73 /high speed peck drilling

G90/G91 G98/G99 G73 X-- Y-- Z- Q-- R-- F--;

• Move rapid to XY• Move rapid to R• Feed to a depth of Q• Retract a small distance• Re-feed to a further depth of Q• Retract and repeat till Z is reached• Retract to R or initial level as specified

G 83/deep hole peck drilling

• Rapid position to XY• Move rapid to R• Feed to a depth of Q• Retract rapid to R• Rapid traverse back to within 1mm depth of Q cut• Feed to a further depth of Q• Retract to R and repeat till a depth of Z is reached

G 84 /Tapping G74 /Counter TappingG76 /Fine Boring G 85-G86-G89 /BoringG 87 /Back boring

Page 34: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 34

G170 - G171 /circular pocket canned cycle

• The canned cycle required two blocks G170&G171• There are three ways to program these canned cycles

G170 R0 P0 Q3 X0 Y0 Z- nI0 J0 K-24; rough cut no allowanceG171 P75 S3000 R75 F250 B J;

For 1st block• R defines the position of the tool to start cycle• P =0 means a roughing cycle• Q defines the peck (vertical cut) increment• XY defines the hole centre• I defines the side finish allowance• J defines the base finish allowance• K defines the radius of the pocket (- means CCW)

For 2nd block• P defines the cut width percentage• S roughing spindle speed• R roughing feed in Z• F roughing feed in XY• B finished spindle speed (ignored when P=0)• J finish feed (ignored when P=0)

• When the tool has finished cutting the tool retracts 1mm in the Z axis, moves to the centre of the circular pocket at rapid traverse, retracts again in the Z axis.

G170 R0 P0 Q3 X0 Y0 Z-- I0.5 J0.1 K-24; rough cut WITHG171 P75 S3000 R75 F250 B3500 J200; finishing allowance

G170 R0 P1 Q3 X0 Y0 Z-6 I0.5 J0.1 K-24; One step finishing cycleG171 P75 S3000 R75 F250 B3500 J200

• I&J are ignored when P=1• S&R&F must be entered but ignored for finishing cycle

Page 35: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 35

G172 - G173 /Rectangular pocket canned cycle

• The canned cycle required two blocks G170&G171

G172 I-50 J-50 K0 P0 Q3 R0 X-25 Y-25 Z-6; Roughing cutG173 I0 K0 P75 T1 S3000 R75 F250 B3500 J200 Z5;

For 1st block• I defines the pocket X length (+ CW/ - CCW)• J defines the pocket Y length• P=0 roughing cycle• Q defines Z peck increment• R defines the absolute Z R point• XYZ absolute position of the pocket corner points

For 2nd block• I pocket side finish allowance (=0 when P=0)• K Pocket base finish allowance (=0 when roughing)• P is the cut width percentage• T is the pocket tool• S roughing spindle speed• R roughing feed for Z• F Rouging feed for X and Y• B finish spindle speed• J finish feed• Z safety Z above R.

G172 I-50 J-50 K0 P0 Q3 R0 X-25 Y-25 Z-6; rough cut WITH finishG173 I0.5 K0.1 P75 T1 S3000 R75 F250 B3500 J200 Z5;

G172 I-50 J-50 K0 P1 Q3 R0 X-25 Y-25 Z-6; One step finishing cycleG173 I0.5 K0.1 P75 T1 S3000 R75 F250 B3500 J200 Z5;

Page 36: M.nazmi ‹#› General 1- Composition of a part programs. 2- Block Configuration. 3- Part programming Block format: N G X(u) Y(w) Z F M S T N (block number):

M.nazmi 36

G90 /Absolute commandActive when machine is first switched on

G91 /Incremental command

G94 /Feed per minute(G29) F6= 6 inches/min(G21) F150= 150 mm/minute

G95 /Feed per revolution of spindle

List of G Codes (Milling machine)

G00 positioning (rapid traverse)G01 liner interpolation (feed)G02 circular interpolation CWG03 circular interpolation CCWG04 dwellG20 inch data inputG21 metric data inputG28 reference point returnG40/G41/G73-G89 Canned cyclesG73 High speed peck drillingG74 Counter tappingG76 Fine boringG80 Canned cycle cancelG81 Drilling – counter boaringG83 Deep hole peck drillingG84 TappingG85 BoringG86 BoringG87 Peck boringG89 BoringG90 Absolute zero commandG91 Incremental commandG94 feed per minuteG95 feed per revolutionG98 Return to initial levelG99 Return to R pointG170-G173 Cirular/Rect pockets