Content deleted Content added
short description, links Tags: Mobile edit Mobile app edit iOS app edit |
No edit summary |
||
Line 28:
}}
'''G-code''' (also '''RS-274''') is the most widely-used [[computer numerical control]] (CNC) [[programming language]]
G-code instructions are provided to a [[Programmable logic controller|machine controller]] (industrial computer) that tells the motors where to move, how fast to move, and what path to follow. The two most common situations are that, within a machine tool such as a [[Metal lathe|lathe]] or [[Milling (machining)|mill]], a [[cutting tool (machining)|cutting tool]] is moved according to these instructions through a toolpath cutting away material to leave only the finished workpiece and/or an unfinished workpiece is precisely positioned in any of up to nine axes<ref>Karlo Apro (2008). ''[https://books.google.com/books?id=Ws228Aht0bcC Secrets of 5-Axis Machining]''. Industrial Press Inc. {{ISBN|0-8311-3375-9}}.</ref> around the three dimensions relative to a toolpath and, either or both can move relative to each other. The same concept also extends to noncutting tools such as [[Forming (metalworking)|forming]] or [[Burnishing (metal)|burnishing]] tools, [[Gerber format|photoplotting]], additive methods such as [[3D printing]], and measuring instruments.
Line 35:
The first implementation of a numerical control programming language was developed at the [[Massachusetts Institute of Technology|MIT]] Servomechanisms Laboratory in the late 1950s. In the decades since, many implementations have been developed by many (commercial and noncommercial) organizations. G-code has often been used in these implementations. The main standardized version used in the United States was settled by the [[Electronic Industries Alliance]] in the early 1960s.{{Citation needed|date=March 2010}} A final revision was approved in February 1980 as ''RS-274-D''.<ref>{{citation| title = EIA Standard RS-274-D Interchangeable Variable Block Data Format for Positioning, Contouring, and Contouring/Positioning Numerically Controlled Machines |publisher = Electronic Industries Association |___location= Washington D.C. |date=February 1979}}</ref> In other countries, the standard ''[[International Organization for Standardization|ISO]] 6983'' is often used, but many European countries use other standards. For example, ''[[Deutsches Institut für Normung|DIN]] 66025'' is used in Germany, and PN-73M-55256 and PN-93/M-55251 were formerly used in Poland.
Extensions and variations have been added independently by control manufacturers and machine tool manufacturers, and operators of a specific controller must be aware of the differences
One standardized version of G-code, known as ''BCL'' (Binary Cutter Language), is used only on very few machines. Developed at MIT, BCL was developed to control CNC machines in terms of straight lines and arcs.<ref>{{Cite book|url=https://books.google.com/books?id=GE8vBQAAQBAJ&q=binary+cutter+language+gcode&pg=PA321|title=Information Technology Standards : Quest for the Common Byte.|last=Martin.|first=Libicki|date=1995|publisher=Elsevier Science|isbn=9781483292489|___location=Burlington|pages=321|oclc=895436474}}</ref>
Line 43:
Some CNC machines use "conversational" programming, which is a [[wizard (software)|wizard]]-like programming mode that either hides G-code or completely bypasses the use of G-code. Some popular examples are Okuma's Advanced One Touch (AOT), Southwestern Industries' ProtoTRAK, Mazak's Mazatrol, Hurco's Ultimax and Winmax, Haas' Intuitive Programming System (IPS), and Mori Seiki's CAPS conversational software.
G-code began as a limited language that lacked constructs such as loops, conditional operators, and programmer-declared variables with [[Natural language|natural]]-word-including names (or the expressions in which to use them). It was unable to encode logic
== Specific codes ==
Line 90:
| valign="top" | {{Visible anchor|L}} || Fixed cycle loop count; <br> Specification of what register to edit using [[#G10|G10]] || ''Fixed cycle loop count:'' Defines number of repetitions ("loops") of a fixed cycle at ''each'' position. Assumed to be 1 unless programmed with another integer. Sometimes the [[#K|K]] address is used instead of L. With incremental positioning ([[#G91|G91]]), a series of equally spaced holes can be programmed as a loop rather than as individual positions. <br> ''[[#G10|G10]] use:'' Specification of what register to edit (work offsets, tool radius offsets, tool length offsets, etc.).
|-
| valign="top" | '''{{Visible anchor|M}}''' || Miscellaneous function || Action code, auxiliary command; descriptions vary. Many M-codes call for machine functions, which is why people often say that the "M" stands for "machine", although it was not intended to. such as M500 to save gcode in [[Additive Manufacturing]]
|-
| valign="top" | {{Visible anchor|N}} || Line (block) number in program; <br> System parameter number to change using [[#G10|G10]] || ''Line (block) numbers:'' Optional, so often omitted. Necessary for certain tasks, such as [[#M99|M99]] [[#P|P]] address (to tell the control which block of the program to return to if not the default) or [[goto|GoTo]] statements (if the control supports those). [[#N|N]] numbering need not increment by 1 (for example, it can increment by 10, 20, or 1000) and can be used on every block or only in certain spots throughout a program. <br> ''System parameter number:'' [[#G10|G10]] allows changing of system parameters under program control.<ref name="Smid2004">{{Harvnb|Smid|2004|p=61}}</ref>
Line 209:
| valign="top" | {{Anchor|G50_scaling_off}} G50 || Scaling function cancel || M || ||
|-
| valign="top" | {{Anchor|G50_position_register}} G50 || Position register (programming of the vector from part zero to tooltip) || || T || Position register is one of the original methods to relate the part (program) coordinate system to the tool position, which indirectly relates it to the [[machine coordinate system]], the only position the control really "knows". Not commonly programmed anymore because [[#G54 to G59|G54 to G59]] (WCSs) are a better, newer method. Called via G50 for turning, [[#G92_position_register|G92]] for milling. Those G addresses also have alternate meanings (''which see''). Position register can still be useful for datum shift programming. The "manual absolute" switch, which has very few useful applications in WCS contexts, was more useful in position register contexts because it allowed the operator to move the tool to a certain distance from the part (for example, by touching off a 2.0000" gage) and then declare to the control what the distance-to-go shall be (2.0000).
|-
| valign="top" | {{Visible anchor|G52}} || Local coordinate system (LCS) || M || || Temporarily shifts program zero to a new ___location. It is simply "an offset from an offset", that is, an additional offset added onto the [[#G54 to G59|WCS]] offset. This simplifies programming in some cases.
|-
| valign="top" | {{Visible anchor|G53}} || [[Machine coordinate system]] || M || T || Takes absolute coordinates (X, Y, Z, A, B, C) with reference to machine zero rather than program zero. Can be helpful for tool changes. Nonmodal and absolute only. Subsequent blocks are interpreted from the previously selected Work Coordinate System, [[G-code#G54 to G59|G54 to G59]], even if it is not explicitly programmed.
|-
| valign="top" | {{Visible anchor|G54 to G59}} || Work coordinate systems (WCSs) || M || T || Have largely replaced position register ([[#G50_position_register|G50]] and [[#G92_position_register|G92]]). Each tuple of axis offsets relates program zero directly to machine zero. The Standard is 6 tuples (G54 to G59), with optional extensibility to 48 more via G54.1 P1 to P48.
|-
| valign="top" | {{Visible anchor|G54.1 P1 to P48}} || Extended work coordinate systems || M || T || Up to 48 more WCSs besides the 6 provided as standard by G54 to G59. Note the floating-point extension of the G-code data type (formerly all integers). Other examples have also evolved (e.g., [[#G84.2|G84.2]]). Modern controls have the [[computer hardware|hardware]] to handle it.
|-
| valign="top" | {{Visible anchor|G61}} || Exact stop check, modal || M || T || Can be canceled with [[#G64|G64]]. The non-modal version is [[#G09|G09]].
Line 225:
| valign="top" | {{Visible anchor|G64}} || Default cutting mode (cancel exact stop check mode) || M || T || Cancels [[#G61|G61]].
|-
| valign="top" | {{Visible anchor|G68}} || Rotate coordinate system || M || || Rotates coordinate system in the current plane given with [[#G17|G17]], [[#G18|G18]], or [[#G19|G19]]. Center of rotation is given with two parameters, which vary with each vendor's implementation. Rotate with the angle given with argument R. This can be used, for instance, to align the coordinate system with a misaligned part. It can also be used to repeat movement sequences around a center. Not all vendors support coordinate system rotation.
|-
| valign="top" | {{Visible anchor|G69}} || Turn off coordinate system rotation || M || || Cancels [[#G68|G68]].
Line 231:
| valign="top" | {{Visible anchor|G70}} || Fixed cycle, multiple repetitive cycle, for finishing (including contours) || || T ||
|-
| valign="top" | {{Visible anchor|G71}} || Fixed cycle, multiple repetitive
|-
| valign="top" | {{Visible anchor|G72}} || Fixed cycle, multiple repetitive
|-
| valign="top" | {{Anchor|G73_rough_turn_pattern_repeat}} G73 || Fixed cycle, multiple repetitive cycle, for roughing, with pattern repetition || || T ||
|-
| valign="top" | {{Anchor|G73_peck_drill}} G73 || Peck drilling cycle for milling – high-speed (NO full retraction from pecks) || M || || Retracts only as far as a clearance increment (system parameter). For when
|-
| valign="top" | {{Anchor|G74_pecking}} G74 || Peck drilling cycle for turning || || T ||
Line 476:
Since about the mid-2000s, it seems "the death of manual programming" (that is, of writing lines of G-code without CAD/CAM assistance) may be approaching. However, it is currently only in ''some'' contexts that manual programming is obsolete. Plenty of CAM programming takes place nowadays among people who are rusty on, or incapable of, manual programming—but it is not true that ''all'' CNC programming can be done, or done ''as well'' or ''as efficiently'', without knowing G-code.<ref name="Lynch_MMS_2010-01-18">{{Citation |last=Lynch |first=Mike |date=2010-01-18 |title=When programmers should know G code |journal=Modern Machine Shop |edition=online |url=http://www.mmsonline.com/columns/when-programmers-should-know-g-code |postscript=.}}</ref><ref name="Lynch_MMS_2011-10-19">{{Citation |last=Lynch |first=Mike |date=2011-10-19 |title=Five CNC myths and misconceptions [CNC Tech Talk column, Editor's Commentary] |journal=Modern Machine Shop |edition=online |url=http://www.mmsonline.com/columns/five-cnc-myths-and-misconceptions |postscript=. |access-date=2011-11-22 |archive-url=https://web.archive.org/web/20170527082655/http://www.mmsonline.com/columns/five-cnc-myths-and-misconceptions |archive-date=2017-05-27 |url-status=dead }}</ref> Tailoring and refining the CNC program at the machine is an area of practice where it can be easier or more efficient to edit the G-code directly rather than editing the CAM toolpaths and re-post-processing the program.
Making a living cutting parts on computer-controlled machines has been made both easier and harder by CAD/CAM software. Efficiently written G-code can be a challenge for CAM software. Ideally, a CNC machinist should know both manual and CAM programming well so that the benefits of both brute-force CAM and elegant hand programming can be used where needed. <!-- True, and the references from Mike Lynch above touch on the same concept. --> Many older machines were built with limited [[computer memory]] at a time when memory was very expensive; 32K was considered plenty of room for manual programs whereas modern CAM software can post gigabytes of code. CAM excels at getting a program out quickly that may take up more machine memory and take longer to run. This often makes it quite valuable to machining a low quantity of parts. But a balance must be struck between the time it takes to create a program and the time the program takes to machine a part. It has become easier and faster to make just a few parts on the newer machines with much memory. This has taken its toll on both hand programmers and manual machinists. Given natural [[turnover (employment)|turnover]] into retirement, it is not realistic to expect to maintain a large pool of operators who are highly skilled in manual programming when their commercial environment ''mostly'' can no longer provide the countless hours of deep experience it took to build that skill; and yet the loss of this experience base can be appreciated, and there are times when such a pool is sorely missed because some CNC or [[3D printing]] runs still cannot be optimized without such skill.
==Abbreviations used by programmers and operators==
Line 583:
* [[Drill file (disambiguation)|Drill file]]
* [[HP-GL]]
* [[[STL (file format)]]
* [[Slicer (3D printing)]]
===Extended developments===
|