G-Code

This information HAS errors and is made available WITHOUT ANY WARRANTY OF ANY KIND and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is not permissible to be read by anyone who has ever met a lawyer or attorney. Use is confined to Engineers with more than 370 course hours of engineering.
If you see an error contact:
+1(785) 841 3089
inform@xtronics.com




  1. G-Code
  2. G-codes - and M codes, S codes
    1. Archaic Terminology notes
    2. Comments in G-code
  3. Modality of G-codes
    1. Coordinates - Systems
      1. Machine Coordinate System
      2. Absolute Coordinate
      3. User Coordinates G54-59.3
      4. Tool Length offset
      5. Hierarchy of offsets
  4. G-Codes
    1. Motion Modes Commands - including cutting cycles and canned cycles (Modal group 1)
      1. G0 Rapid Move (modal group 1)
      2. Rapid Velocity Rate
      3. G1 Linear Move (modal group 1)
      4. G2, G3 Arc Move - Circular interpolation (modal group 1)
        1. IJK-syntax arcs (can't do full circle?) - about G90.1 or G91.1
          1. Incremental vs Absolute Arc Distance Modes
        2. IJK-synax example
        3. IJK syntax Examples
        4. R Syntax Format Arcs
        5. G2 G3 Notes
      5. G4 Dwell (non-modal)
      6. G5 Cubic Spline
      7. G5.1 Quadratic Spline
      8. G5.2 G5.3 NURBS Block
    2. Lathe diameter modes G7 G8 (modal group 15)
      1. G7 Lathe Diameter Mode (modal group 15)
      2. G8 Lathe Radius Mode (modal group 15)
      3. G10 (Non modal)
        1. G10 L0 Reload Tool Table Data
        2. G10 L1 Set Values in Tool Table
        3. G10 L2 Set Active Coordinate System
        4. G10 L10 Set Tool Table Data
        5. G10 L11 Set Tool Table Data for G59.3
        6. G10 L20 Set Coordinate System values (touch off)
    3. Plane Selection mode G17 G18 G19 G17.1 G18.1 G19.1(modal group 2)
    4. Units  Mode - Inch vs mm G20 G21
      1. G20 Inches mode (modal group 6)
      2. G21 mm mode (modal group 6)
      3. G28, G28.1 Go/Set Predefined Position (Non-modal)
      4. G30, G30.1 Go/Set Predefined Position (non Modal)
      5. G33 Spindle Synchronized Motion (modal group 1)
      6. G33.1 Rigid Tapping (modal group 1)
      7. G38.n Straight Probe (modal group 1)
    5. Cutter Radius Offset or Cutter compensation mode G40 G41 G42 G41.1 G42.1 (modal group 7)
      1.  G40 - turn cutter compensation off (Typical default) (modal group 7)
      2. G41 Cutter compensation left (modal group 7)
      3. G42 Cutter compensation Right (modal group 7)
      4. G41.1 Dynamic Cutter Compensation Left (modal group 7)
      5. G42.1 Dynamic Cutter Compensation Right (modal group 7)
    6. Tool length offset or compensation  G43, G43.1, G49 (modal group 8)
      1. G43 Enable Tool Length Offset (compensation) (modal group 8)
      2. G43.1 Dynamic Tool Length Offset (modal group 8)
      3. G43.2 Additional tool lenght Offset (modal group 8)
      4. G49 Cancel Tool Length Compensation (Typical Default)
      5. G52 Local Coordinate System Offset (non Modal)
      6. G53 Move in Machine Coordinates (non Modal)
    7. Coordinate system modes G54 G55 G56 G57 G58 G59 G59.1 G59.2 G59.3 (modal group 12)
      1. G54 - select coordinate system 1 (modal group 12)
      2. G55 - select coordinate system 2 (modal group 12)
      3. G56 - select coordinate system 3 (modal group 12)
      4. G57 select coordinate system 4 (modal group 12)
      5. G58 select coordinate system 5 (modal group 12)
      6. G59 select coordinate system 6 (modal group 12)
      7. G59.1 select coordinate system 7 (modal group 12)
      8. G59.2 select coordinate system 8 (modal group 12)
      9. G59.3 select coordinate system 9 (modal group 12)
    8. Motion modes G61 G61.1 G64 (modal group 13)
      1. G61  Set Exact path mode (modal group 13)
      2. G61.1 Set Exact stop mode (modal group 13)
      3. G64 <P-> <Q>  Path Blending (Typical default)(modal group 13)
      4. G70 Lathe finishing cycle (modal group 1)
      5. G71 G72 Lathe roughing cycles (modal group 1)
      6. G73 Drilling Cycle with Chip Breaking (modal group 1)
      7. G74 Left-hand Tapping Cycle with Dwell (modal group 1)
      8. G76 Threading Cycle (probably only of interest for lathe work) (modal group 1)
    9. G80-G89 Canned Cycles (modal group 1)
      1. Common Words
      2. Sticky Words
      3. Repeat Cycle
      4. Retract Mode
      5. Canned Cycle Errors
      6. Preliminary and In-Between Motion
      7. Why use a canned cycle?
      8. G80 Cancel Canned Cycle (modal group 1)
      9. G81 Drilling Cycle (modal group 1)
      10. G82 Drilling Cycle, Dwell (modal group 1)
      11. G83 Peck Drilling Cycle (modal group 1)
      12. G84 Right-hand Tapping Cycle, Dwell (modal group 1)
      13. G85 Boring Cycle, Feed Out (modal group 1)
      14. G86 Boring Cycle, Spindle Stop, Rapid Move Out (modal group 1)
      15. G87 Back Boring Cycle (modal group 1)
      16. G88 Boring Cycle, Spindle Stop, Manual Out (modal group 1)
      17. G89 Boring Cycle, Dwell, Feed Out (modal group 1)
    10. G90, G91 Absolute vs Relative Distance Mode (modal group 3)
      1. G90 absolute distance mode (modal group 3)
      2. G91 set incremental distance mode (modal group3)
    11. G90.1, G91.1 Arc IJK Relative vs Absolute Distance Mode (modal group 4)
      1. G90.1 absolute distance mode for I, J & K offsets (modal group 4)
      2. G91.1 incremental distance mode for I, J & K offsets (modal group4)
    12. Coordinate System Offset G92 G92.1 -G92.3 G52 (Non Modal)
      1. G92 Set Coordinate System Offset (non modal)
      2. G92.1, G92.2 Reset G92 Offsets (non modal)
      3. G92.3 Restore G92 Offsets ()non modal)
    13. Feedrate Mode G93 G94 G95 (modal group 5)
      1. G94 Units per Minute (typical mode) (modal group 5)
      2. G93 - is Inverse Time Mode. (modal group 5)
      3. G95 - is Units per Revolution Mode (useful for lathes)  (modal group 5)
    14. Spindle Control Mode G96 G97(modal group 14)
      1. G96 <D-> S- (Constant Surface Speed Mode) (modal group 14)
      2. G97 RPM speed Mode (typical default) (modal group 14)
    15. Canned Cycle Return Level G98 G99 (modal group 10)
      1. G98 - retract to previous position (modal group 10)
      2. G99  retract to R position (modal group 10)
  5. M-Codes
    1. Spindle M3 M4 M5
    2. Stopping M0, M1, M2, M30, M60
    3. Coolant (M7 M8 can both be on), M9
    4. Override SwitchesM48, M49
    5. User Defined M100-M199
  6. Examples
    1. Mode commands
    2. Drilling
    3. Active Comments
      1. MSG Message
      2. Probe Logging
      3. Logging
      4. Debug Messages
      5. Print Messages
      6. Expanded parameters Example
    4. Numbered Parameter
      1. Numbered Parameters file

G-codes - and M codes, S codes

Archaic Terminology notes

Block is what computer programmers would call a line today.

Comments in G-code

Comments can be embedded in a line using parentheses () or for the remainder of a line using a semi-colon:

G0 (Rapid to start) X1 Y1
G0 X1 Y1 (Rapid to start; but don't forget the coolant)
M2 ; End of program.

Modality of G-codes

Most G-codes are Modal  and within a modal-group only one G-codes can be active. As an example - only one motion commands can be active. G0 (Rapid move) and G1 (feedrate move) obviously contradict each other.    Most programs will start with a preamble to set the default mode for each of the modal groups.  LinuxCNC does not have all the G-codes that every company uses (there would be conflicts). There is a way to remap gcodes - but that topic won't be covered here.

Thus the G code sections below try to be grouped in modal groups.

There are a few G-codes that are not modal.  Non-modal codes G4 G10 G28 G30 G52 G53 G92 G92.1 G92.2 G92.3

Coordinates - Systems

Machine Coordinate System

At restart of LinuxCNC - Machine Coordinate System is set to zero for where ever the machine was left.
When you home LinuxCNC you set the Machine Coordinate System to 0 for each axis homed - at their homed position.

Absolute Coordinate


User Coordinates G54-59.3

Touch-off system

Tool Length offset

Gets added to Z

Hierarchy of offsets

Empty





G-Codes

Motion Modes Commands - including cutting cycles and canned cycles (Modal group 1)

These jump around numerically - see each in it's section below G0 G1 G2 G3 G33 G38.n G73 G76 G80 G81 G82 G83 G84 G85 G86 G87 G88 G89

G0 Rapid Move (modal group 1)

G0 <axis>

Move at rapid speed to posision of axis

Examples - G0 X10.1 Y 5.0 (makes a coordintated move to (10.1,5,-) - no move in Z

Rapid Velocity Rate

The MAX_VELOCITY setting in the INI file [TRAJ] section defines the maximumrapid 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)

If cutter compensation is active, the motion will differ from the above; see the Cutter Compensation section.

If G53 is programmed on the same line, the motion will also differ; see the G53 section for more information.

The path of a G0 rapid motion can be rounded at direction changes and depends on the 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.

G1 Linear Move (modal group 1)

G1 <x- y- z- F->

For linear (straight line) motion at programmed 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 G90 & F & M2 sections for more information.

If cutter compensation is active, the motion will differ from the above; see the Cutter Compensation section.

If G53 is programmed on the same line, the motion will also differ; see the 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

G2, G3 Arc Move - Circular interpolation (modal group 1)

The axis of the circle or helix must be parallel to one of the X, Y, or Z axes of the machine coordinate system. The axis (or, equivalently, the plane perpendicular to the axis) is selected with G17 (Z-axis, XY-plane), G18 (Y-axis, XZ-plane), or G19 (X-axis, YZ-plane). Planes 17.1, 18.1, and 19.1 are not currently supported. If the arc is circular, it lies in a plane parallel to the selected plane.

There are two formats for G2, G3 - IJK syntax and R syntax.

G2 or G3 axes offsets (center format) G2 or G3 axes R- G2 or G3 offsets|R- <P-> (full circles)
A circular or helical arc is specified using either G2 (clockwise arc) or G3 (counterclockwise arc) at the current feed rate.

To program a helix we include the axis perpendicular to the arc plane ( in the G17 plane we would include  Z ) This causes the Z axis to move coordinated with the circular XY motion.

P - 1 = the number of complete circles to add to the move - For example if you have a full circle with the change in Z of 1  and you change P to 2 - the pitch is cut in half.

It is possible to program an arc with more than one full turn with P specifying the number of full turns plus the programmed arc. P must be an integer. If P is unspecified, P1 is used and only up to one full turn will result. For example, if a 180 degree arc is programmed with a P2, the resulting motion will be 1 1/2 rotations. For each P increment above 1 an extra full circle is added to the programmed arc. Multi turn helical arcs are supported and give motion useful for milling holes or threads.

The arc center is absolute or relative as set by G90.1 or G91.1 respectively.

Two formats are allowed for specifying an arc: Center Format and Radius Format.

An error is thrown if Either no feed rate has been set or the P word is not an integer.

IJK-syntax arcs (can't do full circle?) - about G90.1 or G91.1

IJK-syntax arcs are more accurate than radius format arcs and are the preferred format to use. (Why would this be true?

IJK offsets added to the starting  position point to the center . 

The end position (XYZ) points to the end of the arc.  The end point can be the same as the starting position (full circles).


Incremental vs Absolute Arc Distance Modes
The default is G91.1 IJK incremental - G90.1 is absolute.

IJK-synax example

XY-plane (G17) G2 or G3 X Y R Z F P  ( an earlier G01 provides start point.)

XY provide end point

R sets radius


IJK syntax Examples

From the diagram, you can see the offset is +1 in X  and 0 in Y - thus we use I1 J0, but J0 can be dropped. 

G2 Example  Incremental
G0 X5 Y5 ( go to starting position)
G2 X6 Y6 I1 J0 F10 (clockwise arc in the XY plane Incremental mode)

Or for absolute mode
G2 X6 Y6 I6 J5 F10 (clockwise arc in the XY plane Absolute mode)

 G2 Example

In the next example we see the difference between the offsets for Y if we are doing a G2 or a G3 move. For the G2 move the start position is X0 Y0, for the G3 move it is X0 Y1. The arc center is at X1 Y0.5 for both moves. The G2 move the J offset is 0.5 and the G3 move the J offset is -0.5.

G2-G3 Example Line G0 X0 Y0 G2 X0 Y1 I1 J0.5 F25 (clockwise arc in the XY plane) G3 X0 Y0 I1 J-0.5 F25 (counterclockwise arc in the XY plane) G2-G3 Example Figure 2. G2-G3 Example

In the next example we show how the arc can make a helix in the Z axis by adding the Z word.

G2 Example Helix G0 X0 Y0 Z0 G17 G2 X10 Y16 I3 J4 Z-1 (helix arc with Z added)

In the next example we show how to make more than one turn using the P word.

P word Example G0 X0 Y0 Z0 G2 X0 Y1 Z-1 I1 J0.5 P2 F25

In the center format, the radius of the arc is not specified, but it may be found easily as the distance from the center of the circle to either the current point or the end point of the arc.

R Syntax Format Arcs

G2 or G3 axes R- <P->

R - radius from current position

It is not good practice to program radius format arcs that are nearly full circles or nearly semicircles because a small change in the location of the end point will produce a much larger change in the location of the center of the circle (and, hence, the middle of the arc). The magnification effect is large enough that rounding error in a number can produce out-of-tolerance cuts. For instance, a 1% displacement of the endpoint of a 180 degree arc produced a 7% displacement of the point 90 degrees along the arc. Nearly full circles are even worse. Other size arcs (in the range tiny to 165 degrees or 195 to 345 degrees) are OK.

In the radius format, the coordinates of the end point of the arc in the selected plane are specified along with the radius of the arc. Program G2 axes R- (or use G3 instead of G2 ). R is the radius. The axis words are all optional except that at least one of the two words for the axes in the selected plane must be used. The R number is the radius. A positive radius indicates that the arc turns through less than 180 degrees, while a negative radius indicates a turn of more than 180 degrees. If the arc is helical, the value of the end point of the arc on the coordinate axis parallel to the axis of the helix is also specified.

It is an error if:

both of the axis words for the axes of the selected plane are omitted

the end point of the arc is the same as the current point.

G2 Example Line G17 G2 X10 Y15 R20 Z5 (radius format with arc)

The above example makes a clockwise (as viewed from the positive Z-axis) circular or helical arc whose axis is parallel to the Z-axis, ending where X=10, Y=15, and Z=5, with a radius of 20. If the starting value of Z is 5, this is an arc of a circle parallel to the XY-plane; otherwise it is a helical arc.

G2 G3 Notes

If the pitch of the helix is very small (less than the naive CAM tolerance) then the helix might be converted into a straight line.

If a line of code makes an arc and includes rotary axis motion, the rotary axes turn at a constant rate so that the rotary motion starts and finishes when the XYZ motion starts and finishes. Lines of this sort are hardly ever programmed.

If cutter compensation is active, the motion will differ from the above; see the Cutter Compensation section.

When programming arcs an error due to rounding can result from using a precision of less than 4 decimal places (0.0000) for inch and less than 3 decimal places (0.000) for millimeters.

G4 Dwell (non-modal)

G4 P-

P - seconds to dwell (floating point)

The P number is the time in seconds that all axes will remain unmoving. The P number is a floating point number so fractions of a second may be used. G4 does not affect spindle, coolant and any I/O.

G4 Example Line G4 P0.5 (wait for 0.5 seconds before proceeding)

It is an error if:

the P number is negative or not specified.

G5 Cubic Spline

G5 X- Y- <I- J-> P- Q-

I - X incremental offset from start point to first control point

J - Y incremental offset from start point to first control point

P - X incremental offset from end point to second control point

Q - Y incremental offset from end point to second control point

G5 creates a cubic B-spline in the XY plane with the X and Y axes only. P and Q must both be specified for every G5 command.

For the first G5 command in a series of G5 commands, I and J must both be specified. For subsequent G5 commands, either both I and J must be specified, or neither. If I and J are unspecified, the starting direction of this cubic will automatically match the ending direction of the previous cubic (as if I and J are the negation of the previous P and Q).

For example, to program a curvy N shape:

G5 Sample initial cubic spline G90 G17 G0 X0 Y0 G5 I0 J3 P0 Q-3 X1 Y1

A second curvy N that attaches smoothly to this one can now be made without specifying I and J:

G5 Sample subsequent cubic spline G5 P0 Q-3 X2 Y2

It is an error if:

P and Q are not both specified.

Just one of I or J are specified.

I or J are unspecified in the first of a series of G5 commands.

An axis other than X or Y is specified.

The active plane is not G17.

G5.1 Quadratic Spline

G5.1 X- Y- I- J-

I - X incremental offset from start point to control point

J - Y incremental offset from start point to control point

G5.1 creates a quadratic B-spline in the XY plane with the X and Y axis only. Not specifying I or J gives zero offset for the unspecified axis, so one or both must be given.

For example, to program a parabola, through the origin, from X-2 Y4 to X2 Y4:

G5.1 Sample quadratic spline G90 G17 G0 X-2 Y4 G5.1 X2 I2 J-8

It is an error if:

both I and J offset are unspecified or zero

An axis other than X or Y is specified

The active plane is not G17

G5.2 G5.3 NURBS Block

G5.2 <P-> <X- Y-> <L-> X- Y- <P-> ... G5.3
Warning G5.2, G5.3 is experimental and not fully tested.

G5.2 is for opening the data block defining a NURBS and G5.3 for closing the data block. In the lines between these two codes the curve control points are defined with both their related weights (P) and the parameter (L) which determines the order of the curve.

The current coordinate, before the first G5.2 command, is always taken as the first NURBS control point. To set the weight for this first control point, first program G5.2 P- without giving any X Y.

The default weight if P is unspecified is 1. The default order if L is unspecified is 3.

G5.2 Example G0 X0 Y0 (rapid move) F10 (set feed rate) G5.2 P1 L3 X0 Y1 P1 X2 Y2 P1 X2 Y0 P1 X0 Y0 P2 G5.3 ; The rapid moves show the same path without the NURBS Block G0 X0 Y1 X2 Y2 X2 Y0 X0 Y0 M2 Sample NURBS Output

Sample NURBS Output

More information on NURBS can be found here:

https://wiki.linuxcnc.org/cgi-bin/wiki.pl?NURBS

Lathe diameter modes G7 G8 (modal group 15)

G7 Lathe Diameter Mode (modal group 15)

Set diameter mode for axis X on a lathe. When in the diameter mode the X axis moves on a lathe will be 1/2 the distance to the center of the lathe. For example X1 would move the cutter to 0.500" from the center of the lathe thus giving a 1" diameter part.

G8 Lathe Radius Mode (modal group 15)

Set radius mode for axis X on a lathe. When in Radius mode the X axis moves on a lathe will be the distance from the center. Thus a cut at X1 would result in a part that is 2" in diameter. G8 is default at power up.

G10 (Non modal)

This should have been separate G-codes - but instead we have G10 L0, G10 L1, G10 L2, G10 L10 G10 L11 G10 L20 - Think of them as separate G-codes.

G10 L0 Reload Tool Table Data

G10 L0

G10 L0 reload all tool table data. Requires that there is no current tool loaded in spindle.

NOTE - When using G10 L0, tool parameters (#5401-#5413) will be updated immediately and any altered tool diameters will be used for subsequent G41,42 cutter radius compensation commands. Existing G43 tool length compensation values will remain in effect until updated by new G43 commands.

G10 L1 Set Values in Tool Table

G10 L1 P  <R- X- Y- Z- I- J- Q->

P - tool number

R - radius of tool

I - front angle (lathe)

J - back angle (lathe)

Q - orientation (lathe)

G10 L1 sets the tool table for the P tool number to the values of the words.

A valid G10 L1 rewrites and reloads the tool table for the specified tool.

G10 L1 Example Line G10 L1 P1 Z1.5 (set tool 1 Z offset from the machine origin to 1.5) G10 L1 P2 R0.015 Q3 (lathe example setting tool 2 radius to 0.015 and orientation to 3)

It is an error if:

Cutter Compensation is on

The P number is unspecified

The P number is not a valid tool number from the tool table

The P number is 0

For more information on cutter orientation used by the Q word, see the Lathe Tool Orientation diagram.

G10 L2 Set Active Coordinate System

G10 L2 P- <axes R->

P - coordinate system (0-9)

R - rotation about the Z axis

G10 L2 offsets the origin of the axes in the coordinate system specified to the value of the axis word. The offset is from the machine origin established during homing. The offset value will replace any current offsets in effect for the coordinate system specified. Axis words not used will not be changed.

Program P0 to P9 to specify which coordinate system to change.

P Value Coordinate System G-code

0

Active

n/a

1

1

G54

2

2

G55

3

3

G56

4

4

G57

5

5

G58

6

6

G59

7

7

G59.1

8

8

G59.2

9

9

G59.3

Table 1. Coordinate System

Optionally program R to indicate the rotation of the XY axis around the Z axis. The direction of rotation is CCW as viewed from the positive end of the Z axis.

All axis words are optional.

Being in incremental distance mode (G91) has no effect on G10 L2.

Important Concepts:

G10 L2 Pn does not change from the current coordinate system to the one specified by P, you have to use G54-59.3 to select a coordinate system.

When a rotation is in effect jogging an axis will only move that axis in a positive or negative direction and not along the rotated axis.

If a G52 local offset or G92 origin offset was in effect before G10 L2, it will continue to be in effect afterwards.

When programming a coordinate system with R, any G52 or G92 will be applied after the rotation.

The coordinate system whose origin is set by a G10 command may be active or inactive at the time the G10 is executed. If it is currently active, the new coordinates take effect immediately.

It is an error if:

The P number does not evaluate to an integer in the range 0 to 9.

An axis is programmed that is not defined in the configuration.

G10 L2 Example Line G10 L2 P1 X3.5 Y17.2

In the above example the origin of the first coordinate system (the one selected by G54) is set to be X=3.5 and Y=17.2. Because only X and Y are specified, the origin point is only moved in X and Y; the other coordinates are not changed.

G10 L2 Example Line G10 L2 P1 X0 Y0 Z0 (clear offsets for X,Y & Z axes in coordinate system 1)

The above example sets the XYZ coordinates of the coordinate system 1 to the machine origin.

The coordinate system is described in the Coordinate System section.

G10 L10 Set Tool Table Data

G10 L10 P- axes <R- I- J- Q->

P - tool number

R - radius of tool

I - front angle (lathe)

J - back angle (lathe)

Q - orientation (lathe)

G10 L10 changes the tool table entry for tool P so that if the tool offset is reloaded, with the machine in its current position and with the current G5x and G52/G92 offsets active, the current coordinates for the given axes will become the given values. The axes that are not specified in the G10 L10 command will not be changed. This could be useful with a probe move as described in the G38 section.

G10 L10 Example T1 M6 G43 (load tool 1 and tool length offsets) G10 L10 P1 Z1.5 (set the current position for Z to be 1.5) G43 (reload the tool length offsets from the changed tool table) M2 (end program)

See T & M6, and G43/G43.1 sections for more information.

It is an error if: Cutter Compensation is on, tool number is unspecified, tool number is not valid for the tool table, or if the tool number is 0

G10 L11 Set Tool Table Data for G59.3

G10 L11 P- axes <R- I- J- Q->

P - tool number

R - radius of tool

I - front angle (lathe)

J - back angle (lathe)

Q - orientation (lathe)

G10 L11 is just like G10 L10 except that instead of setting the entry according to the current offsets, it is set so that the current coordinates would become the given value if the new tool offset is reloaded and the machine is placed in the G59.3 coordinate system without any G52/G92 offset active.

This allows the user to set the G59.3 coordinate system according to a fixed point on the machine, and then use that fixture to measure tools without regard to other currently-active offsets.

It is an error if:

Cutter Compensation is on

The P number is unspecified

The P number is not a valid tool number from the tool table

The P number is 0

G10 L20 Set Coordinate System values (touch off)

G10 L20 P- axes

P - coordinate system (0-9)

G10 L20 is similar to G10 L2 except that instead of setting the offset/entry to the given value, it is set to a calculated value that makes the current coordinates become the given value.

G10 L20 Example Line G10 L20 P1 X1.5 (set the X axis current location in coordinate system 1 to 1.5)

It is an error if:

The P number does not evaluate to an integer in the range 0 to 9.

An axis is programmed that is not defined in the configuration.

Plane Selection mode G17 G18 G19 G17.1 G18.1 G19.1(modal group 2)

These codes set the current plane as follows:

  G17 - XY (Typical default)
  G18 - ZX
  G19 - YZ
  G17.1 - UV
  G18.1 - WU
  G19.1 - VW

The UV, WU and VW planes do not support arcs.

The effects of having a plane selected are discussed in section G2 G3 Arcs and section G81 G89.

Units  Mode - Inch vs mm G20 G21

G20 Inches mode (modal group 6)

use inches for length units.

G21 mm mode (modal group 6)

use millimeters for length units.(Typical default)

G28, G28.1 Go/Set Predefined Position (Non-modal)

Warning Only use G28 when your machine is homed to a repeatable position and the desired G28 position has been stored with G28.1.

G28 uses the values stored in parameters 5161-5169 as the X Y Z A B C U V W final point to move to. The parameter values are absolute machine coordinates in the native machine units as specified in the INI file. All axes defined in the INI file will be moved when a G28 is issued. If no positions are stored with G28.1 then all axes will go to the machine origin.

G28 - makes a rapid move from the current position to the absolute position of the values in parameters 5161-5166.

G28 axes - makes a rapid move to the position specified by axes including any offsets, then will make a rapid move to the absolute position of the values in parameters 5161-5166 for all axes specified. Any axis not specified will not move.

G28.1 - stores the current absolute position into parameters 5161-5166.

G28 Example Line G28 Z2.5 (rapid to Z2.5 then to Z location specified in #5163)

It is an error if cutter Compensation is turned on

G30, G30.1 Go/Set Predefined Position (non Modal)

Warning Only use G30 when your machine is homed to a repeatable position and the desired G30 position has been stored with G30.1.

G30 functions the same as G28 but uses the values stored in parameters 5181-5189 as the X Y Z A B C U V W final point to move to. The parameter values are absolute machine coordinates in the native machine units as specified in the INI file. All axes defined in the INI file will be moved when a G30 is issued. If no positions are stored with G30.1 then all axes will go to the machine origin.

Note G30 parameters will be used to move the tool when a M6 is programmed if TOOL_CHANGE_AT_G30=1 is in the [EMCIO] section of the INI file.

G30 - makes a rapid move from the current position to the absolute position of the values in parameters 5181-5189.

G30 axes - makes a rapid move to the position specified by axes including any offsets, then will make a rapid move to the absolute position of the values in parameters 5181-5189 for all axes specified. Any axis not specified will not move.

G30.1 - stores the current absolute position into parameters 5181-5186.

G30 Example Line G30 Z2.5 (rapid to Z2.5 then to the Z location specified in #5i83)

It is an error if :

Cutter Compensation is turned on

G33 Spindle Synchronized Motion (modal group 1)

G33 X- Y- Z- K- $-

K - distance per revolution

For spindle-synchronized motion in one direction, code G33 X- Y- Z- K- where K gives the distance moved in XYZ for each revolution of the spindle. For instance, if starting at Z=0, G33 Z-1 K.0625 produces a 1 inch motion in Z over 16 revolutions of the spindle. This command might be part of a program to produce a 16TPI thread. Another example in metric, G33 Z-15 K1.5 produces a movement of 15mm while the spindle rotates 10 times for a thread of 1.5mm.

The (optional) $ argument sets which spindle the motion is synchronised to (default is zero). For example G33 Z10 K1 $1 will move the spindle in synchrony with the spindle.N.revs HAL pin value.

Spindle-synchronized motion waits for the spindle index and spindle at speed pins, so multiple passes line up. G33 moves end at the programmed endpoint. G33 could be used to cut tapered threads or a fusee.

All the axis words are optional, except that at least one must be used.

Note K follows the drive line described by X- Y- Z-. K is not parallel to the Z axis if X or Y endpoints are used for example when cutting tapered threads.
Technical Info

At the beginning of each G33 pass, LinuxCNC uses the spindle speed and the machine acceleration limits to calculate how long it will take Z to accelerate after the index pulse, and determines how many degrees the spindle will rotate during that time. It then adds that angle to the index position and computes the Z position using the corrected spindle angle. That means that Z will reach the correct position just as it finishes accelerating to the proper speed, and can immediately begin cutting a good thread.

HAL Connections

The pin spindle.N.at-speed must be set or driven true for the motion to start. Additionally spindle.N.revs must increase by 1 for each revolution of the spindle and the spindle.N.index-enable pin must be connected to an encoder (or resolver) counter which resets index-enable once per rev.

See the Integrators Manual for more information on spindle synchronized motion.

G33 Example G90 (absolute distance mode) G0 X1 Z0.1 (rapid to position) S100 M3 (start spindle turning) G33 Z-2 K0.125 (move Z axis to -2 at a rate to equal 0.125 per revolution) G0 X1.25 (rapid move tool away from work) Z0.1 (rapid move to starting Z position) M2 (end program)

See G90 & G0 & M2 sections for more information.

It is an error if:

All axis words are omitted.

The spindle is not turning when this command is executed.

The requested linear motion exceeds machine velocity limits due to the spindle speed.

G33.1 Rigid Tapping (modal group 1)

G33.1 X- Y- Z- K- I- $-

K - distance per revolution

I - optional spindle speed multiplier for faster return move

$ - optional spindle selector

Warning For Z only tapping preposition the XY location prior to calling G33.1 and only use a Z word in the G33.1. If the coordinates specified are not the current coordinates when calling G33.1 for tapping the move will not be along the Z axis but will be a coordinated, spindle-synchronized move from the current location to the location specified and back.

For rigid tapping (spindle synchronized motion with return), code G33.1 X- Y- Z- K- where K- gives the distance moved for each revolution of the spindle.

A rigid tapping move consists of the following sequence:

A move from the current coordinate to the specified coordinate, synchronized with the selected spindle at the given ratio and starting from the current coordinate with a spindle index pulse.

When reaching the endpoint, a command to reverse the spindle, and speed up by a factor set by the multiplier (e.g., from clockwise to counterclockwise).

Continued synchronized motion beyond the specified end coordinate until the spindle actually stops and reverses.

Continued synchronized motion back to the original coordinate.

When reaching the original coordinate, a command to reverse the spindle a second time (e.g., from counterclockwise to clockwise).

Continued synchronized motion beyond the original coordinate until the spindle actually stops and reverses.

An unsynchronized move back to the original coordinate.

Spindle-synchronized motions wait for spindle index, so multiple passes line up.G33.1 moves end at the original coordinate.

All the axis words are optional, except that at least one must be used.

G33.1 Example G90 (set absolute mode) G0 X1.000 Y1.000 Z0.100 (rapid move to starting position) S100 M3 (turn on the spindle, 100 RPM) G33.1 Z-0.750 K0.05 (rigid tap a 20 TPI thread 0.750 deep) M2 (end program)

See G90 & G0 & M2 sections for more information.

It is an error if:

All axis words are omitted.

The spindle is not turning when this command is executed

The requested linear motion exceeds machine velocity limits due to the spindle speed

G38.n Straight Probe (modal group 1)

G38.n axes

G38.2 - probe toward workpiece, stop on contact, signal error if failure

G38.3 - probe toward workpiece, stop on contact

G38.4 - probe away from workpiece, stop on loss of contact, signal error if failure

G38.5 - probe away from workpiece, stop on loss of contact

Important You will not be able to use a probe move until your machine has been set up to provide a probe input signal. The probe input signal must be connected to motion.probe-input in a .hal file. G38.n uses motion.probe-input to determine when the probe has made (or lost) contact. TRUE for probe contact closed (touching), FALSE for probe contact open.

Program G38.n axes to perform a straight probe operation. The axis words are optional, except that at least one of them must be used. The axis words together define the destination point that the probe will move towards, starting from the current location. If the probe is not tripped before the destination is reached G38.2 and G38.4 will signal an error.

The tool in the spindle must be a probe or contact a probe switch.

In response to this command, the machine moves the controlled point (which should be at the center of the probe ball) in a straight line at the current feed rate toward the programmed point. In inverse time feed mode, the feed rate is such that the whole motion from the current point to the programmed point would take the specified time. The move stops (within machine acceleration limits) when the programmed point is reached, or when the requested change in the probe input takes place, whichever occurs first.

Code Target State Move orientation Error Signal

G38.2

Touched

Toward piece

Yes

G38.3

Touched

Toward piece

No

G38.4

Untouched

From piece

Yes

G38.5

Untouched

From piece

No

Table 2. Probing G-Codes

After successful probing, parameters #5061 to #5069 will be set to the X, Y, Z, A, B, C, U, V, W coordinates of the location of the controlled point at the time the probe changed state (in the current work coordinate system). After unsuccessful probing, they are set to the coordinates of the programmed point. Parameter 5070 is set to 1 if the probe succeeded and 0 if the probe failed. If the probing operation failed, G38.2 and G38.4 will signal an error by posting an message on screen if the selected GUI supports that. And by halting program execution.

A comment of the form (PROBEOPEN filename.txt) will open filename.txt and store the 9-number coordinate consisting of XYZABCUVW of each successful straight probe in it. The file must be closed with (PROBECLOSE). For more information see the Comments section.

An example file smartprobe.ngc is included (in the examples directory) to demonstrate using probe moves to log to a file the coordinates of a part. The program smartprobe.ngc could be used with ngcgui with minimal changes.

It is an error if:

the current point is the same as the programmed point.

no axis word is used

cutter compensation is enabled

the feed rate is zero

the probe is already in the target state


Cutter Radius Offset or Cutter compensation mode G40 G41 G42 G41.1 G42.1 (modal group 7)

 G40 - turn cutter compensation off (Typical default) (modal group 7)

If tool compensation was on the next move must be a linear move and longer than the tool diameter. It is OK to turn compensation off when it is already off.

G40 Example ; current location is X1 after finishing cutter compensated move G40 (turn compensation off) G0 X1.6 (linear move longer than current cutter diameter) M2 (end program)

It creates an error if:

A G2/G3 arc move is programmed next after a G40.
The linear move after turning compensation off is less than the tool diameter.

G41 Cutter compensation left (modal group 7)

G41 <D-> (left of programmed path or part profile) G41 starts cutter compensation to the left of the programmed line as viewed from the positive end of the axis perpendicular to the plane.

The D word is optional; if there is no D word the radius of the currently loaded tool will be used (if no tool is loaded and no D word is given, a radius of 0 will be used).

If supplied, the D word is the tool number to use. This would normally be the number of the tool in the spindle (in which case the D word is redundant and need not be supplied), but it may be any valid tool number.

Note G41/G42 D0 is a little special. Its behavior is different on random tool changer machines and nonrandom tool changer machines On nonrandom tool changer machines, G41/G42 D0 applies the Tool Length Offset of the tool currently in the spindle, or a TLO of 0 if no tool is in the spindle. On random tool changer machines, G41/G42 D0 applies the TLO of the tool T0 defined in the tool table file (or causes an error if T0 is not defined in the tool table).

The lead in move must be at least as long as the tool radius. The lead in move can be a rapid move.

Cutter compensation may be performed if the XY-plane or XZ-plane is active.

User M100-M199 commands are allowed when Cutter Compensation is on.

The behavior of the machining center when cutter compensation is on is described in the Cutter Compensation section along with code examples.

It creates an error if: The D number is not a valid tool number or 0 or
The YZ plane is active or
Cutter compensation is commanded to turn on when it is already on.

G42 Cutter compensation Right (modal group 7)

G42 <D-> (right of programmed path or part profile) G42 starts cutter compensation to the right of the programmed line as viewed from the positive end of the axis perpendicular to the plane.
Where D is an optional tool number as above with G41

G41.1 Dynamic Cutter Compensation Left (modal group 7)

G41.1 D- <L-> (left of programmed path)

Where L - tool orientation (see lathe tool orientation - 0 -9 used with lathes)

G41.1 & G42.1 function the same as G41 & G42 with the added scope of being able to program the tool diameter. The L word defaults to 0 if unspecified.

It creates an error if:

The YZ plane is active.

The L number is not in the range from 0 to 9 inclusive.

The L number is used when the XZ plane is not active

Cutter compensation is commanded to turn on when it is already on.

G42.1 Dynamic Cutter Compensation Right (modal group 7)

G42.1 D- <L-> (right of programmed path) D - cutter diameter (modal group 7)Where L - tool orientation (see lathe tool orientation - 0 -9 used with lathes)

G41.1 & G42.1 function the same as G41 & G42 with the added scope of being able to program the tool diameter. The L word defaults to 0 if unspecified.

It creates an error if:

The YZ plane is active.

The L number is not in the range from 0 to 9 inclusive.

The L number is used when the XZ plane is not active

Cutter compensation is commanded to turn on when it is already on.



Tool length offset or compensation  G43, G43.1, G49 (modal group 8)

G43 Enable Tool Length Offset (compensation) (modal group 8)

G43 <H->  where - is the tool number   - example G43 H2  sets the tool offsets from tool 2 in the tool table.

The tool offsets are SUBTRACTED

G43 H0 applies the Tool Length Offset of the tool currently in the spindle


G43.1 Dynamic Tool Length Offset (modal group 8)


G43.1 axes - change subsequent motions by replacing the current offset(s) of axes. G43.1 does not cause any motion. The next time a compensated axis is moved, that axis's endpoint is the compensated location.
Example
G90 (set absolute mode)
T1 M6 G43 (load tool 1 and tool length offsets, Z is at machine 0 and DRO shows Z1.500)
G43.1 Z0.250 (offset current tool offset by 0.250, DRO now shows Z1.250) M2 (end program)

See G90 & T & M6 sections for more information.

It is an error if:

motion is commanded on the same line as G43.1

NOTE: G43.1 does not write to the tool table.

G43.2 Additional tool lenght Offset (modal group 8)


G43.2 H- axes-  Apply additional Tool Length Offset
Where H is the  tool number

G43.2 - applies an additional simultaneous tool offset.
G43.2 Example
G90 (set absolute mode)
T1 M6 (load tool 1)
G43 (or G43 H1 - replace all tool offsets with T1's offset)
G43.2 H10 (also add in T10's tool offset)
M2 (end program)

You can sum together an arbitrary number of offsets by calling G43.2 more times. There are no built-in assumptions about which numbers are geometry offsets and which are wear offsets, or that you should have only one of each.

Like the other G43 commands, G43.2 does not cause any motion. The next time a compensated axis is moved, that axis's endpoint is the compensated location.

It is an error if H is unspecified and no axis offsets are specified. or H is specified and the given tool number does not exist in the tool table or H is specified and axes are also specified.

G43.2 does not write to the tool table.

G49 Cancel Tool Length Compensation (Typical Default)

G49 - cancels tool length compensation
( It is OK to program using the same offset already in use. It is also OK to program using no tool length offset if none is currently being used. ??? needs clarification - might mean the H offset?)


G52 Local Coordinate System Offset (non Modal)

G52 axes

G52 is used in a part program as a temporary "local coordinate system offset" within the workpiece coordinate system. More information on G52 is in the Local and Global Offsets section.

G53 Move in Machine Coordinates (non Modal)

G53 axes

To move in the machine coordinate system, program G53 on the same line as a linear move. G53 is not modal and must be programmed on each line. G0 or G1 does not have to be programmed on the same line if one is currently active.

For example G53 G0 X0 Y0 Z0 will move the axes to the home position even if the currently selected coordinate system has offsets in effect.

G53 Example G53 G0 X0 Y0 Z0 (rapid linear move to the machine origin) G53 X2 (rapid linear move to absolute coordinate X2)

See G0 section for more information.

It is an error if:

G53 is used without G0 or G1 being active,

or G53 is used while cutter compensation is on.

Coordinate system modes G54 G55 G56 G57 G58 G59 G59.1 G59.2 G59.3 (modal group 12)

When we home the machine, it sets zeros for the axis - this is the Machine coordinate system.

Most of the time, you will work in one of the user offset modes - a new zero is calculated from the machine system minus the offset.

Selecting a coordinate system if used while cutter compensation is on creates an error.

G53 cancels any offsets and causes the move to be in the Machine Coordinate System

G54 - select coordinate system 1 (modal group 12)

G55 - select coordinate system 2 (modal group 12)

G56 - select coordinate system 3 (modal group 12)

G57 select coordinate system 4 (modal group 12)

G58 select coordinate system 5 (modal group 12)

G59 select coordinate system 6 (modal group 12)

G59.1 select coordinate system 7 (modal group 12)

G59.2 select coordinate system 8 (modal group 12)

G59.3 select coordinate system 9 (modal group 12)

The coordinate systems store the axis values and the XY rotation angle around the Z axis in the parameters shown in the following table.
Coordinate System Parameters

Select CS X Y Z A B C U V W R
G54 1 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230
G55 2 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250
G56 3 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270
G57 4 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290
G58 5 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310
G59 6 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330
G59.1 7 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350
G59.2 8 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370
G59.3 9 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390


Motion modes G61 G61.1 G64 (modal group 13)

G61  Set Exact path mode (modal group 13)

Movement will be exactly as programmed. Moves will slow or stop as needed to reach every programmed point. If two sequential moves are exactly co-linear movement will not stop.

G61.1 Set Exact stop mode (modal group 13)

Movement will stop at the end of each programmed segment.

G64 <P-> <Q>  Path Blending (Typical default)(modal group 13)


;
Where:
; P - motion blending tolerance
Q - naive cam tolerance

G64 - Without P means to keep the best speed possible, no matter how far away from the programmed point you end up.

G64 P-  With A P number -  Blend between best speed and deviation tolerance

G64 P- <Q- > blending with tolerance. It is a way to fine tune your system for best compromise between speed and accuracy. The P- tolerance means that the actual path will be no more than P- away from the programmed endpoint. The velocity will be reduced if needed to maintain the path.

If you set Q to a non-zero value, it turns on the Naive CAM Detector: when there are a series of linear XYZ feed moves at the same feed rate that are less than Q- away from being collinear, they are collapsed into a single linear move.

On G2/G3 moves in the G17 (XY) plane, when the maximum deviation of an arc from a straight line is less than the G64 P- tolerance,  the arc is broken into two lines (from start of arc to midpoint, and from midpoint to end). those lines are then subject to the naive cam algorithm for lines. Thus, line-arc, arc-arc, and arc-line cases as well as line-line benefit from the Naive CAM Detector.

This improves contouring performance by simplifying the path. It is OK to program for the mode that is already active.

See also the Trajectory Control section for more information on these modes.

If Q is not specified then it will have the same behavior as before and use the value of P-. Set Q to zero to disable the Naive CAM Detector.

Metric Example: G64 P0.015 (set path following to be within 0.015 of the actual path)

G70 Lathe finishing cycle (modal group 1)

G70 Q- <X-> <Z-> <D-> <E-> <P->

Q - The subroutine number.

X - The starting X position, defaults to the initial position.

Z - The starting Z position, defaults to the initial position.

D - The starting distance of the profile, defaults to 0.

E - The ending distance of the profile, defaults to 0.

P - The number of passes to use, defaults to 1.

The G70 cycle is intended to be used after the shape of the profile given in the subroutine with number Q has been cut with G71 or G72.

Preliminary motion.

If Z or X are used a rapid move to that position is done. This position is also used between each finishing pass.

Then a rapid move to the start of the profile is executed.

The path given in Q- is followed using the G1 and [gcode:g2-g3] commands.

If a next pass is required there is another rapid to the intermediate location, before a rapid is done to the start of the profile.

After the final pass, the tool is left at the end of the profile including E-.

Multiple passes. The distance between the pass and the final profile is (pass-1)*(D-E)/P+E. Where pass the pass number and D,E and P are the D/E/P numbers.

The distance is computed using the starting position of the cycle, with a positive distance towards this point.

Fillet and chamfers in the profile. It is possible to add fillets or chamfers in the profile, see [gcode:g71-g72] for more details.

It is an error if:

There is no subroutine defined with the number given in Q.

The path given in the profile is not monotonic in Z or X.

[gcode:g17-g19.1] has not been used to select the ZX plane.

G71 G72 Lathe roughing cycles (modal group 1)

G71 Q- <X-> <Z-> <D-> <I-> <R-> G71.1 Q- <X-> <Z-> <D-> <I-> <R-> G71.2 Q- <X-> <Z-> <D-> <I-> <R-> G72 Q- <X-> <Z-> <D-> <I-> <R-> G72.1 Q- <X-> <Z-> <D-> <I-> <R-> G72.2 Q- <X-> <Z-> <D-> <I-> <R->

Q - The subroutine number.

X - The starting X position, defaults to the initial position.

Z - The starting Z position, defaults to the initial position.

D - The remaining distance to the profile, defaults to 0.

I - The cutting increment, defaults to 1.

R - The retracting distance, defaults to 0.5.

The G71/G72 cycle is intended to rough cut a profile on a lathe. The G71 cycles remove layers of the material while traversing in the Z direction. The G72 cycles remove material while traversing the X axis, the so called facing cycle. The direction of travel is the same as in the path given in the subroutine. For the G71 cycle the Z coordinate must be monotonically changing, for the G72 this is required for the X axis.

The profile is given in a subroutine with number Q-. This subroutine may contain G0, G1, G2 and G3 motion commands. All other commands are ignored, including feed and speed settings. The [gcode:g0] commands are interpreted as G1 commands. Each motion command may also include an optional A- or C- number. If the number A- is added a fillet with the radius given by A will be inserted at the endpoint of that motion, if this radius is too large the algorithm will fail with a non-monotonic path error. It is also possible to use the C- number, which allows a chamfer to be inserted. This chamfer has the same endpoints as a fillet of the same dimension would have but a straight line is inserted instead of an arc.

When in absolute mode the U (for X) and W (for Z) can be used as incremental displacements.

The G7x.1 cycles do not cut pockets. The G7x.2 cycles only cut after the first pocket and continue where G7x.1 stopped. It is advisible to leave some additional material to cut before the G7x.2 cycle, so if G7x.1 used a D1.0 the G7x.2 can use D0.5 and 0.5mm will be removed while moving from one pocket to the next.

The normal G7x cycles cut the entire profile in one cycle.

Preliminary motion.

If Z or X are used a rapid move to that position is done.

After the profile has been cut, the tool stops at the end of the profile, including the distance specified in D.

The D number is used to keep a distance from the final profile, to allow material to remain for finishing.

It is an error if:

There is no subroutine defined with the number given in Q.

The path given in the profile is not monotonic in Z or X.

[gcode:g17-g19.1] has not been used to select the ZX plane.

[gcode:g41-g42] is active.

G73 Drilling Cycle with Chip Breaking (modal group 1)

G73 X- Y- Z- R- Q- <L->

R - retract position along the Z axis.

Q - delta increment along the Z axis.

L - repeat

The G73 cycle is drilling or milling with chip breaking. This cycle takes a Q number which represents a delta increment along the Z axis.

Preliminary motion.

If the current Z position is below the R position, The Z axis does a rapid move to the R position.

Move to the X Y coordinates

Move the Z-axis only at the current feed rate downward by delta or to the Z position, whichever is less deep.

Rapid up .010 of an inch or 0.254 mm.

Repeat steps 2 and 3 until the Z position is reached at step 2.

The Z axis does a rapid move to the R position.

It is an error if:

the Q number is negative or zero.

the R number is not specified

G74 Left-hand Tapping Cycle with Dwell (modal group 1)

G74 (X- Y- Z-) or (U- V- W-) R- L- P- $- F-

R- - Retract position along the Z axis.

L- - Used in incremental mode; number of times to repeat the cycle. See G81 for examples.

P- - Dwell time (seconds).

$- - Selected spindle.

F- - Feed rate (spindle speed multiplied by distance traveled per revolution (thread pitch)).

Warning G74 does not use synchronized motion.

The G74 cycle is intended for tapping with floating chuck and dwell at the bottom of the hole.

Preliminary motion, as described in the Preliminary and In-Between Motion section.

Disable Feed and Speed Overrides.

Move the Z-axis at the current feed rate to the Z position.

Stop the selected spindle (chosen by the $ parameter)

Start spindle rotation clockwise.

Dwell for the P number of seconds.

Move the Z-axis at the current feed rate to clear Z

Restore Feed and Speed override enables to previous state

The length of the dwell is specified by a P- word in the G74 block. The feed rate F- is spindle speed multiplied by distance per revolution (thread pitch). In example S100 with 1.25MM per revolution thread pitch gives a feed of F125.

G76 Threading Cycle (probably only of interest for lathe work) (modal group 1)

G76 P- Z- I- J- R- K- Q- H- E- L- $- G76 Threading Figure 3. G76 Threading

Drive Line - A line through the initial X position parallel to the Z.

P- - The thread pitch in distance per revolution.

Z- - The final position of threads. At the end of the cycle the tool will be at this Z position.

Note When G7 Lathe Diameter Mode is in force the values for I, J and K are diameter measurements. When G8 Lathe Radius Mode is in force the values for I, J and K are radius measurements.

I- - The thread peak offset from the drive line. Negative I values are external threads, and positive I values are internal threads. Generally the material has been turned to this size before the G76 cycle.

J- - A positive value specifying the initial cut depth. The first threading cut will be J beyond the thread peak position.

K- - A positive value specifying the full thread depth. The final threading cut will be K beyond the thread peak position.

Optional settings

$- - The spindle number to which the motion will be synchronised (default 0). For example is $1 is programmed then the motion will begin on the reset od spindle.1.index-enable and proceed in synchrony with the value of spindle.1.revs

R- - The depth degression. R1.0 selects constant depth on successive threading passes. R2.0 selects constant area. Values between 1.0 and 2.0 select decreasing depth but increasing area. Values above 2.0 select decreasing area. Beware that unnecessarily high degression values will cause a large number of passes to be used. (degression = a descent by stages or steps.)

Warning Unnecessarily high degression values will produce an unnecessarily high number of passes. (degressing = dive in stages)

Q- - The compound slide angle is the angle (in degrees) describing to what extent successive passes should be offset along the drive line. This is used to cause one side of the tool to remove more material than the other. A positive Q value causes the leading edge of the tool to cut more heavily. Typical values are 29, 29.5 or 30.

H- - The number of spring passes. Spring passes are additional passes at full thread depth. If no additional passes are desired, program H0.

Thread entries and exits can be programmed tapered with the E and L values.

E- - Specifies the distance along the drive line used for the taper. The angle of the taper will be so the last pass tapers to the thread crest over the distance specified with E. E0.2 will give a taper for the first/last 0.2 length units along the thread. For a 45 degree taper program E the same as K.

L- - Specifies which ends of the thread get the taper. Program L0 for no taper (the default), L1 for entry taper, L2 for exit taper, or L3 for both entry and exit tapers. Entry tapers will pause at the drive line to synchronize with the index pulse then move at the feed rate in to the beginning of the taper. No entry taper and the tool will rapid to the cut depth then synchronize and begin the cut.

The tool is moved to the initial X and Z positions prior to issuing the G76. The X position is the drive line and the Z position is the start of the threads.

The tool will pause briefly for synchronization before each threading pass, so a relief groove will be required at the entry unless the beginning of the thread is past the end of the material or an entry taper is used.

Unless using an exit taper, the exit move is not synchronized to the spindle speed and will be a rapid move. With a slow spindle, the exit move might take only a small fraction of a revolution. If the spindle speed is increased after several passes are complete, subsequent exit moves will require a larger portion of a revolution, resulting in a very heavy cut during the exit move. This can be avoided by providing a relief groove at the exit, or by not changing the spindle speed while threading.

The final position of the tool will be at the end of the drive line. A safe Z move will be needed with an internal thread to remove the tool from the hole.

It is an error if:

The active plane is not the ZX plane.

Other axis words, such as X- or Y-, are specified.

The R- degression value is less than 1.0.

All the required words are not specified.

P-, J-, K- or H- is negative.

E- is greater than half the drive line length.

HAL Connections

The pins spindle.N.at-speed and the encoder.n.phase-Z for the spindle must be connected in your HAL file before G76 will work. See the spindle pins in the Motion section for more information.

Technical Info

The G76 canned cycle is based on the G33 Spindle Synchronized Motion. For more information see the G33 Technical Info.

The sample program g76.ngc shows the use of the G76 canned cycle, and can be previewed and executed on any machine using the sim/lathe.ini configuration.

G76 Example Code G0 Z-0.5 X0.2 G76 P0.05 Z-1 I-.075 J0.008 K0.045 Q29.5 L2 E0.045

In the figure the tool is in the final position after the G76 cycle is completed. You can see the entry path on the right from the Q29.5 and the exit path on the left from the L2 E0.045. The white lines are the cutting moves.

G76 Example Figure 4. G76 Example

G80-G89 Canned Cycles (modal group 1)

The canned cycles G81 through G89 and the canned cycle stop G80 are described in this section.

All canned cycles are performed with respect to the currently-selected plane. Any of the nine planes may be selected. Throughout this section, most of the descriptions assume the XY-plane has been selected. The behavior is analogous if another plane is selected, and the correct words must be used. For instance, in the G17.1 plane, the action of the canned cycle is along W, and the locations or increments are given with U and V. In this case substitute U,V,W for X,Y,Z in the instructions below.

Rotary axis words are not allowed in canned cycles. When the active plane is one of the XYZ family, the UVW axis words are not allowed. Likewise, when the active plane is one of the UVW family, the XYZ axis words are not allowed.

Common Words

All canned cycles use X, Y, Z, or U, V, W groups depending on the plane selected and R words. The R (usually meaning retract) position is along the axis perpendicular to the currently selected plane (Z-axis for XY-plane, etc.) Some canned cycles use additional arguments.

Sticky Words

For canned cycles, we will call a number sticky if, when the same cycle is used on several lines of code in a row, the number must be used the first time, but is optional on the rest of the lines. Sticky numbers keep their value on the rest of the lines if they are not explicitly programmed to be different. The R number is always sticky.

In incremental distance mode X, Y, and R numbers are treated as increments from the current position and Z as an increment from the Z-axis position before the move involving Z takes place. In absolute distance mode, the X, Y, R, and Z numbers are absolute positions in the current coordinate system.

Repeat Cycle

The L number is optional and represents the number of repeats. L=0 is not allowed. If the repeat feature is used, it is normally used in incremental distance mode, so that the same sequence of motions is repeated in several equally spaced places along a straight line. When L- is greater than 1 in incremental mode with the XY-plane selected, the X and Y positions are determined by adding the given X and Y numbers either to the current X and Y positions (on the first go-around) or to the X and Y positions at the end of the previous go-around (on the repetitions). Thus, if you program L10 , you will get 10 cycles. The first cycle will be distance X,Y from the original location. The R and Z positions do not change during the repeats. The L number is not sticky. In absolute distance mode, L>1 means do the same cycle in the same place several times, Omitting the L word is equivalent to specifying L=1.

Retract Mode

The height of the retract move at the end of each repeat (called clear Z in the descriptions below) is determined by the setting of the retract mode, either to the original Z position (if that is above the R position and the retract mode is G98, OLD_Z), or otherwise to the R position. See the G98 G99 section.

Canned Cycle Errors

It creates an error if:
axis words are all missing during a canned cycle axis words from different groups (XYZ) (UVW) are used together a P number is required and a negative P number is used an L number is used that does not evaluate to a positive integer rotary axis motion is used during a canned cycle
inverse time feed rate is active during a canned cycle
cutter compensation is active during a canned cycle. If the XY plane is active, the Z number is sticky: it is an error if:

the Z number is missing and the same canned cycle was not already active, or
the R number is less than the Z number.

If other planes are active, the error conditions are analogous to the XY conditions above.

Preliminary and In-Between Motion

Preliminary motion is a set of motions that is common to all of the milling canned cycles.

If the current Z position is below the R position, the Z axis does a rapid move to the R position. This happens only once, regardless of the value of L.

In between motion : At the beginning of the first cycle and each repeat, the following one or two moves are made:

1 - A rapid move parallel to the XY-plane to the given XY-position.
2 - The Z-axis make a rapid move to the R position, if it is not already at the R position.

If another plane is active, the preliminary and in-between motions are analogous.

Why use a canned cycle?

There are at least two reasons for using canned cycles. The first is the economy of code. A single bore would take several lines of code to execute.

The G81 Example 1 demonstrates how a canned cycle could be used to produce 8 holes with ten lines of G-code within the canned cycle mode. The program below will produce the same set of 8 holes using five lines for the canned cycle. It does not follow exactly the same path nor does it drill in the same order as the earlier example. But the program writing economy of a good canned cycle should be obvious.

Note Line numbers are not needed but help clarify these examples.
Eight Holes N100 G90 G0 X0 Y0 Z0 (move coordinate home) N110 G1 F10 X0 G4 P0.1 N120 G91 G81 X1 Y0 Z-1 R1 L4(canned drill cycle) N130 G90 G0 X0 Y1 N140 Z0 N150 G91 G81 X1 Y0 Z-0.5 R1 L4(canned drill cycle) N160 G80 (turn off canned cycle) N170 M2 (program end)

The G98 on the second line above means that the return move will be to the Z value on the first line since it is higher than the specified R value.

images/eight-holes_en.svg
Twelve Holes in a Square

This example demonstrates the use of the L word to repeat a set of incremental drill cycles for successive blocks of code within the same G81 motion mode. Here we produce 12 holes using five lines of code in the canned motion mode.

N1000 G90 G0 X0 Y0 Z0 (move coordinate home) N1010 G1 F50 X0 G4 P0.1 N1020 G91 G81 X1 Y0 Z-0.5 R1 L4 (canned drill cycle) N1030 X0 Y1 R0 L3 (repeat) N1040 X-1 Y0 L3 (repeat) N1050 X0 Y-1 L2 (repeat) N1060 G80 (turn off canned cycle) N1070 G90 G0 X0 (rapid move home) N1080 Y0 N1090 Z0 N1100 M2 (program end)
images/twelve-holes_en.svg

The second reason to use a canned cycle is that they all produce preliminary moves and returns that you can anticipate and control regardless of the start point of the canned cycle.

G80 Cancel Canned Cycle (modal group 1)

G80 - cancel canned cycle modal motion. G80 is part of modal group 1, so programming any other G-code from modal group 1 will also cancel the canned cycle.

It creates an error if: 

Axis words are programmed when G80 is active.

G80 Example G90 G81 X1 Y1 Z1.5 R2.8 (absolute distance canned cycle) G80 (turn off canned cycle motion) G0 X0 Y0 Z0 (rapid move to coordinate home)

The following code produces the same final position and machine state as the previous code.

G0 Example G90 G81 X1 Y1 Z1.5 R2.8 (absolute distance canned cycle) G0 X0 Y0 Z0 (rapid move to coordinate home)

The advantage of the first set is that, the G80 line clearly turns off the G81 canned cycle. With the first set of blocks, the programmer must turn motion back on with G0, as is done in the next line, or any other motion mode G word.

If a canned cycle is not turned off with G80 or another motion word, the canned cycle will attempt to repeat itself using the next block of code that contains an X, Y, or Z word. The following file drills (G81) a set of eight holes as shown in the following caption.

G80 Example 1 N100 G90 G0 X0 Y0 Z0 (coordinate home) N110 G1 X0 G4 P0.1 N120 G81 X1 Y0 Z0 R1 (canned drill cycle) N130 X2 N140 X3 N150 X4 N160 Y1 Z0.5 N170 X3 N180 X2 N190 X1 N200 G80 (turn off canned cycle) N210 G0 X0 (rapid move home) N220 Y0 N230 Z0 N240 M2 (program end)
Note Notice the Z position change after the first four holes. Also, this is one of the few places where line numbers have some value, being able to point a reader to a specific line of code.

The use of G80 in line N200 is optional because the G0 on the next line will turn off the G81 cycle. But using the G80 as shown in Example 1, will provide for easier to read canned cycle. Without it, it is not so obvious that all of the blocks between N120 and N200 belong to the canned cycle.

G81 Drilling Cycle (modal group 1)

G81 (X- Y- Z-) or (U- V- W-) R- L-

The G81 cycle is intended for drilling.

The cycle functions as follows:

Preliminary motion, as described in the Preliminary and In-Between Motion section.

Move the Z-axis at the current feed rate to the Z position.

The Z-axis does a rapid move to clear Z.

G81 Cycle Figure 5. G81 Cycle Example 1 - Absolute Position G81 G90 G98 G81 X4 Y5 Z1.5 R2.8

Suppose the current position is (X1, Y2, Z3) and the preceding line of NC code is interpreted.

This calls for absolute distance mode (G90) and OLD_Z retract mode (G98) and calls for the G81 drilling cycle to be performed once.

The X value and X position are 4.

The Y value and Y position are 5.

The Z value and Z position are 1.5.

The R value and clear Z are 2.8. OLD_Z is 3.

The following moves take place:

A rapid move parallel to the XY plane to (X4, Y5)

A rapid move move parallel to the Z-axis to (Z2.8).

Move parallel to the Z-axis at the feed rate to (Z1.5)

A rapid move parallel to the Z-axis to (Z3)

images/g81ex1_en.svg Example 2 - Relative Position G81 G91 G98 G81 X4 Y5 Z-0.6 R1.8 L3

Suppose the current position is (X1, Y2, Z3) and the preceding line of NC code is interpreted.

This calls for incremental distance mode (G91) and OLD_Z retract mode (G98). It also calls for the G81 drilling cycle to be repeated three times. The X value is 4, the Y value is 5, the Z value is -0.6 and the R value is 1.8. The initial X position is 5 (=1+4), the initial Y position is 7 (=2+5), the clear Z position is 4.8 (=1.8+3), and the Z position is 4.2 (=4.8-0.6). OLD_Z is 3.

The first preliminary move is a maximum rapid move along the Z axis to (X1,Y2,Z4.8), since OLD_Z < clear Z.

The first repeat consists of 3 moves.

A rapid move parallel to the XY-plane to (X5, Y7)

Move parallel to the Z-axis at the feed rate to (Z4.2)

A rapid move parallel to the Z-axis to (X5, Y7, Z4.8)

The second repeat consists of 3 moves. The X position is reset to 9 (=5+4) and the Y position to 12 (=7+5).

A rapid move parallel to the XY-plane to (X9, Y12, Z4.8)

Move parallel to the Z-axis at the feed rate to (X9, Y12, Z4.2)

A rapid move parallel to the Z-axis to (X9, Y12, Z4.8)

The third repeat consists of 3 moves. The X position is reset to 13 (=9+4) and the Y position to 17 (=12+5).

A rapid move parallel to the XY-plane to (X13, Y17, Z4.8)

Move parallel to the Z-axis at the feed rate to (X13, Y17, Z4.2)

A rapid move parallel to the Z-axis to (X13, Y17, Z4.8)

images/g81ex2_en.svg
Example 3 - Relative Position G81 G90 G98 G81 X4 Y5 Z1.5 R2.8

Now suppose that you execute the first G81 block of code but from (X0, Y0, Z0) rather than from (X1, Y2, Z3).

Since OLD_Z is below the R value, it adds nothing for the motion but since the initial value of Z is less than the value specified in R, there will be an initial Z move during the preliminary moves.

images/g81_en.svg
Example 4 - Absolute G81 R > Z

This is a plot of the path of motion for the second g81 block of code.

G91 G98 G81 X4 Y5 Z-0.6 R1.8 L3

Since this plot starts with (X0, Y0, Z0), the interpreter adds the initial Z0 and R1.8 and rapid moves to that location. After that initial Z move, the repeat feature works the same as it did in example 3 with the final Z depth being 0.6 below the R value.

images/g81a_en.svg
Example 5 - Relative position R > Z G90 G98 G81 X4 Y5 Z-0.6 R1.8

Since this plot starts with (X0, Y0, Z0), the interpreter adds the initial Z0 and R1.8 and rapid moves to that location as in Example 4. After that initial Z move, the rapid move to X4 Y5 is done. Then the final Z depth being 0.6 below the R value. The repeat function would make the Z move in the same location again.

G82 Drilling Cycle, Dwell (modal group 1)

G82 (X- Y- Z-) or (U- V- W-) R- L- P-

The G82 cycle is intended for drilling with a dwell at the bottom of the hole.

Preliminary motion, as described in the Preliminary and In-Between Motion section.

Move the Z-axis at the current feed rate to the Z position.

Dwell for the P number of seconds.

The Z-axis does a rapid move to clear Z.

The motion of a G82 canned cycle looks just like G81 with the addition of a dwell at the bottom of the Z move. The length of the dwell is specified by a P- word in the G82 block.

G90 G82 G98 X4 Y5 Z1.5 R2.8 P2

This will be similar to example 3 above, just with an added dwell of 2 seconds at the bottom of the hole.

G83 Peck Drilling Cycle (modal group 1)

G83 (X- Y- Z-) or (U- V- W-) R- L- Q- F-

The G83 cycle (often called peck drilling) is intended for deep drilling or milling with chip breaking. The retracts in this cycle breaks and clears the hole of chips.

Q represents a delta increment along the Z-axis between retracts.
R Retract plane
F Feed rate
L How many cycles (Omitting the L word is equivalent to specifying L=1.)

The retract before final depth will always be to the retract plane even if G98 is in effect. The final retract will honor the G98/99 in effect.

G83 is similar to G81 only with retracts during the operation.

Preliminary motion, as described in the Preliminary and In-Between Motion section.

Move the Z-axis at the current feed rate downward by delta or to the Z position, whichever is less deep.

Rapid move back out to the retract plane specified by the R word.

Rapid move back down to the current hole bottom, less .010 of an inch or 0.254 mm.

Repeat steps 2, 3, and 4 until the Z position is reached at step 2.

The Z-axis does a rapid move to clear Z.

It is an error if:

the Q number is negative or zero.

G84 Right-hand Tapping Cycle, Dwell (modal group 1)

G84 (X- Y- Z-) or (U- V- W-) R- L- P- $- F-

R- - Retract position along the Z axis.

L- - Used in incremental mode; number of times to repeat the cycle. See G81 for examples.

P- - Dwell time (seconds).

$- - Selected spindle.

F- - Feed rate (spindle speed multiplied by distance traveled per revolution (thread pitch)).

Warning G84 does not use synchronized motion.

The G84 cycle is intended for tapping with floating chuck and dwell at the bottom of the hole.

Preliminary motion, as described in the Preliminary and In-Between Motion section.

Disable Feed and Speed Overrides.

Move the Z-axis at the current feed rate to the Z position.

Stop the selected spindle (chosen by the $ parameter)

Start spindle rotation counterclockwise.

Dwell for the P number of seconds.

Move the Z-axis at the current feed rate to clear Z

Restore Feed and Speed override enables to previous state

The length of the dwell is specified by a P- word in the G84 block. The feed rate F- is spindle speed multiplied by distance per revolution (thread pitch). In example S100 with 1.25MM per revolution thread pitch gives a feed of F125.

G85 Boring Cycle, Feed Out (modal group 1)

G85 (X- Y- Z-) or (U- V- W-) R- L-

The G85 cycle is intended for boring or reaming, but could be used for drilling or milling.

Preliminary motion, as described in the Preliminary and In-Between Motion section.

Move the Z-axis only at the current feed rate to the Z position.

Retract the Z-axis at the current feed rate to the R plane if it is lower than the initial Z.

Retract at the traverse rate to clear Z.

G86 Boring Cycle, Spindle Stop, Rapid Move Out (modal group 1)

G86 (X- Y- Z-) or (U- V- W-) R- L- P- $-

The G86 cycle is intended for boring. This cycle uses a P number for the number of seconds to dwell.

Preliminary motion, as described in the Preliminary and In-Between Motion section.

Move the Z-axis only at the current feed rate to the Z position.

Dwell for the P number of seconds.

Stop the selected spindle turning. (Chosen by the $ parameter)

The Z-axis does a rapid move to clear Z.

Restart the spindle in the direction it was going.

It is an error if:

the spindle is not turning before this cycle is executed.

G87 Back Boring Cycle (modal group 1)

This code is currently unimplemented in LinuxCNC. It is accepted, but the behavior is undefined.

G88 Boring Cycle, Spindle Stop, Manual Out (modal group 1)

This code is currently unimplemented in LinuxCNC. It is accepted, but the behavior is undefined.

G89 Boring Cycle, Dwell, Feed Out (modal group 1)

G89 (X- Y- Z-) or (U- V- W-) R- L- P-

The G89 cycle is intended for boring. This cycle uses a P number, where P specifies the number of seconds to dwell.

Preliminary motion, as described in the Preliminary and In-Between Motion section.

Move the Z-axis only at the current feed rate to the Z position.

Dwell for the P number of seconds.

Retract the Z-axis at the current feed rate to clear Z.


G90, G91 Absolute vs Relative Distance Mode (modal group 3)

Example G90 (set absolute distance mode) G0 X2.5 (rapid move to coordinate X2.5 including any offsets in effect) G91 Example G91 (set incremental distance mode) G0 X2.5 (rapid move 2.5 from current position along the X axis) See G0 section for more information.

G90 absolute distance mode (modal group 3)

 G90 -  In absolute distance mode, axis numbers (X, Y, Z, A, B, C, U, V, W) usually represent positions in terms of the currently active coordinate system. Any exceptions to that rule are described explicitly in the G80 G89 Section.
 G91 - incremental distance mode In incremental distance mode, axis numbers usually represent increments from the current coordinate.
G90 Example
G90 (set absolute distance mode)
G0 X2.5 (rapid move to coordinate X2.5 including any offsets in effect)

G91 set incremental distance mode (modal group3)

G91 - incremental distance mode In incremental distance mode, axis numbers usually represent increments from the current coordinate. G90

G91 Example
G91 (set incremental distance mode)
G0 X2.5 (rapid move 2.5 from current position along the X axis)
 See G0 section for more information.

G90.1, G91.1 Arc IJK Relative vs Absolute Distance Mode (modal group 4)

G90.1 absolute distance mode for I, J & K offsets (modal group 4)

G90.1 - absolute distance mode for I, J & K offsets. When G90.1 is in effect I and J both must be specified with G2/3 for the XY plane or J and K for the XZ plane or it is an error.

G91.1 incremental distance mode for I, J & K offsets (modal group4)

G91.1 - incremental distance mode for I, J & K offsets. G91.1 Returns I, J & K to their default behavior.

Coordinate System Offset G92 G92.1 -G92.3 G52 (Non Modal)

These are used as a temporary offset, set and unset within the localized scope of a part program, in other G-code interpreters G52 does not persist after machine reset, M02 or M30. In LinuxCNC, G52 shares parameters with G92, which, for historical reasons, does persist these parameters. See G92 Persistence Cautions below.
Caution
G52 and G92 share the same offset registers! Therefore, setting G52 will override any earlier G92 setting, and G52 will persist across machine reset when G92 persistence is enabled. These interactions may result in unexpected offsets. See G92 and G52 Interaction Cautions below.
G92 sets G92 sets the current point(location) to have the coordinates specified (without motion),

G92 X5.0 -- the current(displayed) location of the X axis becomes 5

G90 - absolute mode

G92 Set Coordinate System Offset (non modal)

G92 <X- Y- Z- A B- C- U- V- W- >   use G92 after your machine has been positioned to the desired point.

G92 makes the current point have the coordinates you want (without motion), where the axis words contain the axis numbers you want. All axis words are optional, except that at least one must be used. If an axis word is not used for a given axis, the offset for that axis will be zero.

When G92 is executed, the origins of all coordinate systems move. They move such that the value of the current controlled point, in the currently active coordinate system, becomes the specified value. All of the coordinate system's origins (G53-G59.3) are offset this same distance.

G92 uses the values stored in parameters 5211-5219 as the X Y Z A B C U V W offset values for each axis. The parameter values are absolute machine coordinates in the native machine units as specified in the INI file. All axes defined in the INI file will be offset when G92 is active. If an axis was not entered following the G92, that axis' offset will be zero.

For example, suppose the current point is at X=4 and there is currently no G92 offset active. Then G92 X7 is programmed. This moves all origins -3 in X, which causes the current point to become X=7. This -3 is saved in parameter 5211.

Being in incremental distance mode (G91 instead of G90) has no effect on the action of G92.

G92 offsets may be already be in effect when the G92 is called. If this is the case, the offset is replaced with a new offset that makes the current point become the specified value.

It is an error if all axis words are omitted.

LinuxCNC stores the G92 offsets and reuses them on the next run of a program. To prevent this, one can program a G92.1 (to erase them), or program a G92.2 (to remove them - they are still stored).

The G52 command can also be used to change this offset; see the Offsets section for more details about G92 and G52 and how they interact.

See the Coordinate System section for an overview of coordinate systems.

See the Parameters section for more information.

G92.1, G92.2 Reset G92 Offsets (non modal)

G92.1 - turn off G92 offsets and reset parameters 5211 - 5219 to zero.

G92.2 - turn off G92 offsets but keep parameters 5211 - 5219 available.

Note G92.1 only clears G92 offsets, to change G53-G59.3 coordinate system offsets in G-code use either G10 L2 or G10 L20.

G92.3 Restore G92 Offsets ()non modal)

G92.3 - set the G92 offset to the values saved in parameters 5211 to 5219

You can set axis offsets in one program and use the same offsets in another program. Program G92 in the first program. This will set parameters 5211 to 5219. Do not use G92.1 in the remainder of the first program. The parameter values will be saved when the first program exits and restored when the second one starts up. Use G92.3 near the beginning of the second program. That will restore the offsets saved in the first program.

Feedrate Mode G93 G94 G95 (modal group 5)

G94 Units per Minute (typical mode) (modal group 5)

In units per minute feed mode, an F word is interpreted to mean the controlled point should move at a certain number of inches per minute, millimeters per minute, or degrees per minute, depending upon what length units are being used and which axis or axes are moving.

G93 - is Inverse Time Mode. (modal group 5)

In inverse time feed rate mode, an F word means the move should be completed in [one divided by the F number] minutes. For example, if the F number is 2.0, the move should be completed in half a minute.

When the inverse time feed rate mode is active, an F word must appear on every line which has a G1, G2, or G3 motion, and an F word on a line that does not have G1, G2, or G3 is ignored. Being in inverse time feed rate mode does not affect G0 (rapid move) motions.

G95 - is Units per Revolution Mode (useful for lathes)  (modal group 5)

In this mode, an F word is interpreted to mean the controlled point should move a certain number of inches per revolution of the spindle, depending on what length units are being used and which axis or axes are moving. G95 is not suitable for threading, for threading use G33 or G76. G95 requires that spindle.N.speed-in to be connected. The actual spindle to which the feed is synchronised is chosen by the $ parameter.
;It is an error if:

Inverse time feed mode is active and a line with G1, G2, or G3 (explicitly or implicitly) does not have an F word.

A new feed rate is not specified after switching to G94 or G95.


Spindle Control Mode G96 G97(modal group 14)

G96 <D-> S- (Constant Surface Speed Mode) (modal group 14)

D - maximum rotation speed (RPM), optional

S - spindle speed

$ - the spindle of which the speed will be varied, optional.

G96 S- <D-> - selects constant surface speed of S:

In feet per minute if G20 is in effect,

or meters per minute if G21 is in effect.

When using G96, ensure that X0 in the current coordinate system (including offsets and tool lengths) is the center of rotation or LinuxCNC will not give the desired surface speed. G96 is not affected by radius or diameter mode.

To achieve CSS mode on selected spindles programme successive G96 commands for each spindle prior to issuing M3.

G96 Example Line G96 D2500 S250 (set CSS with a max rpm of 2500 and a surface speed of 250)

It is an error if S is not specified with or a feed move is specified while the spindle is not turning

G97 RPM speed Mode (typical default) (modal group 14)

RPM mode.

Canned Cycle Return Level G98 G99 (modal group 10)

When spindle retracts during canned cycles, there are two modes to choose from.

G98 - retract to previous position (modal group 10)

Tetract to the position that axis was in just before this series of one or more contiguous canned cycles was started.

The canned cycle will use the Z position prior to the canned cycle as the Z return position if it is higher than the R value specified in the cycle. Conversely, if it is lower, the R value will be used. Remember that the R word has different meanings in absolute distance mode and incremental distance mode.

Example

G98 Retract to Origin G0 X1 Y2 Z3
G90 G98 G81 X4 Y5 Z-0.6 R1.8 F10

The G98 to the second line above means that the return move will be to the value of Z from the first line since it is higher that the R value specified.

The initial (G98) plane is reset any time cycle motion mode is abandoned, whether explicitly (G80) or implicitly (any motion code that is not a cycle). Switching among cycle modes (say G81 to G83) does NOT reset the initial plane.

G99  retract to R position (modal group 10)

retract to the position specified by the R word of the canned cycle.

 It is possible to switch between G98 and G99 during a series of cycles.

M-Codes

Stopping M0, M1, M2, M30, M60 (M-modal group 4)

M0 - pause a running program (M-modal group 4)

LinuxCNC remains in the Auto Mode so MDI and other manual actions are not enabled. Pressing the resume button will restart the program at the following line.


M1 - pause a running program IF the optional stop switch is on (M-modal group 4)

LinuxCNC remains in the Auto Mode so MDI and other manual actions are not enabled. Pressing the resume button will restart the program at the following line.

M2 - end the program (M-modal group 4)

Pressing Cycle Start ("R" in the Axis GUI) will restart the program at the beginning of the file.

 M30 - exchange pallet shuttles and end the program (M-modal group 4)

Pressing Cycle Start will start the program at the beginning of the file.
Both of M2 and M30  commands have the following effects:

 Lines of code after M2/M30 will not be executed. Pressing Cycle Start will start the program at the beginning of the file.
Warning
 Using % to wrap the G-code does not do the same thing as a Program End. See the section on File Requirements for more information on what using % does not do.


Spindle M3 M4 M5 (M-modal group 7)

M3 [$n] - start the selected spindle clockwise at the S speed.
 M4 [$n] - start the selected spindle counterclockwise at the S speed.
 M5 [$n] - stop the selected spindle.
Use $ to operate on specific spindles. If $ is omitted then the commands default to operating on spindle 0. Use $-1 to operate on all active spindles.
This example will start spindles 0, 1, and 2 simultaneously at different speeds:
S100 $0
S200 $1
S300 $2
M3 $-1
This example will then reverse spindle 1 but leave the other spindles rotating forwards:
M4 $1
And this will stop spindle 2 and leave the other spindles rotating:
M5 $2
If the $ is omitted then behaviour is exactly as normal for a single spindle machine.
It is OK to use M3 or M4 if the S spindle speed is set to zero. If this is done (or if the speed override switch is enabled and set to zero), the spindle will not start turning. If, later, the spindle speed is set above zero (or the override switch is turned up), the spindle will start turning. It is OK to use M3 or M4 when the spindle is already turning or to use M5 when the spindle is already stopped.

M6 Tool Change (non modal)

. Manual Tool Change
If the HAL component hal_manualtoolchange is loaded, M6 will stop the spindle and prompt the user to change the tool based on the last T- number programmed. For more information on hal_manualtoolchange see the Manual Tool Change section.
6.2. Tool Changer
To change a tool in the spindle from the tool currently in the spindle to the tool most recently selected (using a T word - see section Select Tool), program M6. When the tool change is complete:
 The spindle will be stopped.
 The tool that was selected (by a T word on the same line or on any line after the previous tool change) will be in the spindle.
 If the selected tool was not in the spindle before the tool change, the tool that was in the spindle (if there was one) will be placed back into the tool changer magazine.
 If configured in the INI file some axis positions may move when a M6 is issued. See the EMCIO section for more information on tool change options.
 No other changes will be made. For example, coolant will continue to flow during the tool change unless it has been turned off by an M9.
Note
 The T- word is an integer number designating the tool pocket number in the carousel (not its index).
Warning
 The tool length offset is not changed by M6, use G43 after the M6 to change the tool length offset.
The tool change may include axis motion. It is OK (but not useful) to program a change to the tool already in the spindle. It is OK if there is no tool in the selected slot; in that case, the spindle will be empty after the tool change. If slot zero was last selected, there will definitely be no tool in the spindle after a tool change. The tool changer will have to be setup to perform the tool change in HAL and possibly ClassicLadder.

M19 Orient Spindle

M19 R- Q- [P-] [$-]
  • R Position to rotate to from 0, valid range is 0-360 degrees

  • Q Number of seconds to wait until orient completes. If spindle.N.is-oriented does not become true within Q timeout an error occurs.

  • P Direction to rotate to position.

    • 0 rotate for smallest angular movement (default)

    • 1 always rotate clockwise (same as M3 direction)

    • 2 always rotate counterclockwise (same as M4 direction)

  • $ The spindle to orient (actually only determines which HAL pins carry the spindle position commands)

M19 is a command of modal group 7, like M3, M4 and M5. M19 is cleared by any of M3,M4,M5.

Spindle orientation requires a quadrature encoder with an index to sense the spindle shaft position and direction of rotation.

INI Settings in the [RS274NGC] section:

  • ORIENT_OFFSET = 0-360 (fixed offset in degrees added to M19 R word)

  • HAL Pins

    • spindle.N.orient-angle (out float) Desired spindle orientation for M19. Value of the M19 R word parameter plus the value of the [RS274NGC]ORIENT_OFFSET INI parameter.

    • spindle.N.orient-mode (out s32) Desired spindle rotation mode. Reflects M19 P parameter word, default = 0.

    • spindle.N.orient (out bit) Indicates start of spindle orient cycle. Set by M19. Cleared by any of M3,M4,M5. If spindle-orient-fault is not zero during spindle-orient true, the M19 command fails with an error message.

    • spindle.N.is-oriented (in bit) Acknowledge pin for spindle-orient. Completes orient cycle. If spindle-orient was true when spindle-is-oriented was asserted, the spindle-orient pin is cleared and the spindle-locked pin is asserted. Also, the spindle-brake pin is asserted.

    • spindle.N.orient-fault (in s32) Fault code input for orient cycle. Any value other than zero will cause the orient cycle to abort.

    • spindle.N.locked (out bit) Spindle orient complete pin. Cleared by any of M3,M4,M5.

M48, M49 Speed and Feed Override Control


These commands also take an optional $ parameter to determine which spindle they operate on.

It is OK to enable or disable the controls when they are already enabled or disabled. See the Feed Rate section for more details.

They also can be be toggled individually using M50 and M51, see below.

    M48 <$-> enable the spindle speed and feed rate override controls.


    M49 <$-> disable both controls.

M50 Feed Override Control
 M50 <P1> - enable the feed rate override control. The P1 is optional.
 M50 P0 - disable the feed rate control.
While disabled the feed override will have no influence, and the motion will be executed at programmed feed rate. (unless there is an adaptive feed rate override active).
11. M51 Spindle Speed Override Control
 M51 <P1> <$->- enable the spindle speed override control for the selected spindle. The P1 is optional.
 M51 P0 <$-> - disable the spindle speed override control program.
While disabled the spindle speed override will have no influence, and the spindle speed will have the exact program specified value of the S-word (described in the Spindle Speed section).
12. M52 Adaptive Feed Control
 M52 <P1> - use an adaptive feed. The P1 is optional.
 M52 P0 - stop using adaptive feed.
When adaptive feed is enabled, some external input value is used together with the user interface feed override value and the commanded feed rate to set the actual feed rate. In LinuxCNC, the HAL pin motion.adaptive-feed is used for this purpose. Values on motion.adaptive-feed should range from -1 (programmed speed in reverse) to 1 (full speed). 0 is equivalent to feed-hold.
Note
 The use of negative adaptive-feed for reverse run is a new feature and is not very well tested as yet. The intended use is for plasma cutters and wire spark eroders but it is not limited to such applications.
13. M53 Feed Stop Control
 M53 <P1> - enable the feed stop switch. The P1 is optional. Enabling the feed stop switch will allow motion to be interrupted by means of the feed stop control. In LinuxCNC, the HAL pin motion.feed-hold is used for this purpose. A true value will cause the motion to stop when M53 is active.
 M53 P0 - disable the feed stop switch. The state of motion.feed-hold will have no effect on feed when M53 is not active.

Coolant Mode (M7 M8 can both be on), M9 (M-modal group 8)

M7 - turn mist coolant on. M7 controls iocontrol.0.coolant-mist pin.
 M8 - turn flood coolant on. M8 controls iocontrol.0.coolant-flood pin.
 M9 - turn both M7 and M8 off.
Connect one or both of the coolant control pins in HAL before M7 or M8 will control an output. M7 and M8 can be used to turn on any output via G-code.
It is OK to use any of these commands, regardless of the current coolant state.

Override SwitchesM48, M49 (M-modal group 9)

User Defined M100-M199 (M-modal group 10)

Examples


Mode commands

Programs start with a preamble like this:

G17 G54 G40 G49 G80 G90 G21


Where:

G17 selects xy plane

G54 selects coordinate system 1

G40 turns off cutter compensation

G49 Cancel Tool Length Compensation

G80 Cancel canned cycle

G90 be in absolute mode

G21 Use metric units (mm)

Drilling

Peck cycle


G83 XYZ R P Q F L

XY: Coordinates of the hole

Z: Hole bottom

R: Retract position in Z. Motions from initial Z to R are performed at rapids speeds. From R to hole bottom is done at feed speed.

P: Dwell time at bottom of hole.

Q: Depth to increase on each peck.

F: Cutting feedrate

L: Number of repeats

Freecad - Path notes

Active Comments

MSG Message


 (MSG, example text ) - displays message if MSG appears after the left parenthesis and before any other printing characters.  The rest of the characters before the right parenthesis are considered to be a message. Messages should be displayed on the message display device of the user interface if provided.

(MSG, This is a message)

A popup will apear in Axis with "this is a message".

Probe Logging

    (PROBEOPEN filename.txt) - will open filename.txt and store the 9-number coordinate consisting of XYZABCUVW of each successful straight probe in it. ( see the G38 Section about probing)

    (PROBECLOSE) - will close the open probelog file.

Logging

    (LOGOPEN,filename.txt) - opens the named log file. If the file already exists, it is replace.

    (LOGAPPEND,filename) - opens the named log file. If the file already exists, the data is appended.

    (LOGCLOSE) - closes an open log file.

    (LOG,) - everything past the , is written to the log file if it is open. Supports expansion of parameters as described below.

Examples of logging are in nc_files/examples/smartprobe.ngc and in nc_files/ngcgui_lib/rectange_probe.ngc sample G code files.

Debug Messages

    (DEBUG,) - displays a message like (MSG,) with the addition of special handling for comment parameters.

In the DEBUG, PRINT and LOG comments, the values of parameters in the message are expanded.  Parameters are in the form #5400 -

Print Messages

    (PRINT,) - messages are output to stderr.  The values of parameters in the message are expanded.

Expanded parameters Example

Print a named global variable to stderr (the default console window).

(print,endmill dia = #<_endmill_dia>)   ; named parameter
(print,value of variable 123 is: #123)    ; simple parameter

Sequences like #<named parameter> are replaced by the value of the named parameter. Named parameters will have white space removed from them. So, #<named parameter> will be converted to #<namedparameter>.

#123 is replaced by the actual value of parameter 123 = and sent to stderr.


Numbered Parameter


  Expressed via the pound character( #) followed by an integer between 1 and (currently) 5602 . The parameter is referred to by this integer, and its value is whatever number is stored in the parameter.

A value is stored in a parameter in gcode with the = operator; for example:

#3 = 15 (set parameter 3 to 15)

A parameter setting does not take effect until after all parameter values on the same line have been found. For example, if parameter 3 has been previously set to 15 and the line #3=6 G1 X#3 is interpreted, a straight move to a point where X equals 15 will occur and the value of parameter 3 will be 6.

The # character takes precedence over other operations, so that, for example, #1+2 means the number found by adding 2 to the value of parameter 1, not the value found in parameter 3. Of course, #[1+2] does mean the value found in parameter 3. The # character may be repeated; for example ##2 means the value of the parameter whose index is the (integer) value of parameter 2.

    31-5000 - G code user parameters. These parameters are global in the G code file, and available for general use. Volatile.

    5061-5069 - Coordinates of a G38 probe result (X, Y, Z, A, B, C, U, V & W). Coordinates are in the coordinate system in which the G38 took place. Volatile.

    5070 - G38 probe result: 1 if success, 0 if probe failed to close. Used with G38.3 and G38.5. Volatile.

    5161-5169 - "G28" Home for X, Y, Z, A, B, C, U, V & W. Persistent.

    5181-5189 - "G30" Home for X, Y, Z, A, B, C, U, V & W. Persistent.

    5210 - 1 if "G52" or "G92" offset is currently applied, 0 otherwise. Volatile by default; persistent if DISABLE_G92_PERSISTENCE = 1 in the [RS274NGC] section of the .ini file.

    5211-5219 - Shared "G52" and "G92" offset for X, Y, Z, A, B, C, U, V & W. Volatile by default; persistent if DISABLE_G92_PERSISTENCE = 1 in the [RS274NGC] section of the .ini file.

    5220 - Coordinate System number 1 - 9 for G54 - G59.3. Persistent.

    5221-5230 - Coordinate System 1, G54 for X, Y, Z, A, B, C, U, V, W & R. R denotes the XY rotation angle around the Z axis. Persistent.

    5241-5250 - Coordinate System 2, G55 for X, Y, Z, A, B, C, U, V, W & R. Persistent.

    5261-5270 - Coordinate System 3, G56 for X, Y, Z, A, B, C, U, V, W & R. Persistent.

    5281-5290 - Coordinate System 4, G57 for X, Y, Z, A, B, C, U, V, W & R. Persistent.

    5301-5310 - Coordinate System 5, G58 for X, Y, Z, A, B, C, U, V, W & R. Persistent.

    5321-5330 - Coordinate System 6, G59 for X, Y, Z, A, B, C, U, V, W & R. Persistent.

    5341-5350 - Coordinate System 7, G59.1 for X, Y, Z, A, B, C, U, V, W & R. Persistent.

    5361-5370 - Coordinate System 8, G59.2 for X, Y, Z, A, B, C, U, V, W & R. Persistent.

    5381-5390 - Coordinate System 9, G59.3 for X, Y, Z, A, B, C, U, V, W & R. Persistent.

    5399 - Result of M66 - Check or wait for input. Volatile.

    5400 - Tool Number. Volatile.

    5401-5409 - Tool Offsets for X, Y, Z, A, B, C, U, V & W. Volatile.

    5410 - Tool Diameter. Volatile.

    5411 - Tool Front Angle. Volatile.

    5412 - Tool Back Angle. Volatile.

    5413 - Tool Orientation. Volatile.

    5420-5428 - Current relative position in the active coordinate system including all offsets and in the current program units for X, Y, Z, A, B, C, U, V & W, volatile.

    5599 - Flag for controlling the output of (DEBUG,) statements. 1=output, 0=no output; default=1. Volatile.

    5600 - Toolchanger fault indicator. Used with the iocontrol-v2 component. 1: toolchanger faulted, 0: normal. Volatile.

    5601 - Toolchanger fault code. Used with the iocontrol-v2 component. Reflects the value of the toolchanger-reason HAL pin if a fault occurred. Volatile.

Numbered Parameters file

The file name is set in machine.ini  Example:
PARAMETER_FILE = linuxcnc.var

The values of parameters in the persistent range are stored in this file and survives power down.

The file has two columns. It skips any lines which do not contain exactly two numeric values. The first column is an integer value (the parameter’s number). The second column is a floating point number ( parameter value).

Parameters in the user-defined range (31-5000) may be added to this file. Such parameters will be read by the Interpreter and written to the file as it exits.

Missing Parameters in the persistent range are initialized to zero.

The parameter numbers MUST be arranged in ascending order. Out of order parameter files trigger an error.

The original file is saved as a backup file when the new file is written.

Top Page wiki Index

Email

(C) Copyright 1994-2023
All trademarks are the property of their respective owners.