Misplaced Pages

G-code: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Browse history interactively← Previous editContent deleted Content addedVisualWikitext
Revision as of 08:35, 1 August 2023 editThumperward (talk | contribs)Administrators122,786 edits tidy endnotes, rm unreferenced commentary on the general state of CNC← Previous edit Latest revision as of 00:15, 17 December 2024 edit undo76.69.142.126 (talk) History: Fixed grammar: verbal tense (are to were), readability (slightly shorter sentence).Tags: Mobile edit Mobile app edit Android app edit App section source 
(12 intermediate revisions by 10 users not shown)
Line 10: Line 10:
| developer = ] (RS-274), ] (ISO-6983) | developer = ] (RS-274), ] (ISO-6983)
| implementations = Numerous; mainly ] Sinumerik, ], ], ], ], ] | implementations = Numerous; mainly ] Sinumerik, ], ], ], ], ]
| dialects = | dialects =
| influenced by = | influenced by =
| influenced = | influenced =
| programming language = | programming language =
| platform = | platform =
| operating system = | operating system =
| license = | license =
| website = | website =
| wikibooks = | wikibooks =
}} }}


'''G-code''' (also '''RS-274''') is the most widely used ] (CNC) and ] ]. It is used mainly in ] to control automated ]s, as well as for ]. The ''G'' stands for geometry. G-code has many variants. '''G-code''' (also '''RS-274''') is the most widely used ] (CNC) and ] ]. It is used mainly in ] to control automated ]s, as well as for ]. The ''G'' stands for geometry. G-code has many variants.


G-code instructions are provided to a ] (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 ] or ], a ] 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). ''''. 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 ] or ] tools, ], additive methods such as ], and measuring instruments. G-code instructions are provided to a ] (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 ] or ], a ] 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). ''''. 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 ] or ] tools, ], additive methods such as 3D printing, and measuring instruments.


== History ==
==Background and implementations==
The first implementation of a numerical control programming language was developed at the ] in the 1950s. In the decades that followed, many implementations were developed by numerous organizations, both commercial and noncommercial. Elements of G-code had often been used in these implementations.<ref>{{cite book | last=Xu | first=Xun | date=2009 | url=https://www.google.com/books/edition/Integrating_Advanced_Computer_Aided_Desi/habcATPQWJ4C | title=Integrating Advanced Computer-aided Design, Manufacturing, and Numerical Control: Principles and Implementations | publisher=Information Science Reference | page=166 | isbn=9781599047164 | via=Google Books}}</ref><ref>{{cite book | last=Harik | first=Ramy | author2=Thorsten Wuest | date=2019 | url=https://www.google.com/books/edition/Introduction_to_Advanced_Manufacturing/O3h0EAAAQBAJ | title=Introduction to Advanced Manufacturing | publisher=SAE International | page=116 | isbn=9780768090963 | via=Google Books}}</ref> The first ] version of G-code used in the United States, ''RS-274'', was published in 1963 by the ] (EIA; then known as Electronic Industries Association).<ref>{{cite book | last=Evans | first=John M., Jr. | date=1976 | url=https://www.govinfo.gov/content/pkg/GOVPUB-C13-2ef4aaa5a150eedcb85a1e6985e90bfa/pdf/GOVPUB-C13-2ef4aaa5a150eedcb85a1e6985e90bfa.pdf | title=National Bureau of Standards Information Report (NBSIR) 76-1094 (R): Standards for Computer Aided Manufacturing | publisher=National Bureau of Standards | page=43}}</ref> In 1974, EIA approved ''RS-274-C'', which merged ''RS-273'' (variable block for positioning and straight cut) and ''RS-274-B'' (variable block for contouring and contouring/positioning). A final revision of ''RS-274'' was approved in 1979, as ''RS-274-D''.<ref>{{cite journal | last=Schenck | first=John P. | date=January 1, 1998 | url=https://link.gale.com/apps/doc/A20429590/GPS?sid=wikipedia | title=Understanding common CNC protocols | work=Wood & Wood Products | publisher=Vance Publishing | volume=103 | issue=1 | page=43 | via=Gale}}</ref><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 ''] 6983'' (finalized in 1982) is often used, but many European countries use other standards.<ref>{{cite book | last=Stark | first=J. | author2=V.&nbsp;K. Nguyen | date=2009 | url=https://www.google.com/books/edition/Advanced_Design_and_Manufacturing_Based/RIgLRe12RD4C | chapter=STEP-compliant CNC Systems, Present and Future Directions | title=Advanced Design and Manufacturing Based on STEP | editor-last=Xu | editor-first=Xun | editor2=Andrew Yeh Ching Nee | publisher=Springer London | page=216 | isbn=9781848827394 | via=Google Books}}</ref> For example, ''] 66025'' is used in Germany, and PN-73M-55256 and PN-93/M-55251 were formerly used in Poland.


The first implementation of a numerical control programming language was developed at the ] in the 1950s. In the decades that followed, many implementations were developed by numerous organizations, both commercial and noncommercial. Elements of G-code had often been used in these implementations.<ref>{{cite book | last=Xu | first=Xun | date=2009 | url=https://books.google.com/books?id=habcATPQWJ4C | title=Integrating Advanced Computer-aided Design, Manufacturing, and Numerical Control: Principles and Implementations | publisher=Information Science Reference | page=166 | isbn=978-1-59904-716-4 | via=Google Books}}</ref><ref>{{cite book | last=Harik | first=Ramy | author2=Thorsten Wuest | date=2019 | url=https://books.google.com/books?id=O3h0EAAAQBAJ | title=Introduction to Advanced Manufacturing | publisher=SAE International | page=116 | isbn=978-0-7680-9096-3 | via=Google Books}}</ref> The first ] version of G-code used in the United States, ''RS-274'', was published in 1963 by the ] (EIA; then known as Electronic Industries Association).<ref>{{cite book | last=Evans | first=John M. Jr. | date=1976 | url=https://www.govinfo.gov/content/pkg/GOVPUB-C13-2ef4aaa5a150eedcb85a1e6985e90bfa/pdf/GOVPUB-C13-2ef4aaa5a150eedcb85a1e6985e90bfa.pdf | title=National Bureau of Standards Information Report (NBSIR) 76-1094 (R): Standards for Computer Aided Manufacturing | publisher=National Bureau of Standards | page=43}}</ref> In 1974, EIA approved ''RS-274-C'', which merged ''RS-273'' (variable block for positioning and straight cut) and ''RS-274-B'' (variable block for contouring and contouring/positioning). A final revision of ''RS-274'' was approved in 1979, as ''RS-274-D''.<ref>{{cite journal | last=Schenck | first=John P. | date=January 1, 1998 | url=https://link.gale.com/apps/doc/A20429590/GPS?sid=wikipedia | title=Understanding common CNC protocols | journal=Wood & Wood Products | publisher=Vance Publishing | volume=103 | issue=1 | page=43 | via=Gale}}</ref><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 ''] 6983'' (finalized in 1982) is often used, but many European countries use other standards.<ref>{{cite book | last=Stark | first=J. | author2=V.&nbsp;K. Nguyen | date=2009 | url=https://books.google.com/books?id=RIgLRe12RD4C | chapter=STEP-compliant CNC Systems, Present and Future Directions | title=Advanced Design and Manufacturing Based on STEP | editor-last=Xu | editor-first=Xun | editor2=Andrew Yeh Ching Nee | publisher=Springer London | page=216 | isbn=978-1-84882-739-4 | via=Google Books}}</ref> For example, ''] 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 between each manufacturer's product.


During the 1970s through 1990s, many CNC machine tool builders attempted to overcome compatibility difficulties by standardizing on machine tool controllers built by ]. ] was another market dominator in CNC controls, especially in Europe. In the 2010s, controller differences and incompatibility were mitigated with the widespread adoption of CAD/CAM applications that were capable of outputting machine operations in the appropriate G-code for a specific machine through a software tool called a post-processor (sometimes shortened to just a "post").
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>


== Syntax ==
During the 1970s through 1990s, many CNC machine tool builders attempted to overcome compatibility difficulties by standardizing on machine tool controllers built by ]. ] was another market dominator in CNC controls, especially in Europe. In the 2010s, controller differences and incompatibility are not as troublesome because machining operations are usually developed with CAD/CAM applications that can output the appropriate G-code for a specific machine through a software tool called a post-processor (sometimes shortened to just a "post").


G-code began as a limited language that lacked constructs such as loops, conditional operators, and programmer-declared variables with ]-word-including names (or the expressions in which to use them). It was unable to encode logic but was just a way to "connect the dots" where the programmer figured out many of the dots' locations longhand. The latest implementations of G-code include macro language capabilities somewhat closer to a ]. Additionally, all primary manufacturers (e.g., Fanuc, Siemens, ]) provide access to ] (PLC) data, such as axis positioning data and tool data,<ref>{{cite web |archive-date=2014-05-03 |url=http://www.machinetoolhelp.com/Applications/macro/system_variables.html |title=Fanuc macro system variables |access-date=2014-06-30 |archive-url=https://web.archive.org/web/20140503030834/http://www.machinetoolhelp.com/Applications/macro/system_variables.html }}</ref> via variables used by NC programs. These constructs make it easier to develop automation applications.
Some CNC machines use "conversational" programming, which is a ]-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.


== Extensions and variations ==
G-code began as a limited language that lacked constructs such as loops, conditional operators, and programmer-declared variables with ]-word-including names (or the expressions in which to use them). It was unable to encode logic but was just a way to "connect the dots" where the programmer figured out many of the dots' locations longhand. The latest implementations of G-code include macro language capabilities somewhat closer to a ]. Additionally, all primary manufacturers (e.g., Fanuc, Siemens, ]) provide access to ] (PLC) data, such as axis positioning data and tool data,<ref>{{cite web |url-status=dead |archive-date=2014-05-03 |url=http://www.machinetoolhelp.com/Applications/macro/system_variables.html |title=Fanuc macro system variables |access-date=2014-06-30 |archive-url=https://web.archive.org/web/20140503030834/http://www.machinetoolhelp.com/Applications/macro/system_variables.html }}</ref> via variables used by NC programs. These constructs make it easier to develop automation applications.


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 between each manufacturer's product.
==Programming environments==
{{Original research section|date=January 2016}}


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=978-1-4832-9248-9|location=Burlington|page=321|oclc=895436474}}</ref>
G-code's programming environments have evolved in parallel with those of general programming—from the earliest environments (e.g., writing a program with a pencil, typing it into a tape puncher) to the latest environments that combine CAD (]), CAM (]), and richly featured G-code editors. (G-code editors are analogous to ]s, using colors and indents semantically to aid the user in ways that basic ]s can't. CAM packages are analogous to ] in general programming.)


Some CNC machines use "conversational" programming, which is a ]-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.
Two high-level paradigm shifts have been toward:

# abandoning "manual programming" (with nothing but a pencil or text editor and a human mind) for ] systems that generate G-code automatically via postprocessors (analogous to the development of ] techniques in general programming)
# abandoning hardcoded constructs for parametric ones (analogous to the difference in general programming between hardcoding a constant into an equation versus declaring it a variable and assigning new values to it at will; and to the ] approach in general).

Macro (parametric) CNC programming uses human-friendly variable names, ]s, and loop structures, much as general programming does, to capture information and logic with machine-readable semantics. Whereas older manual CNC programming could only describe particular instances of parts in numeric form, macro programming describes abstractions that can easily apply in a wide variety of instances.

