Milling Codes Important M-Codes for Milling and Turning
1)Positioning M00 (Program Stop)
G90 (Absolute) M01 (Optional Program Stop)
G91 (Incremental) M02 (End program)
M30 (End program and reset to the top)
2)Dimensioning
M99 (End subprogram)
G20 (Inches)
M98 (Call sub program)
G21 (mms)
3)Plane Selection M03 (Spindle on CW)
G17 (X-Y), G18 (X-Z), G19 (Y-Z) M04 (Spindle on CCW)
4) Coordinates Selection M05 (Spindle off)
G92 (Absolute Zero position) M06 (Tool Change)
G53 (Machine Datum)
M08 (Coolant No.1 on)
G54:G59 (W.P Datum)
M09 (Coolant off)
To set W.P datum use: G10 P [0:6] X... Y... Z...;
Where: P0: active, P1: G54, P2: G55, etc. M41 (Spindle low range for turning)
5)Tool Change process M42 (Spindle high range for turning)
G28 (Return home position) M43 (Call Subprogram for turning)
T… M06; (Change tool with #...) Group 0 is only non-modal group like:
S…M [03 or 04]; (Spindle on … rpm) (G04, G10, G28, G29, G30, G53, G92)
Before G28, use G91 / Skipping Block
G29 (back from home position) % Start & End transferring program
6)Tool Length Compensation ; End of Block
G43 Z … H …; (+ve) O_ _ _ _; Program Identifier
G44 Z … H …; (-ve ) Each block starts with sequence num. N…;
G45/G49; (Cancel length compensation) M98 P_ _ _ _ _; or M98 P_ _ _ _ L _ ;
H: length offset num. (H00 Standard tool) Where P # of repeats and four numbers are sun
7)Tool radius compensation program name.
G41 … D…; (left) In case 2 different G-codes from the same group
G42 … D…; (right) introduced in the same block, the 2nd one is valid.
G40; (Cancel radius compensation) (1st one is ignored)
8)Traverse Motion 1801#3=0 like G90
G00 X … Y … Z …; (Rapid), (Not Sync) 1801#3=1 like G91
G01 X … Y … Z … F…; (Linear),(Sync)
1800#0 and 1000#1 are used to identify unit
G02 R…
X… Y… Z... F…; sensitivity (mm vs micrometers).
G03 I… J…
(Circular) [G02 (CW) and G03 (CCW)] Milling Canned Cycles
(F: federate) units identified by: G80; cancel canned cycle
G94 (mm/min) or G95 (mm/rev), G98 Return to initial point
XYZ end point, G99 return to R- level
IJ Center of arc:(Identified relatively wrt start point), Drilling Cycle
R radius of arc: (+ve(short arc) or -ve(long)) G81 X_Y_Z_R_F_;
9)Stroke Check and limits Drilling with Dwell P in (ms)
G22 X… Y… Z… I… J… K…; G82 X_Y_Z_R_P_F_;
G23; (Cancel) Peck Drilling (with Q intermitted cuts)
XYZ initial limit, IJK End limit. G83 X_Y_Z_ Q_ R_ F_;
10)Scaling High Speed Peck Drilling
G51 I _ J_ K_ P_ ; or G51 X_ Y_ I_J_ ; G73 X_ Y _ Z_ R_ Q_ F_ K_;
G50; Cancel Right-Handed Tapping (with Peck)
Where: G84 X_ Y_ Z_ R_ F_ P_ K_ (Q_);
1st format: I J center point and P scaling ratio
Left-Handed Tapping (with Peck)
P1000 scale 1:1, P500 scale 1:2, etc.
G74 X_ Y_ Z_ R_ F_ P_ K_ (Q_);
2nd format: X Y is center points and I J are scaling
ratio for XY directions respectively Boring with repeated cycles L
G85 X_ Y_ Z_ R_ F_ L_;
Turning Codes
Circular Pocket milling (CW/CCW)
G-Codes
G12/G13 Z_ I_ D_ F_;
G28 Zero/ Home position Return
Multi-Pass Pocket milling
G40 Tool Nose Compensation Cancel
G12/G13 Z_I_K_Q_D_F_;
G41 Tool Nose Compensation, Left
Circular Groove G42 Tool Nose Compensation, Right
Roughing G50 W. P Coordinate setting/ Speed Clamp
G110/G111 X Y Z R I L W Q V D F K; G77 Revolution per minute input
Finishing G98 Feed rate per minute
G112/G113 X Y Z R I L D F K; G99 Feed rate per revolution
Rectangular Groove W.P Datum Setting
Roughing G92 X_ Z_; (WP Coordinates preset)
G130/G131 XYZ R I J L W Q V U D F K; Note that X is defined as diameter
Finishing
Surface speed vs rotational speed
G132/G133 X Y Z R I J L U D F K;
G96 constant Surface speed cutting Vc
Outside Finishing
G97 constant rotational speed N
G136/G137 X Y Z I J D L U F K;
Feed Drive Analysis G96 used for axial operation, on another hand
𝐿𝑒𝑎𝑑 G97 used for radial operation
• tan α = Selecting spindle speed
2𝜋 𝑟𝑚
• tan 𝜃𝑛 = tan 𝜃 cos 𝛼 M41 Spindle low speed range for roughing
tan 𝛼+
𝜇𝑠 M42 Spindle High speed ranges for finishing
• 𝑇𝑠 = 𝐹𝑠 {𝑟𝑚 [
cos 𝜃𝑛
𝜇 tan 𝛼 ] + 𝜇𝑐 𝑟𝑐 }
1− 𝑠 Those are used with M03 and M04
cos 𝜃𝑛
• 𝐹𝑠 = 𝐹𝑓𝑟𝑖𝑐𝑡𝑖𝑜𝑛 + 𝐹𝑓𝑒𝑒𝑑 Tool Homing
G28 home position for indexing
= 𝜇𝑔 [𝑔(𝑚𝑤 + 𝑚𝑡 ) + 𝐹𝑝 ] + 𝐹𝑓
Turning Canned Cycles
2𝜋
• 𝑇𝑑 = 𝐽𝑒𝑞 ∗ ∗ 𝑣𝑓 ° Rough turning
𝑟𝑔 𝐿𝑒𝑎𝑑
G71 P_Q_U_W_D_F_;
𝑧𝑚
• 𝑟𝑔 = Finish turning
𝑧𝑠 G70 P_Q_F_;
• 𝑇𝑎𝑙𝑙 = 𝑇𝑑 + 𝑇𝑠 P = line number for the start of profile
= 𝑇𝑑𝑦𝑛𝑎𝑚𝑖𝑐 + 𝑇𝑓𝑟𝑖𝑐𝑡𝑖𝑜𝑛 + 𝑇𝑓𝑒𝑒𝑑 Q = line number for the end of profile
100 tan 𝛼 U = finishing allowance in the X-axis
𝐸𝑓𝑓𝑖𝑐𝑖𝑒𝑛𝑐𝑦 = W = finishing allowance in the Z-axis
tan 𝛼 + 𝜇 ⁄cos 𝜃𝑛 𝜇 𝑟
+ 𝑟𝑐 𝑐 D = depth removed per pass
1 − 𝜇 tan 𝛼⁄cos 𝜃𝑛 𝑚
Peck Drilling
Where:
G74 X0.0 Z_F_K_;
θ for acme thread = 14.5˚
K= depth of peck
θ for square thread =5˚
Grooving Cycle
G75X_Z_F_I_K_;
X = diameter at the bottom of the groove
Z = end position of the groove
Ix= depth of cut on the X-axis
Kz= depth of cut on the Z-axis
Fx= the retract of the grooving tool
Threading cycle
G76X_Z_K_D_F_A_;
X = diameter at the bottom of the thread
Z = end position of the thread
K = thread height
D = depth of cut in the first pass
F = thread lead (pitch for a single start)
A = included thread angle