Complete G-Code & M-Code Reference for CNC Programmers and Operators
Discover the full list of standard G-codes and M-codes used in CNC programming. Includes real-world examples, usage explanations, and downloadable G-code charts. Perfect for beginners and professionals.
G-Code (geometric code) and M-Code (machine code) are the fundamental languages of CNC machining. Whether you’re programming a mill, lathe, or router, understanding these codes is critical. Below is a detailed reference guide to help you understand how each code works, what it does, and how to apply it correctly in your CNC programs.
📋 G-Code Command List (ISO Standard)
G-Code | Description | Example |
---|---|---|
G00 | Rapid Positioning | G00 X0 Y0 Z0 |
G01 | Linear Interpolation | G01 X50 Y50 F100 |
G02 | Circular Interpolation CW | G02 X30 Y30 I10 J0 |
G03 | Circular Interpolation CCW | G03 X10 Y10 I-5 J5 |
G17/G18/G19 | Plane Selection (XY/XZ/YZ) | G17 |
G20/G21 | Inch/MM Mode | G21 ; Metric |
G28 | Return to Machine Zero | G28 X0 Y0 |
G40/G41/G42 | Tool Radius Compensation | G41 D1 |
G43 | Tool Length Compensation | G43 H05 |
G80–G89 | Canned Cycles | G81 ; Drilling |
🛠️ G-Code Example: Hole Drilling Cycle
G90 G21 ; Absolute, metric
G17 G40 G80 ; XY plane, cancel comp/cycle
T01 M06 ; Tool change
G00 X10 Y10 ; Position
G43 H01 Z5.0 ; Tool length offset
M03 S1200 ; Spindle on
G81 R2 Z-10 F200 ; Drilling cycle
G80 ; Cancel cycle
G00 Z50 ; Retract
M05 ; Spindle stop
M30 ; End of program
⚙️ M-Code Command List (Fanuc/Haas Style)
M-Code | Description | Example |
---|---|---|
M00 | Program Stop | M00 |
M01 | Optional Stop | M01 |
M03/M04 | Spindle On (CW/CCW) | M03 S1500 |
M05 | Spindle Stop | M05 |
M06 | Tool Change | T2 M06 |
M08/M09 | Coolant On/Off | M08 |
M30 | End of Program | M30 |
📈 High-TBM Keywords for SEO
- G-code cheat sheet PDF
- M-code list Fanuc CNC
- tool change G-code tutorial
- how to use G43 H offset
- G02 vs G03 explained
📄 G-Code Troubleshooting Table
Issue | Cause | Solution |
---|---|---|
Tool crashes into workpiece | G43/H offset missing | Use G43 Hxx before Z move |
Circular arc error | Missing I/J values | Double check arc center offsets |
Alarm 017: Invalid G-code | Unsupported G-code | Refer to machine G-code list |
📥 Downloadable G-Code Chart
Offer a free downloadable PDF G-code chart covering over 100 commands with syntax, usage, and machine-specific tips. Great for shop floor printout or student reference.
✅ Conclusion
Mastering G-code and M-code is a foundational skill in CNC machining. Whether you’re fine-tuning a complex program or writing basic tool paths, this reference is an essential resource. cnccode.com provides industrial-grade content for CNC operators, educators, and professionals worldwide — with real code, verified examples, and practical applications.
Leave a comment