Skip to content
g-code.rst 78.1 KiB
Newer Older
Fabrice Salvaire's avatar
Fabrice Salvaire committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
G Codes
=======

Conventions
-----------

Conventions used in this section

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

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

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

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

A real value may be:

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

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

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

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

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

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

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

G Code Quick Reference Table
----------------------------

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

G0 Rapid Move
-------------

::

   G0 axes

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

Rapid Velocity Rate
~~~~~~~~~~~~~~~~~~~

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

G0 Example

::

   G90 (set absolute distance mode)
   G0 X1 Y-2.3 (Rapid linear move from current location to X1 Y-2.3)
   M2 (end program)

* See `G90 <#gcode:g90-g91>`__ & `M2 <#mcode:m2-m30>`__ sections for more information.

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

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

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

It is an error if:

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

G1 Linear Move
--------------

::

   G1 axes

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

G1 Example

::

   G90 (set absolute distance mode)
   G1 X1.2 Y-3 F10 (linear move at a feed rate of 10 from current position to X1.2 Y-3)
   Z-2.3 (linear move at same feed rate from current position to Z-2.3)
   Z1 F25 (linear move at a feed rate of 25 from current position to Z1)
   M2 (end program)

* See `G90 <#gcode:g90-g91>`__ & `F <#sec:set-feed-rate>`__ &
   `M2 <#mcode:m2-m30>`__ sections for more information.

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

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

It is an error if:

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

G2, G3 Arc Move
---------------

::

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

A circular or helical arc is specified using either 'G2' (clockwise arc) or 'G3' (counterclockwise
arc) at the current `feed rate <#sec:set-feed-rate>`__. The direction (CW, CCW) is as viewed from
the positive end of the axis about which the circular motion occurs.

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

To program a helix, include the axis word perpendicular to the arc plane: for example, if in the
'G17' plane, include a 'Z' word. This will cause the 'Z' axis to move to the programmed value during
the circular 'XY' motion.

To program an arc that gives more than one full turn, use the 'P' word specifying the number of full
turns plus the programmed arc. The 'P' word must be an integer. If 'P' is unspecified, the behavior
is as if 'P1' was given: that is, only one full or partial turn will result. For example, if a 180
degree arc is programmed with a P2, the resulting motion will be 1 1/2 rotations. For each P
increment above 1 an extra full circle is added to the programmed arc. Multi turn helical arcs are
supported and give motion useful for milling holes or threads.

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

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

The arc center is absolute or relative as set by `G90.1 or G91.1 <#gcode:g90.1-g91.1>`__
respectively.

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

It is an error if:

* No feed rate has been set.
* The P word is not an integer.

Center Format Arcs
~~~~~~~~~~~~~~~~~~

Center format arcs are more accurate than radius format arcs and are the preferred format to use.

The end point of the arc along with the offset to the center of the arc from the current location
are used to program arcs that are less than a full circle. It is OK if the end point of the arc is
the same as the current location.

The offset to the center of the arc from the current location and optionally the number of turns are
used to program full circles.

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

Incremental Arc Distance Mode

Arc center offsets are a relative distance from the start location of the arc. Incremental Arc
Distance Mode is default.

One or more axis words and one or more offsets must be programmed for an arc that is less than 360
degrees.

No axis words and one or more offsets must be programmed for full circles. The 'P' word defaults to
1 and is optional.

For more information on 'Incremental Arc Distance Mode see the `G91.1 <#gcode:g90.1-g91.1>`__
section.

Absolute Arc Distance Mode

Arc center offsets are the absolute distance from the current 0 position of the axis.

One or more axis words and 'both' offsets must be programmed for arcs
less than 360 degrees.

No axis words and both offsets must be programmed for full circles. The 'P' word defaults to 1 and
is optional.

For more information on 'Absolute Arc Distance Mode see the `G90.1 <#gcode:g90.1-g91.1>`__ section.

XY-plane (G17)

::

   G2 or G3 <X- Y- Z- I- J- P->

* 'Z' - helix
* 'I' - X offset
* 'J' - Y offset
* 'P' - number of turns

XZ-plane (G18)

::

   G2 or G3 <X- Z- Y- I- K- P->

* 'Y' - helix
* 'I' - X offset
* 'K' - Z offset
* 'P' - number of turns

YZ-plane (G19)

::

   G2 or G3 <Y- Z- X- J- K- P->

* 'X' - helix
* 'J' - Y offset
* 'K' - Z offset
* 'P' - number of turns

It is an error if:

* No feed rate is set with the `F <#sec:set-feed-rate>`__ word.
* No offsets are programmed.
* When the arc is projected on the selected plane, the distance from the current point to the center
  differs from the distance from the end point to the center by more than (.05 inch/.5 mm) OR
  ((.0005 inch/.005mm) AND .1% of radius).

Deciphering the Error message 'Radius to end of arc differs from radius to start:'

