summaryrefslogtreecommitdiff
path: root/docs/src/gcode/gcode_es.txt
blob: 010971def5f962868de6e5b1ea96c936a64402a1 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
= G Codes

[[cha:g-codes]] (((G Codes)))

////
ATTENTION TRANSLATORS before translating this document copy the base document
into this copy to get the latest version. Untranslated documents are not kept
up to date with the English documents. 

Do not translate anchors or links, translate only the text of a link after the
comma.
Anchor [[anchor-name]]
Link <<anchor-name,text after the comma can be translated>>

Make sure the documents build after translating.
////

== 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.

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

(((G Code Table)))

[width="75%", options="header", cols="2^,5<"]
|====================================================================
|Code                               |Description
|<<sec:G0,G0>>                      |Coordinated Straight Motion Rapid
|<<sec:G1-Linear-Motion,G1>>        |Coordinated Straight Motion Feed Rate
|<<sec:G2-G3-Arc,G2, G3>>           |Coordinated Helical Motion Feed Rate
|<<sec:G4-Dwell,G4>>                |Dwell
|<<sec:G5.1-B-spline,G5.1>>         |Quadratic B-Spline
|<<sec:G5.2-G5.3-NURBs,G5.2, G5.3>> |NURBs Block
|<<sec:G7-Diameter-Mode,G7>>        |Diameter Mode (lathe)
|<<sec:G8-Radius-Mode,G8>>          |Radius Mode (lathe)
|<<sec:G10-L1_,G10 L1>>             |Set Tool Table Entry
|<<sec:G10-L10,G10 L10>>            |Set Tool Table, Calculated, Workpiece
|<<sec:G10-L11,G10 L11>>            |Set Tool Table, Calculated, Fixture
|<<sec:G10-L2_,G10 L2>>             |Coordinate System Origin Setting
|<<sec:G10-L20,G10 L20>>            |Coordinate System Origin Setting Calculated
|<<sec:G17-G18-G19,G17 - G19.1>>    |Plane Select
|<<sec:G20-G21-Units,G20, G21>>     |Units of Measure
|<<sec:G28-G28.1,G28 - G28.1>>      |Go to Predefined Position
|<<sec:G30-G30.1,G30 - G30.1>>      |Go to Predefined Position
|<<sec:G33-Spindle-Sync,G33>>       |Spindle Synchronized Motion
|<<sec:G33.1-Rigid-Tapping,G33.1>>  |Rigid Tapping
|<<sec:G38-probe,G38.2 - G38.5>>        |Probing
|<<sec:G40,G40>>                    |Cancel Cutter Compensation
|<<sec:G41-G42,G41, G42>>           |Cutter Compensation
|<<sec:G41.1-G42.1,G41.1, G42.1>>   |Cutter Compensation Transient
|<<sec:G43-G43.1,G43, G43.1>>  |Use Tool Length Offset from Tool Table
|<<sec:G49-Tool,G49>>               |Cancel Tool Length Offset
|<<sec:G53-Move-in,G53>>            |Motion in Machine Coordinate System
|<<sec:G54-G59.3,G54-G59>>          |Select Coordinate System (1 - 6)
|<<sec:G54-G59.3,G59.1-G59.3>>      |Select Coordinate System (7 - 9)
|<<sec:G61-G61.1-G64,G61, G61.1>>   |Path Control Mode
|<<sec:G61-G61.1-G64,G64>>          |Path Control Mode with Optional Tolerance
|<<sec:G73-Drilling-Cycle,G73>>     |Drilling Cycle with Chip Breaking
|<<sec:G76-Threading-Canned,G76>>   |Multi-pass Threading Cycle (Lathe)
|<<sec:G80-Cancel-Modal,G80>>       |Cancel Motion Modes
|<<sec:G81-Drilling-Cycle,G81>>     |Drilling Cycle
|<<sec:G82-Drilling-Dwell,G82>>     |Drilling Cycle with Dwell
|<<sec:G83-Drilling-Peck,G83>>      |Drilling Cycle with Peck
|<<sec:G84-Right-Hand-Tapping,G84>> |Right Hand Tapping Cycle *(unimplemented)*
|<<sec:G85-Boring-Feed-Out,G85>>    |Boring Cycle, No Dwell, Feed Out
|<<sec:G86-Boring-Rapid-Out,G86>>   |Boring Cycle, Stop, Rapid Out
|<<sec:G87-Back-Boring,G87>>        |Back-Boring Cycle *(unimplemented)*
|<<sec:G88-Boring-Manual-Out,G88>>  |Boring Cycle, Stop, Manual Out *(unimplemented)*
|<<sec:G89-Boring-Dwell,G89>>       |Boring Cycle, Dwell, Feed Out
|<<sec:G90-G91,G90, G91>>           |Distance Mode
|<<sec:G90.1-G91.1,G90.1, G91.1>>   |Arc Distance Mode
|<<sec:G92-G92.1-G92.2-G92.3,G92>>  |Offset Coordinate Systems & Set Parameters
|<<sec:G92-G92.1-G92.2-G92.3,G92.1 G92.2>>|Cancel Offsets
|<<sec:G92-G92.1-G92.2-G92.3,G92.3>>|Apply Parameters to Offset Coordinate Systems
|<<sec:G93-G94-G95-Mode,G93, G94, G95>> |Feed Modes
|<<sec:G96-G97-Spindle,G96>>        |Constant Surface Speed
|<<sec:G96-G97-Spindle,G97>>        |RPM Mode
|<<sec:G98-G99-Set,G98, G99>>       |Canned Cycle Z Retract Mode 
|====================================================================

