/ docs / src / gcode / g-code.txt
g-code.txt
   1  [[cha:g-codes]]
   2  = G Codes
   3  
   4  :ini: {basebackend@docbook:'':ini}
   5  :hal: {basebackend@docbook:'':hal}
   6  :ngc: {basebackend@docbook:'':ngc}
   7  
   8  == Conventions
   9  
  10  Conventions used in this section
  11  
  12  In the G code prototypes the hyphen ('-') stands for a real value
  13  and ('<>') denotes an optional item.
  14  
  15  If 'L-' is written in a prototype the '-' will often be referred to
  16  as the 'L number', and so on for any other letter.
  17  
  18  In the G code prototypes the word 'axes' stands for any axis as defined
  19  in your configuration.
  20  
  21  An optional value will be written like this '<L->'.
  22  
  23  A real value may be:
  24  
  25  * An explicit number, '4'
  26  * An expression, '[2+2]'
  27  * A parameter value, '#88'
  28  * A unary function value, 'acos[0]'
  29  
  30  In most cases, if 'axis' words are given
  31  (any or all of 'X Y Z A B C U V W'),
  32  they specify a destination point.
  33  
  34  Axis numbers are in the currently active coordinate system,
  35  unless explicitly described as being
  36  in the absolute coordinate system.
  37  
  38  Where axis words are optional, any omitted axes will retain their original value.
  39  
  40  Any items in the G code prototypes not explicitly described as
  41  optional are required.
  42  
  43  The values following letters are often given as explicit numbers.
  44  Unless stated otherwise, the explicit numbers can be real values. For
  45  example, 'G10 L2' could equally well be written 'G[2*5] L[1+1]'. If the
  46  value of parameter 100 were 2, 'G10 L#100' would also mean the same.
  47  
  48  If 'L-' is written in a prototype the '-' will often be referred to
  49  as the 'L number', and so on for any other letter.
  50  
  51  == G Code Quick Reference Table[[gcode:quick-reference-table]]
  52  
  53  (((G Code Table)))
  54  
  55  [width="75%", options="header", cols="2^,5<"]
  56  |====================================================================
  57  |Code                               |Description
  58  |<<gcode:g0,G0>>                    |Coordinated Motion at Rapid Rate
  59  |<<gcode:g1,G1>>                    |Coordinated Motion at Feed Rate
  60  |<<gcode:g2-g3,G2 G3>>              |Coordinated Helical Motion at Feed Rate
  61  |<<gcode:g4,G4>>                    |Dwell
  62  |<<gcode:g5,G5>>                    |Cubic Spline
  63  |<<gcode:g5.1,G5.1>>                |Quadratic B-Spline
  64  |<<gcode:g5.2-g5.3,G5.2,G5.3>>      |NURBS, add control point
  65  |<<gcode:g7,G7>>                    |Diameter Mode (lathe)
  66  |<<gcode:g8,G8>>                    |Radius Mode (lathe)
  67  |<<gcode:g10-l1,G10 L1>>            |Set Tool Table Entry
  68  |<<gcode:g10-l10,G10 L10>>          |Set Tool Table, Calculated, Workpiece
  69  |<<gcode:g10-l11,G10 L11>>          |Set Tool Table, Calculated, Fixture
  70  |<<gcode:g10-l2,G10 L2>>            |Coordinate System Origin Setting
  71  |<<gcode:g10-l20,G10 L20>>          |Coordinate System Origin Setting Calculated
  72  |<<gcode:g17-g19.1,G17 - G19.1>>    |Plane Select
  73  |<<gcode:g20-g21,G20 G21>>          |Set Units of Measure
  74  |<<gcode:g28-g28.1,G28 - G28.1>>    |Go to Predefined Position
  75  |<<gcode:g30-g30.1,G30 - G30.1>>    |Go to Predefined Position
  76  |<<gcode:g33,G33>>                  |Spindle Synchronized Motion
  77  |<<gcode:g33.1,G33.1>>              |Rigid Tapping
  78  |<<gcode:g38,G38.2 - G38.5>>        |Probing
  79  |<<gcode:g40,G40>>                  |Cancel Cutter Compensation
  80  |<<gcode:g41-g42,G41 G42>>          |Cutter Compensation
  81  |<<gcode:g41.1-g42.1,G41.1 G42.1>>  |Dynamic Cutter Compensation
  82  |<<gcode:g43,G43>>                  |Use Tool Length Offset from Tool Table
  83  |<<gcode:g43.1,G43.1>>              |Dynamic Tool Length Offset
  84  |<<gcode:g43.2,G43.2>>              |Apply additional Tool Length Offset
  85  |<<gcode:g49,G49>>                  |Cancel Tool Length Offset
  86  |<<gcode:g52,G52>>                  |Local Coordinate System Offset
  87  |<<gcode:g53,G53>>                  |Move in Machine Coordinates
  88  |<<gcode:g54-g59.3,G54-G59.3>>      |Select Coordinate System (1 - 9)
  89  |<<gcode:g61,G61>>                  |Exact Path Mode
  90  |<<gcode:g61.1,G61.1>>              |Exact Stop Mode
  91  |<<gcode:g64,G64>>                  |Path Control Mode with Optional Tolerance
  92  |<<gcode:g70,G70>>                  |Lathe finishing cycle
  93  |<<gcode:g71-g72,G71-G72>>          |Lathe roughing cycle
  94  |<<gcode:g73,G73>>                  |Drilling Cycle with Chip Breaking
  95  |<<gcode:g74,G74>>                  |Left-hand Tapping Cycle with Dwell
  96  |<<gcode:g76,G76>>                  |Multi-pass Threading Cycle (Lathe)
  97  |<<gcode:g80,G80>>                  |Cancel Motion Modes
  98  |<<gcode:g81,G81>>                  |Drilling Cycle
  99  |<<gcode:g82,G82>>                  |Drilling Cycle with Dwell
 100  |<<gcode:g83,G83>>                  |Drilling Cycle with Peck
 101  |<<gcode:g84,G84>>                  |Right-hand Tapping Cycle with Dwell
 102  |<<gcode:g85,G85>>                  |Boring Cycle, No Dwell, Feed Out
 103  |<<gcode:g86,G86>>                  |Boring Cycle, Stop, Rapid Out
 104  |<<gcode:g89,G89>>                  |Boring Cycle, Dwell, Feed Out
 105  |<<gcode:g90-g91,G90 G91>>          |Distance Mode
 106  |<<gcode:g90.1-g91.1,G90.1 G91.1>>  |Arc Distance Mode
 107  |<<gcode:g92,G92>>                  |Coordinate System Offset
 108  |<<gcode:g92.1-g92.2,G92.1 G92.2>>  |Cancel G92 Offsets
 109  |<<gcode:g92.3,G92.3>>              |Restore G92 Offsets
 110  |<<gcode:g93-g94-g95,G93 G94 G95>>  |Feed Modes
 111  |<<gcode:g96-g97,G96>>              |Spindle Control Mode
 112  |<<gcode:g98-g99,G98 G99>>          |Canned Cycle Z Retract Mode 
 113  |====================================================================
 114  
 115  [[gcode:g0]]
 116  == G0 Rapid Move
 117  (((G0 Rapid Move)))
 118  
 119  -------------------
 120  G0 axes
 121  -------------------
 122  
 123  For rapid motion, program 'G0 axes', where all the axis words are optional.
 124  The 'G0' is optional if the current motion mode is 'G0'. This will produce
 125  coordinated motion to the destination point at the maximum rapid rate
 126  (or slower). 'G0' is typically used as a positioning move.
 127  
 128  === Rapid Velocity Rate
 129  
 130  The MAX_VELOCITY setting in the ini file [TRAJ] section defines the maximum
 131  rapid traverse rate. The maximum rapid traverse rate can be higher than the
 132  individual axes MAX_VELOCITY setting during a coordinated move. The maximum
 133  rapid traverse rate can be slower than the MAX_VELOCITY setting in the [TRAJ]
 134  section if an axis MAX_VELOCITY or trajectory constraints limit it.
 135  
 136  
 137  .G0 Example
 138  ----
 139  G90 (set absolute distance mode)
 140  G0 X1 Y-2.3 (Rapid linear move from current location to X1 Y-2.3)
 141  M2 (end program)
 142  ----
 143  * See <<gcode:g90-g91,G90>> & <<mcode:m2-m30,M2>> sections for more information.
 144  
 145  If cutter compensation is active, the motion will differ from
 146  the above; see the <<sec:cutter-compensation,Cutter Compensation>> Section.
 147  
 148  If 'G53' is programmed on the same line, the motion will also differ;
 149  see the <<gcode:g53,G53>> Section for more information.
 150  
 151  The path of a G0 rapid motion can be rounded at direction changes and depends
 152  on the <<sec:trajectory-control,trajectory control>> settings and maximum
 153  acceleration of the axes.
 154  
 155  It is an error if:
 156  
 157  * An axis letter is without a real value.
 158  * An axis letter is used that is not configured
 159  
 160  [[gcode:g1]](((G1 Linear Move)))
 161  
 162  == G1 Linear Move
 163  
 164  -------------------
 165  G1 axes
 166  -------------------
 167  
 168  For linear (straight line) motion at programed <<sec:set-feed-rate,feed rate>>
 169  (for cutting or not), program 'G1 'axes'', where all the axis words are
 170  optional. The 'G1' is optional if the current motion mode is 'G1'. This will
 171  produce coordinated motion to the destination point at the current feed
 172  rate (or slower).
 173  
 174  .G1 Example
 175  ----
 176  G90 (set absolute distance mode)
 177  G1 X1.2 Y-3 F10 (linear move at a feed rate of 10 from current position to X1.2 Y-3)
 178  Z-2.3 (linear move at same feed rate from current position to Z-2.3)
 179  Z1 F25 (linear move at a feed rate of 25 from current position to Z1)
 180  M2 (end program)
 181  ----
 182  * See <<gcode:g90-g91,G90>> & <<sec:set-feed-rate,F>> & <<mcode:m2-m30,M2>> sections
 183  for more information.
 184  
 185  If cutter compensation is active, the motion will differ from
 186  the above; see the <<sec:cutter-compensation,Cutter Compensation>> Section.
 187  
 188  If 'G53' is programmed on the same line, the motion will also differ;
 189  see the <<gcode:g53,G53>> Section for more information.
 190  
 191  It is an error if:
 192  
 193  * No feed rate has been set.
 194  * An axis letter is without a real value.
 195  * An axis letter is used that is not configured
 196  
 197  [[gcode:g2-g3]]
 198  == G2, G3 Arc Move
 199  (((G2, G3 Arc Move)))
 200  
 201  ----
 202  G2 or G3 axes offsets (center format)
 203  G2 or G3 axes R- (radius format)
 204  G2 or G3 offsets|R- <P-> (full circles)
 205  ----
 206  
 207  A circular or helical arc is specified using either 'G2' (clockwise
 208  arc) or 'G3' (counterclockwise arc) at the current 
 209  <<sec:set-feed-rate,feed rate>>. The direction (CW, CCW) is as viewed from the
 210  positive end of the axis about which the circular motion occurs.
 211  
 212  The axis of the circle or helix must be parallel to the
 213  X, Y, or Z axis of the machine coordinate system.
 214  The axis (or, equivalently, the plane perpendicular to the axis)
 215  is selected with 'G17' (Z-axis, XY-plane),
 216  'G18' (Y-axis, XZ-plane), or 'G19' (X-axis, YZ-plane).
 217  Planes '17.1', '18.1', and '19.1' are not currently supported.
 218  If the arc is circular,
 219  it lies in a plane parallel to the selected plane.
 220  
 221  To program a helix, include the axis word perpendicular to the arc
 222  plane, for example, if in the 'G17' plane, include a 'Z' word. This
 223  will cause the 'Z' axis to move to the programmed value during the
 224  circular 'XY' motion. 
 225  
 226  To program an arc that gives more than one full turn, use the 'P' word
 227  specifying the number of full turns plus the programmed arc. The 'P' word
 228  must be an integer. If 'P' is unspecified, the behavior is as if 'P1' was
 229  given that is, only one full or partial turn will result. For example, if a
 230  180 degree arc is programmed with a P2, the resulting motion will be 1 1/2
 231  rotations. For each P increment above 1 an extra full circle is added to the
 232  programmed arc. Multi turn helical arcs are supported and give motion useful
 233  for milling holes or threads.
 234  
 235  If a line of code makes an arc and includes rotary axis motion,
 236  the rotary axes turn at a constant rate so that the rotary
 237  motion starts and finishes when the XYZ motion starts and finishes.
 238  Lines of this sort are hardly ever programmed.
 239  
 240  If cutter compensation is active, the motion will differ from
 241  the above; see the <<sec:cutter-compensation,Cutter Compensation>> Section.
 242  
 243  The arc center is absolute or relative as set by <<gcode:g90.1-g91.1,G90.1
 244  or G91.1>> respectively.
 245  
 246  Two formats are allowed for specifying an arc:
 247  Center Format and Radius Format.
 248  
 249  It is an error if:
 250  
 251  * No feed rate has been set.
 252  * The P word is not an integer.
 253  
 254  === Center Format Arcs
 255  
 256  Center format arcs are more accurate than radius format arcs and are
 257  the preferred format to use.
 258  
 259  The end point of the arc along with the offset to the center of the
 260  arc from the current location are used to program arcs that are less
 261  than a full circle. It is OK if the end point of the arc is the same
 262  as the current location.
 263  
 264  The offset to the center of the arc from the current location and
 265  optionally the number of turns are used to program full circles.
 266  
 267  When programming arcs an error due to rounding can result from using a
 268  precision of less than 4 decimal places (0.0000) for inch and less than
 269  3 decimal places (0.000) for millimeters.
 270  
 271  .Incremental Arc Distance Mode
 272  Arc center offsets are a relative distance from the start location of the arc.
 273  Incremental Arc Distance Mode is default.
 274  
 275  One or more axis words and one or more offsets must be programmed for an
 276  arc that is less than 360 degrees.
 277  
 278  No axis words and one or more offsets must be programmed for full circles.
 279  The 'P' word defaults to 1 and is optional.
 280  
 281  For more information on 'Incremental Arc Distance Mode see the
 282  <<gcode:g90.1-g91.1,G91.1>> section.
 283  
 284  .Absolute Arc Distance Mode
 285  Arc center offsets are the absolute distance from the current 0 position of the axis.
 286  
 287  One or more axis words and 'both' offsets must be programmed for arcs
 288  less than 360 degrees.
 289  
 290  No axis words and both offsets must be programmed for full circles.
 291  The 'P' word defaults to 1 and is optional.
 292  
 293  For more information on 'Absolute Arc Distance Mode see the
 294  <<gcode:g90.1-g91.1,G90.1>> section.
 295  
 296  .XY-plane (G17)
 297  ----
 298  G2 or G3 <X- Y- Z- I- J- P->
 299  ----
 300  * 'Z' - helix
 301  * 'I' - X offset
 302  * 'J' - Y offset
 303  * 'P' - number of turns
 304  
 305  .XZ-plane (G18)
 306  ----
 307  G2 or G3 <X- Z- Y- I- K- P->
 308  ----
 309  * 'Y' - helix
 310  * 'I' - X offset
 311  * 'K' - Z offset
 312  * 'P' - number of turns
 313  
 314  .YZ-plane (G19)
 315  ----
 316  G2 or G3 <Y- Z- X- J- K- P->
 317  ----
 318  * 'X' - helix
 319  * 'J' - Y offset
 320  * 'K' - Z offset
 321  * 'P' - number of turns
 322  
 323  It is an error if:
 324  
 325  * No feed rate is set with the <<sec:set-feed-rate,F>> word.
 326  
 327  * No offsets are programmed.
 328  
 329  * When the arc is projected on the selected plane, the distance from
 330    the current point to the center differs from the distance from the end
 331    point to the center by more than (.05 inch/.5 mm) 
 332    OR ((.0005 inch/.005mm) AND .1% of radius).
 333  
 334  Deciphering the Error message 'Radius to end of arc differs from radius to start:'
 335  
 336  * 'start' - the current position
 337  * 'center' - the center position as calculated using the i, j, or k words
 338  * 'end' - the programmed end point
 339  * 'r1' - radius from the start position to the center
 340  * 'r2' - radius from the end position to the center
 341  
 342  === Center Format Examples
 343  
 344  Calculating arcs by hand can be difficult at times. One option is to
 345  draw the arc with a cad program to get the coordinates and offsets.
 346  Keep in mind the tolerance mentioned above, you may have to change the
 347  precision of your cad program to get the desired results. Another
 348  option is to calculate the coordinates and offset using formulas. As
 349  you can see in the following figures a triangle can be formed from the
 350  current position the end position and the arc center.
 351  
 352  In the following figure you can see the start position is X0 Y0, the
 353  end position is X1 Y1. The arc center position is at X1 Y0. This gives
 354  us an offset from the start position of 1 in the X axis and 0 in the Y
 355  axis. In this case only an I offset is needed.
 356  
 357  .G2 Example Line
 358  [source,{ngc}]
 359  ----
 360  G0 X0 Y0
 361  G2 X1 Y1 I1 F10 (clockwise arc in the XY plane)
 362  ----
 363  
 364  .G2 Example
 365  
 366  image::images/g2_en.svg[align="center", alt="G2 Example"]
 367  
 368  In the next example we see the difference between the offsets for Y if
 369  we are doing a G2 or a G3 move. For the G2 move the start position is
 370  X0 Y0, for the G3 move it is X0 Y1. The arc center is at X1 Y0.5 for
 371  both moves. The G2 move the J offset is 0.5 and the G3 move the J
 372  offset is -0.5.
 373  
 374  .G2-G3 Example Line
 375  [source,{ngc}]
 376  ----
 377  G0 X0 Y0
 378  G2 X0 Y1 I1 J0.5 F25 (clockwise arc in the XY plane)
 379  G3 X0 Y0 I1 J-0.5 F25 (counterclockwise arc in the XY plane)
 380  ----
 381  
 382  .G2-G3 Example
 383  
 384  image::images/g2-3_en.svg[align="center", alt="G2-G3 Example"]
 385  
 386  In the next example we show how the arc can make a helix in the Z axis
 387  by adding the Z word.
 388  
 389  .G2 Example Helix
 390  [source,{ngc}]
 391  ----
 392  G0 X0 Y0 Z0
 393  G17 G2 X10 Y16 I3 J4 Z-1 (helix arc with Z added)
 394  ----
 395  
 396  In the next example we show how to make more than one turn using the P word.
 397  
 398  .P word Example
 399  ----
 400  G0 X0 Y0 Z0
 401  G2 X0 Y1 Z-1 I1 J0.5 P2 F25
 402  ----
 403  
 404  In the center format, the radius of the arc is not specified, but it
 405  may be found easily as the distance from the center of the circle to
 406  either the current point or the end point of the arc.
 407  
 408  === Radius Format Arcs
 409  
 410  ----
 411  G2 or G3 axes R- <P->
 412  ----
 413  * 'R' - radius from current position
 414  
 415  It is not good practice to program radius format arcs that are nearly
 416  full circles or nearly semicircles because a small change in the
 417  location of the end point will produce a much larger change in the
 418  location of the center of the circle (and, hence, the middle of the
 419  arc). The magnification effect is large enough that rounding error in a
 420  number can produce out-of-tolerance cuts. For instance, a 1%
 421  displacement of the endpoint of a 180 degree arc produced a 7%
 422  displacement of the point 90 degrees along the arc. Nearly full circles
 423  are even worse. Other size arcs (in the range tiny to 165 degrees or
 424  195 to 345 degrees) are OK.
 425  
 426  In the radius format, the coordinates of the end point of the arc in
 427  the selected plane are specified along with the radius of the arc.
 428  Program 'G2' 'axes' 'R-' (or use 'G3' instead of 'G2' ). R is the
 429  radius. The axis words are all optional except that at
 430  least one of the two words for the axes in the selected plane must be
 431  used. The R number is the radius. A positive radius indicates that the
 432  arc turns through less than 180 degrees, while a negative radius
 433  indicates a turn of more than 180 degrees. If the arc is helical, the
 434  value of the end point of the arc on the coordinate axis parallel to
 435  the axis of the helix is also specified.
 436  
 437  It is an error if:
 438  
 439  * both of the axis words for the axes of the selected plane are omitted
 440  * the end point of the arc is the same as the current point.
 441  
 442  .G2 Example Line
 443  [source,{ngc}]
 444  ----
 445  G17 G2 X10 Y15 R20 Z5 (radius format with arc)
 446  ----
 447  
 448  The above example makes a clockwise (as viewed from the positive Z-axis)
 449  circular or helical arc whose axis is parallel to the Z-axis, ending
 450  where X=10, Y=15, and Z=5, with a radius of 20. If the starting value
 451  of Z is 5, this is an arc of a circle parallel to the XY-plane;
 452  otherwise it is a helical arc.
 453  
 454  [[gcode:g4]]
 455  == G4 Dwell
 456  (((G4 Dwell)))
 457  
 458  ----
 459  G4 P-
 460  ----
 461  * 'P' - seconds to dwell (floating point)
 462  
 463  The P number is the time in seconds that all axes will remain unmoving.
 464  The P number is a floating point number so fractions of a second may be used.
 465  G4 does not affect spindle, coolant and any I/O.
 466  
 467  .G4 Example Line
 468  ----
 469  G4 P0.5 (wait for 0.5 seconds before proceeding)
 470  ----
 471  
 472  It is an error if:
 473  
 474  * the P number is negative or not specified.
 475  
 476  [[gcode:g5]]
 477  == G5 Cubic Spline
 478  (((G5 Cubic spline)))
 479  
 480  ----
 481  G5 X- Y- <I- J-> P- Q-
 482  ----
 483  * 'I' - X incremental offset from start point to first control point
 484  * 'J' - Y incremental offset from start point to first control point
 485  * 'P' - X incremental offset from end point to second control point
 486  * 'Q' - Y incremental offset from end point to second control point
 487  
 488  G5 creates a cubic B-spline in the XY plane with the X and Y axes only.
 489  P and Q must both be specified for every G5 command.
 490  
 491  For the first G5 command in a series of G5 commands, I and J must both
 492  be specified.  For subsequent G5 commands, either both I and J must be
 493  specified, or neither.  If I and J are unspecified, the starting
 494  direction of this cubic will automatically match the ending direction of
 495  the previous cubic (as if I and J are the negation of the previous P and
 496  Q).
 497  
 498  For example, to program a curvy N shape:
 499  
 500  .G5 Sample initial cubic spline
 501  ----
 502  G90 G17
 503  G0 X0 Y0
 504  G5 I0 J3 P0 Q-3 X1 Y1
 505  ----
 506  
 507  A second curvy N that attaches smoothly to this one can now be made
 508  without specifying I and J:
 509  
 510  .G5 Sample subsequent cubic spline
 511  ----
 512  G5 P0 Q-3 X2 Y2
 513  ----
 514  
 515  It is an error if:
 516  
 517  * P and Q are not both specified
 518  * Just one of I or J are specified
 519  * I or J are unspecified in the first of a series of G5 commands
 520  * An axis other than X or Y is specified
 521  * The active plane is not G17
 522  
 523  [[gcode:g5.1]]
 524  == G5.1 Quadratic Spline
 525  (((G5.1 Quadratic spline)))
 526  
 527  ----
 528  G5.1 X- Y- I- J-
 529  ----
 530  * 'I' - X incremental offset from start point to control point
 531  * 'J' - Y incremental offset from start point to control point
 532  
 533  G5.1 creates a quadratic B-spline in the XY plane with the X and Y axis
 534  only.  Not specifying I or J gives zero offset for the unspecified axis,
 535  so one or both must be given.
 536  
 537  For example, to program a parabola, through the origin, from X-2 Y4 to X2 Y4:
 538  
 539  .G5.1 Sample quadratic spline
 540  ----
 541  G90 G17
 542  G0 X-2 Y4
 543  G5.1 X2 I2 J-8
 544  ----
 545  
 546  It is an error if:
 547  
 548  * both I and J offset are unspecified or zero
 549  * An axis other than X or Y is specified
 550  * The active plane is not G17
 551  
 552  [[gcode:g5.2-g5.3]]
 553  == G5.2 G5.3 NURBS Block
 554  (((G5.2 G5.3 NURBS Block)))
 555  
 556  ----
 557  G5.2 <P-> <X- Y-> <L->
 558  X- Y- <P->
 559  ...
 560  G5.3
 561  ----
 562  
 563  Warning: G5.2, G5.3 is experimental and not fully tested.
 564  
 565  G5.2 is for opening the data block defining a NURBS and G5.3 for
 566  closing the data block. In the lines between these two codes the curve
 567  control points are defined with both their related 'weights' (P) and
 568  the parameter (L) which determines the order of the curve.
 569  
 570  The current coordinate, before the first G5.2 command, is always taken
 571  as the first NURBS control point.  To set the weight for this first
 572  control point, first program G5.2 P- without giving any X Y.
 573  
 574  The default weight if P is unspecified is 1.  The default order if L is
 575  unspecified is 3.
 576  
 577  .G5.2 Example
 578  [source,{ngc}]
 579  ----
 580  G0 X0 Y0 (rapid move)
 581  F10 (set feed rate)
 582  G5.2 P1 L3
 583       X0 Y1 P1
 584       X2 Y2 P1
 585       X2 Y0 P1
 586       X0 Y0 P2
 587  G5.3
 588  ; The rapid moves show the same path without the NURBS Block
 589  G0 X0 Y1
 590     X2 Y2
 591     X2 Y0
 592     X0 Y0
 593  M2
 594  ----
 595  
 596  .Sample NURBS Output
 597  
 598  image:images/nurbs01.png[align="center", alt="Sample NURBS Output"]
 599  
 600  More information on NURBS can be found here:
 601  
 602  http://wiki.linuxcnc.org/cgi-bin/wiki.pl?NURBS[http://wiki.linuxcnc.org/cgi-bin/wiki.pl?NURBS]
 603  
 604  [[gcode:g7]]
 605  == G7 Lathe Diameter Mode
 606  (((G7 Lathe Diameter Mode)))
 607  
 608  ----
 609  G7
 610  ----
 611  
 612  Program G7 to enter the diameter mode for axis X on a lathe. When in
 613  the diameter mode the X axis moves on a lathe will be 1/2 the distance
 614  to the center of the lathe. For example X1 would move the cutter to
 615  0.500” from the center of the lathe thus giving a 1” diameter part.
 616  
 617  [[gcode:g8]]
 618  == G8 Lathe Radius Mode
 619  (((G8 Lathe Radius Mode)))
 620  
 621  ----
 622  G8
 623  ----
 624  
 625  Program G8 to enter the radius mode for axis X on a lathe. When in
 626  Radius mode the X axis moves on a lathe will be the distance from the
 627  center. Thus a cut at X1 would result in a part that is 2" in diameter.
 628  G8 is default at power up.
 629  
 630  [[gcode:g10-l1]]
 631  == G10 L1 Set Tool Table
 632  (((G10 L1 Tool Table)))
 633  
 634  ----
 635  G10 L1 P- axes <R- I- J- Q->
 636  ----
 637  * 'P' - tool number
 638  * 'R' - radius of tool
 639  * 'I' - front angle (lathe)
 640  * 'J' - back angle (lathe)
 641  * 'Q' - orientation (lathe)
 642  
 643  G10 L1 sets the tool table for the 'P' tool number to the values of the words.
 644  
 645  A valid G10 L1 rewrites and reloads the tool table.
 646  
 647  .G10 L1 Example Line
 648  ----
 649  G10 L1 P1 Z1.5 (set tool 1 Z offset from the machine origin to 1.5)
 650  G10 L1 P2 R0.015 Q3 (lathe example setting tool 2 radius to 0.015 and orientation to 3)
 651  ----
 652  
 653  It is an error if:
 654  
 655  * Cutter Compensation is on
 656  * The P number is unspecified
 657  * The P number is not a valid tool number from the tool table
 658  * The P number is 0
 659  
 660  For more information on cutter orientation used by the 'Q' word,
 661  see the <<lathe-tool-orientation,Lathe Tool Orientation>> diagram.
 662  
 663  [[gcode:g10-l2]]
 664  == G10 L2 Set Coordinate System
 665  (((G10 L2 Coordinate System)))
 666  
 667  ----
 668  G10 L2 P- <axes R->
 669  ----
 670  * 'P' - coordinate system (0-9)
 671  * 'R' - rotation about the Z axis
 672  
 673  G10 L2 offsets the origin of the axes in the coordinate system specified to
 674  the value of the axis word. The offset is from the machine origin established
 675  during homing. The offset value will replace any current offsets in effect for
 676  the coordinate system specified. Axis words not used will not be changed.
 677  
 678  Program P0 to P9 to specify which coordinate system to change.
 679  
 680  .Coordinate System
 681  
 682  [width="50%", options="header", cols="^,^,^"]
 683  |========================================
 684  |P Value |Coordinate System |G code
 685  |0 |Active |n/a
 686  |1 |1 |G54
 687  |2 |2 |G55
 688  |3 |3 |G56
 689  |4 |4 |G57
 690  |5 |5 |G58
 691  |6 |6 |G59
 692  |7 |7 |G59.1
 693  |8 |8 |G59.2
 694  |9 |9 |G59.3
 695  |========================================
 696  
 697  
 698  Optionally program R to indicate the rotation of the XY axis around the Z axis.
 699  The direction of rotation is CCW as viewed from the positive end of the Z axis.
 700  
 701  All axis words are optional.
 702  
 703  Being in incremental distance mode (<<gcode:g90-g91,'G91'>>) has no effect on 'G10 L2'.
 704  
 705  Important Concepts:
 706  
 707  * G10 L2 Pn does not change from the current coordinate system to the one specified by P,
 708    you have to use G54-59.3 to select a coordinate system.
 709  * When a rotation is in effect jogging an axis will only move that axis
 710    in a positive or negative direction and not along the rotated axis.
 711  * If a 'G52' local offset or 'G92' origin offset was in effect before
 712    'G10 L2', it will continue to be in effect afterwards.
 713  * When programming a coordinate system with R, any 'G52' or 'G92' will
 714    be applied *after* the rotation.
 715  * The coordinate system whose origin is set by a 'G10' command may be
 716    active or inactive at the time the 'G10' is executed.
 717    If it is currently active, the new coordinates take effect immediately.
 718  
 719  It is an error if:
 720  
 721  * The P number does not evaluate to an integer in the range 0 to 9.
 722  * An axis is programmed that is not defined in the configuration.
 723  
 724  .G10 L2 Example Line
 725  [source,{ngc}]
 726  ----
 727  G10 L2 P1 X3.5 Y17.2
 728  ----
 729  
 730  In the above example the origin of the first coordinate system
 731  (the one selected by 'G54') is set to be X=3.5 and Y=17.2. 
 732  Because only X and Y are specified, the origin point is only moved in X and Y;
 733  the other coordinates are not changed.
 734  
 735  .G10 L2 Example Line
 736  [source,{ngc}]
 737  ----
 738  G10 L2 P1 X0 Y0 Z0 (clear offsets for X,Y & Z axes in coordinate system 1)
 739  ----
 740  
 741  The above example sets the XYZ coordinates of the coordinate system 1 to the machine origin.
 742  
 743  The coordinate system is described in the <<cha:coordinate-system,Coordinate System>> Section.
 744  
 745  [[gcode:g10-l10]]
 746  == G10 L10 Set Tool Table
 747  (((G10 L10 Set Tool Table)))
 748  
 749  ----
 750  G10 L10 P- axes <R- I- J- Q->
 751  ----
 752  * 'P' - tool number
 753  * 'R' - radius of tool
 754  * 'I' - front angle (lathe)
 755  * 'J' - back angle (lathe)
 756  * 'Q' - orientation (lathe)
 757  
 758  G10 L10 changes the tool table entry for tool P so that if the
 759  tool offset is reloaded, with the machine in its current position
 760  and with the current G5x and G52/G92 offsets active, the current coordinates
 761  for the given axes will become the given values. The axes that are
 762  not specified in the G10 L10 command will not be changed. This could be
 763  useful with a probe move as described in the <<gcode:g38,G38>> section.
 764  
 765  .G10 L10 Example
 766  ----
 767  T1 M6 G43 (load tool 1 and tool length offsets)
 768  G10 L10 P1 Z1.5 (set the current position for Z to be 1.5)
 769  G43 (reload the tool length offsets from the changed tool table)
 770  M2 (end program)
 771  ----
 772  * See <<sec:select-tool,T>> & <<mcode:m6,M6>>, and
 773    <<gcode:g43,G43>>/<<gcode:g43.1,G43.1>> sections for more information.
 774  
 775  It is an error if:
 776  
 777  * Cutter Compensation is on
 778  * The P number is unspecified
 779  * The P number is not a valid tool number from the tool table
 780  * The P number is 0
 781  
 782  [[gcode:g10-l11]]
 783  == G10 L11 Set Tool Table
 784  (((G10 L11 Set Tool Table)))
 785  
 786  ----
 787  G10 L11 P- axes <R- I- J- Q->
 788  ----
 789  * 'P' - tool number
 790  * 'R' - radius of tool
 791  * 'I' - front angle (lathe)
 792  * 'J' - back angle (lathe)
 793  * 'Q' - orientation (lathe)
 794  
 795  G10 L11 is just like G10 L10 except that instead of setting the entry
 796  according to the current offsets, it is set so that the current
 797  coordinates would become the given value if the new tool offset
 798  is reloaded and the machine is placed in the G59.3 coordinate
 799  system without any G52/G92 offset active.
 800  
 801  This allows the user to set the G59.3 coordinate system according to a
 802  fixed point on the machine, and then use that fixture to measure tools
 803  without regard to other currently-active offsets.
 804  
 805  // .G10 L11 Example FIX ME!
 806  // ----
 807  // G10 L11 P1
 808  // ----
 809  
 810  It is an error if:
 811  
 812  * Cutter Compensation is on
 813  * The P number is unspecified
 814  * The P number is not a valid tool number from the tool table
 815  * The P number is 0
 816  
 817  [[gcode:g10-l20]]
 818  == G10 L20 Set Coordinate System
 819  (((G10 L20 Set Coordinate System)))
 820  
 821  ----
 822  G10 L20 P- axes
 823  ----
 824  * 'P' - coordinate system (0-9)
 825  
 826  G10 L20 is similar to G10 L2 except that instead of setting the
 827  offset/entry to the given value, it is set to a calculated value that
 828  makes the current coordinates become the given value.
 829  
 830  .G10 L20 Example Line
 831  ----
 832  G10 L20 P1 X1.5 (set the X axis current location in coordinate system 1 to 1.5)
 833  ----
 834  
 835  It is an error if:
 836  
 837  * The P number does not evaluate to an integer in the range 0 to 9.
 838  * An axis is programmed that is not defined in the configuration.
 839  
 840  [[gcode:g17-g19.1]]
 841  == G17 - G19.1 Plane Select
 842  (((G17 - G19.1 Plane Select)))
 843  
 844  These codes set the current plane as follows:
 845  
 846  * 'G17' - XY (default)
 847  * 'G18' - ZX
 848  * 'G19' - YZ
 849  * 'G17.1' - UV
 850  * 'G18.1' - WU
 851  * 'G19.1' - VW
 852  
 853  The UV, WU and VW planes do not support arcs.
 854  
 855  It is a good idea to include a plane selection in the preamble
 856  of each G code file.
 857  
 858  The effects of having a plane selected are discussed in Section
 859  <<gcode:g2-g3,G2 G3 Arcs>> and Section <<gcode:g80-g89,G81 G89>>
 860  
 861  [[gcode:g20-g21]]
 862  == G20, G21 Units
 863  (((G20 Units)))
 864  
 865  * 'G20' - to use inches for length units.
 866  * 'G21' - to use millimeters for length units.
 867  
 868  It is a good idea to include units in the preamble
 869  of each G code file.
 870  
 871  [[gcode:g28-g28.1]]
 872  == G28, G28.1 Go/Set Predefined Position
 873  (((G28 Go/Set Predefined Position)))
 874  
 875  [WARNING]
 876  Only use G28 when your machine is homed to a repeatable position and the
 877  desired G28 position has been stored with G28.1.
 878  
 879  G28 uses the values stored in <<sub:numbered-parameters,parameters>> 
 880  5161-5169 as the X Y Z A B C U V W final point to move to. The parameter
 881  values are 'absolute' machine coordinates in the native machine 'units' as 
 882  specified in the ini file. All axes defined in the ini file will be moved when
 883  a G28 is issued. If no positions are stored with G28.1 then all axes will go to
 884  the <<sec.machine-corrdinate-system,machine origin>>.
 885  
 886  * 'G28' - makes a <<gcode:g0,rapid move>> from the current
 887    position to the 'absolute' position of the values in parameters 5161-5166.
 888  
 889  * 'G28 axes' - makes a rapid move to the position specified by
 890    'axes' including any offsets, then will make a rapid move to the 'absolute'
 891    position of the values in parameters 5161-5166 for all 'axes' specified. Any
 892    'axis' not specified will not move.
 893  
 894  * 'G28.1' - stores the current 'absolute' position into parameters 5161-5166.
 895  
 896  .G28 Example Line
 897  ----
 898  G28 Z2.5 (rapid to Z2.5 then to Z location specified in #5163)
 899  ----
 900  
 901  It is an error if :
 902  
 903  * Cutter Compensation is turned on
 904  
 905  [[gcode:g30-g30.1]]
 906  == G30, G30.1 Go/Set Predefined Position
 907  (((G30 Go/Set Predefined Position)))
 908  
 909  [WARNING]
 910  Only use G30 when your machine is homed to a repeatable position and the
 911  desired G30 position has been stored with G30.1.
 912  
 913  G30 functions the same as G28 but uses the values stored in
 914  <<sub:numbered-parameters,parameters>> 5181-5189 as the X Y Z A B C U V W
 915  final point to move to. The parameter values are 'absolute' machine
 916  coordinates in the native machine 'units' as specified in the ini file.
 917  All axes defined in the ini file will be moved when a G30 is issued.  If no
 918  positions are stored with G30.1 then all axes will go to the
 919  <<sec.machine-corrdinate-system,machine origin>>.
 920  
 921  [NOTE]
 922  G30 parameters will be used to move the tool when a M6 is programmed
 923  if TOOL_CHANGE_AT_G30=1 is in the [EMCIO] section of the ini file.
 924  
 925  * 'G30' - makes a <<gcode:g0,rapid move>> from the current
 926    position to the 'absolute' position of the values in parameters 5181-5189.
 927  
 928  * 'G30 axes' - makes a rapid move to the position specified
 929    by 'axes' including any offsets, then will make a rapid move to the
 930    'absolute' position of the values in parameters 5181-5189 for all 'axes'
 931    specified. Any 'axis' not specified will not move.
 932  
 933  * 'G30.1' - stores the current absolute position into parameters 5181-5186.
 934  
 935  .G30 Example Line
 936  ----
 937  G30 Z2.5 (rapid to Z2.5 then to the Z location specified in #5i83)
 938  ----
 939  
 940  It is an error if :
 941  
 942  * Cutter Compensation is turned on
 943  
 944  [[gcode:g33]]
 945  == G33 Spindle Synchronized Motion
 946  (((G33 Spindle Synchronized Motion)))
 947  
 948  ----
 949  G33 X- Y- Z- K- $-
 950  ----
 951  * 'K' - distance per revolution
 952  
 953  For spindle-synchronized motion in one direction, code 'G33 X- Y- Z- K-'
 954  where K gives the distance moved in XYZ for each revolution of the spindle.
 955  For instance, if starting at 'Z=0', 'G33 Z-1 K.0625' produces
 956  a 1 inch motion in Z over 16 revolutions of the spindle.
 957  This command might be part of a program to produce a 16TPI thread.
 958  Another example in metric, 'G33 Z-15 K1.5' produces
 959  a movement of 15mm while the spindle rotates 10 times for a thread of 1.5mm.
 960  
 961  The (optional) $ argument sets which spindle the motion is synchronised
 962  to (default is zero). For example G33 Z10 K1 $1 will move the spindle in
 963  synchrony with the spindle.N.revs HAL pin value. 
 964  
 965  Spindle-synchronized motion waits for the spindle index and spindle at speed
 966  pins, so multiple passes line up. 'G33' moves end at the programmed endpoint.
 967  G33 could be used to cut tapered threads or a fusee.
 968  
 969  All the axis words are optional, except that at least one must be used.
 970  
 971  [NOTE]
 972  K follows the drive line described by 'X- Y- Z-'. K is not parallel to
 973  the Z axis if X or Y endpoints are used for example when cutting tapered
 974  threads.
 975  
 976  .Technical Info[[gcode:g33-tech-info]]
 977  At the beginning of each G33 pass, LinuxCNC uses the spindle speed and the
 978  machine acceleration limits to calculate how long it will take Z to
 979  accelerate after the index pulse, and determines how many degrees the
 980  spindle will rotate during that time. It then adds that angle to the
 981  index position and computes the Z position using the corrected spindle
 982  angle. That means that Z will reach the correct position just as it
 983  finishes accelerating to the proper speed, and can immediately begin
 984  cutting a good thread.
 985  
 986  .HAL Connections
 987  The pin 'spindle.N.at-speed' must be set or driven true for the motion to
 988  start. Additionally spindle.N.revs must increase by 1 for each revolution
 989  of the spindle and the spindle.N.index-enable pin must be connected to
 990  an encoder (or resolver) counter which resets index-enable once per rev.
 991  
 992  See the Integrators Manual for more information on spindle synchronized motion.
 993  
 994  .G33 Example
 995  ----
 996  G90 (absolute distance mode)
 997  G0 X1 Z0.1 (rapid to position)
 998  S100 M3 (start spindle turning)
 999  G33 Z-2 K0.125 (move Z axis to -2 at a rate to equal 0.125 per revolution)
1000  G0 X1.25 (rapid move tool away from work)
1001  Z0.1 (rapid move to starting Z position)
1002  M2 (end program)
1003  ----
1004  * See <<gcode:g90-g91,G90>> & <<gcode:g0,G0>> & <<mcode:m2-m30,M2>> sections for more information.
1005  
1006  It is an error if:
1007  
1008  * All axis words are omitted.
1009  * The spindle is not turning when this command is executed
1010  * The requested linear motion exceeds machine velocity limits
1011      due to the spindle speed
1012  
1013  [[gcode:g33.1]]
1014  == G33.1 Rigid Tapping
1015  (((G33.1 Rigid Tapping)))
1016  
1017  ----------------
1018  G33.1 X- Y- Z- K- I- $-
1019  ----------------
1020  * 'K' - distance per revolution
1021  * 'I' - optional spindle speed multiplier for faster return move
1022  * '$' - optional spindle selector
1023  
1024  [WARNING]
1025  For Z only tapping preposition the XY location prior to calling G33.1 and only
1026  use a Z word in the G33.1. If the coordinates specified are not the current
1027  coordinates when calling G33.1 for tapping the move will not be along the Z axis
1028  but will be a coordinated, spindle-synchronized move from the current location
1029  to the location specified and back.
1030  
1031  For rigid tapping (spindle synchronized motion with return),
1032  code 'G33.1 X- Y- Z- K-' where 'K-' gives the distance moved
1033  for each revolution of the spindle.
1034  
1035  A rigid tapping move consists of the following sequence:
1036  
1037  . A move from the current coordinate to the specified coordinate, synchronized
1038     with the selected spindle at the given ratio and starting from the
1039     current coordinate with a spindle index pulse.
1040  . When reaching the endpoint, a command to reverse the spindle, and speed up
1041    by a factor set by the multiplier (e.g., from clockwise to counterclockwise).
1042  . Continued synchronized motion beyond the specified end coordinate
1043     until the spindle actually stops and reverses.
1044  . Continued synchronized motion back to the original coordinate.
1045  . When reaching the original coordinate,
1046     a command to reverse the spindle a second time
1047     (e.g., from counterclockwise to clockwise).
1048  . Continued synchronized motion beyond the original coordinate
1049     until the spindle actually stops and reverses.
1050  . An *unsynchronized* move back to the original coordinate.
1051  
1052  Spindle-synchronized motions wait for spindle index,
1053  so multiple passes line up.'G33.1' moves end at the original coordinate.
1054  
1055  All the axis words are optional, except that at least one must be used.
1056  
1057  .G33.1 Example
1058  [source,{ngc}]
1059  ----
1060  G90 (set absolute mode)
1061  G0 X1.000 Y1.000 Z0.100 (rapid move to starting position)
1062  S100 M3 (turn on the spindle, 100 RPM)
1063  G33.1 Z-0.750 K0.05 (rigid tap a 20 TPI thread 0.750 deep)
1064  M2 (end program)
1065  ----
1066  * See <<gcode:g90-g91,G90>> & <<gcode:g0,G0>> & <<mcode:m2-m30,M2>> sections for more information.
1067  
1068  It is an error if:
1069  
1070  * All axis words are omitted.
1071  * The spindle is not turning when this command is executed
1072  * The requested linear motion exceeds machine velocity limits
1073     due to the spindle speed
1074  
1075  [[gcode:g38]]
1076  == G38.n Straight Probe
1077  (((G38.n Probe)))
1078  
1079  ----
1080  G38.n axes
1081  ----
1082  
1083  * 'G38.2' - probe toward workpiece, stop on contact, signal error if failure
1084  * 'G38.3' - probe toward workpiece, stop on contact
1085  * 'G38.4' - probe away from workpiece, stop on loss of contact, signal error if failure
1086  * 'G38.5' - probe away from workpiece, stop on loss of contact
1087  
1088  [IMPORTANT]
1089  You will not be able to use a probe move until your
1090  machine has been set up to provide a probe input signal.
1091  The probe input signal must be connected to 'motion.probe-input' in a .hal file.
1092  G38.n uses motion.probe-input to determine when the probe has made (or lost) contact.
1093  TRUE for probe contact closed (touching), FALSE for probe contact open.
1094  
1095  Program 'G38.n axes' to perform a straight probe operation.
1096  The axis words are optional, except that at least one of them must be used.
1097  The axis words together define the destination point that the probe will move towards,
1098  starting from the current location. If the probe is not tripped before the destination
1099  is reached G38.2 and G38.4 will signal an error.
1100  
1101  The tool in the spindle must be a probe or contact a probe switch.
1102  
1103  In response to this command, the machine moves the controlled point
1104  (which should be at the center of the probe ball) in a straight line at the
1105  current <<sec:set-feed-rate,feed rate>> toward the programmed point.
1106  In inverse time feed mode, the feed rate is such that the whole motion
1107  from the current point to the programmed point would take the specified time.
1108  The move stops (within machine acceleration limits)
1109  when the programmed point is reached,
1110  or when the requested change in the probe input takes place,
1111  whichever occurs first.
1112  
1113  After successful probing, parameters #5061 to #5069 will be set to the
1114  X, Y, Z, A, B, C, U, V, W coordinates of the location of the controlled point
1115  at the time the probe changed state (in the current work coordinate system).
1116  After unsuccessful probing, they are set to the coordinates of the programmed point.
1117  Parameter 5070 is set to 1 if the probe succeeded and 0 if the probe failed.
1118  If the probing operation failed, G38.2 and G38.4 will signal an error
1119  by posting an message on screen if the selected GUI supports that.
1120  And by halting program execution.
1121  
1122  A comment of the form '(PROBEOPEN filename.txt)' will open
1123  'filename.txt' and store the 9-number coordinate consisting of
1124  XYZABCUVW of each successful straight probe in it.
1125  The file must be closed with '(PROBECLOSE)'. For more information
1126  see the <<gcode:comments, Comments>> Section.
1127  
1128  An example file 'smartprobe.ngc' is included (in the examples directory)
1129  to demonstrate using probe moves to log to a file the coordinates of a part.
1130  The program 'smartprobe.ngc' could be used with 'ngcgui' with minimal changes.
1131  
1132  It is an error if:
1133  
1134  * the current point is the same as the programmed point.
1135  * no axis word is used
1136  * cutter compensation is enabled
1137  * the feed rate is zero
1138  * the probe is already in the target state
1139  
1140  [[gcode:g40]]
1141  == G40 Compensation Off
1142  (((G40 Cutter Compensation Off)))
1143  
1144  * 'G40' - turn cutter compensation off. If tool compensation was on the
1145            next move must be a linear move and longer than the tool diameter.
1146            It is OK to turn compensation off when it is already off.
1147  
1148  .G40 Example
1149  ----
1150  ; current location is X1 after finishing cutter compensated move
1151  G40 (turn compensation off)
1152  G0 X1.6 (linear move longer than current cutter diameter)
1153  M2 (end program)
1154  ----
1155  See <<gcode:g0,G0>> & <<mcode:m2-m30,M2>> sections for more information.
1156  
1157  It is an error if:
1158  
1159  * A G2/G3 arc move is programmed next after a G40.
1160  * The linear move after turning compensation off is less than the tool diameter.
1161  
1162  [[gcode:g41-g42]]
1163  == G41, G42 Cutter Compensation
1164  (((G41 G42 Cutter Compensation)))
1165  
1166  ----
1167  G41 <D-> (left of programmed path)
1168  G42 <D-> (right of programmed path)
1169  ----
1170  * 'D' - tool number
1171  
1172  The D word is optional; if there is no D word the radius of the currently
1173  loaded tool will be used (if no tool is loaded and no D word is given,
1174  a radius of 0 will be used).
1175  
1176  If supplied, the D word is the tool number to use.  This would normally
1177  be the number of the tool in the spindle (in which case the D word is
1178  redundant and need not be supplied), but it may be any valid tool number.
1179  
1180  [NOTE]
1181  'G41/G42 D0' is a little special.  Its behavior is different on
1182  random tool changer machines and nonrandom tool changer machines
1183  (see the <<mcode:m6,Tool Change>> section).  On nonrandom
1184  tool changer machines, 'G41/G42 D0' applies the TLO of the tool currently
1185  in the spindle, or a TLO of 0 if no tool is in the spindle.  On random
1186  tool changer machines, 'G41/G42 D0' applies the TLO of the tool T0 defined
1187  in the tool table file (or causes an error if T0 is not defined in the
1188  tool table).
1189  
1190  To start cutter compensation to the left of the part profile, use G41.
1191  G41 starts cutter compensation to the left of the programmed line
1192  as viewed from the positive end of the axis perpendicular to the plane.
1193  
1194  To start cutter compensation to the right of the part profile, use G42.
1195  G42 starts cutter compensation to the right of the programmed line
1196  as viewed from the positive end of the axis perpendicular to the plane.
1197  
1198  The lead in move must be at least as long as the tool radius.
1199  The lead in move can be a rapid move.
1200  
1201  Cutter compensation may be performed if the XY-plane or XZ-plane is active.
1202  
1203  User M100-M199 commands are allowed when Cutter Compensation is on.
1204  
1205  The behavior of the machining center when cutter compensation
1206  is on is described in the <<sec:cutter-compensation,Cutter Compensation>>
1207  Section along with code examples.
1208  
1209  It is an error if:
1210  
1211  * The D number is not a valid tool number or 0.
1212  * The YZ plane is active.
1213  * Cutter compensation is commanded to turn on when it is already on.
1214  
1215  [[gcode:g41.1-g42.1]]
1216  == G41.1, G42.1 Dynamic Cutter Compensation
1217  (((G41.1 G42.1 Dynamic Compensation)))
1218  
1219  ----
1220  G41.1 D- <L-> (left of programmed path)
1221  G42.1 D- <L-> (right of programmed path)
1222  ----
1223  * 'D' - cutter diameter
1224  * 'L' - tool orientation (see <<lathe-tool-orientation,lathe tool orientation>>)
1225  
1226  G41.1 & G42.1 function the same as G41 & G42 with the added scope of being able
1227  to program the tool diameter. The L word defaults to 0 if unspecified. 
1228  
1229  It is an error if:
1230  
1231  * The YZ plane is active.
1232  * The L number is not in the range from 0 to 9 inclusive.
1233  * The L number is used when the XZ plane is not active.
1234  * Cutter compensation is commanded to turn on when it is already on.
1235  
1236  [[gcode:g43]]
1237  == G43 Tool Length Offset
1238  (((G43 Tool Length Offset)))
1239  
1240  ----
1241  G43 <H->
1242  ----
1243  * 'H' - tool number (optional)
1244  
1245  G43 enables tool length compensation.  G43 changes subsequent motions
1246  by offsetting the axis coordinates by the length of the offset. G43
1247  does not cause any motion. The next time a compensated axis is moved,
1248  that axis's endpoint is the compensated location.
1249  
1250  'G43' without an H word uses the currently loaded tool from the last
1251  'Tn M6'.
1252  
1253  'G43 Hn' uses the offset for tool n.
1254  
1255  [NOTE]
1256  'G43 H0' is a little special.  Its behavior is different on random
1257  tool changer machines and nonrandom tool changer machines (see the
1258  <<sec:tool-changers,Tool Changers>> section).  On nonrandom tool changer
1259  machines, 'G43 H0' applies the TLO of the tool currently in the spindle,
1260  or a TLO of 0 if no tool is in the spindle.  On random tool changer
1261  machines, 'G43 H0' applies the TLO of the tool T0 defined in the tool
1262  table file (or causes an error if T0 is not defined in the tool table).
1263  
1264  .G43 H- Example Line
1265  ----
1266  G43 H1 (set tool offsets using the values from tool 1 in the tool table)
1267  ----
1268  
1269  It is an error if:
1270  
1271  * the H number is not an integer, or
1272  
1273  * the H number is negative, or
1274  
1275  * the H number is not a valid tool number (though note that 0 is a valid
1276      tool number on nonrandom tool changer machines, it means "the tool
1277      currently in the spindle")
1278  
1279  
1280  [[gcode:g43.1]]
1281  == G43.1 Dynamic Tool Length Offset
1282  (((G43.1 Dynamic Tool Length Offset)))
1283  
1284  ----
1285  G43.1 axes
1286  ----
1287  
1288  * 'G43.1 axes' - change subsequent motions by replacing the current offset(s)
1289     of axes. G43.1 does not cause any motion. The next time a compensated axis
1290     is moved, that axis's endpoint is the compensated location.
1291  
1292  .G43.1 Example
1293  ----
1294  G90 (set absolute mode)
1295  T1 M6 G43 (load tool 1 and tool length offsets, Z is at machine 0 and DRO shows Z1.500)
1296  G43.1 Z0.250 (offset current tool offset by 0.250, DRO now shows Z1.250)
1297  M2 (end program)
1298  ----
1299  * See <<gcode:g90-g91,G90>> & <<sec:select-tool,T>> & <<mcode:m6,M6>>
1300    sections for more information.
1301  
1302  It is an error if:
1303  
1304  * motion is commanded on the same line as 'G43.1'
1305  
1306  NOTE: G43.1 does not write to the tool table.
1307  
1308  [[gcode:g43.2]]
1309  == G43.2 Apply additional Tool Length Offset
1310  (((G43.2 Apply additional Tool Length Offset)))
1311  
1312  ----
1313  G43.2 H-
1314  ----
1315  * 'H' - tool number
1316  
1317  G43.2 applies an additional simultaneous tool offset.
1318  
1319  .G43.2 Example
1320  ----
1321  G90 (set absolute mode)
1322  T1 M6 (load tool 1)
1323  G43 (or G43 H1 - replace all tool offsets with T1's offset)
1324  G43.2 H10 (also add in T10's tool offset)
1325  M2 (end program)
1326  ----
1327  
1328  You can sum together an arbitrary number of offsets by calling G43.2
1329  more times.  There are no built-in assumptions about which numbers are geometry
1330  offsets and which are wear offsets, or that you should have only one of each.
1331  
1332  Like the other G43 commands, G43.2 does not cause any motion.  The next time a
1333  compensated axis is moved, that axis's endpoint is the compensated location.
1334  
1335  It is an error if:
1336  
1337  * 'H' is unspecified, or
1338  * the given tool number does not exist in the tool table
1339  
1340  NOTE: G43.2 does not write to the tool table.
1341  
1342  [[gcode:g49]]
1343  == G49 Cancel Tool Length Compensation
1344  (((G49 Cancel Tool Length Offset)))
1345  
1346  * 'G49' - cancels tool length compensation
1347  
1348  It is OK to program using the same offset already in use. It is also
1349  OK to program using no tool length offset if none is currently being
1350  used.
1351  
1352  
1353  [[gcode:g52]]
1354  == G52 Local Coordinate System Offset
1355  (((Local Offsets)))
1356  
1357  ----
1358  G53 axes
1359  ----
1360  
1361  G52 is used in a part program as a temporary "local coordinate system offset"
1362  within the workpiece coordinate system. More information on G52 is in the
1363  <<sec:g52, Local and Global Offsets>> section.
1364  
1365  
1366  [[gcode:g53]]
1367  == G53 Move in Machine Coordinates
1368  (((G53 Machine Coordinates)))
1369  
1370  ----
1371  G53 axes
1372  ----
1373  
1374  To move in the <<sec.machine-corrdinate-system,machine coordinate system>>,
1375  program 'G53' on the same line as a linear move. 'G53' is not modal and must be
1376  programmed on each line. 'G0' or 'G1' does not have to be programmed on the same
1377  line if one is currently active.
1378  
1379  For example 'G53 G0 X0 Y0 Z0' will move the axes to the home position even if
1380  the currently selected coordinate system has offsets in effect.
1381  
1382  .G53 Example
1383  ----
1384  G53 G0 X0 Y0 Z0 (rapid linear move to the machine origin)
1385  G53 X2 (rapid linear move to absolute coordinate X2)
1386  ----
1387  * See <<gcode:g0,G0>> section for more information.
1388  
1389  It is an error if:
1390  
1391  * G53 is used without G0 or G1 being active, 
1392  * or G53 is used while cutter compensation is on.
1393  
1394  [[gcode:g54-g59.3]]
1395  == G54-G59.3 Select Coordinate System
1396  (((G54-G59.3 Select Coordinate System)))
1397  
1398  * 'G54' - select coordinate system 1
1399  * 'G55' - select coordinate system 2
1400  * 'G56' - select coordinate system 3
1401  * 'G57' - select coordinate system 4
1402  * 'G58' - select coordinate system 5
1403  * 'G59' - select coordinate system 6
1404  * 'G59.1' - select coordinate system 7
1405  * 'G59.2' - select coordinate system 8
1406  * 'G59.3' - select coordinate system 9
1407  
1408  The coordinate systems store the axis values and the
1409  XY rotation angle around the Z axis
1410  in the parameters shown in the following table.
1411  
1412  .Coordinate System Parameters
1413  
1414  [width="80%", options="header", cols="<,11*^"]
1415  |============================================================
1416  |Select|CS|X   |Y   |Z   |A   |B   |C   |U   |V   |W   |R   
1417  |G54   |1 |5221|5222|5223|5224|5225|5226|5227|5228|5229|5230
1418  |G55   |2 |5241|5242|5243|5244|5245|5246|5247|5248|5249|5250
1419  |G56   |3 |5261|5262|5263|5264|5265|5266|5267|5268|5269|5270
1420  |G57   |4 |5281|5282|5283|5284|5285|5286|5287|5288|5289|5290
1421  |G58   |5 |5301|5302|5303|5304|5305|5306|5307|5308|5309|5310
1422  |G59   |6 |5321|5322|5323|5324|5325|5326|5327|5328|5329|5330
1423  |G59.1 |7 |5341|5342|5343|5344|5345|5346|5347|5348|5349|5350
1424  |G59.2 |8 |5361|5362|5363|5364|5365|5366|5367|5368|5369|5370
1425  |G59.3 |9 |5381|5382|5383|5384|5385|5386|5387|5388|5389|5390
1426  |============================================================
1427  
1428  It is an error if:
1429  
1430  * selecting a coordinate system is used while cutter compensation is on.
1431  
1432  See the <<cha:coordinate-system,Coordinate System>> Section for an overview of coordinate
1433  systems.
1434  
1435  [[gcode:g61]]
1436  == G61 Exact Path Mode
1437  (((G61 G61.1 G64 Path Mode)))
1438  
1439  * 'G61' - Exact path mode, movement exactly as programed. Moves will slow or
1440  stop as needed to reach every programed point. If two sequential moves are
1441  exactly co-linear movement will not stop.
1442  
1443  [[gcode:g61.1]]
1444  ==  G61.1 Exact Stop Mode
1445  
1446  * 'G61.1' - Exact stop mode, movement will stop at the end of each programed
1447  segment.
1448  
1449  [[gcode:g64]]
1450  == G64 Path Blending
1451  (((G64 Path Blending)))
1452  
1453  ----
1454  G64 <P- <Q->>
1455  ----
1456  * 'P' - motion blending tolerance
1457  * 'Q' - naive cam tolerance 
1458  
1459  * 'G64' - best possible speed.
1460  * 'G64 P- <Q- >' blending with tolerance.
1461  
1462  * 'G64' - without P means to keep the best speed possible, no matter how
1463  far away from the programmed point you end up.
1464  
1465  * 'G64 P- Q-' - is a way to fine tune your system for best compromise
1466  between speed and accuracy. The P- tolerance means that the actual path
1467  will be no more than P- away from the programmed endpoint. The velocity
1468  will be reduced if needed to maintain the path. In addition, when you
1469  activate G64 P- Q- it turns on the 'naive cam detector'; when there are
1470  a series of linear XYZ feed moves at the same <<sec:set-feed-rate,feed rate>>
1471  that are less than Q- away from being collinear, they are collapsed into a
1472  single linear move. On G2/G3 moves in the G17 (XY) plane when the maximum
1473  deviation of an arc from a straight line is less than the G64 P-
1474  tolerance the arc is broken into two lines (from start of arc to
1475  midpoint, and from midpoint to end). those lines are then subject to
1476  the naive cam algorithm for lines. Thus, line-arc, arc-arc, and
1477  arc-line cases as well as line-line benefit from the 'naive cam
1478  detector'. This improves contouring performance by simplifying the
1479  path. It is OK to program for the mode that is already active. See also
1480  the <<sec:trajectory-control,Trajectory Control>> Section for more
1481  information on these modes.
1482  If Q is not specified then it will have the same behavior as before and
1483  use the value of P-.
1484  
1485  .G64 P- Example Line
1486  ----
1487  G64 P0.015 (set path following to be within 0.015 of the actual path)
1488  ----
1489  
1490  It is a good idea to include a path control specification in the preamble
1491  of each G code file.
1492  
1493  [[gcode:g70]]
1494  == G70 Lathe finishing cycle
1495  (((G70 Lathe finishing cycle)))
1496  
1497  ----
1498  G70 Q- <X-> <Z-> <D-> <E-> <P->
1499  ----
1500  * 'Q' - The subroutine number.
1501  * 'X' - The starting X position, defaults to the initial position.
1502  * 'Z' - The starting Z position, defaults to the initial position.
1503  * 'D' - The starting distance of the profile, defaults to 0.
1504  * 'E' - The ending distance of the profile, defaults to 0.
1505  * 'P' - The number of passes to use, defaults to 1.
1506  
1507  The 'G70' cycle is intended to be used after the shape of the profile given
1508  in the subroutine with number Q has been cut with G71 or G72.
1509  
1510   . Preliminary motion.
1511     ** If Z or X are used a <<gcode:g0,rapid move>> to that position
1512     is done. This position is also used between each finishing pass.
1513     ** Then a <<gcode:g0,rapid move>> to the start of the profile is
1514        executed.
1515     ** The path given in Q- is followed using the <<gcode:g1,G1>> and
1516        <<gcode:g2-g3>> commands.
1517     ** If a next pass is required there is another rapid to the intermediate
1518        location, before a rapid is done to the start of the profile.
1519     ** After the final pass, the tool is left at the end of the profile
1520        including E-.
1521   . Multiple passes.
1522     The distance between the pass and the final profile is (pass-1)*(D-E)/P+E.
1523     Where pass the pass number and D,E and P are the D/E/P numbers.
1524   . The distance is computed using the starting position of the cycle, with
1525     a positive distance towards this point.
1526   . Fillet and chamfers in the profile.
1527     It is possible to add fillets or chamfers in the profile, see
1528     <<gcode:g71-g72>> for more details.
1529  
1530  It is an error if:
1531  
1532  * There is no subroutine defined with the number given in Q.
1533  * The path given in the profile is not monotonic in Z or X.
1534  * <<gcode:g17-g19.1>> has not been used to select the ZX plane.
1535  
1536  [[gcode:g71-g72]]
1537  == G71 G72 Lathe roughing cycle
1538  (((G71 G72 Lathe roughing cycle)))
1539  
1540  ----
1541  G71   Q- <X-> <Z-> <D-> <I-> <R->
1542  G71.1 Q- <X-> <Z-> <D-> <I-> <R->
1543  G71.2 Q- <X-> <Z-> <D-> <I-> <R->
1544  G72   Q- <X-> <Z-> <D-> <I-> <R->
1545  G72.1 Q- <X-> <Z-> <D-> <I-> <R->
1546  G72.2 Q- <X-> <Z-> <D-> <I-> <R->
1547  ----
1548  * 'Q' - The subroutine number.
1549  * 'X' - The starting X position, defaults to the initial position.
1550  * 'Z' - The starting Z position, defaults to the initial position.
1551  * 'D' - The remaining distance to the profile, defaults to 0.
1552  * 'I' - The cutting increment, defaults to 1.
1553  * 'R' - The retracting distance, defaults to 0.5.
1554  
1555  The G71/G72 cycle is intended to rough cut a profile on a lathe. The G71
1556  cycles remove layers of the material while traversing in the Z direction.
1557  The G72 cycles remove material while traversing the X axis, the so called
1558  facing cycle. The direction of travel is the same as in the path given in
1559  the subroutine. For the G71 cycle the Z coordinate must be monotonically
1560  changing, for the G72 this is required for the X axis.
1561  
1562  The profile is given in a subroutine with number Q-. This subroutine
1563  may contain G0, G1, G2 and G3 motion commands. All other commands are
1564  ignored, including feed and speed settings. The <<gcode:g0>> commands are
1565  interpreted as <<gcode:g1,G1>> commands. Each motion command may also include
1566  an optional A- or C- number.  If the number A- is added a fillet with
1567  the radius given by A will be inserted at the endpoint of that motion, if
1568  this radius is too large the algorithm will fail with a non-monotonic path
1569  error. It is also possible to use the C- number, which allows a chamfer to
1570  be inserted. This chamfer has the same endpoints as a fillet of the same
1571  dimension would have but a straight line is inserted instead of an arc.
1572  
1573  When in absolute mode the U (for X) and W (for Z) can be used as
1574  incremental displacements.
1575  
1576  The G7x.1 cycles do not cut pockets. The G7x.2 cycles only cut after the
1577  first pocket and continue where G7x.1 stopped. It is advisible to leave
1578  some additional material to cut before the G7x.2 cycle, so if G7x.1 used
1579  a D1.0 the G7x.2 can use D0.5 and 0.5mm will be removed while moving
1580  from one pocket to the next.
1581  
1582  The normal G7x cycles cut the entire profile in one cycle.
1583  
1584   . Preliminary motion.
1585     ** If Z or X are used a <<gcode:g0,rapid move>> to that position
1586     is done.
1587     ** After the profile has been cut, the tool stops at the end of the
1588     profile, including the distance specified in D.
1589   . The D number is used to  keep a distance from the final profile,
1590     to allow material to remain for finishing.
1591  
1592  It is an error if:
1593  
1594  * There is no subroutine defined with the number given in Q.
1595  * The path given in the profile is not monotonic in Z or X.
1596  * <<gcode:g17-g19.1>> has not been used to select the ZX plane.
1597  * <<gcode:g41-g42>> is active.
1598  
1599  [[gcode:g73]]
1600  == G73 Drilling Cycle with Chip Breaking
1601  (((G73 Drilling Cycle Chip Break)))
1602  
1603  ----
1604  G73 X- Y- Z- R- Q- <L-> 
1605  ----
1606  * 'R' - retract position along the Z axis.
1607  * 'Q' - delta increment along the Z axis.
1608  * 'L' - repeat
1609  
1610  The 'G73' cycle is drilling or milling with chip breaking.
1611  This cycle takes a Q number which represents a 'delta' increment along the Z axis.
1612  
1613   . Preliminary motion.
1614     ** If the current Z position is below the R position, The Z axis does a
1615     <<gcode:g0,rapid move>> to the R position.
1616     ** Move to the X Y coordinates
1617   . Move the Z-axis only at the current <<sec:set-feed-rate,feed rate>> downward
1618     by delta or to the Z position, whichever is less deep.
1619   . Rapid up a bit.
1620   . Repeat steps 2 and 3 until the Z position is reached at step 2.
1621   . The Z axis does a rapid move to the R position.
1622  
1623  It is an error if:
1624  
1625  * the Q number is negative or zero.
1626  * the R number is not specified
1627  
1628  
1629  [[gcode:g74]]
1630  == G74 Left-hand Tapping Cycle, Dwell
1631  (((G74 Left-hand Tapping Cycle Dwell)))
1632  
1633  ----
1634  G74 (X- Y- Z-) or (U- V- W-) R- L- P- $-
1635  ----
1636  
1637  The 'G74' cycle is intended for tapping with floating chuck and dwell at the bottom of the hole.
1638  
1639      1. Preliminary motion, as described in the
1640         <<gcode:preliminary-motion,Preliminary and In-Between Motion>> section.
1641  
1642      2. Disable Feed and Speed Overrides.
1643  
1644      3. Move the Z-axis at the current feed rate to the Z position.
1645  
1646      4. Stop the selected spindle (chosen by the $ parameter)
1647  
1648      5. Start spindle rotation clockwise.
1649  
1650      6. Dwell for the P number of seconds.
1651  
1652      7. Move the Z-axis at the current feed rate to clear Z
1653  
1654      8. Restore Feed and Speed override enables to previous state
1655  
1656  The length of the dwell is specified by a 'P-' word in the G74 block. Thread pitch is F divided by S.
1657  In example S100 F125 gives pitch of 1.25MM per revolution.
1658  
1659  [[gcode:g76]]
1660  == G76 Threading Cycle
1661  (((G76 Threading Cycle)))
1662  
1663  ----
1664  G76 P- Z- I- J- R- K- Q- H- E- L- $-
1665  ----
1666  
1667  .G76 Threading
1668  
1669  image::images/g76-threads_en.svg[align="center", alt="G76 Threading"]
1670  
1671  
1672  * 'Drive Line' - A line through the initial X position parallel to the Z.
1673  
1674  * 'P-' - The 'thread pitch' in distance per revolution.
1675  
1676  * 'Z-' - The final position of threads. At the end of the cycle the tool will
1677  be at this Z position.
1678  
1679  [NOTE]
1680  When G7 'Lathe Diameter Mode' is in force the values for 'I', 'J' and 'K' are
1681  diameter measurements. When G8 'Lathe Radius Mode' is in force the values for
1682  'I', 'J' and 'K' are radius measurements.
1683  
1684  * 'I-' - The 'thread peak' offset from the 'drive line'. Negative 'I' values
1685  are external threads, and positive 'I' values are internal threads.
1686  Generally the material has been turned to this size before the 'G76' cycle.
1687  
1688  * 'J-' - A positive value specifying the 'initial cut depth'. The first
1689  threading cut will be 'J' beyond the 'thread peak' position.
1690  
1691  * 'K-' - A positive value specifying the 'full thread depth'. The final
1692  threading cut will be 'K' beyond the 'thread peak' position.
1693  
1694  Optional settings
1695  
1696  * '$-' - The spindle number to which the motion will be synchronised
1697  (default 0). For example is $1 is programmed then the motion will begin
1698  on the reset od spindle.1.index-enable and proceed in synchrony with the
1699  value of spindle.1.revs
1700  
1701  * 'R-' - The 'depth degression'. 'R1.0' selects constant depth on successive
1702  threading passes. 'R2.0' selects constant area. Values between 1.0 and
1703  2.0 select decreasing
1704  depth but increasing area. Values above 2.0 select decreasing area.
1705  Beware that unnecessarily high degression values will cause a large
1706  number of passes to be used. (degression = a descent by stages or
1707  steps.)
1708  
1709  * 'Q-' - The 'compound slide angle' is the angle (in degrees) describing to
1710  what extent successive passes should be offset along the drive line.
1711  This is used to cause one side of the tool to remove more material than
1712  the other. A positive 'Q' value causes the leading edge of the tool to
1713  cut more heavily.
1714  Typical values are 29, 29.5 or 30.
1715  
1716  * 'H-' - The number of 'spring passes'. Spring passes are additional passes at
1717  full thread depth. If no additional passes are desired, program 'H0'.
1718  
1719  * 'E-' - Specifies the distance along the drive line used for the taper. The
1720  angle of the taper will be so the last pass tapers to the thread crest
1721  over the distance specified with E.' E0.2' will give a taper for the
1722  first/last 0.2 length units along the
1723  thread. For a 45 degree taper program E the same as K
1724  
1725  * 'L-' - Specifies which ends of the thread get the taper. Program 'L0' for no
1726  taper (the default), 'L1' for entry taper, 'L2' for exit taper, or 'L3'
1727  for both entry and exit tapers. Entry tapers will pause at the drive line to
1728  synchronize with the index pulse then move at the <<sec:set-feed-rate,feed rate>>
1729  in to the beginning of the taper. No entry taper and the tool will rapid to the
1730  cut depth then synchronize and begin the cut.
1731  
1732  The tool is moved to the initial X and Z positions prior to issuing
1733  the G76. The X position is the 'drive line' and the Z position is the
1734  start of the threads.
1735  
1736  The tool will pause briefly for synchronization before each threading
1737  pass, so a relief groove will be required at the entry unless the
1738  beginning of the thread is past the end of the material or an entry
1739  taper is used.
1740  
1741  Unless using an exit taper, the exit move is not synchronized to the spindle
1742  speed and will be a <<gcode:g0,rapid move>>. With a slow spindle, the
1743  exit move might take only a small fraction of a revolution. If the spindle
1744  speed is increased after several passes are complete, subsequent exit
1745  moves will require a larger portion of a revolution, resulting in a
1746  very heavy cut during the exit move. This can be avoided by providing a
1747  relief groove at the exit, or by not changing the spindle speed while
1748  threading.
1749  
1750  The final position of the tool will be at the end of the 'drive line'.
1751  A safe Z move will be needed with an internal thread to remove the tool
1752  from the hole.
1753  
1754  It is an error if:
1755  
1756  * The active plane is not the ZX plane
1757  * Other axis words, such as X- or Y-, are specified
1758  * The 'R-' degression value is less than 1.0.
1759  * All the required words are not specified
1760  * 'P-', 'J-', 'K-' or 'H-' is negative
1761  * 'E-' is greater than half the drive line length
1762  
1763  .HAL Connections
1764  The pins 'spindle.N.at-speed' and the 'encoder.n.phase-Z' for the
1765  spindle must be connected in your HAL file before G76 will work.
1766  See the <<sec:motion-pins, spindle>> pins in the Motion section for more
1767  information.
1768  
1769  .Technical Info
1770  The G76 canned cycle is based on the G33 Spindle Synchronized Motion. For more
1771  information see the G33 <<gcode:g33-tech-info,Technical Info>>.
1772  
1773  The sample program 'g76.ngc' shows the use of the G76 canned cycle,
1774  and can be previewed and
1775  executed on any machine using the 'sim/lathe.ini' configuration.
1776  
1777  .G76 Example
1778  [source,{ngc}]
1779  ---------------
1780  G0 Z-0.5 X0.2
1781  G76 P0.05 Z-1 I-.075 J0.008 K0.045 Q29.5 L2 E0.045
1782  ---------------
1783  
1784  In the figure the tool is in the final position after the G76 cycle
1785  is completed. You can see the entry path on the right from the Q29.5
1786  and the exit path on the left from the L2 E0.045. The white lines
1787  are the cutting moves.
1788  
1789  .G76 Example
1790  
1791  image::images/g76-01.png[align="center", alt="G76 Example"]
1792  
1793  [[gcode:g80-g89]]
1794  == Canned Cycles
1795  (((G80-G89 Canned Cycles)))
1796  
1797  The canned cycles 'G81' through 'G89' and the canned cycle stop 'G80'
1798  are described in this section.
1799  
1800  All canned cycles are performed with respect to the currently-selected
1801  plane. Any of the nine planes may be selected. Throughout this section,
1802  most of the descriptions assume the XY-plane has been selected. The
1803  behavior is analogous if another plane is selected, and the correct
1804  words must be used. For instance, in the 'G17.1' plane, the action of
1805  the canned cycle is along W, and the locations
1806  or increments are given with U and V. In this case substitute U,V,W for
1807  X,Y,Z in the instructions below.
1808  
1809  Rotary axis words are not allowed in canned cycles. When the
1810  active plane is one of the XYZ family, the UVW axis words are not
1811  allowed. Likewise, when the active plane is one of the UVW family, the
1812  XYZ axis words are not allowed.
1813  
1814  === Common Words
1815  
1816  All canned cycles use X, Y, Z, or U, V, W groups depending on the
1817  plane selected and R words. The R (usually meaning retract) position is
1818  along the axis perpendicular to the currently selected plane (Z-axis
1819  for XY-plane, etc.) Some canned cycles use additional arguments.
1820  
1821  === Sticky Words
1822  
1823  For canned cycles, we will call a number 'sticky' if, when the same
1824  cycle is used on several lines of code in a row, the number must be
1825  used the first time, but is optional on the rest of the lines. Sticky
1826  numbers keep their value on the rest of the lines if they are not
1827  explicitly programmed to be different. The R number is always sticky.
1828  
1829  In incremental distance mode X, Y, and R numbers are treated as
1830  increments from the current position and Z as an increment from the
1831  Z-axis position before the move involving Z takes place. In absolute
1832  distance mode, the X, Y, R, and Z numbers are absolute positions in the
1833  current coordinate system.
1834  
1835  === Repeat Cycle
1836  
1837  The L number is optional and represents the number of repeats.
1838  L=0 is not allowed. If the repeat feature is used, it is
1839  normally used in incremental distance mode, so that the same sequence
1840  of motions is repeated in several equally spaced places along a
1841  straight line. When L- is greater than 1 in incremental mode with the
1842  XY-plane selected, the X and Y positions are determined by adding the
1843  given X and Y numbers either to the current X and Y positions (on the
1844  first go-around) or to the X and Y positions at the end of the previous
1845  go-around (on the repetitions). Thus, if you program 'L10' , you will
1846  get 10 cycles. The first cycle will be distance X,Y from
1847  the original location. The R and Z positions do not change during the
1848  repeats. The L number is not sticky. In absolute distance mode,
1849  L>1 means 'do the same cycle in the same place several
1850  times', Omitting the L word is equivalent to specifying L=1.
1851  
1852  === Retract Mode
1853  
1854  The height of the retract move at the end of each repeat (called
1855  'clear Z' in the descriptions below) is determined by the setting of
1856  the retract mode, either to the original Z position (if that is above
1857  the R position and the retract mode is 'G98', OLD_Z), or otherwise to
1858  the R position. See the <<gcode:g98-g99,G98 G99>> Section.
1859  
1860  [[gcode:canned-cycle-errors]]
1861  === Canned Cycle Errors
1862  
1863  It is an error if:
1864  
1865  * axis words are all missing during a canned cycle,
1866  * axis words from different groups (XYZ) (UVW) are used together,
1867  * a P number is required and a negative P number is used,
1868  * an L number is used that does not evaluate to a positive integer,
1869  * rotary axis motion is used during a canned cycle,
1870  * inverse time feed rate is active during a canned cycle,
1871  * or cutter compensation is active during a canned cycle.
1872  
1873  If the XY plane is active, the Z number is sticky, and it is an error
1874  if:
1875  
1876  * the Z number is missing and the same canned cycle was not already
1877     active, 
1878  * or the R number is less than the Z number.
1879  
1880  If other planes are active, the error conditions are analogous to the
1881  XY conditions above.
1882  
1883  [[gcode:preliminary-motion]]
1884  === Preliminary and In-Between Motion
1885  
1886  Preliminary motion is a set of motions that is common to all of the
1887  milling canned cycles. If the current Z position is below the R position,
1888  the Z axis does a <<gcode:g0,rapid move>> to the R position. This happens only
1889  once, regardless of the value of L.
1890  
1891  In addition, at the beginning of the first cycle and each repeat, the
1892  following one or two moves are made
1893  
1894  . A <<gcode:g0,rapid move>> parallel to the XY-plane to
1895    the given XY-position,
1896  . The Z-axis make a rapid move to the R position, if it is
1897    not already at the R position.
1898  
1899  If another plane is active, the preliminary and in-between motions are
1900  analogous.
1901  
1902  === Why use a canned cycle?
1903  
1904  There are at least two reasons for using canned cycles. The first is
1905  the economy of code. A single bore would take several lines of code to
1906  execute.
1907  
1908  The G81 <<gcode:g81-example,Example 1>> demonstrates how a canned cycle could be
1909  used to produce 8 holes with ten lines of G code within the canned cycle mode.
1910  The program below will produce the same set of 8 holes using five lines
1911  for the canned cycle. It does not follow exactly the same path nor does
1912  it drill in the same order as the earlier example. But the program
1913  writing economy of a good canned cycle should be obvious.
1914  
1915  NOTE: Line numbers are not needed but help clarify these examples
1916  
1917  .Eight Holes
1918  ----
1919  N100 G90 G0 X0 Y0 Z0 (move coordinate home)
1920  N110 G1 F10 X0 G4 P0.1
1921  N120 G91 G81 X1 Y0 Z-1 R1 L4(canned drill cycle)
1922  N130 G90 G0 X0 Y1
1923  N140 Z0
1924  N150 G91 G81 X1 Y0 Z-0.5 R1 L4(canned drill cycle)
1925  N160 G80 (turn off canned cycle)
1926  N170 M2 (program end)
1927  ----
1928  The G98 to the second line above means that the return move will be to
1929  the value of Z in the first line since it is higher that the R value
1930  specified.
1931  
1932  image::images/eight-holes_en.svg[align="center"]
1933  
1934  
1935  .Twelve Holes in a Square
1936  
1937  This example demonstrates the use of the L word to repeat a set of
1938  incremental drill cycles for successive blocks of code within the same
1939  G81 motion mode. Here we produce 12 holes using five lines of code in
1940  the canned motion mode.
1941  
1942  ----
1943  N1000 G90 G0 X0 Y0 Z0 (move coordinate home)
1944  N1010 G1 F50 X0 G4 P0.1
1945  N1020 G91 G81 X1 Y0 Z-0.5 R1 L4 (canned drill cycle)
1946  N1030 X0 Y1 R0 L3 (repeat)
1947  N1040 X-1 Y0 L3 (repeat)
1948  N1050 X0 Y-1 L2 (repeat)
1949  N1060 G80 (turn off canned cycle)
1950  N1070 G90 G0 X0 (rapid move home)
1951  N1080 Y0
1952  N1090 Z0
1953  N1100 M2 (program end)
1954  ----
1955  
1956  image::images/twelve-holes_en.svg[align="center"]
1957  
1958  The second reason to use a canned cycle is that they all produce
1959  preliminary moves and returns that you can anticipate and control
1960  regardless of the start point of the canned cycle.
1961  
1962  
1963  [[gcode:g80]]
1964  == G80 Cancel Canned Cycle
1965  (((G80 Cancel Modal Motion)))
1966  
1967  * 'G80' - cancel canned cycle modal motion. 'G80' is part of modal group 1,
1968            so programming any other G code from modal group 1 will also
1969            cancel the canned cycle.
1970  
1971  It is an error if:
1972  
1973  *  Axis words are programmed when G80 is active.
1974  
1975  .G80 Example
1976  ----
1977  G90 G81 X1 Y1 Z1.5 R2.8 (absolute distance canned cycle)
1978  G80 (turn off canned cycle motion)
1979  G0 X0 Y0 Z0 (rapid move to coordinate home)
1980  ----
1981  
1982  The following code produces the same final position and machine state as
1983  the previous code.
1984  
1985  .G0 Example
1986  ----
1987  G90 G81 X1 Y1 Z1.5 R2.8 (absolute distance canned cycle)
1988  G0 X0 Y0 Z0 (rapid move to coordinate home)
1989  ----
1990  
1991  The advantage of the first set is that, the G80 line clearly turns off the
1992  G81 canned cycle. With the first set of blocks, the programmer must turn
1993  motion back on with G0, as is done in the next line, or any other motion
1994  mode G word.
1995  
1996  If a canned cycle is not turned off with G80 or another motion word, the
1997  canned cycle will attempt to repeat itself using the next block of code
1998  that contains an X, Y, or Z word. The following file drills (G81) a set
1999  of eight holes as shown in the following caption. 
2000  
2001  .G80 Example 1
2002  ----
2003  N100 G90 G0 X0 Y0 Z0 (coordinate home)
2004  N110 G1 X0 G4 P0.1
2005  N120 G81 X1 Y0 Z0 R1 (canned drill cycle)
2006  N130 X2
2007  N140 X3
2008  N150 X4
2009  N160 Y1 Z0.5
2010  N170 X3
2011  N180 X2
2012  N190 X1
2013  N200 G80 (turn off canned cycle)
2014  N210 G0 X0 (rapid move home)
2015  N220 Y0
2016  N230 Z0
2017  N240 M2 (program end)
2018  ----
2019  
2020  [NOTE]
2021  Notice the z position change after the first four holes.
2022  Also, this is one of the few places where line numbers have some value,
2023  being able to point a reader to a specific line of code.
2024  
2025  .G80 Cycle
2026      
2027  image::images/g81mult_en.svg[align="center", alt="G80 Cycle"]
2028  
2029  The use of G80 in line N200 is optional because the G0 on the next
2030  line will turn off the G81 cycle. But using the G80 as shown in 
2031  Example 1, will provide for easier to read canned cycle. Without it, it
2032  is not so obvious that all of the blocks between N120 and N200 belong
2033  to the canned cycle.
2034  
2035  [[gcode:g81]]
2036  == G81 Drilling Cycle
2037  (((G81 Drilling Cycle)))
2038  
2039  ----
2040  G81 (X- Y- Z-) or (U- V- W-) R- L-
2041  ----
2042  
2043  The 'G81' cycle is intended for drilling.
2044  
2045  The cycle functions as follows:
2046  
2047   . Preliminary motion, as described in the
2048     <<gcode:preliminary-motion,Preliminary and In-Between Motion>> section.
2049  
2050  . Move the Z-axis at the current <<sec:set-feed-rate,feed rate>> to the Z
2051    position.
2052  
2053  . The Z-axis does a <<gcode:g0,rapid move>> to clear Z.
2054  
2055  .Example 1 - Absolute Position G81[[gcode:g81-example]]
2056  
2057  Suppose the current position is (X1, Y2, Z3) and the following line of NC
2058  code is interpreted.
2059  
2060  [source,{ngc}]
2061  ----
2062  G90 G98 G81 X4 Y5 Z1.5 R2.8
2063  ----
2064  
2065  This calls for absolute distance mode (G90) and OLD_Z retract mode
2066  (G98) and calls for the G81 drilling cycle to be performed once.
2067  
2068  The X value and X position are 4.
2069  
2070  The Y value and Y position are 5.
2071  
2072  The Z value and Z position are 1.5.
2073  
2074  The R value and clear Z are 2.8. OLD_Z is 3.
2075  
2076  The following moves take place:
2077  
2078  . a <<gcode:g0,rapid move>> parallel to the XY plane to (X4, Y5)
2079  
2080  . a rapid move move parallel to the Z-axis to (Z2.8).
2081  
2082  . move parallel to the Z-axis at the <<sec:set-feed-rate,feed rate>> to (Z1.5)
2083  
2084  . a rapid move parallel to the Z-axis to (Z3)
2085  
2086  image::images/g81ex1_en.svg[align="center"]
2087  
2088  .Example 2 - Relative Position G81
2089  
2090  Suppose the current position is (X1, Y2, Z3) and the following line of NC
2091  code is interpreted.
2092  
2093  [source,{ngc}]
2094  ----
2095  G91 G98 G81 X4 Y5 Z-0.6 R1.8 L3
2096  ----
2097  
2098  This calls for incremental distance mode (G91) and OLD_Z retract mode
2099  (G98). It also calls for the G81 drilling cycle to be repeated three
2100  times. The X value is 4, the Y value is 5, the Z value is -0.6 and the
2101  R value is 1.8. The initial X position is 5 (=1+4), the initial Y
2102  position is 7 (=2+5), the clear Z position is 4.8 (=1.8+3), and the Z
2103  position is 4.2 (=4.8-0.6). OLD_Z is 3.
2104  
2105  The first preliminary move is a maximum rapid move along the Z axis to
2106  (X1,Y2,Z4.8), since OLD_Z < clear Z.
2107  
2108  The first repeat consists of 3 moves.
2109  
2110  . a <<gcode:g0,rapid move>> parallel to the XY-plane to (X5, Y7)
2111  
2112  . move parallel to the Z-axis at the <<sec:set-feed-rate,feed rate>> to (Z4.2)
2113  
2114  . a rapid move parallel to the Z-axis to (X5, Y7, Z4.8) 
2115  
2116  The second repeat consists of 3 moves. The X position is reset to
2117   9 (=5+4) and the Y position to 12 (=7+5).
2118  
2119  . a <<gcode:g0,rapid move>> parallel to the XY-plane to (X9, Y12, Z4.8)
2120  
2121  . move parallel to the Z-axis at the feed rate to (X9, Y12, Z4.2)
2122  
2123  . a rapid move parallel to the Z-axis to (X9, Y12, Z4.8) 
2124  
2125  The third repeat consists of 3 moves. The X position is reset to
2126   13 (=9+4) and the Y position to 17 (=12+5).
2127  
2128  . a <<gcode:g0,rapid move>> parallel to the XY-plane to (X13, Y17, Z4.8)
2129  
2130  . move parallel to the Z-axis at the feed rate to (X13, Y17, Z4.2)
2131  
2132  . a rapid move parallel to the Z-axis to (X13, Y17, Z4.8)
2133  
2134  image::images/g81ex2_en.svg[align="center"]
2135  
2136  .Example 3 - Relative Position G81
2137  
2138  Now suppose that you execute the first G81 block of code but from (X0,
2139  Y0, Z0) rather than from (X1, Y2, Z3).
2140  
2141  ----
2142  G90 G98 G81 X4 Y5 Z1.5 R2.8
2143  ----
2144  
2145  Since OLD_Z is below the R value, it adds
2146  nothing for the motion but since the initial value of Z is less than
2147  the value specified in R, there will be an initial Z move during the
2148  preliminary moves.
2149  
2150  image::images/g81_en.svg[align="center"]
2151  
2152  .Example 4 - Absolute G81 R > Z
2153  
2154  This is a plot of the path of motion for the second g81 block of code.
2155  
2156  ----
2157  G91 G98 G81 X4 Y5 Z-0.6 R1.8 L3
2158  ----
2159  
2160  Since this plot starts with (X0, Y0, Z0), the interpreter adds the
2161  initial Z0 and R1.8 and rapid moves to that location. After that initial Z
2162  move, the repeat feature works the same as it did in example 3 with the
2163  final Z depth being 0.6 below the R value.
2164  
2165  image::images/g81a_en.svg[align="center"]
2166  
2167  .Example 5 - Relative position R > Z
2168  
2169  ----
2170  G90 G98 G81 X4 Y5 Z-0.6 R1.8
2171  ----
2172  
2173  Since this plot starts with (X0, Y0, Z0), the interpreter adds the initial Z0
2174  and R1.8 and rapid moves to that location as in 'Example 4'. After that initial Z
2175  move, the <<gcode:g0,rapid move>> to X4 Y5 is done. Then the final Z
2176  depth being 0.6 below the R value. The repeat function would make the Z move
2177  in the same location again.
2178  
2179  [[gcode:g82]]
2180  == G82 Drilling Cycle, Dwell
2181  (((G82 Drilling Cycle Dwell)))
2182  
2183  ----
2184  G82 (X- Y- Z-) or (U- V- W-) R- L- P-
2185  ----
2186  
2187  The 'G82' cycle is intended for drilling with a dwell at the bottom of
2188  the hole.
2189  
2190   . Preliminary motion, as described in the
2191     <<gcode:preliminary-motion,Preliminary and In-Between Motion>> section.
2192   . Move the Z-axis at the current <<sec:set-feed-rate,feed rate>> to the Z position.
2193   . Dwell for the P number of seconds.
2194   . The Z-axis does a <<gcode:g0,rapid move>> to clear Z.
2195  
2196  The motion of a G82 canned cycle looks just like G81 with the
2197  addition of a dwell at the bottom of the Z move. The length of
2198  the dwell is specified by a 'P-' word in the G82 block.
2199  
2200  [[gcode:g83]]
2201  == G83 Peck Drilling Cycle
2202  (((G83 Peck Drilling)))
2203  
2204  ----
2205  G83 (X- Y- Z-) or (U- V- W-) R- L- Q-
2206  ----
2207  
2208  The 'G83' cycle (often called peck drilling) is intended for deep
2209  drilling or
2210  milling with chip breaking. The retracts in this cycle clear the hole
2211  of chips and cut off any long stringers (which are common when drilling
2212  in aluminum). This cycle takes a Q number which represents a 'delta'
2213  increment along the Z-axis. The retract before final depth will always
2214  be to the 'retract' plane even if G98 is in effect. The final retract will
2215  honor the G98/99 in effect. G83 functions the same as G81 with the addition
2216  of retracts during the drilling operation.
2217  
2218  
2219   . Preliminary motion, as described in the
2220     <<gcode:preliminary-motion,Preliminary and In-Between Motion>> section.
2221   . Move the Z-axis at the current <<sec:set-feed-rate,feed rate>> downward by
2222     delta or to the Z position, whichever is less deep. 
2223   . Rapid move back out to the retract plane specified by the R word.
2224   . Rapid move back down to the current hole bottom, backed off a bit.
2225   . Repeat steps 2, 3, and 4 until the Z position is reached at step 2.
2226   . The Z-axis does a <<gcode:g0,rapid move>> to clear Z. 
2227  
2228  It is an error if:
2229  
2230  * the Q number is negative or zero.
2231  
2232  [[gcode:g84]]
2233  == G84 Right-hand Tapping Cycle, Dwell
2234  (((G84 Right-hand Tapping Cycle Dwell)))
2235  
2236  ----
2237  G84 (X- Y- Z-) or (U- V- W-) R- L- P- $-
2238  ----
2239  
2240  The 'G84' cycle is intended for tapping with floating chuck and dwell at the bottom of the hole.
2241  
2242      1. Preliminary motion, as described in the
2243         <<gcode:preliminary-motion,Preliminary and In-Between Motion>> section.
2244  
2245      2. Disable Feed and Speed Overrides.
2246  
2247      3. Move the Z-axis at the current feed rate to the Z position.
2248  
2249      4. Stop the seleted spindle (chosen by the $ parameter)
2250  
2251      5. Start spindle rotation counterclockwise.
2252  
2253      6. Dwell for the P number of seconds.
2254  
2255      7. Move the Z-axis at the current feed rate to clear Z
2256  
2257      8. Restore Feed and Speed override enables to previous state
2258  
2259  The length of the dwell is specified by a 'P-' word in the G84 block. Thread pitch is F divided by S.
2260  In example S100 F125 gives pitch of 1.25MM per revolution.
2261  
2262  [[gcode:g85]]
2263  == G85 Boring Cycle, Feed Out
2264  (((G85 Boring, Feed Out)))
2265  
2266  ----
2267  G85 (X- Y- Z-) or (U- V- W-) R- L-
2268  ----
2269  
2270  The 'G85' cycle is intended for boring or reaming, but could be used
2271  for drilling or milling.
2272  
2273   . Preliminary motion, as described in the
2274     <<gcode:preliminary-motion,Preliminary and In-Between Motion>> section.
2275   . Move the Z-axis only at the current <<sec:set-feed-rate,feed rate>> to the Z
2276     position.
2277   . Retract the Z-axis at the current feed rate to the R plane if it is lower 
2278   than the initial Z.
2279   . Retract at the traverse rate to clear Z. 
2280  
2281  [[gcode:g86]]
2282  == G86 Boring Cycle, Spindle Stop, Rapid Move Out
2283  (((G86 Boring, Spindle Stop, Rapid Move Out)))
2284  
2285  ----
2286  G86 (X- Y- Z-) or (U- V- W-) R- L- P- $-
2287  ----
2288  
2289  The 'G86' cycle is intended for boring. This cycle uses a P number
2290  for the number of seconds to dwell.
2291  
2292   . Preliminary motion, as described in the
2293     <<gcode:preliminary-motion,Preliminary and In-Between Motion>> section.
2294   . Move the Z-axis only at the current <<sec:set-feed-rate,feed rate>> to the Z
2295     position.
2296   . Dwell for the P number of seconds.
2297   . Stop the selected spindle turning. (Chosen by the $ parameter)
2298   . The Z-axis does a <<gcode:g0,rapid move>> to clear Z.
2299   . Restart the spindle in the direction it was going. 
2300  
2301  It is an error if:
2302  
2303  * the spindle is not turning before this cycle is executed.
2304  
2305  == G87 Back Boring Cycle
2306  
2307  This code is currently unimplemented in LinuxCNC. It is accepted, but the
2308  behavior is undefined.
2309  
2310  == G88 Boring Cycle, Spindle Stop, Manual Out
2311  
2312  This code is currently unimplemented in LinuxCNC. It is accepted, but the
2313  behavior is undefined.
2314  
2315  [[gcode:g89]]
2316  == G89 Boring Cycle, Dwell, Feed Out
2317  (((G89 Boring, Dwell, Feed Out)))
2318  
2319  ----
2320  G89 (X- Y- Z-) or (U- V- W-) R- L- P-
2321  ----
2322  
2323  The 'G89' cycle is intended for boring. This cycle uses a P number,
2324  where P specifies the number of seconds to dwell.
2325  
2326   . Preliminary motion, as described in the
2327     <<gcode:preliminary-motion,Preliminary and In-Between Motion>> section.
2328   . Move the Z-axis only at the current <<sec:set-feed-rate,feed rate>> to the Z
2329     position.
2330   . Dwell for the P number of seconds. 
2331   . Retract the Z-axis at the current feed rate to clear Z. 
2332  
2333  [[gcode:g90-g91]]
2334  == G90, G91 Distance Mode
2335  (((G90, G91 Distance Mode)))
2336  
2337  * 'G90' - absolute distance mode In absolute 
2338    distance mode, axis numbers (X, Y, Z, A, B, C, U, V, W)
2339    usually represent positions in terms of the currently active
2340    coordinate system. Any exceptions to that rule are described
2341    explicitly in the <<gcode:g80-g89,G80 G89>> Section.
2342  
2343  * 'G91' - incremental distance mode In incremental
2344    distance mode, axis numbers usually represent
2345    increments from the current coordinate.
2346  
2347  .G90 Example
2348  ----
2349  G90 (set absolute distance mode)
2350  G0 X2.5 (rapid move to coordinate X2.5 including any offsets in effect)
2351  ----
2352  
2353  .G91 Example
2354  ----
2355  G91 (set incremental distance mode)
2356  G0 X2.5 (rapid move 2.5 from current position along the X axis)
2357  ----
2358  
2359  * See <<gcode:g0,G0>> section for more information.
2360  
2361  [[gcode:g90.1-g91.1]]
2362  == G90.1, G91.1 Arc Distance Mode
2363  (((Arc Distance Mode)))
2364  
2365  * 'G90.1' - absolute distance mode for I, J & K offsets.
2366    When G90.1 is in effect I and J both must be specified with G2/3
2367    for the XY plane or J and K for the XZ plane or it is an error.
2368  
2369  * 'G91.1' - incremental distance mode for I, J & K offsets. G91.1 Returns 
2370    I, J & K to their default behavior.
2371  
2372  [[gcode:g92]]
2373  == G92 Coordinate System Offset
2374  (((G92 Coordinate System Offset)))
2375  
2376  ----
2377  G92 axes
2378  ----
2379  
2380  [WARNING]
2381  Only use 'G92' after your machine has been positioned to the desired point. 
2382  
2383  'G92' makes the current point have the coordinates you want (without
2384  motion), where the axis words contain the axis numbers you want.
2385  All axis words are optional, except that at least one must be used.
2386  If an axis word is not used for a given axis, the offset for that axis 
2387  will be zero. 
2388  
2389  When 'G92' is executed, the <<sec.machine-corrdinate-system,origins>> 
2390  of all coordinate systems move. They move such that the value of the 
2391  current controlled point, in the currently active coordinate system, 
2392  becomes the specified value. All of the coordinate system's origins 
2393  (G53-G59.3) are offset this same distance. 
2394  
2395  'G92' uses the values stored in <<sub:numbered-parameters,parameters>> 
2396  5211-5219 as the X Y Z A B C U V W offset values for each axis. 
2397  The parameter values are 'absolute' machine coordinates 
2398  in the native machine 'units' as specified in the ini file.
2399  All axes defined in the ini file will be offset when G92 is active. 
2400  If an axis was not entered following the G92, that axis' offset 
2401  will be zero. 
2402  
2403  For example, suppose the current point is at X=4 and there is
2404  currently no 'G92' offset active. Then 'G92 X7' is programmed. This
2405  moves all origins -3 in X, which causes the
2406  current point to become X=7. This -3 is saved in parameter 5211.
2407  
2408  Being in incremental distance mode (G91 instead of G90) has no effect 
2409  on the action of 'G92'.
2410  
2411  'G92' offsets may be already be in effect when the 'G92' is called.
2412  If this is the case, the offset is replaced with a new
2413  offset that makes the current point become the specified value.
2414  
2415  It is an error if:
2416  
2417  * all axis words are omitted.
2418  
2419  LinuxCNC stores the G92 offsets and reuses them on the next run of a
2420  program. To prevent this, one can program a G92.1 (to erase them), or
2421  program a G92.2 (to remove them - they are still stored).
2422  
2423  [NOTE]
2424  The 'G52' command can also be used to change this offset; see the
2425  <<sec:g52-and-g92-offsets,Offsets>> Section for more details about
2426  'G92' and 'G52' and how they interact.
2427  
2428  See the <<cha:coordinate-system,Coordinate System>> Section for an
2429  overview of coordinate systems.
2430  
2431  See the <<gcode:parameters,Parameters>> Section for more information.
2432  
2433  [[gcode:g92.1-g92.2]]
2434  == G92.1, G92.2 Reset G92 Offsets
2435  
2436  * 'G92.1' - turn off G92 offsets and reset <<sub:numbered-parameters,parameters>> 5211 - 5219 to zero.
2437  * 'G92.2' - turn off G92 offsets but keep <<sub:numbered-parameters,parameters>> 5211 - 5219 available. 
2438  
2439  [NOTE]
2440  G92.1 only clears G92 offsets, to change G53-G59.3 coordinate system offsets
2441  in G code use either <<gcode:g10-l2,G10 L2>> or <<gcode:g10-l20,G10 L20>>.
2442  
2443  [[gcode:g92.3]]
2444  == G92.3 Restore G92 Offsets
2445  (((G92.3 Restore G92 Offsets)))
2446  
2447  * 'G92.3' - set the G92 offset to the values saved in parameters 5211 to 5219
2448  
2449  You can set axis offsets in one program and use the same offsets in
2450  another program. Program 'G92' in the first program. This will set
2451  parameters 5211 to 5219. Do not use 'G92.1' in the remainder of the
2452  first program. The parameter values will be saved when the first
2453  program exits and restored when the second one starts up.
2454  Use 'G92.3' near the beginning of the second program. That will restore
2455  the offsets saved in the first program.
2456  
2457  [[gcode:g93-g94-g95]]
2458  == G93, G94, G95 Feed Rate Mode
2459  (((G93, G94, G95 Feed Rate Mode)))
2460  
2461  * 'G93' - is Inverse Time Mode. In inverse time feed rate mode, an F word
2462    means the move should be completed in [one divided by the F number]
2463    minutes. For example, if the F number is 2.0, the move should be
2464    completed in half a minute.
2465  +
2466  When the inverse time feed rate mode is active, an F word must appear
2467  on every line which has a G1, G2, or G3 motion, and an F word on a line
2468  that does not have G1, G2, or G3 is ignored. Being in inverse time feed
2469  rate mode does not affect G0 (<<gcode:g0,rapid move>>) motions.
2470  
2471  * 'G94' - is Units per Minute Mode.
2472  In units per minute feed mode, an F word is interpreted to mean
2473  the controlled point should move at a certain number of inches per
2474  minute, millimeters per minute, or degrees per minute, depending upon
2475  what length units are being used and which axis or axes are moving.
2476  
2477  * 'G95' - is Units per Revolution Mode
2478  In units per revolution mode, an F word is interpreted to mean the
2479  controlled point should move a certain number of inches per revolution
2480  of the spindle, depending on what length units are being used and which
2481  axis or axes are moving. G95 is not suitable for threading, for
2482  threading use G33 or G76.
2483  G95 requires that spindle.N.speed-in to be connected. The actual spindle
2484  to which the feed is synchronised is chosen by the $ parameter
2485  
2486  It is an error if:
2487  
2488  * Inverse time feed mode is active and a line with G1, G2, or G3
2489     (explicitly or implicitly) does not have an F word.
2490  * A new feed rate is not specified after switching to G94 or G95
2491  
2492  [[gcode:g96-g97]]
2493  == G96, G97 Spindle Control Mode
2494  (((G96, G97 Spindle Control Mode)))
2495  
2496  ----
2497  G96 <D-> S- <$-> (Constant Surface Speed Mode)
2498  G97 S- <$-> (RPM Mode)
2499  ----
2500  
2501  * 'D' - maximum spindle RPM
2502  * 'S' - surface speed
2503  * '$" - the spindle of which the speed will be varied. 
2504  
2505  * 'G96 D- S-' - selects constant surface speed of 'S' feet per minute
2506                  (if G20 is in effect) or meters per minute
2507                  (if G21 is in effect). D- is optional.
2508  +                
2509  When using G96, ensure that X0 in
2510  the current coordinate system (including offsets and tool lengths) is
2511  the center of rotation or LinuxCNC will not give the desired ssurface speed.
2512  G96 is not affected by radius or diameter mode.
2513  
2514  To achieve CSS mode on selected spindles programme successive G96 commands
2515  for each spindle prior to issuing M3.
2516  
2517  * 'G97' selects RPM mode.
2518  
2519  .G96 Example Line
2520  ----
2521  G96 D2500 S250 (set CSS with a max rpm of 2500 and a surface speed of 250)
2522  ----
2523  
2524  It is an error if:
2525  
2526  * S is not specified with G96
2527  * A feed move is specified in G96 mode while the spindle is not turning
2528  
2529  [[gcode:g98-g99]]
2530  == G98, G99 Canned Cycle Return Level
2531  (((G98, G99 Canned Cycle Return)))
2532  
2533  * 'G98' - retract to the position that axis was in just before this series
2534  of one or more contiguous canned cycles was started.
2535  
2536  * 'G99' - retract to the position specified by the R word of the canned cycle.
2537  
2538  Program a 'G98' and the canned cycle will use the Z position prior to
2539  the canned cycle as the Z return position if it is higher than the R
2540  value specified in the cycle. If it is lower, the R value will be
2541  used. The R word has different meanings in absolute distance mode and
2542  incremental distance mode.
2543  
2544  .G98 Retract to Origin
2545  ----
2546  G0 X1 Y2 Z3
2547  G90 G98 G81 X4 Y5 Z-0.6 R1.8 F10
2548  ----
2549  
2550  The G98 to the second line above means that the return move will be to
2551  the value of Z in the first line since it is higher that the R value
2552  specified.
2553  
2554  The 'initial' (G98) plane is reset any time cycle motion mode is
2555  abandoned, whether explicitly (G80) or implicitly (any motion code
2556  that is not a cycle). Switching among cycle modes (say G81
2557  to G83) does NOT reset the 'initial' plane. It is possible to switch
2558  between G98 and G99 during a series of cycles.
2559  
2560  // vim: set syntax=asciidoc: