Common GCode for Mach 3 and Linux EMC
Mach 3
Quick Reference G Codes
G01 Linear interpolation
G02 Clockwise circular/helical interpolation
G03 Counter clockwise circular/Helical interpolation
G04 Dwell
G10 Coordinate system origin setting
G15/G16 Polar Coordinate moves in G0 and G1
G17 XY Plane select
G18 XZ plane select
G19 YZ plane select
G20/G21 Inch/Millimetre unit
G28 Return home
G28.1 Reference axes
G30 Return home
G32 Threading
G40 Cancel nose radius compensation
G41/G42 Start nose radius compensation left/right
G50 Reset all scale factors to 1.0
G51 Set axis data input scale factors
G52 Temporary coordinate system offsets
G53 Move in absolute machine coordinate system
G54 Use fixture offset 1
G55 Use fixture offset 2
G56 Use fixture offset 3
G57 Use fixture offset 4
G58 Use fixture offset 5
G59 Use fixture offset 6 / use general fixture number
G61/G64 Exact stop/Constant Velocity mode
G76 Canned cycle – screw cutting
G77 Canned cycle
G78
G80 Cancel motion mode (including canned cycles)
G81 Canned cycle – drilling
G82 Canned cycle – drilling with dwell
G83 Canned cycle – peck drilling
G90 Absolute distance mode
G91 Incremental distance mode
G92 Offset coordinates and set parameters
G92.x Cancel G92 etc.
G94 Feed per minute mode
G95 Feed per rev mode
G98 Initial level return after canned cycles
G99 R-point level return after canned cycles
The modal Groups for G codes are
· group 1 = {G00, G01, G02, G03, G38.2, G80, G81, G82, G84, G85,
G86, G87, G88, G89} motion
· group 2 = {G17, G18, G19} plane selection
· group 3 = {G90, G91} distance mode
· group 5 = {G93, G94} feed rate mode
· group 6 = {G20, G21} units
· group 7 = {G40, G41, G42} cutter radius compensation
· group 8 = {G43, G49} tool length offset
· group 10 = {G98, G99} return mode in canned cycles
· group 12 = {G54, G55, G56, G57, G58, G59, G59.xxx} coordinate
system selection
· group 13 = {G61, G61.1, G64} path control mode
The modal groups for M codes are:
¨ group 4 = {M00, M01, M02, M30} stopping
¨ group 6 = {M06} tool change
¨ group 7 = {M03, M04, M05} spindle turning
¨ group 8 = {M07, M08, M09} coolant (special case: M07 and M08 may
be active at the same time)
¨ group 9 = {M48, M49} enable/disable feed and speed override controls
In addition to the above modal groups, there is a group for non-modal
G codes:
¨ group 0 = {G04, G10, G28, G30, G53, G92, G92.1, G92.2, G92.3}
This is a list of GCode used by Linux EMC
Linux CNC G-Code Quick Reference
Code |
Parameters |
Description |
---|---|---|
Motion |
(X Y Z A B C U V W apply to all motions) |
|
Rapid motion |
||
Coordinated motion (“Straight feed”) |
||
I J K or R, P |
Coordinated helical motion (“Arc feed”) CW or CCW |
|
P |
Dwell (no motion for P seconds) |
|
I J P Q |
Cubic spline |
|
I J |
Quadratic spline |
|
P L |
NURBS, add control point |
|
NURBS, execute |
||
Straight probe |
||
K |
Spindle-synchronized motion |
|
K |
Rigid tapping |
|
Cancel motion mode |
||
Canned cycles |
(X Y Z or U V W apply to canned cycles, depending on active plane) |
|
R L (P) |
Drilling cycle without (with) dwell |
|
R L Q |
Peck and Chip-break drilling cycles |
|
R L (P) |
Boring cycle without (with) dwell |
|
P Z I J R K Q H L E |
Multipass lathe threading cycle |
|
Distance Mode |
||
Absolute distance mode |
||
Incremental distance mode |
||
Arc centers I,J,K are absolute |
||
Arc centers I,J,K are relative to the arc’s starting point |
||
X Diameter mode (lathe) |
||
X Radius mode (lathe) |
||
Feed Rate Mode |
||
Inverse time feed rate |
||
Units per minute feed rate |
||
Units per revolution |
||
Spindle Control |
||
S |
Turn spindle clockwise or counterclockwise |
|
Stop spindle |
||
Orient spindle |
||
S D |
CSS mode (Constant Surface Speed) |
|
RPM mode |
||
Coolant |
||
Turn mist on |
||
Turn flood on |
||
Turn all coolant off |
||
Tool Length Offset |
||
H |
Use tool length offset from tool table |
|
Use specified tool length offset for transient tool |
||
H |
Apply additional tool length offset |
|
Cancel tool length offset |
||
Stopping |
||
Program Pause |
||
Optional Pause |
||
End Program |
||
Pallet Change Pause |
||
Units |
||
Inches |
||
Millimetres |
||
Plane Selection |
(affects G2, G3, G81…G89, G40…G42) |
|
Select XY plane |
||
Select XZ plane |
||
Select YZ plane |
||
Cutter Radius Compensation |
||
Cancel cutter radius compensation |
||
D |
Start cutter radius compensation left or right |
|
D L |
Start cutter radius compensation left or right, transient tool |
|
Path Control Mode |
||
Exact Path mode |
||
Exact Stop mode |
||
P |
Continuous mode with optional path tolerance |
|
Return Mode in Canned Cycles |
||
Retract to prior position |
||
Retract to R position |
||
Other Modal Codes |
||
Set Feed Rate |
||
Set Spindle Speed |
||
Select Tool (also see M6) |
||
Speed and Feed Override Control |
||
P0 (off) or P1 (on) |
Feed Override Control |
|
P0 (off) or P1 (on) |
Spindle Speed Override Control |
|
P0 (off) or P1 (on) |
Adaptive Feed Control |
|
P0 (off) or P1 (on) |
Feed Stop Control |
|
Select coordinate system |
||
Flow-control Codes |
||
Subroutines, sub/endsub call |
||
Looping, while/endwhile do/while |
||
Conditional, if/else/endif |
||
Run enclosed code more than once |
||
Save modal state |
||
Invalidate stored state |
||
Restore modal state |
||
Save and Auto-restore modal state |
||
Input/Output Codes |
||
P |
Digital Output Control |
|
P E L Q |
Digital and Analog Input Control |
|
T |
Analog Output Synchronized with Motion |
|
T |
Analog Output Immediate |
|
Non-modal Codes |
||
T |
Change tool |
|
Q |
Set Current Tool |
|
P |
Dwell (seconds) |
|
P Q R axes |
Tool offset, radius, orientation setting |
|
P axes |
Tool offset, setting calculated from workpiece |
|
P axes |
Tool offset, setting calculated from fixture |
|
P R axes |
Coordinate system origin, rotation setting |
|
P axes |
Coordinate system origin setting calculated |
|
Return to or Set reference point 1 |
||
Return to or Set reference point 2 |
||
Motion in machine coordinate system |
||
axes |
Offset coordinate systems and set parameters |
|
Cancel offset coordinate systems and set parameters to zero |
||
Cancel offset coordinate systems but do not reset parameters |
||
Apply parameters to offset coordinate systems |
||
P Q |
User-defined M-codes |
|
Comments & Messages |
||
An inline comment |
||
Display a message “…” to the user (e.g., in a popup) |
||
Display a message (with variables substituted) like MSG |
||
Display a message (with variables substituted) to stderr |