شعار معرض هانوفر

2025 3.31 - 4.4

التقوا بنا في معرض هانوفر

  1. بيت
  2. موارد
  3. بيانات
  4. G-Code Command Reference Table

G-Code Command Reference Table

جدول المحتويات

G-code (Geometric Code) is the universal programming language used to control CNC (Computer Numerical Control) machines.  Developed in the 1950s at MIT, G-code remains the backbone of modern CNC machining, enabling precise control over machining processes like milling, turning, and laser cutting.

Each G-code command starts with a letter (e.g., G, M, or F) followed by numerical values, directing the machine to:

  • Control movement (G-commands): Determine the tool’s path and speed (e.g., moving to coordinates, linear/arc motion).
  • Manage functions (M-commands): Handle start/stop actions (e.g., spindle rotation, tool changes, coolant on/off).

While standardized under ISO 6983, variations exist across machine manufacturers (e.g., Fanuc, Haas, Siemens). This table covers 90% of general-purpose G-codes. For advanced functions (5-axis, macros), always consult your machine’s manual for compatibility.

Key Concepts:

  • Modal Commands: Remain active until replaced (e.g., ج01 stays in linear motion mode).
  • Non-Modal Commands: Execute once (e.g., جي28 returns to home position).
  • الوحداتمجموعة العشرين (inches) / مجموعة الـ21 (millimeters).
  • Coordinate SystemsG54-G59 (work offsets), جي90 (absolute positioning), جي91 (incremental positioning).
  • Sequential Execution: The machine reads code line by line, from top to bottom, No skipping or looping unless using advanced features
g code syntax
مصدر: CNC Kicten

G-Code Categories

CategoryExample CommandsPrimary Function
Motion ControlG00, G01, G02, G03Tool movement (rapid/linear/arc)
Plane SelectionG17, G18, G19Select working plane (XY/XZ/YZ)
Units & MeasurementG20 (inches), G21 (mm)Set measurement system
Coordinate SystemsG54-G59, G92Define work offsets or temporary coordinates
Tool CompensationG40, G41, G42, G43Adjust for tool size/length
Canned CyclesG81-G89Automated drilling/tapping routines
Spindle ControlM03, M04, M05Start/stop spindle rotation
Coolant ControlM08, M09Turn coolant on/off
Program ControlM30, M02End program/reset machine
Special FunctionsG28, G53Return to home/machine coordinates

Note: 80% of basic programs use just: G00/G01G17/G20/G21M03/M05، و M30.

Common G-Code Command Reference Table

CommandوظيفةParametersExampleملحوظات
جي00Rapid Positioning (Non-cutting move)X, Y, Z (target coordinates)G00 X10 Y5 Z2Avoid collisions; no cutting occurs.
ج01Linear Interpolation (Cutting move)X, Y, Z, F (feed rate)G01 X20 Y15 Z0 F150Maintain consistent feed rate for surface finish.
جي02Clockwise Circular InterpolationX, Y, I, J, K (arc center offsets)G02 X30 Y30 I5 J0I/J/K define arc center relative to start point.
ج03Counter-Clockwise Circular InterpolationSame as G02G03 X40 Y20 I0 J-5Used for arcs and circles.
جي17اختيار المستوى XYلا أحدجي17Default plane for most milling operations.
مجموعة 18اختيار الطائرة XZلا أحدمجموعة 18Used for lathe operations.
مجموعة 19اختيار طائرة YZلا أحدمجموعة 19Rarely used in standard milling.
مجموعة العشرينInch Unitsلا أحدمجموعة العشرينSets all values to inches.
مجموعة الـ21Metric Unitsلا أحدمجموعة الـ21Sets all values to millimeters.
جي28Return to Home PositionX, Y, Z (optional via intermediate)G28 X0 Y0 Z0Machine moves to reference point.
جي40Cancel Cutter Compensationلا أحدجي40Disables tool radius offset.
جي41Left Cutter CompensationD (tool radius offset number)G41 D1Compensates for tool radius to the left of the path.
جي42Right Cutter CompensationD (tool radius offset number)G42 D2Compensates for tool radius to the right of the path.
G43Tool Length CompensationH (tool height offset number)G43 H3Adjusts for tool length; critical for multi-tool setups.
G54Work Coordinate System 1لا أحدG54Selects pre-defined work offset (G54–G59).
G80Cancel Motion Modesلا أحدG80Cancels cycles (e.g., drilling, tapping).
جي90التموضع المطلقلا أحدجي90All coordinates are relative to origin.
جي91التموضع التدريجيلا أحدجي91Coordinates are relative to current position.
M03Spindle Start (Clockwise)S (spindle speed)M03 S2000Spindle rotates clockwise at 2000 RPM.
M04Spindle Start (Counter-Clockwise)S (spindle speed)M04 S1500Used for reverse cutting operations.
M05Spindle Stopلا أحدM05Stops spindle after operation.
M06Tool ChangeT (tool number)M06 T5Automatic tool change (requires ATC).
M08Coolant Onلا أحدM08Activates flood coolant.
M09Coolant Offلا أحدM09Turns off coolant.
M30Program End & Resetلا أحدM30Ends program and resets machine.
فFeed RateFeed value (units/min or units/rev)F200Set in G94 (units/min) or G95 (units/rev).
سSpindle SpeedRPM valueS3000Speed depends on material and tool type.
تاختيار الأدواتTool numberت4Prepares tool for M06 command.

التعليمات

No. Modern CAM software generates most code automatically. Focus on understanding common commands like جي00ج01M03، و M30

Basics are universal, but advanced features vary by brand. For example:

  • Haas: G187 (high-speed mode)
  • Fanuc: G05.1 (smoothing)

Always check your machine’s manual for specifics.

Yes. For examples:

Using جي00 (rapid move) instead of ج01 (slow cut) → Tool crashes into the workpiece.

Forgetting M05 (spindle stop) → Spinner keeps rotating after the program ends.

  1. Test first: Run programs in "dry run" mode (no cutting).
  2. Single-block mode: Execute one line at a time to catch errors.
  3. Backup settings: Note down machine offsets before editing.
  4. Clean workspace: Remove debris that could interfere with motion.

Yes, but only tweak values you fully understand and never modify tool paths without CAM software – small errors can cause crashes.

CAM programs: Fusion 360, Mastercam, SolidWorks CAM (paid), FreeCAD, Easel (web-based).

Note: Avoid writing code from scratch unless you’re experienced.

موارد

انتقل إلى الأعلى