LinuxCNC "G-Code" Quick Reference
Code | Parameters | Description |
Motion | (X Y Z A B C U V W apply to all motions) |
G0 | | Rapid Move |
G1 | | Linear Move |
G2, G3 | I J K or R, P | Arc Move |
G4 | P | Dwell |
G5 | I J P Q | Cubic Spline |
G5.1 | I J | Quadratic Spline |
G5.2 | P L | NURBS |
G38.2 - G38.5 | | Straight Probe |
G33 | K ($) | Spindle Synchronized Motion |
G33.1 | K ($) | Rigid Tapping |
G80 | | Cancel Canned Cycle |
Canned cycles | (X Y Z or U V W apply to canned cycles, depending on active plane) |
G81 | R L (P) | Drilling Cycle |
G82 | R L (P) | Drilling Cycle, Dwell |
G83 | R L Q | Drilling Cycle, Peck |
G84 | R L (P) ($) | Right-hand Tapping Cycle, Dwell |
G73 | R L Q | Drilling Cycle, Chip Breaking |
G74 | R L (P) ($) | Left-hand Tapping Cycle, Dwell |
G85 | R L (P) | Boring Cycle, Feed Out |
G89 | R L (P) | Boring Cycle, Dwell, Feed Out |
G76 | P Z I J R K Q H L E ($) | Threading Cycle |
Distance Mode |
G90, G91 | | Distance Mode |
G90.1, G91.1 | | Arc Distance Mode |
G7 | | Lathe Diameter Mode |
G8 | | Lathe Radius Mode |
Feed Rate Mode |
G93, G94, G95 | S ($) | Feed Rate Mode |
Spindle Control |
M3, M4, M5 | S ($) | Spindle Control |
M19 | R Q (P) ($) | Orient Spindle |
G96, G97 | S D ($) | Spindle Control Mode |
Coolant |
M7, M8, M9 | | Coolant Control |
Tool Length Offset |
G43 | H | Tool Length Offset |
G43.1 | | Dynamic Tool Length Offset |
G43.2 | H | Apply additional Tool Length Offset |
G49 | | Cancel Tool Length Compensation |
Stopping |
M0, M1 | | Program Pause |
M2, M30 | | Program End |
M60 | | Pallet Change Pause |
Units |
G20, G21 | | Units (inch, mm) |
Plane Selection | (affects G2, G3, G81…G89, G40…G42) |
G17 - G19.1 | | Plane Select |
Cutter Radius Compensation |
G40 | | Compensation Off |
G41,G42 | D | Cutter Compensation |
G41.1, G42.1 | D L | Dynamic Cutter Compensation |
Path Control Mode |
G61 G61.1 | | Exact Path Mode |
G61.1 | | Exact Stop Mode |
G64 | P Q | Path Blending |
Return Mode in Canned Cycles |
G98, G99 | | Canned Cycle Return Level |
Other Modal Codes |
F | | Set Feed Rate |
S | ($) | Set Spindle Speed |
T | | Select Tool) |
M48, M49 | | Speed and Feed Override Control |
M50 | P0 (off) or P1 (on) | Feed Override Control |
M51 | P0 (off) or P1 (on) ($) | Spindle Speed Override Control |
M52 | P0 (off) or P1 (on) | Adaptive Feed Control |
M53 | P0 (off) or P1 (on) | Feed Stop Control |
G54-G59.3 | | Select Coordinate System |
Flow-control Codes |
o sub | | Subroutines, sub/endsub call |
o while | | Looping, while/endwhile do/while |
o if | | Conditional, if/else/endif |
o repeat | | Repeat a loop of code |
[] | | Indirection |
o call | | Call named file |
M70 | | Save modal state |
M71 | | Invalidate stored state |
M72 | | Restore modal state |
M73 | | Save and Auto-restore modal state |
Input/Output Codes |
M62 - M65 | P | Digital Output Control |
M66 | P E L Q | Wait on Input |
M67 | T | Analog Output,Synchronized |
M68 | T | Analog Output, Immediate |
Non-modal Codes |
M6 | T | Tool Change |
M61 | Q | Set Current Tool |
G10 L1 | P Q R | Set Tool Table |
G10 L10 | P | Set Tool Table |
G10 L11 | P | Set Tool Table |
G10 L2 | P R | Set Coordinate System |
G10 L20 | P | Set Coordinate System |
G28, G28.1 | | Go/Set Predefined Position |
G30, G30.1 | | Go/Set Predefined Position |
G53 | | Move in Machine Coordinates |
G52, G92 | | Coordinate System Offset |
G92.1, G92.2 | | Reset G92 Offsets |
G92.3 | | Restore G92 Offsets |
M101 - M199 | P Q | User Defined Commands |
Comments & Messages |
; (…) | | Comments |
(MSG,…) | | Messages |
(DEBUG,…) | | Debug Messages |
(PRINT,…) | | Print Messages |