* 'start' - the current position
* 'center' - the center position as calculated using the i, j, or k words
* 'end' - the programmed end point
* 'r1' - radius from the start position to the center
* 'r2' - radius from the end position to the center

Center Format Examples
~~~~~~~~~~~~~~~~~~~~~~

Calculating arcs by hand can be difficult at times. One option is to draw the arc with a cad program
to get the coordinates and offsets. Keep in mind the tolerance mentioned above, you may have to
change the precision of your cad program to get the desired results. Another option is to calculate
the coordinates and offset using formulas. As you can see in the following figures a triangle can be
formed from the current position the end position and the arc center.

In the following figure you can see the start position is X0 Y0, the end position is X1 Y1. The arc
center position is at X1 Y0. This gives us an offset from the start position of 1 in the X axis and
0 in the Y axis.  In this case only an I offset is needed.

G2 Example Line

.. code:: highlight

   G0 X0 Y0
   G2 X1 Y1 I1 F10 (clockwise arc in the XY plane)

|G2 Example|

Figure 1. G2 Example

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

G2-G3 Example Line

.. code:: highlight

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

|G2-G3 Example|

Figure 2. G2-G3 Example

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

G2 Example Helix

.. code:: highlight

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

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

P word Example

::

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

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

Radius Format Arcs
~~~~~~~~~~~~~~~~~~

::

   G2 or G3 axes R- <P->

* 'R' - radius from current position

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

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

It is an error if:

* both of the axis words for the axes of the selected plane are omitted
* the end point of the arc is the same as the current point.

G2 Example Line

.. code:: highlight

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

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

G4 Dwell
--------

::

   G4 P-

* 'P' - seconds to dwell (floating point)

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

G4 Example Line

::

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

It is an error if:

* the P number is negative or not specified.

G5 Cubic Spline
---------------

::

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

* 'I' - X incremental offset from start point to first control point
* 'J' - Y incremental offset from start point to first control point
* 'P' - X incremental offset from end point to second control point
* 'Q' - Y incremental offset from end point to second control point

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

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

For example, to program a curvy N shape:

G5 Sample initial cubic spline

::

   G90 G17
   G0 X0 Y0
   G5 I0 J3 P0 Q-3 X1 Y1

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

G5 Sample subsequent cubic spline

::

   G5 P0 Q-3 X2 Y2

It is an error if:

* P and Q are not both specified
* Just one of I or J are specified
* I or J are unspecified in the first of a series of G5 commands
* An axis other than X or Y is specified
* The active plane is not G17

.. _g51-quadratic-spline:

G5.1 Quadratic Spline
---------------------

::

   G5.1 X- Y- I- J-

* 'I' - X incremental offset from start point to control point
* 'J' - Y incremental offset from start point to control point

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

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

G5.1 Sample quadratic spline

::

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

It is an error if:

* both I and J offset are unspecified or zero
* An axis other than X or Y is specified
* The active plane is not G17

.. _g52-g53-nurbs-block:

G5.2 G5.3 NURBS Block
---------------------

::

   G5.2 <P-> <X- Y-> <L->
   X- Y- <P->
   ...
   G5.3

Warning: G5.2, G5.3 is experimental and not fully tested.

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

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

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

G5.2 Example

.. code:: highlight

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

Sample NURBS Output

|Sample NURBS Output|

More information on NURBS can be found here:

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

G7 Lathe Diameter Mode
----------------------

::

   G7

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

G8 Lathe Radius Mode
--------------------

::

   G8

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

G10 L1 Set Tool Table
---------------------

::

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

* 'P' - tool number
* 'R' - radius of tool
* 'I' - front angle (lathe)
* 'J' - back angle (lathe)
* 'Q' - orientation (lathe)

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

A valid G10 L1 rewrites and reloads the tool table.

G10 L1 Example Line

::

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

It is an error if:

* Cutter Compensation is on
* The P number is unspecified
* The P number is not a valid tool number from the tool table
* The P number is 0

For more information on cutter orientation used by the 'Q' word, see the `Lathe Tool Orientation
<#lathe-tool-orientation>`__ diagram.

G10 L2 Set Coordinate System
----------------------------

::

   G10 L2 P- <axes R->

* 'P' - coordinate system (0-9)
* 'R' - rotation about the Z axis

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

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

======= ================= ======
P Value Coordinate System G code
======= ================= ======
0       Active            n/a
1       1                 G54
2       2                 G55
3       3                 G56
4       4                 G57
5       5                 G58
6       6                 G59
7       7                 G59.1
8       8                 G59.2
9       9                 G59.3
======= ================= ======

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

All axis words are optional.

Being in incremental distance mode (`'G91' <#gcode:g90-g91>`__) has no effect on 'G10 L2'.

Important Concepts:

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

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

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

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

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

It is an error if:

* The P number does not evaluate to an integer in the range 0 to 9.
* An axis is programmed that is not defined in the configuration.

G10 L2 Example Line

.. code:: highlight

   G10 L2 P1 X3.5 Y17.2

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