== G0 Rapid Motion[[sec:G0]]
(((G0 Rapid)))(((Rapid Motion)))

----
G0 axes
----

For rapid linear (straight line) 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 linear motion to
the destination point at the current maximum traverse rate (or slower if
the machine will not go that fast). It is expected that cutting 
will not take place when a 'G0' command is executing.

.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 <<sec:G90-G91,G90>> & <<sec:M2-M30,M2>> sections for more information.

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

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

It is an error if:

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

== G1 Linear Feed[[sec:G1-Linear-Motion]]
(((G1 Linear Motion)))(((Linear Motion)))

----
G1 axes
----

For linear (straight line) motion at programed 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 linear motion to the destination point
at the current feed rate (or slower if the machine will not go that
fast).

.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 <<sec:G90-G91,G90>> & <<sec:F-feed-rate,F>> & <<sec:M2-M30,M2>> sections for more information.

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

If 'G53' is programmed on the same line, the motion will also differ;
see the <<sec:G53-Move-in,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 Feed[[sec:G2-G3-Arc]]
(((G2, G3 Arc)))(((Arc Motion)))

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

A circular or helical arc is specified using either 'G2' (clockwise
arc) or 'G3' (counterclockwise arc). 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 a 'P' word
specifying the number of full or partial turns of arc. If 'P' is
unspecified, the behavior is as if 'P1' was given: that is, only one
full or partial turn will result, giving an arc less than or equal to
one full circle. For example, if an arc is programmed with P2, the
resulting motion will be more than one full circle and up to two full
circles (depending on the programmed endpoint.) 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 radius compensation is active, the motion will differ from
the above; see the <<sec:cutter-radius-compensation,Radius Compensation>> Section.

The arc offset is relative or absolute as set by <<sec:G90.1-G91.1,G90.1 & G91.1>>.

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

It is an error if:

* No feed rate has been set.

=== 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
<<sec:G90.1-G91.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
<<sec:G90.1-G91.1,G90.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 <<sec:F-feed-rate,F>> 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
----
G2 X1 Y1 I1 F10 (clockwise arc in the XY plane)
----

.G2 Example[[fig:G2-Example]]

image::images/g2.png[align="center"]

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
----
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[[fig:G2/3-Example]]

image::images/g2-3.png[align="center"]

.G2 Example Line
----
G17 G2 X10 Y16 I3 J4 Z9 (helix arc with Z added)
----

The above example line will make 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=16, and Z=9, with its center offset in the X direction by
3 units from the current X location and offset in the Y direction by 4
units from the current Y location. If the current location has X=7, Y=7
at the outset, the center will be at X=10, Y=11. If the starting value
of Z is 9, this is a circular arc; otherwise it is a helical arc. The
radius of this arc would be 5.

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-
----
* 'R' - radius from current position

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

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

It is an error if:

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

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

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

== G4 Dwell[[sec:G4-Dwell]]
(((G4 Dwell)))

----
G4 P-
----
* 'P' - seconds to dwell

The P number is the time in seconds that all axes will remain unmoving.
This does not affect spindle, coolant and other I/O.

.G4 Example Line
----
G4 P1.5 (wait for 1.5 seconds before proceeding)
----

It is an error if:

* the P number is negative.

== G5.1 Quadratic B-spline[[sec:G5.1-B-spline]]
(((G5.1 Quadratic B-spline)))

----
G5.1 X- Y- I- J-
----
* 'I' - X axis offset
* 'J' - Y axis offset

G5.1 creates a quadratic B-spline in the XY plane with the X and Y axis only.
The offsets are I for X axis and J for Y axis.

// FIX ME add example code

It is an error if:

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

== G5.2 G5.3 NURBs Block[[sec:G5.2-G5.3-NURBs]]
(((G5.2 G5.3 NURBs Block)))

----
G5.2 X- Y- P- <L->
X- Y- P- <L->
...
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
their parameter (L) which determines the order of the curve (k) and
subsequently its degree (k-1).

Using this curve definition the knots of the NURBs curve are not
defined by the user they are calculated by the inside algorithm, in the
same way as it happens in a great number of graphic applications, where
the curve shape can be modified only acting on either control points or
weights.

