Tag Archives: M Code

How can I use subprograms to increase productivity on my machining center?

How can I use subprograms to increase productivity on my machining center?

Generally speaking, subprograms do not increase throughput for a machining operation. The real benefit of using subprograms is to decrease setup time and NC file size.
Subprograms allow you to repeat a portion of a program many times. For instance, if you had a particular section of a program that needed to be repeated several times, instead of copying that section of the program over and over (and ending up with a very large NC file), you could use a subprogram. You would write the subprogram section once, then refer to it as many times as you need to.

For example, suppose a very sophisticated design needs to be cut into a piece of steel with a 0.050” end mill. The total depth of the cut needs to be 0.125”; a much deeper cut than the small end mill can make.
Through experience we know that the deepest we can cut at any one time is 0.005”. Therefore we can calculate that we need to make 25 passes on the X,Y plane to reach the final depth of 0.125”. Let’s assume that the code required to make just one of these passes is 2000 blocks. If we used a CAM package to generate a program with the 25 passes, we would end up with an NC program with 50,000+ blocks.

The alternative is to use the CAM package to generate a program that provides one pass in the XY plane. We could then manually add the subprogram codes necessary to “call” that section 25 times (incrementally moving the Z axis down 0.005” each time). Not only would this save considerable disk space, but we would end up with a program that machines the same part in only 2010 blocks, a considerable savings.
For information on building and utilizing subprograms, refer to your User’s Guide.

See Also:

Subprogram Block Numbers, O Code
Call to Subprogram, M98 Code
Return from Subprogram, M99 Code
Subprogram Reference Number, P Code

CNC Program: #Part 00023

%
N10 G17 G20 G40 G49 G80 G90 
N20 G28 G91 Z0
N30 G28 X0 Y0
N40 T10 M6 (1 1/5 – TFEM)
N50 G0 G54 G90 X0 Y4. S640 M3
N60 G43 Z2. H10 M8 
N70 Z.1 
N80 G1 Z-.25 F6.72
N90 G2 J-4.05 F13.44
N100 G0 G80 Z2. M5
N110 G28 G49 Z0 M5
N120 M1
N130 T4 M6
N140 G0 G54 G90 X0 Y.3 S2560 M3
N150 G43 Z2. H4 M8
N160 Z.1 
N170 G1 Z-.1 F10.24
N180 X.695 Y-.9 F20.48
N190 X-.695
N200 X0 Y.3
N210 G0 Z.1
N220 X-1.750 Y1.2
N230 G1 Z-.1 F10.24
N240 G3 X1.15 Y1.8
N250 G1 X-2.316
N260 G0 X2.0
N270 X2.316
N280 Z.1
N290 G1 Z-.1 F10.24
N310 X1.5 F20.48
N320 G3 X1.75 Y1.2
N330 G0 Z2. M9
N340 G28 G49 G91 Z0 M5
N350 M1
N360 T2 M6 (1/4 TFEM)
N370 G0 G54 G90 X-2.457 Y-.85 S3840 M3 
N380 G43 Z2.0
N390 Z.1
N400 G1 Z-.1 F11.52
N410 G3 X-1.4 Y-2.144 I2.457 J.85 F2.144
N420 G2 X1.47 I1.47 J-1.356 
N430 G3 X-3.457 Y-.85 I-1.47 J2.144
N440 G0 Z2. M9
N450 G28 G49 G91 Z0 M5
N460 G28 X0 Y0
N470 M30
%

G-Codes

List of Haas G Code

G00 RAPID POSITIONING MOTION (X,Z,U,W,B) (SETTING 10, 101)

G01 LINEAR INTERPOLATION MOTION (X,Z,U,W,B,F)

G01 CHAMFERING AND CORNER ROUNDING (X,Z,U,W,B,I,K,R,A,F)

G02 CW CIRCULAR INTERPOLATION MOTION (X,Z,U,W,I,K,R,F)

G03 CCW CIRCULAR INTERPOLATION MOTION (X,Z,U,W,I,K,R,F)

G04 DWELL (P) (P=seconds…milliseconds)

G05 FINE SPINDLE CONTROL MOTION (X,Z,U,W,R,F) (LIVE TOOLING)

G09 EXACT STOP, NON-MODAL

G10 PROGRAMMABLE OFFSET SETTING (X,Z,U,W,L,P,Q,R)

G14 MAIN-SPINDLE SHIFT TO SUB-SPINDLE

G15 MAIN-SPINDLE SHIFT TO SUB-SPINDLE CANCEL

G17 CIRCULAR MOTION XY PLANE SELECTION (G02,G03) (LIVE TOOLING)

G18 CIRCULAR MOTION ZX PLANE SELECTION (G02,G03) (SETTING 56)

G19 CIRCULAR MOTION YZ PLANE SELECTION (G02,G03) (LIVE TOOLING)

G20 VERIFY INCH COORDINATE POSITIONING (SETTING 9 needs to be INCH)

G21 VERIFY METRIC COORDINATE POSITIONING (SETTING 9 needs to be METRIC)

