logotipo de la feria de hannover

2025 3.31 - 4.4

Encuéntrenos en la Hannover Messe

  1. Hogar
  2. Recursos
  3. Datos
  4. Tabla de referencia de comandos de código G

Tabla de referencia de comandos de código G

Tabla de contenido

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., G01 stays in linear motion mode).
  • Non-Modal Commands: Execute once (e.g., G28 returns to home position).
  • UnidadesG20 (inches) / G21 (millimeters).
  • Coordinate SystemsG54G59 (work offsets), G90 (absolute positioning), G91 (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
Fuente: 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, y M30.

Common G-Code Command Reference Table

CommandFunciónParametersExampleNotas
G00Rapid Positioning (Non-cutting move)X, Y, Z (target coordinates)G00 X10 Y5 Z2Avoid collisions; no cutting occurs.
G01Linear Interpolation (Cutting move)X, Y, Z, F (feed rate)G01 X20 Y15 Z0 F150Maintain consistent feed rate for surface finish.
G02Clockwise Circular InterpolationX, Y, I, J, K (arc center offsets)G02 X30 Y30 I5 J0I/J/K define arc center relative to start point.
G03Counter-Clockwise Circular InterpolationSame as G02G03 X40 Y20 I0 J-5Used for arcs and circles.
G17Selección del plano XYNingunoG17Default plane for most milling operations.
G18Selección del plano XZNingunoG18Used for lathe operations.
G19Selección del plano YZNingunoG19Rarely used in standard milling.
G20Inch UnitsNingunoG20Sets all values to inches.
G21Unidades metricasNingunoG21Sets all values to millimeters.
G28Return to Home PositionX, Y, Z (optional via intermediate)G28 X0 Y0 Z0Machine moves to reference point.
G40Cancel Cutter CompensationNingunoG40Disables tool radius offset.
G41Left Cutter CompensationD (tool radius offset number)G41 D1Compensates for tool radius to the left of the path.
G42Right 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 1NingunoG54Selects pre-defined work offset (G54–G59).
G80Cancel Motion ModesNingunoG80Cancels cycles (e.g., drilling, tapping).
G90Posicionamiento absolutoNingunoG90All coordinates are relative to origin.
G91Posicionamiento incrementalNingunoG91Coordinates 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 StopNingunoM05Stops spindle after operation.
M06Tool ChangeT (tool number)M06 T5Automatic tool change (requires ATC).
M08Coolant OnNingunoM08Activates flood coolant.
M09Coolant OffNingunoM09Turns off coolant.
M30Program End & ResetNingunoM30Ends program and resets machine.
FFeed RateFeed value (units/min or units/rev)F200Set in G94 (units/min) or G95 (units/rev).
SSpindle SpeedRPM valueS3000Speed depends on material and tool type.
TSelección de herramientasTool numberT4Prepares tool for M06 command.

Preguntas más frecuentes

No. Modern CAM software generates most code automatically. Focus on understanding common commands like G00G01M03, y 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:

Usando G00 (rapid move) instead of G01 (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.

Recursos

Scroll al inicio