G10 L2 Example Line

.. code:: highlight

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

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

The coordinate system is described in the `Coordinate System <#cha:coordinate-system>`__ Section.

G10 L10 Set Tool Table
----------------------

::

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

* 'P' - tool number
* 'R' - radius of tool
* 'I' - front angle (lathe)
* 'J' - back angle (lathe)
* 'Q' - orientation (lathe)

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

G10 L10 Example

::

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

* See `T <#sec:select-tool>`__ & `M6 <#mcode:m6>`__, and `G43 <#gcode:g43>`__/`G43.1
   <#gcode:g43.1>`__ sections for more information.

It is an error if:

* Cutter Compensation is on
* The P number is unspecified
* The P number is not a valid tool number from the tool table
* The P number is 0

G10 L11 Set Tool Table
----------------------

::

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

* 'P' - tool number
* 'R' - radius of tool
* 'I' - front angle (lathe)
* 'J' - back angle (lathe)
* 'Q' - orientation (lathe)

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

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

It is an error if:

* Cutter Compensation is on
* The P number is unspecified
* The P number is not a valid tool number from the tool table
* The P number is 0

G10 L20 Set Coordinate System
-----------------------------

::

   G10 L20 P- axes

* 'P' - coordinate system (0-9)

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

G10 L20 Example Line

::

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

It is an error if:

* The P number does not evaluate to an integer in the range 0 to 9.
* An axis is programmed that is not defined in the configuration.

.. _g17---g191-plane-select:

G17 - G19.1 Plane Select
------------------------

These codes set the current plane as follows:

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

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

It is a good idea to include a plane selection in the preamble of each G code file.

The effects of having a plane selected are discussed in Section `G2 G3 Arcs <#gcode:g2-g3>`__ and
Section `G81 G89 <#gcode:g80-g89>`__

G20, G21 Units
--------------

* 'G20' - to use inches for length units.
* 'G21' - to use millimeters for length units.

It is a good idea to include units in the preamble of each G code file.

.. _g28-g281-goset-predefined-position:

G28, G28.1 Go/Set Predefined Position
-------------------------------------

G28 uses the values stored in `parameters <#sub:numbered-parameters>`__ 5161-5169 as the X Y Z A B C
U V W final point to move to. The parameter values are 'absolute' machine coordinates in the native
machine 'units' as specified in the ini file. All axes defined in the ini file will be moved when a
G28 is issued. If no positions are stored with G28.1 then all axes will go to the `machine origin
<#sec.machine-corrdinate-system>`__.

* 'G28' - makes a `rapid move <#gcode:g0>`__ from the current position to the 'absolute' position of
  the values in parameters 5161-5166.

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

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

G28 Example Line

::

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

It is an error if :

* Cutter Compensation is turned on

.. _g30-g301-goset-predefined-position:

G30, G30.1 Go/Set Predefined Position
-------------------------------------

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

* 'G30' - makes a `rapid move <#gcode:g0>`__ from the current position to the 'absolute' position of
  the values in parameters 5181-5186.

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

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

G30 Example Line

::

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

It is an error if :

* Cutter Compensation is turned on

G33 Spindle Synchronized Motion
-------------------------------

::

   G33 X- Y- Z- K- $-

* 'K' - distance per revolution

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

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

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

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

Technical Info

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

HAL Connections

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

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

G33 Example

::

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

* See `G90 <#gcode:g90-g91>`__ & `G0 <#gcode:g0>`__ & `M2 <#mcode:m2-m30>`__ sections for more
   information.

It is an error if:

* All axis words are omitted.
* The spindle is not turning when this command is executed
* The requested linear motion exceeds machine velocity limits due to the spindle speed

.. _g331-rigid-tapping:

G33.1 Rigid Tapping
-------------------

::

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

* 'K' - distance per revolution
* 'I' - optional spindle speed multiplier for faster return move
* '$' - optional spindle selector

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

A rigid tapping move consists of the following sequence:

#. A move from the current coordinate to the specified coordinate, synchronized with the selected
   spindle at the given ratio and starting from the current coordinate with a spindle index pulse.
#. When reaching the endpoint, a command to reverse the spindle, and speed up by a factor set by the
   multiplier (e.g., from clockwise to counterclockwise).
#. Continued synchronized motion beyond the specified end coordinate until the spindle actually
   stops and reverses.
#. Continued synchronized motion back to the original coordinate.
#. When reaching the original coordinate, a command to reverse the spindle a second time (e.g., from
   counterclockwise to clockwise).
#. Continued synchronized motion beyond the original coordinate until the spindle actually stops and
   reverses.
#. An **unsynchronized** move back to the original coordinate.

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

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

G33.1 Example

.. code:: highlight

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

* See `G90 <#gcode:g90-g91>`__ & `G0 <#gcode:g0>`__ &
   `M2 <#mcode:m2-m30>`__ sections for more information.

It is an error if:

* All axis words are omitted.