G28 MACHINE ZERO RETURN THRU REF. POINT (X,Z,U,W,B) (Fanuc)

G29 MOVE TO LOCATION THROUGH G29 REF. POINT (X,Z) (Fanuc)

G31 FEED UNTIL SKIP FUNCTION (X,Z,U,W,F)

G32 THREAD CUTTING PATH, MODAL (X,Z,U,W,F)

G40 TOOL NOSE COMPENSATION CANCEL G41/G42 (X,Z,U,W,I,K) (SETTING 56)

G41 TOOL NOSE COMPENSATION, LEFT (X,Z,U,W) (SETTING 43, 44, 58)

G42 TOOL NOSE COMPENSATION, RIGHT (X,Z,U,W) (SETTING 43, 44, 58)

G50 SPINDLE SPEED MAXIMUM RPM LIMIT (S)

G51 RETURN TO MACHINE ZERO, CANCEL OFFSET (Yasnac)

G52 WORK OFFSET COORDINATE POSITIONING (Yasnac)

G52 GLOBAL WORK COORDINATE SYSTEM SHIFT (Fanuc)

G53 MACHINE COORDINATE POSITIONING, NON-MODAL (X,Z,B)

G54 WORK OFFSET COORDINATE POSITIONING #1 (SETTING 56)

G55 WORK OFFSET COORDINATE POSITIONING #2

G56 WORK OFFSET COORDINATE POSITIONING #3

G57 WORK OFFSET COORDINATE POSITIONING #4

G58 WORK OFFSET COORDINATE POSITIONING #5

G59 WORK OFFSET COORDINATE POSITIONING #6

G61 EXACT STOP, MODAL (X,Z)

G64 EXACT STOP G61 CANCEL (SETTING 56)

G65 MACRO SUB-ROUTINE CALL

G70 FINISHING CYCLE (P,Q)

G71 O.D. / I.D. STOCK REMOVAL CYCLE (P,Q,U,W,I,K,D,S,T,R1,F) (SETTING 72, 73)

G72 END FACE STOCK REMOVAL CYCLE (P,Q,U,W,I,K,D,S,T,R1,F) (SETTING 72, 73)

G73 IRREGULAR PATH STOCK REMOVAL CYCLE (P,Q,U,W,I,K,D,S,T,F)

G74 FACE GROOVING, or HIGH SPEED PECK DRILL CYCLE (X,Z,U,W,I,K,D,F) (SETTING 22)

G75 O.D. / I.D. PECK GROOVING CYCLE, (X,Z,U,W,I,K,D,F) (SETTING 22)

G76 THREAD CUTTING CYCLE, MULTIPLE PASS (X,Z,U,W,I,K,A,D,F) (SETTING 86, 95, 96, 99)

G77 FLATTING CYCLE (I,J,L,R,S,K) (LIVE TOOLING)

G80 CANCEL CANNED CYCLE (SETTING 56)

G81 DRILL CANNED CYCLE (X,Z,W,R,F)

G82 SPOT DRILL / COUNTERBORE CANNED CYCLE (X,Z,W,P,R,F)

G83 PECK DRILLING CANNED CYCLE (X,Z,W,I,J,K,Q,P,R,F) (SETTING 22, 52)

G84 TAPPING CANNED CYCLE (X,Z,W,R,F)

G85 BORE IN, BORE OUT CANNED CYCLE (X,Z,U,W,R,L,F)

G86 BORE IN, STOP, RAPID OUT CANNED CYCLE (X,Z,U,W,R,L,F)

G87 BORE IN, STOP, MANUAL RETRACT CANNED CYCLE (X,Z,U,W,R,L,F)

G88 BORE IN, DWELL, MANUAL RETRACT CANNED CYCLE (X,Z,U,W,P,R,L,F)

G89 BORE IN, DWELL, BORE OUT CANNED CYCLE (X,Z,U,W,P,R,L,F)

G90 O.D. / I.D. TURNING CYCLE, MODAL (X,Z,U,W,I,F)

G92 THREADING CYCLE, MODAL (X,Z,U,W,I,F) (SETTING 95, 96)

G94 END FACING CYCLE, MODAL (X,Z,U,W,K,F)

G95 END FACE LIVE TOOLING RIGID TAP (X,Z,W,R,F)

G96 CONSTANT SURFACE SPEED, CSS ON (S)

G97 CONSTANT NON-VARYING SPINDLE SPEED, CSS OFF (S) (SETTING 56)

G98 FEED PER MINUTE (F)

G99 FEED PER REVOLUTION (F) (SETTING 56)

G100 MIRROR IMAGE CANCEL G101

G101 MIRROR IMAGE (X,Z) (SETTING 45, 47)

G102 PROGRAMMABLE OUTPUT TO RS-232 (X,Z)

G103 LIMIT BLOCK LOOKAHEAD (P0 – P15 max. for number control looks ahead)

G105 SERVO BAR COMMAND

G110-G111 WORK OFFSET COORDINATE POSITIONING #7- #8

G112 CARTESIAN TO POLAR TRANSFORMATION

