Professional Documents
Culture Documents
Ex.No.1
Study of G Codes and M Codes to Write Manual Part Programming for Fanuc Control
Systems
The preparatory functions are the commands, which prepare the machine for different modes of
movement like contouring, thread cutting, positioning, peck drilling etc. These functions are also called as
G codes. G codes are used as machining commands.
The miscellaneous functions are the commands describing miscellaneous functions like
subprogram call or exit., spindle clockwise or counter clockwise, coolant ON/ OFF, program end etc.
these functions are also called as M codes. M codes are used as machine control commands.
SUBROUTINES
Subroutines or subprograms are mini programs similar to macros but are used in manual part
programming. It can be defined as a set of instructions that can be activated and used for repetitive
applications in the main program. In Fanuc control systems, subprograms are written as separate
programs with specific subprogram names. When a subprogram name is called in the main program, the
set of instructions in the subprogram is executed. After execution of the program flow returns to the main
program at a point immediately after the original call point.
CANNED CYCLE
Canned cycles are built-in- functions that are available to perform specific tasks like thread
cutting, grooving, pattern repeating, pocketing etc. A canned cycle simplifies the program using one or
two blocks with specific G codes to specify the machining operations, instead of using several blocks.
Examples are
G71 - Multiple turning cycle
G73 - Pattern turning cycle
G75 - Grooving cycle
G76 - Multiple thread cutting cycle
G170, G171 - Rectangular pocketing
G172, G173 - Circular pocketing
The list of G codes and M codes that can be used in milling machines are given below.
M CODES FUNCTION
M00 PROGRAM STOP
M08 COOLANT ON
M10 VICE ON
M70 X MIRROR ON
M71 Y MIRROR ON
G04 DWELL
G21 INPUT IN MM
M CODES FUNCTION
M00 PROGRAM STOP
M08 COOLANT ON
G CODES FUNCTION
G04 DWELL
G21 INPUT IN mm
Ex.No.2
Write a manual part program for the given diagram using Linear interpolation and circular
interpolation
O2000
[BILLET X100 Y100 Z10;
[TOOLDEF T1 D5;
[EDGEMOVE X0 Y0;
N10 G21 G40 G94;
N20 G50 S2000;
N30 G91 G28 Z0;
N40 G28 X0 Y0;
N50 M06 T0101;
N60 M03 S1000;
N70 G90;
N80 G00 X20 Y20 Z1;
N90 G01 X20 Y20 Z-1 F35;
N100 G01 X60 Y20 Z-1 F35;
N110 G03 X80 Y40 Z-1 R20 F35;
N120 G01 X80 Y60 Z-1 F35;
N130 G02 X60 Y80 Z-1 R20 F35;
N140 G01 X40 Y80 Z-1 F35;
N150 G03 X20 Y60 Z-1 R20 F35;
N160 G01 X20 Y20 Z-1 F35;
N170 G00 Z1;
N180 G91 G28 Z0;
N190 G28 X0 Y0;
N200 M05;
N210 M30;
The same program can also be written as given below.
O2001
[BILLET X100 Y100 Z10;
[TOOLDEF T1 D5;
[EDGEMOVE X0 Y0;
N10 G21 G40 G94;
N20 G50 S2000;
N30 G91 G28 Z0;
N40 G28 X0 Y0;
N50 M06 T0101;
N60 M03 S1000;
N70 G90;
N80 G00 X20 Y20 Z1;
N90 G01 Z-1 F35;
N100 X60 ;
N110 G03 X80 Y40 R20;
N120 G01 Y60;
N130 G02 X60 Y80 R20;
N140 G01 X40;
N150 G03 X20 Y60 R20;
N160 G01 Y20;
N170 G91 G28 Z2;
N180 G28 X0 Y0;
N190 M05;
N200 M30;
CIRCULAR POCKETING AND RECTANGULAR POCKETING
Ex.No.3
Write a CNC program for milling machine for the profile given using circular pocketing and
rectangular pocketing.
Write a CNC program for milling machine for the profile given using sub program.
Profile depth = 5 mm
SUBPROGRAM
O9000;
N10 G91 G01 Z-1 F35;
N20 G90;
N30 G01 X40 Y20;
N40 G02 X60 Y20 R10;
N50 G01 X80 Y20;
N60 X80 Y50;
N70 G03 X20 Y50 R30;
N80 G01 X20 Y20;
N90 M99;
** save the subprogram as 4 digit number 9000.
Main Program
O2003
[BILLET X100 Y100 Z20;
[EDGEMOVE X0 Y0;
[TOOLDEF T1 D5;
N10 G21 G94 G40;
N20 G91 G28 Z0;
N30 G28 X0 Y0;
N40 M06 T0101;
N50 M03 S1000;
N60 G90 G00 X20 Y20 Z1;
N70 G01 Z0 F35;
N80 M98 P0059000;
N90 G01 Z1;
N100 G91 G28 Z0;
N110 G28 X0 Y0;
N120 M05;
N130 M30;
The statement M98 P0059000 can be explained as follows:
M 98 – For subprogram call.
P0059000 – 005 is the number of times the subprogram 9000 has to be called. (i.e. the subprogram 9000
has to be executed for 5 times.)
MIRRORING USING SUBPROGRAM
Ex.No.5
Write a CNC program for milling machine for the profile given using sub program and mirror
command.
Subprogram
O8000;
N10 G90 G00 X10 Y10 Z1;
N20 G01 Z-1 F35;
N30 G01 X30 Y10;
N40 G03 X10 Y30;
N50 G01 X10 Y10;
N60 G00 Z1;
N70 G00 X0 Y0;
N80 M99;
Ex.No.6
Write a CNC program for milling machine as shown in diagram using drilling cycle.
O2005;
[BILLET X100 Y100 Z20;
[TOOLDEF T1 D10;
[EDGEMOVE X-50 Y-50;
N10 G21 G94 G41;
N20 G91 G28 Z0;
N30 G28 X0 Y0;
N40 M06 T0101;
N50 M03 S1000;
N60 G90 G00 X0 Y0 Z5;
N70 G83 X0 Y25 Z-10 Q0.5 R1 F35; ⎯⎯⎯⎯⎯⎯⎯ DRILL 1
N80 X21.65 Y12.5; ⎯⎯⎯⎯⎯⎯⎯ DRILL 2
N90 X21.65 Y-12.5 ; ⎯⎯⎯⎯⎯⎯⎯ DRILL 3
N100 X0 Y-25; ⎯⎯⎯⎯⎯⎯⎯ DRILL 4
N110 X-21.65 Y - 12.5; ⎯⎯⎯⎯⎯⎯⎯ DRILL 5
N120 X-21.65 Y 12.5; ⎯⎯⎯⎯⎯⎯⎯ DRILL 6
N130 G80;
N140 G91 G28 Z0;
N150 G28 X0 Y0;
N160 M05;
N170 M30;
CNC PROGRAM USING FAST DRILLING CYCLE
Ex.No.7
Write a CNC program for milling machine as shown in diagram using fast peck drilling cycle.
O2006