top of page

Introduction To G-Code And M-Code

G-codes G-codes are used to command specific movements of the machine, such as machine moves or drilling functions. The majority of G-Code programs start with a percent (%) symbol on the first line, then followed by an "O" with a numerical name for the program (i.e. "O0001") on the second line, then another percent (%) symbol on the last line of the program. The format for a G-code is the letter G followed by two to three digits; for example G01. G-codes differ slightly between a mill and lathe application, for example: [G00 Rapid Motion Positioning] [G01 Linear Interpolation Motion] [G02 Circular Interpolation Motion-Clockwise] [G03 Circular Interpolation Motion-Counter Clockwise] [G04 Dwell (Group 00) Mill] [G10 Set offsets (Group 00) Mill] [G12 Circular Pocketing-Clockwise] [G13 Circular Pocketing-Counter Clockwise]

M-codes [Code Miscellaneous Functions (M-Code)][citation needed]. M-codes are miscellaneous machine commands that do not command axis motion. The format for an M-code is the letter M followed by two to three digits; for example: [M02 End of Program] [M03 Start Spindle - Clockwise] [M04 Start Spindle - Counter Clockwise] [M05 Stop Spindle] [M06 Tool Change] [M07 Coolant on mist coolant] [M08 Flood coolant on] [M09 Coolant off] [M10 Chuck open] [M11 Chuck close] [M13 BOTH M03&M08 Spindle clockwise rotation & flood coolant] [M14 BOTH M04&M08 Spindle counter clockwise rotation & flood coolant] [M16 Special tool call] [M19 Spindle orientate] [M29 DNC mode ] [M30 Program reset & rewind] [M38 Door open] [M39 Door close] [M40 Spindle gear at middle] [M41 Low gear select] [M42 High gear select] [M53 Retract Spindle] (raises tool spindle above current position to allow operator to do whatever they would need to do) [M68 Hydraulic chuck close] [M69 Hydraulic chuck open] [M78 Tailstock advancing] [M79 Tailstock reversing]



As For Example

%
O0001
G20 G40 G80 G90 G94 G54(Inch, Cutter Comp. Cancel, Deactivate all canned cycles, moves axes to machine coordinate, feed per min., origin coordinate system)
M06 T01 (Tool change to tool 1)
G43 H01 (Tool length comp. in a positive direction, length compensation for the tool)
M03 S1200 (Spindle turns CW at 1200RPM)
G00 X0. Y0. (Rapid Traverse to X=0. Y=0.)
G00 Z.5 (Rapid Traverse to z=.5)
G00 X1. Y-.75 (Rapid traverse to X1. Y-.75)
G01 Z-.1 F10 (Plunge into part at Z-.25 at 10in per min.)
G03 X.875 Y-.5 I.1875 J-.75 (CCW arc cut to X.875 Y-.5 with radius origin at I.625 J-.75)
G03 X.5 Y-.75 I0.0 J0.0 (CCW arc cut to X.5 Y-.75 with radius origin at I0.0 J0.0)
G03 X.75 Y-.9375 I0.0 J0.0(CCW arc cut to X.75 Y-.9375 with radius origin at I0.0 J0.0)
G02 X1. Y-1.25 I.75 J-1.25 (CW arc cut to X1. Y-1.25 with radius origin at I.75 J-1.25)
G02 X.75 Y-1.5625 I0.0 J0.0 (CW arc cut to X.75 Y-1.5625 with same radius origin as the previous arc)
G02 X.5 Y-1.25 I0.0 J0.0 (CW arc cut to X.5 Y-1.25 with same radius origin as the previous arc)
G00 Z.5 (Rapid traverse to z.5)
M05 (spindle stops)
G00 X0.0 Y0.0 (Mill returns to origin)
M30 (Program End)
%

Comments


Post: Blog2_Post
bottom of page