G113 CARTESIAN TO POLAR TRANSFORMATION CANCEL

G114-G129 WORK OFFSET COORDINATE POSITIONING #9 – #24

G159 BACKGROUND PICKUP / PART RETURN

G160 APL AXIS COMMAND MODE ON

G161 APL AXIS COMMAND MODE OFF

G184 REVERSE TAPPING CANNED CYCLE (X,Z,W,R,F) (SETTING 130)

G187 ACCURACY CONTROL FOR HIGH SPEED MACHINING (E) (SETTING 85)

G194 SUB-SPINDLE / TAPPING CANNED CYCLE

G195 LIVE TOOLING VECTOR TAPPING (X,F)

G196 LIVE TOOLING VECTOR TAPPING REVERSE (X,F)

G200 INDEX ON THE FLY (X,Z,U,W,T)

Haas M codes

M00 PROGRAM STOP (SETTING 42, 101)

M01 OPTIONAL PROGRAM STOP (SETTING 17)

M02 PROGRAM END

M03 SPINDLE ON FORWARD (S) (SETTING 144)

M04 SPINDLE ON REVERSE (S) (SETTING 144)

M05 SPINDLE STOP

M08 COOLANT ON (SETTING 32)

M09 COOLANT OFF

M10 CHUCK CLAMP (SETTING 92)

M11 CHUCK UNCLAMP (SETTING 92)

M12 AUTO AIR JET ON (P)

M13 AUTO AIR JET OFF

M14 MAIN SPINDLE CLAMP

M15 MAIN SPINDLE UNCLAMP

M17 ROTATE TURRET FORWARD (T) (SETTING 97)

M18 ROTATE TURRET REVERSE (T) (SETTING 97)

M19 ORIENT SPINDLE (P,R)

M21 TAILSTOCK ADVANCE (SETTING 93, 94, 106, 107, 121, 145)

M22 TAILSTOCK RETRACT (SETTING 105)

M23 ANGLE OUT OF THREAD ON (SETTING 95, 96)

M24 ANGLE OUT OF THREAD OFF

M30 PROGRAM END AND RESET (SETTING 2, 39, 56, 83)

M31 CHIP AUGER FORWARD (SETTING 114, 115)

M32 CHIP AUGER REVERSE (SETTING 114, 115)

M33 CHIP AUGER STOP

M36 PARTS CATCHER ON

M37 PARTS CATCHER OFF

M41 SPINDLE LOW GEAR OVERRIDE

M42 SPINDLE HIGH GEAR OVERRIDE

M43 TURRET UNLOCK (FOR SERVICE USE ONLY)

M44 TURRET LOCK (FOR SERVICE USE ONLY)

M51-M58 OPTIONAL USER M CODE SET

M59 OUTPUT RELAY SET (N)

M61-M68 OPTIONAL USER M CODE CLEAR

M69 OUTPUT RELAY CLEAR (N)

M76 PROGRAM DISPLAYS INACTIVE

M77 PROGRAM DISPLAYS ACTIVE

M78 ALARM IF SKIP SIGNAL FOUND

M79 ALARM IF SKIP SIGNAL NOT FOUND

M85 AUTOMATIC DOOR OPEN (SETTING 51, 131)

M86 AUTOMATIC DOOR CLOSE (SETTING 51, 131)

M88 HIGH PRESSURE COOLANT ON (SETTING 32)

M89 HIGH PRESSURE COOLANT OFF

M93 AXIS POSITION CAPTURE START (P,Q)

M94 AXIS POSITION CAPTURE STOP

M95 SLEEP MODE (hh:mm)

M96 JUMP IF NO SIGNAL (P,Q)

M97 LOCAL SUB-ROUTINE CALL (P,L)

M98 SUB-PROGRAM CALL (P,L)

M99 SUB-PROGRAM/ROUTINE RETURN OR LOOP (P) (SETTING 118)

M109 INTERACTIVE USER INPUT (P)

M110 TAILSTOCK CHUCK CLAMP (SETTING 122)

M111 TAILSTOCK CHUCK UNCLAMP (SETTING 122)

M119 SUB-SPINDLE ORIENT (P,R)

M121-M128 OPTIONAL USER M CODE INTERFACE WITH M-FIN SIGNAL

M133 LIVE TOOL DRIVE FORWARD (P)

M134 LIVE TOOL DRIVE REVERSE (P)

M135 LIVE TOOL DRIVE STOP

M143 SUB-SPINDLE FORWARD (P)

M144 SUB-SPINDLE REVERSE (P)

M145 SUB-SPINDLE STOP

M154 C AXIS ENGAGE (SETTING 102)

M155 C AXIS DISENGAGE

M164 ROTATE APL GRIPPERS TO "n" POSITION (Pn)

M165 OPEN APL GRIPPER 1 (RAW MATERIAL)

M166 CLOSE APL GRIPPER 1 (RAW MATERIAL)

M167 OPEN APL GRIPPER 2 (FINISHED MATERIAL)

M168 CLOSE APL GRIPPER 2 (FINISHED MATERIAL)