Skip to content
g-code.txt 81.7 KiB
Newer Older
[[cha:g-codes]]
= G Codes

:ini: {basebackend@docbook:'':ini}
:hal: {basebackend@docbook:'':hal}
:ngc: {basebackend@docbook:'':ngc}

== Conventions

Conventions used in this section

In the G code prototypes the hyphen ('-') stands for a real value
and ('<>') denotes an optional item.

If 'L-' is written in a prototype the '-' will often be referred to
as the 'L number', and so on for any other letter.

In the G code prototypes the word 'axes' stands for any axis as defined
in your configuration.

An optional value will be written like this '<L->'.

A real value may be:

* An explicit number, '4'
* An expression, '[2+2]'
* A parameter value, '#88'
* A unary function value, 'acos[0]'

In most cases, if 'axis' words are given
(any or all of 'X Y Z A B C U V W'),
they specify a destination point.

Axis numbers are in the currently active coordinate system,
unless explicitly described as being
in the absolute coordinate system.

Where axis words are optional, any omitted axes will retain their original value.

Any items in the G code prototypes not explicitly described as
optional are required.

The values following letters are often given as explicit numbers.
Unless stated otherwise, the explicit numbers can be real values. For
example, 'G10 L2' could equally well be written 'G[2*5] L[1+1]'. If the
value of parameter 100 were 2, 'G10 L#100' would also mean the same.

If 'L-' is written in a prototype the '-' will often be referred to
as the 'L number', and so on for any other letter.

== G Code Quick Reference Table[[gcode:quick-reference-table]]

(((G Code Table)))

[width="75%", options="header", cols="2^,5<"]
|====================================================================
|Code                               |Description
|<<gcode:g0,G0>>                    |Coordinated Motion at Rapid Rate
|<<gcode:g1,G1>>                    |Coordinated Motion at Feed Rate
|<<gcode:g2-g3,G2 G3>>              |Coordinated Helical Motion at Feed Rate
|<<gcode:g4,G4>>                    |Dwell
|<<gcode:g5,G5>>                    |Cubic Spline
|<<gcode:g5.1,G5.1>>                |Quadratic B-Spline
|<<gcode:g5.2-g5.3,G5.2,G5.3>>      |NURBS, add control point
|<<gcode:g7,G7>>                    |Diameter Mode (lathe)
|<<gcode:g8,G8>>                    |Radius Mode (lathe)
|<<gcode:g10-l1,G10 L1>>            |Set Tool Table Entry
|<<gcode:g10-l10,G10 L10>>          |Set Tool Table, Calculated, Workpiece
|<<gcode:g10-l11,G10 L11>>          |Set Tool Table, Calculated, Fixture
|<<gcode:g10-l2,G10 L2>>            |Coordinate System Origin Setting
|<<gcode:g10-l20,G10 L20>>          |Coordinate System Origin Setting Calculated
|<<gcode:g17-g19.1,G17 - G19.1>>    |Plane Select
|<<gcode:g20-g21,G20 G21>>          |Set Units of Measure
|<<gcode:g28-g28.1,G28 - G28.1>>    |Go to Predefined Position
|<<gcode:g30-g30.1,G30 - G30.1>>    |Go to Predefined Position
|<<gcode:g33,G33>>                  |Spindle Synchronized Motion
|<<gcode:g33.1,G33.1>>              |Rigid Tapping
|<<gcode:g38,G38.2 - G38.5>>        |Probing
|<<gcode:g40,G40>>                  |Cancel Cutter Compensation
|<<gcode:g41-g42,G41 G42>>          |Cutter Compensation
|<<gcode:g41.1-g42.1,G41.1 G42.1>>  |Dynamic Cutter Compensation
|<<gcode:g43,G43>>                  |Use Tool Length Offset from Tool Table
|<<gcode:g43.1,G43.1>>              |Dynamic Tool Length Offset
|<<gcode:g43.2,G43.2>>              |Apply additional Tool Length Offset
|<<gcode:g49,G49>>                  |Cancel Tool Length Offset
|<<gcode:g53,G53>>                  |Move in Machine Coordinates
|<<gcode:g54-g59.3,G54-G59.3>>      |Select Coordinate System (1 - 9)
|<<gcode:g61-g61.1,G61 G61.1>>      |Path Control Mode
|<<gcode:g64,G64>>                  |Path Control Mode with Optional Tolerance
|<<gcode:g73,G73>>                  |Drilling Cycle with Chip Breaking
|<<gcode:g74,G74>>                  |Left-hand Tapping Cycle with Dwell
|<<gcode:g76,G76>>                  |Multi-pass Threading Cycle (Lathe)
|<<gcode:g80,G80>>                  |Cancel Motion Modes
|<<gcode:g81,G81>>                  |Drilling Cycle
|<<gcode:g82,G82>>                  |Drilling Cycle with Dwell
|<<gcode:g83,G83>>                  |Drilling Cycle with Peck
|<<gcode:g84,G84>>                  |Right-hand Tapping Cycle with Dwell
|<<gcode:g85,G85>>                  |Boring Cycle, No Dwell, Feed Out
|<<gcode:g86,G86>>                  |Boring Cycle, Stop, Rapid Out
|<<gcode:g89,G89>>                  |Boring Cycle, Dwell, Feed Out
|<<gcode:g90-g91,G90 G91>>          |Distance Mode
|<<gcode:g90.1-g91.1,G90.1 G91.1>>  |Arc Distance Mode
|<<gcode:g92,G92>>                  |Coordinate System Offset
|<<gcode:g92.1-g92.2,G92.1 G92.2>>  |Cancel G92 Offsets
|<<gcode:g92.3,G92.3>>              |Restore G92 Offsets
|<<gcode:g93-g94-g95,G93 G94 G95>>  |Feed Modes
|<<gcode:g96-g97,G96>>              |Spindle Control Mode
|<<gcode:g98-g99,G98 G99>>          |Canned Cycle Z Retract Mode 
|====================================================================

