CNC G-Code

Basic G, L and M-Codes used in Wincnc on a CAMaster machine

G-Code is a language for CNC. There are several G-codes. They put the machine in the correct mode and perform certain operations.
Definitions to get started:

Feed move – A cutting move. Done at a controlled speed or feed rate.
Rapid move – A non-cutting move meant to be performed above the material. Done at the axis maximum speed.

Basic G-Codes

G0 – Perform a rapid move.
G1– Perform a straight line feed move.
G2 – Perform a clockwise arc feed move.
G3 – Perform a counter-clockwise feed move.
G4 X# – Pause for # of seconds. G04 alone pauses until user hits Enter Key.
G20 – G23 – Unit of measure conversion. G20 = in. G21 = mm. G22 = cm. G23 = Return to last used unit of measure.
G28 – Moves axes to limit switches to determine exact position. After touching off, moves to correct home positions. CAMaster machines move to X low, Y low, and Z high switches to perform this operation.
G43 – Tool Length Offset On – Sets tool length offsets to the values set be the last M37 command. G43 alone turns all offsets on.
G49 – Tool length Offset On – Cancels tool length offsets for the axis specified G49Z. – G49 alone turns all offsets off.
G53 – Used to move an axis to a specific absolute machine coordinate. G53 by itself lifts vertical axes to home positions. G53 with a letter moves that axis. Example: G53 X0 Y0 would move X and Y to the absolute X0Y0 positions, ignoring local (G92) positions.
G54-G59 – Workspace offsets. Single head machines usually only use G54.
G90 – Absolute coordinates mode.
G91 – Relative coordinates mode.
G92– Set or remove Local Zeros (green boxes). G92X0Y0 sets local zeros for X and Y where the tool is located, G92 by itself removes all local zeros, G92.1XG92.1Y or G92.1Z will remove one local  zero

Basic L-Codes

L20 – Enable soft limits
L21 – Disable soft limits
L28 – Sets axes coordinates.  L28A0 will set you’re A axis machine coordinate to zero.
L82 – Used with a touch probe. Lowers probe to a surface and sets that as the value given. Example L82Z-0.25 will set a zero for the probe at ¼” above the surface touched.
L90 – A one line absolute mode move.
L91 – A one line relative mode move.
L92 – Used in a file or macro to make WinCNC remember local zero (G92) after exiting the file or macro. Without the L92, WinCNC reverts back to the G92 settings that existed before the file was run.
L210 – Used to turn on alternate low limits for a particular axis. L210Z enables the alternate low limit switch for the Z axis.
L212 – Disables alternate limits and restores all primary limits.

Basic M-Codes

M11 – Turn an auxiliary output channel on – M11C1
M12 – Turn an auxiliary output channel off – M12C1
M17 – Pause until input channel specified is on – M17C3
M17.1 – Skip next command if input channel specified is off – M17.1C3
M17.2 – Skip next command if auxout channel specified is off – M17.2C1
M18 – Pause until input channel specified is off – M18C3
M18.1 – Skip next line if input channel specified is on – M18.1C3
M18.2 – Skip next line if auxout channel specified is on – M18.2C1
M37 – Set and store tool length measure – M37 Z0 T1 or H1
M37.1 – Store distance between spoilboard surface and tool measure switch
M98 – Run a subprogram – M98 MyFile.tap will run MyFile.tap
M99 – End subprogram – M99 in a file will send WinCNC back to calling program

2 Responses to CNC G-Code

  1. David Thomas says:

    GREAT website, lots of information, I have been looking for G-code overview, keep up the great work +++

Comments are closed.