G-Code
Language: Haas which is similar to Fanuc.
Modal: commands are modal. They will not stop being in effect un l the machine is put into a different
mode. Commands in the same group disable the mode of the previous command from the same group.
Group 00: non modal commands. Complete an executed command and then stops.
Mill M-Codes
M00 (Stop Program): stops the program, axes, spindle, and turns off coolant. Block a er M00 is
highlighted when viewed in program editor, press [CYCLE START] to con nue program opera on from
highlighted block. You have to reac vate spindle and coolant (M03 and M08) if you want it back on.
Notes: you can use M00 to leave a note for the operator. Could be an instruc on to do before
resuming the code. E.g.
M00;
(REMOVE CHIPS!);
M01 (Op onal Program Stop): works same as M00 though [OPTION STOP] toggle must be on for it to
trigger when its read. If [OPTION STOP] is not toggled, it will be ignored. Move M01 to a er M06 code so
that the look ahead func on can prepare carousel for tool change. If M01 is before M06 it won’t prepare
for tool change.
M03 (Spindle Forward): turns spindle on in CW direc on. Used for all cu ng opera ons. Control spindle
speed with S address code. E.g., M03 S5000 commands spindle speed of 5000 RPM. Always do M05
before switching direc ons, otherwise you will signal the machine to spin CW and CCW at the same
me, breaking the machine.
M04 (Spindle Reverse): turns spindle on in CCW direc on. Uses S like M03.
M05 (Spindle Stop): stops the spindle, waits for spindle to fully stop before program execu on
con nues. You don’t need an M05 before a tool change as M06 automa cally stops the spindle.
M06 (Tool Change): changes tool and automa cally takes from the machine’s tool carousel.
Automa cally stops spindle and coolant and moves Z axis to tool change posi on and orients spindle for
tool change. Uses T address code to select tool. E.g., M06 T12 puts tool 12 in the spindle.
Prepara on: You can preposi on the carousel with a T code without an M06. Do this a er a tool
change to set up for the next tool. Then when its me to change tool, use M06 code and the
next tool you need will already be in place.
M08 (Coolant On): starts op onal coolant supply. Control checks coolant level only at start of program. A
low coolant condi on will not stop a running program.
M09 (Coolant Off): stops coolant supply.
M30 (Program End and Reset): stops a program, stops spindle and turns off coolant. Returns program
cursor to start of program. (M02 doesn’t return to beginning). Press [CYCLE START] to start the program
again.
M97 (Local Subprogram Call):Call a subprogram referenced by a line number (N) within the same
program. The subprogram is within the body of the main program, placed a er M30. Subprogram must
end with M99. P – program line number to go to when condi onal test is met. L – repeats subprogram
call 1-99 mes. E.g.
%
O00001;
M97 P100 L4;
M30;
N100;
M00
M99
%
Calls N100 Subprogram and repeats 4 times
Subprogram
Returns to main program
M98 (Subprogram Call): calls a subprogram separate to the pain program. P – the subprogram number
to run. L – repeats the subprogram call 1-99 mes. E.g., M98 P0001 calls the 0001 program. Alterna vely
you can use M98 (<path>/Onnnnn), where <path> is the device path that leads to the subprogram. File
paths are case sensi ve. E.g.,
%
O00002;
M98 P100 L4;
M30;
%
%
O00100;
M00;
M99;
%
Program number call
Calls O00100 sub 5 times
Subprogram
Return to main program
A call using a path would be coded as:
%
O00002;
M98 (USB0/O00100.nc) L4;
M30;
%
Program number call
Calls O00100 sub 5 times
M99 (Subprogram Return or Loop): Used at the end of a subprogram, local subprogram or macro to
return to the main program. A M99 Pnn jumps the program to the corresponding Nnn in the program.
M99 in main program causes the program to loop back to the beginning and execute un l [RESET] is
pressed. P – program line number to go to when condi onal test is met.
Mill G-Codes
G00 (Rapid Mo on Posi oning) (Group 01): move the machine axes at maximum speed. Used to quickly
posi on machine before each feed command. Machine waits un l all mo ons are completed before
star ng the next command.
G01 (Linear Interpola on Mo on) (Group 01): moves the axes at a commanded feed rate. Used to cut
the workpiece. F – controls rate of axis movement. Feed rate can be in units per minute or per spindle
revolu on or me to complete mo on. Control will always use the most recent specified feed rate value.
If a federate above machine capabili es is specified, the control will not proceed and an alarm will
sound.
G02 (Circular Interpola on Mo on CW) (Group 01): specifies clockwise circular mo on. Two axes and
the correct plane are necessary to complete circular mo on. Can be commanded using IJK addresses or
an R address.
G03 (Circular Interpola on Mo on CCW) (Group 01): specifies counterclockwise circular mo on. Works
the same as G02.
G04 (Dwell) (Group 00): specifies a delay or a dwell in the program. P – dwell me in seconds (Pnn.) or
milliseconds (Pnn). E.g., P10 will delay for 10 milliseconds, P10. will delay for 10 seconds.
G12 (Circular Pocket Milling CW) (Group 00): mill circular shape in clockwise direc on.
G13 (Circular Pocked Milling CCW) (Group 00): mill circular shape in counterclockwise direc on.
G17 (XY Plane Selec on):
G18 (ZX Plane Selec on):
G19 (YZ Plane Selec on):
G20 (Select Inches):
G21 (Select Millimeters):
G28 (Return to Machine Zero Point):
G40 (Cu er Compensa on Cancel):
G41 (2D Cu er Compensa on Le ):
G42 (2D Cu er Compensa on Right):
G43 (Tool Length Compensa on + (Add)):
G49 (G43/G44/G143 Cancel):
G53 (Non-Modal Machine Coordinate Selec on):
G54 (Select Work Coordinate System #1):
G55 (Select Work Coordinate System #2):
G56 (Select Work Coordinate System #3):
G57 (Select Work Coordinate System #4):
G58 (Select Work Coordinate System #5):
G59 (Select Work Coordinate System #6):
G65 (Macro Subprogram Call Op on):
G73 (High-Speed Peck Drilling Canned Cycle):
G74 (Reverse Tap Canned Cycle):
G76 (Fine Boring Canned Cycle):
G80 (Canned Cycle Cancel):
G81 (Drill Canned Cycle):
G82 (Spot Drill Canned Cycle):
G83 (Normal Peck Drilling Canned Cycle):
G84 (Tapping Canned Cycle):
G85 (Boring Canned Cycle):
G88 (Return to Home Posi on):
G90 (Absolute Posi on Command):
G91 (Incremental Posi on Command):
G98 (Canned Cycle Ini al Point Return):
G99 (Canned Cycle R Plane Return):
G150 (General Purpose Pocket Milling):
Cartesian Coordinate System and CNC Machines
Le er Variables for G&M Code
A
Rotary axis around X axis
B
Rotary axis around Y axis
C
Rotary axis around Z axis
D
Diameter or Radius offset used in Cutter Compensation designated in tool offset table
F
De ines Feed Rate in selected units (inches or millimetres) per minute
G
Preparatory Commands which dictate what kind of motion is desired
H
Calls Tool Length Offset (height value) as designated in machine tool offset table
I
Incremental distance in X from the arc start point to the arc centre
J
Incremental distance in Y from the arc start point to the arc centre
K
Incremental distance in Z from the arc start point to the arc centre
L
Fixed cycle loop count
M
Miscellaneous functions accompanied by an integer that determines meaning
N
Block numbering system. N is accompanied by a unique integer
O
Program Name followed by 4 or 5 integers
P
Parameter address for various G and M Codes
Q
Peck increment in various canned cycles
R
De ines size of arc radius or de ines retract height in canned cycles
S
De ines spindle speed in Revolutions Per Minuet. Followed by an integer with no decimal
T
Tool number selection followed by an integer
U
Incremental axis corresponding to the Z axis (on Lathes)
V
Incremental axis corresponding to the Y axis (on Lathes)
W
Incremental axis corresponding to the X axis (on Lathes)
X
Coordinate axis for X axis
Y
Coordinate axis for Y axis
Z
Coordinate axis for Z axis