The tendency is comparable to a computer programming evolution from ]s to ].{{Citation needed|date=January 2022}}

] reflects the same theme, which can be viewed as yet another step along a path that started with the development of machine tools, jigs and fixtures, and numerical control, which all sought to "build the skill into the tool." Recent developments of G-code and STEP-NC aim to build the information and semantics into the tool. This idea is not new; from the beginning of numerical control, the concept of an end-to-end CAD/CAM environment was the goal of such early technologies as ] and ]. Those efforts were fine for huge corporations like GM and Boeing. However, ] went through an era of simpler implementations of NC, with relatively primitive "connect-the-dots" G-code and manual programming until CAD/CAM improved and disseminated throughout the industry.


== See also == == See also ==

* ]
* ] * ]
* ] * ]
* ]
* ] (DNC)
* ]
* ]
* ]
* ]
* ] * ]
* ]
* ]
* ]
* ]
* ]
* ]


== References == == References ==
{{Reflist}}

{{refs}}


== Bibliography == == Bibliography ==

* {{MachinerysHandbook25e}} * {{MachinerysHandbook25e}}
* {{Smid2008}} * {{Smid2008}}
* {{Smid2010}} * {{Smid2010}}
* {{Citation |last=Smid |first=Peter |year=2004 |title=Fanuc CNC Custom Macros |publisher=Industrial Press |url=https://books.google.com/books?id=YKvH-zYd3VwC&pg=PR11 |isbn=978-0831131579 |postscript=.}} * {{Citation |last=Smid |first=Peter |year=2004 |title=Fanuc CNC Custom Macros |publisher=Industrial Press |url=https://books.google.com/books?id=YKvH-zYd3VwC&pg=PR11 |isbn=978-0-8311-3157-9 |postscript=.}}


== External links == == External links ==

* *
* {{Citation |last1=Kramer |first1=T. R. |last2=Proctor |first2=F. M. |last3=Messina |first3=E. R. |title=The NIST RS274NGC Interpreter – Version 3 |date=1 Aug 2000 |id=NISTIR 6556 |journal=] |url=https://www.nist.gov/manuscript-publication-search.cfm?pub_id=823374 |ref=none}} * {{Citation |last1=Kramer |first1=T. R. |last2=Proctor |first2=F. M. |last3=Messina |first3=E. R. |title=The NIST RS274NGC Interpreter – Version 3 |date=1 Aug 2000 |id=NISTIR 6556 |journal=] |url=https://www.nist.gov/manuscript-publication-search.cfm?pub_id=823374 |ref=none}}
* http://museum.mit.edu/150/86 {{Webarchive|url=https://web.archive.org/web/20160319102859/http://museum.mit.edu/150/86 |date=2016-03-19 }} Has several links (including history of MIT Servo Lab) * http://museum.mit.edu/150/86 {{Webarchive|url=https://web.archive.org/web/20160319102859/http://museum.mit.edu/150/86 |date=2016-03-19 }} Has several links (including history of MIT Servo Lab)
* * at reprap.org
* *
* *

Latest revision as of 00:15, 17 December 2024

Primary programming language used in CNC For other uses, see G-code (disambiguation) and G programming language (disambiguation). "RS-274" redirects here. For the photoplotter format, see Gerber format.
G-code
ParadigmProcedural, imperative
Designed byMassachusetts Institute of Technology
DeveloperElectronic Industries Association (RS-274), International Organization for Standardization (ISO-6983)
First appeared1963 (1963) (RS-274)
Filename extensions.gcode, .mpt, .mpf, .nc and several others
Major implementations
Numerous; mainly Siemens Sinumerik, FANUC, Haas, Heidenhain, Mazak, Okuma

G-code (also RS-274) is the most widely used computer numerical control (CNC) and 3D printing programming language. It is used mainly in computer-aided manufacturing to control automated machine tools, as well as for 3D-printer slicer applications. The G stands for geometry. G-code has many variants.

G-code instructions are provided to a 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 lathe or mill, a 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 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 or burnishing tools, photoplotting, additive methods such as 3D printing, and measuring instruments.

History

The first implementation of a numerical control programming language was developed at the MIT Servomechanisms Laboratory in the 1950s. In the decades that followed, many implementations were developed by numerous organizations, both commercial and noncommercial. Elements of G-code had often been used in these implementations. The first standardized version of G-code used in the United States, RS-274, was published in 1963 by the Electronic Industries Alliance (EIA; then known as Electronic Industries Association). In 1974, EIA approved RS-274-C, which merged RS-273 (variable block for positioning and straight cut) and RS-274-B (variable block for contouring and contouring/positioning). A final revision of RS-274 was approved in 1979, as RS-274-D. In other countries, the standard ISO 6983 (finalized in 1982) is often used, but many European countries use other standards. For example, DIN 66025 is used in Germany, and PN-73M-55256 and PN-93/M-55251 were formerly used in Poland.

During the 1970s through 1990s, many CNC machine tool builders attempted to overcome compatibility difficulties by standardizing on machine tool controllers built by Fanuc. Siemens was another market dominator in CNC controls, especially in Europe. In the 2010s, controller differences and incompatibility were mitigated with the widespread adoption of CAD/CAM applications that were capable of outputting machine operations in the appropriate G-code for a specific machine through a software tool called a post-processor (sometimes shortened to just a "post").

Syntax

G-code began as a limited language that lacked constructs such as loops, conditional operators, and programmer-declared variables with natural-word-including names (or the expressions in which to use them). It was unable to encode logic but was just a way to "connect the dots" where the programmer figured out many of the dots' locations longhand. The latest implementations of G-code include macro language capabilities somewhat closer to a high-level programming language. Additionally, all primary manufacturers (e.g., Fanuc, Siemens, Heidenhain) provide access to programmable logic controller (PLC) data, such as axis positioning data and tool data, via variables used by NC programs. These constructs make it easier to develop automation applications.

Extensions and variations

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 between each manufacturer's product.

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.

Some CNC machines use "conversational" programming, which is a 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.

See also

References

  1. Karlo Apro (2008). Secrets of 5-Axis Machining. Industrial Press Inc. ISBN 0-8311-3375-9.
  2. Xu, Xun (2009). Integrating Advanced Computer-aided Design, Manufacturing, and Numerical Control: Principles and Implementations. Information Science Reference. p. 166. ISBN 978-1-59904-716-4 – via Google Books.
  3. Harik, Ramy; Thorsten Wuest (2019). Introduction to Advanced Manufacturing. SAE International. p. 116. ISBN 978-0-7680-9096-3 – via Google Books.
  4. Evans, John M. Jr. (1976). National Bureau of Standards Information Report (NBSIR) 76-1094 (R): Standards for Computer Aided Manufacturing (PDF). National Bureau of Standards. p. 43.
  5. Schenck, John P. (January 1, 1998). "Understanding common CNC protocols". Wood & Wood Products. 103 (1). Vance Publishing: 43 – via Gale.
  6. EIA Standard RS-274-D Interchangeable Variable Block Data Format for Positioning, Contouring, and Contouring/Positioning Numerically Controlled Machines, Washington D.C.: Electronic Industries Association, February 1979
  7. Stark, J.; V. K. Nguyen (2009). "STEP-compliant CNC Systems, Present and Future Directions". In Xu, Xun; Andrew Yeh Ching Nee (eds.). Advanced Design and Manufacturing Based on STEP. Springer London. p. 216. ISBN 978-1-84882-739-4 – via Google Books.
  8. "Fanuc macro system variables". Archived from the original on 2014-05-03. Retrieved 2014-06-30.
  9. Martin., Libicki (1995). Information Technology Standards: Quest for the Common Byte. Burlington: Elsevier Science. p. 321. ISBN 978-1-4832-9248-9. OCLC 895436474.

Bibliography

External links

Metalworking
Machining and computing
Computer-aided
engineering
Drilling and
threading
Grinding and
lapping
Machining
Machine tools
Terminology
Categories: