логотип ганноверской ярмарки

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).
  • ЕдиницыG20 (inches) / Г21 (millimeters).
  • Coordinate SystemsG54G59 (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Выбор плоскости XYNoneГ17Default plane for most milling operations.
Г18Выбор плоскости XZNoneГ18Used for lathe operations.
Г19Выбор самолета YZNoneГ19Rarely used in standard milling.
G20Inch UnitsNoneG20Sets all values to inches.
Г21Метрические единицыNoneГ21Sets all values to millimeters.
Г28Return to Home PositionX, Y, Z (optional via intermediate)G28 X0 Y0 Z0Machine moves to reference point.
Г40Cancel Cutter CompensationNoneГ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 1NoneG54Selects pre-defined work offset (G54–G59).
G80Cancel Motion ModesNoneG80Cancels cycles (e.g., drilling, tapping).
Г90Абсолютное позиционированиеNoneГ90All coordinates are relative to origin.
Г91Инкрементное позиционированиеNoneГ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 StopNoneM05Stops spindle after operation.
M06Tool ChangeT (tool number)M06 T5Automatic tool change (requires ATC).
M08Coolant OnNoneM08Activates flood coolant.
M09Coolant OffNoneM09Turns off coolant.
M30Program End & ResetNoneM30Ends 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:

С использованием Г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.

Ресурсы

Пролистать наверх