[[gcode:g0]]
== G0 Rapid Move
(((G0 Rapid Move)))

-------------------
G0 axes
-------------------

For rapid motion, program 'G0 axes', where all the axis words are optional.
The 'G0' is optional if the current motion mode is 'G0'. This will produce
coordinated motion to the destination point at the maximum rapid rate
(or slower). 'G0' is typically used as a positioning move.

=== Rapid Velocity Rate

The MAX_VELOCITY setting in the ini file [TRAJ] section defines the maximum
rapid traverse rate. The maximum rapid traverse rate can be higher than the
individual axes MAX_VELOCITY setting during a coordinated move. The maximum
rapid traverse rate can be slower than the MAX_VELOCITY setting in the [TRAJ]
section if an axis MAX_VELOCITY or trajectory constraints limit it.


.G0 Example
----
G90 (set absolute distance mode)
G0 X1 Y-2.3 (Rapid linear move from current location to X1 Y-2.3)
M2 (end program)
----
* See <<gcode:g90-g91,G90>> & <<mcode:m2-m30,M2>> sections for more information.

If cutter compensation is active, the motion will differ from
the above; see the <<sec:cutter-compensation,Cutter Compensation>> Section.

If 'G53' is programmed on the same line, the motion will also differ;
see the <<gcode:g53,G53>> Section for more information.

The path of a G0 rapid motion can be rounded at direction changes and depends
on the <<sec:trajectory-control,trajectory control>> settings and maximum
acceleration of the axes.

It is an error if:

* An axis letter is without a real value.
* An axis letter is used that is not configured

[[gcode:g1]](((G1 Linear Move)))

== G1 Linear Move

-------------------
G1 axes
-------------------

For linear (straight line) motion at programed <<sec:set-feed-rate,feed rate>>
(for cutting or not), program 'G1 'axes'', where all the axis words are
optional. The 'G1' is optional if the current motion mode is 'G1'. This will
produce coordinated motion to the destination point at the current feed
rate (or slower).

.G1 Example
----
G90 (set absolute distance mode)
G1 X1.2 Y-3 F10 (linear move at a feed rate of 10 from current position to X1.2 Y-3)
Z-2.3 (linear move at same feed rate from current position to Z-2.3)
Z1 F25 (linear move at a feed rate of 25 from current position to Z1)
M2 (end program)
----
* See <<gcode:g90-g91,G90>> & <<sec:set-feed-rate,F>> & <<mcode:m2-m30,M2>> sections
for more information.

If cutter compensation is active, the motion will differ from
the above; see the <<sec:cutter-compensation,Cutter Compensation>> Section.

If 'G53' is programmed on the same line, the motion will also differ;
see the <<gcode:g53,G53>> Section for more information.

It is an error if:

* No feed rate has been set.
* An axis letter is without a real value.
* An axis letter is used that is not configured

[[gcode:g2-g3]]
== G2, G3 Arc Move
(((G2, G3 Arc Move)))

----
G2 or G3 axes offsets (center format)
G2 or G3 axes R- (radius format)
G2 or G3 offsets|R- <P-> (full circles)
Loading full blame...