.G5.2 Example
----
G0 X0 Y0 (rapid move)
F10 (set feed rate)
G5.2 X0 Y1 P1 L3
     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

image:images/nurbs01.png[align="center"]

More information on NURBs can be found here:

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

== G7 Lathe Diameter Mode[[sec:G7-Diameter-Mode]]
(((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[[sec:G8-Radius-Mode]]
(((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[[sec:G10-L1_]]
(((G10 L1 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

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[[sec:G10-L2_]]
(((G10 L2 Coordinate System)))

----
G10 L2 P- <axes R->
----
* 'P' - coordinate system (0-9)
* 'R' - rotation about the Z axis

G10 L2 sets the origin of a coordinate system.

To specify a coordinate system program P1 to P9 corresponding to 'G54' to 'G59.3'.
For the currently active coordinate system program P0.

Optionally program R to indicate the rotation of the XY axis around the Z axis.
All axis words are optional.

The origin of the coordinate system specified by the P number is
set to the given values (in terms of the not offset machine coordinate system).
Only those coordinates for which an axis word is included on the line will be set.

Being in incremental distance mode (<<sec:G90-G91,'G91'>>) has no effect on 'G10 L2'.
The direction of rotation is CCW as viewed from the Top View.

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 'G92' origin offset was in effect before 'G10 L2',
  it will continue to be in effect afterwards.
* The coordinate system whose origin is set by a 'G10' command may be
  active or inactive at the time the 'G10' is executed.
  If it is currently active, the new coordinates take effect immediately.

It is an error if:

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

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

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

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

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

.Coordinate System[[cap:Set-Coordinate-System]]

[width="50%", options="header", cols="^,^,^"]
|========================================
|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
|========================================

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

== G10 L10 Set Tool Table[[sec:G10-L10]]
(((G10 L10 Set Tool Table)))

----
G10 L10 P- axes <R- I- J- Q->
----
* 'P' - tool number
* 'R' - rotation about the Z axis
* '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 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 <<sec:G38-probe,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 <<sec:T-Select-Tool,T>> & <<sec:M6-Tool-Change,M6>> & <<sec:G43-G43.1,G43>>
  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

== G10 L11 Set Tool Table[[sec:G10-L11]]
(((G10 L11 Set Tool Table)))

----
G10 L11 P- axes <R- I- J- Q->
----
* 'P' - coordinate system (0-9)
* 'R' - rotation about the Z axis
* '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 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.

// .G10 L11 Example FIX ME!
// ----
// G10 L11 P1
// ----

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

== G10 L20 Set Coordinate System[[sec:G10-L20]]
(((G10 L20 Set Coordinate System)))

----
G10 L20 P- axes <R->
----
* 'P' - coordinate system (0-9)
* 'R' - rotation about the Z axis

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 - G19.1 Plane Selection[[sec:G17-G18-G19]]
(((G17 G18 G19 Plane Selection)))(((Plane Selection)))

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
<<sec:G2-G3-Arc,G2 G3>> and Section <<sec:G80-G89,G81 G89>>

== G20, G21 Units[[sec:G20-G21-Units]](((G20 Inches)))(((G21 Millimeters)))

* '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, G28.1 Go to Predefined Position[[sec:G28-G28.1]]
(((G28)))

* 'G28' - makes a rapid traverse move from the current position to the
          absolute position of the values in <<sub:numbered-parameters,parameters>>
          5161-5166. The parameter values are in terms of the 'absolute' coordinate
          system and the machine's native coordinate system.

* 'G28 axes' - will make a rapid traverse move to the position specified by
              'axes', then will make a rapid traverse move to the 'absolute'
              position of the values in <<sub:numbered-parameters,parameters>>
              5161-5166.

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

.G30 Example Line
----
G28 Z2.5 (rapid to Z2.5 then to location specified in the G28 stored parameters)
----

It is an error if :

* Radius compensation is turned on

== G30, G30.1 Go to Predefined Position[[sec:G30-G30.1]]
(((G30)))

* 'G30' - makes a rapid traverse move from the current position to the
          absolute position of the values in <<sub:numbered-parameters,parameters>>
          5181-5186. The parameter values are in terms of the 'absolute' coordinate
          system and the machine's native coordinate system.

* 'G30 axes' - will make a rapid traverse move to the position specified by
              'axes', then will make a rapid traverse move to the 'absolute'
              position of the values in <<sub:numbered-parameters,parameters>>
              5181-5186.

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

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

.G30 Example Line
----
G30 Z2.5 (rapid to Z2.5 then to the location specified in the G30 stored parameters)
----

It is an error if :

* Radius compensation is turned on

== G33 Spindle Synchronized Motion[[sec:G33-Spindle-Sync]]
(((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.

[NOTE]
K follows the drive line described by 'X- Y- Z-' and is not parallel to the Z axis.

Spindle-synchronized motions wait for spindle index, 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.

.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 <<sec:G90-G91,G90>> & <<sec:G0,G0>> & <<sec:M2-M30,M2>> sections for more information.

It is an error if:

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

== G33.1 Rigid Tapping[[sec:G33.1-Rigid-Tapping]]
(((G33.1 Rigid Tapping)))

----
G33.1 X- Y- Z- K-
----
* 'K' - distance per revolution

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:

[WARNING]
If the X Y coordinates specified are not the current coordinates when
calling G33.1 for tapping the move will not be along the Z axis
but will traverse from the current location to the X Y specified.

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

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

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

.G33.1 Example
----
G90 (set absolute mode)
G0 X1.000 Y1.000 Z0.100 (rapid move to starting position)
G33.1 Z-0.750 K0.05 (rigid tap a 20 TPI thread 0.750 deep)
M2 (end program)
----
* See <<sec:G90-G91,G90>> & <<sec:G0,G0>> & <<sec:M2-M30,M2>> sections for more information.

It is an error if:

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

== G38.x Straight Probe[[sec:G38-probe]](((G38.x Probe)))

----
G38.x axes
----

* 'G38.2' - probe toward workpiece, stop on contact, signal error if failure
* 'G38.3' - probe toward workpiece, stop on contact
* 'G38.4' - probe away from workpiece, stop on loss of contact, signal error if failure
* 'G38.5' - probe away from workpiece, stop on loss of contact

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

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

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

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

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

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

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

It is an error if:

* the current point is the same as the programmed point.
* no axis word is used
* cutter radius compensation is enabled
* the feed rate is zero
* the probe is already in the target state

== G40 Compensation Off[[sec:G40]]
(((G40 Radius Compensation Off)))

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

.G40 Example
----
; current location is X1 after finishing cutter compensated move
G40 (turn compensation off)
G0 X1.6 (linear move longer than current cutter diameter)
M2 (end program)
----
See <<sec:G0,G0>> & <<sec:M2-M30,M2>> sections for more information.

It is an error if:

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

== G41, G42 Tool Radius Compensation[[sec:G41-G42]]
(((G41 G42 Radius Compensation)))

----
G41 <D-> (left of programmed path)
G42 <D-> (right of programmed path)
----
* 'D' - tool number

The D word is optional; if there is no D word or if the D word is 0,
the radius of the currently loaded tool will be used.

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

To start tool radius compensation to the left of the part profile, use G41.
G41 starts cutter radius compensation to the left of the programmed line
as viewed from the positive end of the axis perpendicular to the plane.

To start tool radius compensation to the right of the part profile, use G42.
G42 starts cutter radius compensation to the right of the programmed line
as viewed from the positive end of the axis perpendicular to the plane.

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

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

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

The behavior of the machining center when cutter radius compensation
is on is described in the <<sec:cutter-radius-compensation,Radius Compensation>>
Section along with code examples.

It is an error if:

* The D number is not a valid tool number or 0.
* The YZ plane is active.
* Cutter radius compensation is commanded to turn on when it is already on.

== G41.1, G42.1 Dynamic Cutter Radius Compensation[[sec:G41.1-G42.1]]
(((G41.1 G42.1 Dynamic Radius Compensation)))

----
G41.1 D- <L-> (left of programmed path)
G42.1 D- <L-> (right of programmed path)
----
* 'D' - cutter diameter
* 'L' - tool orientation (see <<lathe-tool-orientation,lathe tool orientation>>)

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

It is an error if:

* The YZ plane is active.
* The L number is not in the range from 0 to 9 inclusive.
* The L number is used when the XZ plane is not active.
* Cutter compensation is commanded to turn on when it is already on.

== G43 Tool Length Offset[[sec:G43-G43.1]]
(((G43 Tool Length Offset)))

----
G43 <H->
----
* 'H' - tool number

* 'G43' - use the currently loaded tool from the last Tn M6.
          G43 changes subsequent motions by offsetting the Z and/or X
          coordinates by the length of the tool. G43 does not cause any
          motion. The next time a compensated axis is moved, that axis's
          endpoint is the compensated location.

* 'G43 H-' - use an offset from tool table.
             It is OK for the H number to be zero; the currently loaded tool will be used.

.G43 H- Example Line
----
G43 H1 (set tool offsets using the values from tool 1 in the tool table)
----

It is an error if:

* the H number is not an integer, is negative, or is not 0 or a valid tool
    number.

== G43.1: Dynamic Tool Length Offset[[sec:G43.1-dynamic-tool-length-offset]]
(((G43.1 Dynamic Tool Length Offset)))

----
G43.1 axes
----

* 'G43.1 axes' - change subsequent motions by offsetting the Z and/or X
                 offsets stored in the tool table. G43.1 does not cause any
                 motion. The next time a compensated axis is moved, that axis's
                 endpoint is the compensated location.

.G43.1 Example
----
G90 (set absolute mode)
T1 M6 G43 (load tool 1 and tool length offsets, Z is at machine 0 and DRO shows Z1.500)
G43.1 Z0.250 (offset current tool offset by 0.250, DRO now shows Z1.250)
M2 (end program)
----
* See <<sec:G90-G91,G90>> & <<sec:T-Select-Tool,T>> & <<sec:M6-Tool-Change,M6>> sections for more information.

It is an error if:

* motion is commanded on the same line as 'G43.1'

== G49: Cancel Tool Length Compensation[[sec:G49-Tool]]
(((G49 Cancel Tool Length Offset)))

* 'G49' - cancels tool length compensation

It is OK to program using the same offset already in use. It is also
OK to program using no tool length offset if none is currently being
used.

== G53 Move in Absolute Coordinates[[sec:G53-Move-in]]
(((G53 Absolute Coordinates)))

----
G53 axes
----

To move in 'absolute coordinates' from the machine origin, program 'G53'
on the same line as a linear move. 'G53' is not modal and must be
programmed on each line. 'G0' or 'G1' does not have to be programmed
on the same line if one is currently active. 
For example 'G53 G0 X0 Y0 Z0' will move the axes to the home
position even if the currently
selected coordinate system has offsets in effect.

.G53 Example Line
----
G53 G0 X0 Y0 Z0 (rapid linear move to the machine origin)
G53 X2 (rapid linear move to absolute coordinate X2)
----
* See <<sec:G0,G0>> section for more information.

It is an error if:

* G53 is used without G0 or G1 being active, 
* or G53 is used while cutter radius compensation is on.

== G54-G59.3 Select Coordinate System[[sec:G54-G59.3]]
(((G54-G59.3 Select Coordinate System)))

* 'G54' - select coordinate system 1
* 'G55' - select coordinate system 2
* 'G56' - select coordinate system 3
* 'G57' - select coordinate system 4
* 'G58' - select coordinate system 5
* 'G59' - select coordinate system 6
* 'G59.1' - select coordinate system 7
* 'G59.2' - select coordinate system 8
* 'G59.3' - select coordinate system 9

The coordinate systems store the axis values
in the parameters shown in the following table.

.Coordinate System Parameters[[cap:Coordinate-Systems]]

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

It is an error if:

* selecting a coordinate system is used while cutter radius compensation is on.

See the <<cha:coordinate-system,Coordinate System>> Section for an overview of coordinate
systems.

== G61, G61.1 Exact Path Mode[[sec:G61-G61.1-G64]]
(((G61 G61.1 G64 Path Control)))(((Path Control)))(((Trajectory Control)))

* 'G61' - exact path mode. G61 visits the programmed point exactly,
          even though that means temporarily coming to a complete stop.

* 'G61.1' - exact stop mode. Same as G61

== G64 Path Blending[[sec:G64-path-blending]]
(((G64 Path Blending)))

----
G64 <P- <Q->>
----
* 'P' - motion blending tolerance
* 'Q' - naive cam tolerance 

* 'G64' - best possible speed.
* 'G64 P- <Q- >' blending with tolerance.

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

* 'G64 P- Q-' - is a way to fine tune your system for best compromise
between speed and accuracy. The P- tolerance means that the actual path
will be no more than P- away from the programmed endpoint. The velocity
will be reduced if needed to maintain the path. In addition, when you
activate G64 P- Q- it turns on the 'naive cam detector'; when there are
a series of linear XYZ feed moves at the same feed rate that are less
than Q- away from being collinear, they are collapsed into a single
linear move. On G2/G3 moves in the G17 (XY) plane when the maximum
deviation of an arc from a straight line is less than the G64 P-
tolerance the arc is broken into two lines (from start of arc to
midpoint, and from midpoint to end). those lines are then subject to
the naive cam algorithm for lines. Thus, line-arc, arc-arc, and
arc-line cases as well as line-line benefit from the 'naive cam
detector'. This improves contouring performance by simplifying the
path. It is OK to program for the mode that is already active. See also
the <<sec:Path-Control-Mode,Path Control Mode>> Section and 
<<sec:trajectory-control,Trajectory Control>> Section for more
information on these modes. 
If Q is not specified then it will have the same behavior as before and
use the value of P-.

.G64 P- Example Line
----
G64 P0.015 (set path following to be within 0.015 of the actual path)
----

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

== G90, G91 Distance Mode[[sec:G90-G91]]
(((G90, G91 Distance Mode)))

* 'G90' - absolute distance mode In absolute 
          distance mode, axis numbers (X, Y, Z, A, B, C, U, V, W)
          usually represent positions in terms of the currently active
          coordinate system. Any exceptions to that rule are described
          explicitly in the <<sec:G80-G89,G80 G89>> Section.

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

.G90 Example
----
G90 (set absolute distance mode)
G0 X2.5 (rapid linear move to coordinate X2.5 including any offsets in effect)
----

.G91 Example
----
G91 (set incremental distance mode)
G0 X2.5 (rapid linear move 2.5 from current position along the X axis)
----

* See <<sec:G0,G0>> section for more information.

== G90.1, G91.1 Arc Distance Mode[[sec:G90.1-G91.1]]
(((Arc Distance Mode)))

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

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

== G92 Coordinate System Offset[[sec:G92-G92.1-G92.2-G92.3]]
(((G92 Coordinate System Offset)))

----
G92 axes
----

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

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

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

Being in incremental distance mode has no effect on the action of 'G92'.

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

It is an error if:

* all axis words are omitted.

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

See the <<cha:coordinate-system,Coordinate System>> Section for an
overview of coordinate systems.

See the <<sec:G92-Offsets,Offsets>> Section for more information.

See the <<sec:parameters,Parameters>> Section for more information.

== G92.1, G92.2 Reset Coordinate System Offsets[[sec:G92.1-G92.2]]

* 'G92.1' - reset axis offsets to zero and set <<sub:numbered-parameters,parameters>>
            5211 - 5219 to zero.
* 'G92.2' - reset axis offsets to zero.

== G92.3 Restore Axis Offsets[[sec:G92.3]]

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

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

== G93, G94, G95: Feed Rate Mode[[sec:G93-G94-G95-Mode]]
(((G93, G94, G95: Feed Rate Mode)))

* 'G93' - is Inverse Time Mode. In inverse time feed rate mode, an F word
          means the move should be completed in [one divided by the F number]
          minutes. For example, if the F number is 2.0, the move should be
          completed in half a minute.
+
When the inverse time feed rate mode is active, an F word must appear
on every line which has a G1, G2, or G3 motion, and an F word on a line
that does not have G1, G2, or G3 is ignored. Being in inverse time feed
rate mode does not affect G0 (rapid traverse) motions.

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

* 'G95' - is Units per Revolution Mode
In units per revolution mode, an F word is interpreted to mean the
controlled point should move a certain number of inches per revolution
of the spindle, depending on what length units are being used and which
axis or axes are moving. G95 is not suitable for threading, for
threading use G33 or G76.

It is an error if:

* Inverse time feed rate mode is active and a line with G1, G2, or G3
   (explicitly or implicitly) does not have an F word.
* A new feed rate is not specified after switching to G94 or G95

== G96, G97 Spindle Control Mode[[sec:G96-G97-Spindle]]
(((G96, G97 Spindle Control Mode)))

----
G96 <D-> S- (Constant Surface Speed)
G97 (RPM Mode)
----

* 'D' - maximum spindle RPM
* 'S' - surface speed

* 'G96 D- S-' - selects constant surface speed of 'S' feet per minute
                (if G20 is in effect) or meters per minute
                (if G21 is in effect). D- is optional.
+                
When using G96, ensure that X0 in
the current coordinate system (including offsets and tool lengths) is
the center of rotation or LinuxCNC will not give the desired spindle speed.
G96 is not affected by radius or diameter mode.

* 'G97' selects RPM mode.

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

It is an error if:

* S is not specified with G96
* A feed move is specified in G96 mode while the spindle is not turning

== G73 Drilling Cycle with Chip Breaking[[sec:G73-Drilling-Cycle]]
(((G73 Drilling Cycle Chip Break)))

----
G73 X- Y- Z- R- Q- <L-> 
----
* 'R' - retract position along the Z axis.
* 'Q' - delta increment along the Z axis.
* 'L' - repeat

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

 . Preliminary motion.
   ** If the current Z position is below the R position,
   the Z axis is traversed to the R position.
   ** Move to the X Y coordinates
 . Move the Z-axis only at the current feed rate downward by delta or to
   the Z position, whichever is less deep.
 . Rapid up a bit.
 . Repeat steps 2 and 3 until the Z position is reached at step 2.
 . Retract the Z-axis at traverse rate to R. 

It is an error if:

* the Q number is negative or zero.
* the R number is not specified

== G76 Threading Cycle[[sec:G76-Threading-Canned]]

(((G76 Threading)))

----
G76 P- Z- I- J- R- K- Q- H- E- L-
----

.G76 Threading[[fig:G76-Threading]]

image::images/g76-threads.png[align="center"]


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

* 'P-' - The 'thread pitch' in distance per revolution.

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

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

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

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

Optional settings

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

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

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

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

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

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

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

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

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

It is an error if:

* The active plane is not the ZX plane
* Other axis words, such as X- or Y-, are specified
* The 'R-' degression value is less than 1.0.
* All the required words are not specified
* 'P-', 'J-', 'K-' or 'H-' is negative
* 'E-' is greater than half the drive line length

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

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

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

.G76 Example[[fig:G76-Threading-Example]]

image::images/g76-01.png[align="center"]

== Canned Cycles[[sec:G80-G89]](((G80-G89 Canned Cycles)))

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

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

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

=== Common Words

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

=== Sticky Words

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

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

=== Repeat Cycle

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

=== Retract Mode

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

=== Canned Cycle Errors

It is an error if:

* axis words are all missing during a canned cycle,
* axis words from different groups (XYZ) (UVW) are used together,
* a P number is required and a negative P number is used,
* an L number is used that does not evaluate to a positive integer,
* rotary axis motion is used during a canned cycle,
* inverse time feed rate is active during a canned cycle,
* or cutter radius compensation is active during a canned cycle.

If the XY plane is active, the Z number is sticky, and it is an error
if:

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

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

=== Preliminary and In-Between Motion

Preliminary motion is a set of motions that is common to all of the
milling canned cycles. If the current Z position is below the R position,
the Z axis is traversed to the R position. This happens only once,
regardless of the value of L.

In addition, at the beginning of the first cycle and each repeat, the
following one or two moves are made

. a straight traverse parallel to the XY-plane to the given XY-position,
. a straight traverse of the Z-axis only to the R position, if it is not
 already at the R position. 

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

=== Why use a canned cycle?

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

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

.Eight Holes
----
G90 G0 X0 Y0 Z0 (move coordinate home)
G1 F10 X0 G4 P0.1
G91 G81 X1 Y0 Z-1 R1 L4(canned drill cycle)
G90 G0 X0 Y1
Z0
G91 G81 X1 Y0 Z-0.5 R1 L4(canned drill cycle)
G80 (turn off canned cycle)
M2 (program end)
----
The G98 to the second line above means that the return move will be to
the value of Z in the first line since it is higher that the R value
specified.

image::images/eight.png[align="center"]


.Twelve Holes in a Square

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

----
G90 G0 X0 Y0 Z0 (move coordinate home)
G1 F50 X0 G4 P0.1
G91 G81 X1 Y0 Z-0.5 R1 L4 (canned drill cycle)
X0 Y1 R0 L3 (repeat)
X-1 Y0 L3 (repeat)
X0 Y-1 L2 (repeat)
G80 (turn off canned cycle)
G90 G0 X0 (rapid home)
Y0
Z0
M2 (program end)
----

image::images/twelve.png[align="center"]

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


== G80 Cancel Canned Cycle[[sec:G80-Cancel-Modal]]
(((G80 Cancel Modal Motion)))

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

It is an error if:

*  Axis words are programmed when G80 is active.

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

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

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

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

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

.G80 Example 1
----
N100 G90 G0 X0 Y0 Z0 (coordinate home)
N110 G1 X0 G4 P0.1
N120 G81 X1 Y0 Z0 R1 (canned drill cycle)
N130 X2
N140 X3
N150 X4
N160 Y1 Z0.5
N170 X3
N180 X2
N190 X1
N200 G80 (turn off canned cycle)
N210 G0 X0 (rapid home moves)
N220 Y0
N230 Z0
N240 M2 (program end)
----

[NOTE]
Notice the z position change after the first four holes.
Also, this is one of the few places where line numbers have some value,
being able to point a reader to a specific line of code.

.G80 Cycle[[cap:G80-Cycle]]
    
image::images/G81mult.png[align="center"]

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

== G81 Drilling Cycle[[sec:G81-Drilling-Cycle]]

(((G81 Drilling Cycle)))

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

The 'G81' cycle is intended for drilling.

The cycle functions as follows:

. Preliminary motion to start position.

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

. Retract the Z-axis at traverse rate to clear Z. This cycle was used
  in the description of G80 above but is explained in detail here.

.Example 1 - Absolute Position G81[[G81-example-1]]

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

----
G90 G98 G81 X4 Y5 Z1.5 R2.8
----

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

The X value and X position are 4.

The Y value and Y position are 5.

The Z value and Z position are 1.5.

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

The following moves take place:

. a traverse parallel to the XY plane to (X4, Y5, Z3)

. a traverse parallel to the Z-axis to (X4, Y5, Z2.8).

. a feed parallel to the Z-axis to (X4, Y5, Z1.5)

. a traverse parallel to the Z-axis to (X4, Y5, Z3)

image::images/G81ex1.png[align="center"]

.Example 2 - Relative Position G81

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

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

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

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

The first repeat consists of 3 moves.

. a traverse parallel to the XY-plane to (X5, Y7, Z4.8)

. a feed parallel to the Z-axis to (X5, Y7, Z4.2)

. a traverse parallel to the Z-axis to (X5, Y7, Z4.8) 

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

. a traverse parallel to the XY-plane to (X9, Y12, Z4.8)

. a feed parallel to the Z-axis to (X9, Y12, Z4.2)

. a traverse parallel to the Z-axis to (X9, Y12, Z4.8) 

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

. a traverse parallel to the XY-plane to (X13, Y17, Z4.8)

. a feed parallel to the Z-axis to (X13, Y17, Z4.2)

. a traverse parallel to the Z-axis to (X13, Y17, Z4.8)

image::images/G81ex2.png[align="center"]

.Example 3 - Relative Position G81

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

----
G90 G98 G81 X4 Y5 Z1.5 R2.8
----

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

image::images/G81.png[align="center"]

.Example 4 - Absolute G81 R > Z

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

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

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

image::images/G81a.png[align="center"]

.Example 5 - Relative position R > Z

----
G90 G98 G81 X4 Y5 Z-0.6 R1.8
----

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

== G82 Drilling Cycle, Dwell[[sec:G82-Drilling-Dwell]]

(((G82 Drilling Cycle Dwell)))

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

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

 . Preliminary motion, as described above.
 . Move the Z-axis only at the current feed rate to the Z position.
 . Dwell for the P number of seconds.
 . Retract the Z-axis at traverse rate to clear Z.

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

== G83 Peck Drilling Cycle[[sec:G83-Drilling-Peck]]

(((G83 Peck Drilling)))

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

The 'G83' cycle (often called peck drilling) is intended for deep
drilling or
milling with chip breaking. The retracts in this cycle clear the hole
of chips and cut off any long stringers (which are common when drilling
in aluminum). This cycle takes a Q number which represents a 'delta'
increment along the Z-axis. The retract before final depth will always
be to the 'retract' plane even if G98 is in effect. The final retract will
honor the G98/99 in effect. G83 functions the same as G81 with the addition
of retracts during the drilling operation.


 . Preliminary motion, as described above.
 . Move the Z-axis only at the current feed rate downward by delta or to
   the Z position, whichever is less deep. 
 . Rapid back out to the retract plane specified by the R word.
 . Rapid back down to the current hole bottom, backed off a bit.
 . Repeat steps 2, 3, and 4 until the Z position is reached at step 2.
 . Retract the Z-axis at traverse rate to clear Z. 

It is an error if:

* the Q number is negative or zero.

== G84 Right-Hand Tapping Cycle[[sec:G84-Right-Hand-Tapping]]

(((G84 Right-Hand Tapping)))

This code is currently unimplemented in LinuxCNC. It is accepted, but the
behavior is undefined. See section <<sec:G33.1-Rigid-Tapping,G33.1>>

== G85 Boring Cycle, Feed Out[[sec:G85-Boring-Feed-Out]]

(((G85 Boring, Feed Out)))

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

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

 . Preliminary motion, as described above. 
 . Move the Z-axis only at the current feed rate to the Z position.
 . Retract the Z-axis at the current feed rate to clear Z. 

== G86 Boring Cycle, Spindle Stop, Rapid Out[[sec:G86-Boring-Rapid-Out]]

(((G86 Boring, Spindle Stop, Rapid Out)))

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

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

 . Preliminary motion, as described above. 
 . Move the Z-axis only at the current feed rate to the Z position.
 . Dwell for the P number of seconds.
 . Stop the spindle turning.
 . Retract the Z-axis at traverse rate to clear Z.
 . Restart the spindle in the direction it was going. 

It is an error if:

* the spindle is not turning before this cycle is executed.

== G87 Back Boring Cycle[[sec:G87-Back-Boring]]

(((G87 Back Boring)))

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

== G88 Boring Cycle, Spindle Stop, Manual Out[[sec:G88-Boring-Manual-Out]]

(((G88 Boring Cycle, Spindle Stop, Manual Out)))

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

== G89 Boring Cycle, Dwell, Feed Out[[sec:G89-Boring-Dwell,]]

(((G89 Boring, Dwell, Feed Out)))

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

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

 . Preliminary motion, as described above.
 . Move the Z-axis only at the current feed rate to the Z position.
 . Dwell for the P number of seconds. 
 . Retract the Z-axis at the current feed rate to clear Z. 

== G98, G99 Canned Cycle Return Level[[sec:G98-G99-Set]]
(((G98, G99 Canned Cycle Return)))

* 'G98' - retract to the position that axis was in just before this series
of one or more contiguous canned cycles was started.

* 'G99' - retract to the position specified by the R word of the canned cycle.

Program a 'G98' and the canned cycle will use the Z position prior to
the canned cycle as the Z return position if it is higher than the R
value specified in the cycle. If it is lower then the R value will be
used. The R word has different meanings in absolute distance mode and
incremental distance mode.

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

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

The 'initial' (G98) plane is reset any time cycle motion mode is
abandoned, whether explicitly (G80) or implicitly (any motion code
that is not a cycle). Switching among cycle modes (say G81
to G83) does NOT reset the 'initial' plane. It is possible to switch
between G98 and G99 during a series of cycles.

// vim: set syntax=asciidoc: