==Programming environments==
{{Original research section|date=January 2016}}
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 ([[computer-aided design]]), CAM ([[computer-aided manufacturing]]), and richly featured G-code editors. (G-code editors are analogous to [[XML editor]]s, using colors and indents semantically [plus other features] to aid the user in ways that basic [[text editor]]s can't. CAM packages are analogous to [[integrated development environment|IDEs]] in general programming.)
[[STEP-NC]] 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 [[DAC-1]] and [[APT (programming language)|APT]]. Those efforts were fine for huge corporations like GM and Boeing. However, [[small and medium enterprises]] 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 ==
Any machine tool with a great number of axes, spindles, and tool stations is difficult to program well manually. It has been done over the years, but not easily. This challenge has existed for decades in CNC screw machine and rotary transfer programming, and it now also arises with today's newer machining centers called "turn-mills", "mill-turns", "multitasking machines", and "multifunction machines". Now that [[Computer-aided technologies|CAD/CAM]] systems are widely used, CNC programming (such as with G-code) requires CAD/CAM (as opposed to manual programming) to be practical and competitive in the market segments these classes of machines serve.<ref name="MMS_2010-12-20_CAM_Sys">{{Citation |last=MMS editorial staff |date=2010-12-20 |title=CAM system simplifies Swiss-type lathe programming |journal=Modern Machine Shop |volume=83 |issue=8 [2011 Jan] |pages=100–105 |url=http://www.mmsonline.com/articles/cam-system-simplifies-swiss-type-lathe-programming}} ''Online ahead of print.''</ref> As Smid says, "Combine all these axes with some additional features, and the amount of knowledge required to succeed is quite overwhelming, to say the least."<ref name="Smid2008p457">{{Harvnb|Smid|2008|p=457}}.</ref> At the same time, however, programmers still must thoroughly understand the principles of manual programming and must think critically and second-guess some aspects of the software's decisions.
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==
This list is only a selection and, except for a few key terms, mostly avoids duplicating the many abbreviations listed at [[engineering drawing abbreviations and symbols]].
<!--
| valign="top" | {{Visible anchor|}} || expansion ||
|-
-->
{| class="wikitable"
|-
! Abbreviation !! Expansion !! Corollary info
|-
| valign="top" | {{Visible anchor|APC}} || automatic pallet changer || See [[#M60|M60]].
|-
| valign="top" | {{Visible anchor|ATC}} || automatic tool changer || See [[#M06|M06]].
|-
| valign="top" | {{Visible anchor|CAD/CAM}} || [[computer-aided design]] and [[computer-aided manufacturing]] ||
|-
| valign="top" | {{Visible anchor|CCW}} || [[clockwise|counterclockwise]] || See [[#M04|M04]].
|-
| valign="top" | {{Visible anchor|CNC}} || [[numerical control|computerized numerical control]] ||
|-
| valign="top" | {{Visible anchor|CRC}} || [[cutter ___location|cutter radius compensation]] || See also [[#G40|G40]], [[#G41|G41]], and [[#G42|G42]].
|-
| valign="top" | {{Visible anchor|CS}} || cutting speed || Referring to [[speeds and feeds#Cutting speed|cutting speed (surface speed)]] in [[surface feet per minute]] (sfm, sfpm) or meters per minute (m/min).
|-
| valign="top" | {{Visible anchor|CSS}} || constant surface speed || See [[#G96|G96]] for explanation.
|-
| valign="top" | {{Visible anchor|CW}} || [[clockwise]] || See [[#M03|M03]].
|-
| valign="top" | {{Visible anchor|DNC}} || [[direct numerical control|direct numerical control ''or'' distributed numerical control]] || Sometimes referred to as "Drip Feeding" or "Drip Numerical Control" due to the fact that a file can be "drip" fed to a machine, line by line, over a serial protocol such as RS232. DNC allows machines with limited amounts of memory to run larger files.
|-
|DOC
|depth of cut
|Refers to how deep (in the Z direction) a given cut will be
|-
| valign="top" | {{Visible anchor|EOB}} || end of block || The G-code synonym of ''end of line (EOL)''. A [[control character]] equating to [[newline]]. In many implementations of G-code (as also, more generally, in many [[programming language]]s), a [[semicolon]] (;) is synonymous with EOB. In some controls (especially older ones) it must be explicitly typed and displayed. Other software treats it as a nonprinting/nondisplaying character, much like [[word processor|word processing apps]] treat the [[pilcrow]] (¶).
|-
| valign="top" | {{Visible anchor|E-stop}} || [[emergency stop#Industrial equipment|emergency stop]] ||
|-
| valign="top" | {{Visible anchor|EXT}} || external || On the operation panel, one of the positions of the mode switch is "external", sometimes abbreviated as "EXT", referring to any external source of data, such as tape or DNC, in contrast to the [[computer memory]] that is built into the CNC itself.
|-
| valign="top" | {{Visible anchor|FIM}} || [[total indicator reading|full indicator movement]] ||
|-
| valign="top" | {{Visible anchor|FPM}} || feet per minute || See [[#SFM|SFM]].
|-
| valign="top" | {{Visible anchor|HBM}} || horizontal boring mill || A type of machine tool that specializes in boring, typically large holes in large workpieces.
|-
| valign="top" | {{Visible anchor|HMC}} || [[milling machine|horizontal machining center]] ||
|-
| valign="top" | {{Visible anchor|HSM}} || high speed machining || Refers to machining at [[speeds and feeds|speeds]] considered high by traditional standards. Usually achieved with special geared-up spindle attachments or with the latest high-rev spindles. On modern machines HSM refers to a cutting strategy with a light, constant chip load and high feed rate, usually at or near the full depth of cut.<ref>{{Cite web|url=https://www.mmsonline.com/articles/tool-path-strategies-for-high-speed-machining|title=Tool Path Strategies For High-Speed Machining|last=Marinac|first=Dan|website=www.mmsonline.com|date=15 February 2000 |access-date=2018-03-06}}</ref>
|-
| valign="top" | {{Visible anchor|HSS}} || [[high-speed steel]] || A type of [[tool steel]] used to make cutters. Still widely used today (versatile, affordable, capable) although carbide and others continue to erode its share of commercial applications due to their higher rate of material removal.
|-
| valign="top" | {{Visible anchor|in}} || [[inch]](es) ||
|-
| valign="top" | {{Visible anchor|IPF}} || inches per flute || Also known as ''chip load'' or [[#IPT|IPT]]. See [[#F|F address]] and [[speeds and feeds#Feed rate|feed rate]].
|-
| valign="top" | {{Visible anchor|IPM}} || inches per minute || See [[#F|F address]] and [[speeds and feeds#Feed rate|feed rate]].
|-
| valign="top" | {{Visible anchor|IPR}} || inches per revolution || See [[#F|F address]] and [[speeds and feeds#Feed rate|feed rate]].
|-
| valign="top" | {{Visible anchor|IPT}} || inches per tooth || Also known as ''chip load'' or [[#IPF|IPF]]. See [[#F|F address]] and [[speeds and feeds#Feed rate|feed rate]].
|-
| valign="top" | {{Visible anchor|MDI}} || manual data input || A mode of operation in which the operator can type in lines of program (blocks of code) and then execute them by pushing cycle start.
|-
| valign="top" | {{Visible anchor|MEM}} || memory || On the operation panel, one of the positions of the mode switch is "memory", sometimes abbreviated as "MEM", referring to the [[computer memory]] that is built into the CNC itself, in contrast to any external source of data, such as tape or DNC.
|-
| valign="top" | {{Visible anchor|MFO}} || manual feed rate override || The MFO dial or buttons allow the CNC operator or machinist to multiply the programmed feed value by any percentage typically between 10% and 200%. This is to allow fine-tuning of [[speeds and feeds]] to minimize [[machining vibrations|chatter]], improve [[surface finish]], lengthen tool life, and so on. The [[#SSO|SSO]] and MFO features can be locked out for various reasons, such as for synchronization of speed and feed in threading, or even to prevent "soldiering"/"dogging" by operators. {{Anchor|Arbitrary-speed_threading}} On some newer controls, the synchronization of speed and feed in threading is sophisticated enough that SSO and MFO can be available during threading, which helps with fine-tuning speeds and feeds to reduce chatter on the threads or in repair work involving the picking up of existing threads.<ref name="Korn_2014-05-06">{{Citation |last=Korn |first=Derek |date=2014-05-06 |title=What is arbitrary speed threading? |journal=[[Modern Machine Shop]] |url=http://www.mmsonline.com/blog/post/what-is-arbitrary-speed-threading |postscript=.}}</ref>
|-
| valign="top" | {{Visible anchor|mm}} || [[millimetre]](s) ||
|-
| valign="top" | {{Visible anchor|MPG}} || [[manual pulse generator]] || Referring to the handle (handwheel) (each click of the handle generates one pulse of servo input)
|-
| valign="top" | {{Visible anchor|NC}} || [[numerical control]] ||
|-
| valign="top" | {{Visible anchor|OSS}} || oriented spindle stop || See comments at [[#M19|M19]].
|-
| valign="top" | {{Visible anchor|SFM}} || [[surface feet per minute]] || See also [[speeds and feeds]] and [[#G96|G96]].
|-
| valign="top" | {{Visible anchor|SFPM}} || [[surface feet per minute]] || See also [[speeds and feeds]] and [[#G96|G96]].
|-
| valign="top" | {{Visible anchor|SPT}} || [[Threading (manufacturing)#Single-point threading|single-point threading]] ||
|-
| valign="top" | {{Visible anchor|SSO}} || spindle speed override || The SSO dial or buttons allow the CNC operator or machinist to multiply the programmed speed value by any percentage typically between 10% and 200%. This is to allow fine-tuning of [[speeds and feeds]] to minimize [[machining vibrations|chatter]], improve [[surface finish]], lengthen tool life, and so on. The SSO and [[#MFO|MFO]] features can be locked out for various reasons, such as for synchronization of speed and feed in threading, or even to prevent "[[Scientific_management#Soldiering|soldiering"/"dogging"]] by operators. On some newer controls, the synchronization of speed and feed in threading is sophisticated enough that SSO and MFO can be available during threading, which helps with fine-tuning speeds and feeds to reduce chatter on the threads or in repair work involving the picking up of existing threads.<ref name="Korn_2014-05-06"/>
|-
| valign="top" | {{Visible anchor|TC}} or T/C || tool change, tool changer || See [[#M06|M06]].
|-
| valign="top" | {{Visible anchor|TIR}} || [[total indicator reading]] ||
|-
| valign="top" | {{Visible anchor|TPI}} || [[screw thread#Lead, pitch, and starts|threads per inch]] ||
|-
| valign="top" | {{Visible anchor|USB}} || [[Universal Serial Bus]] || One type of connection for data transfer
|-
| valign="top" | {{Visible anchor|VMC}} || [[milling machine|vertical machining center]] ||
|-
| valign="top" | {{Visible anchor|VTL}} || [[turret lathe#Vertical turret lathes|vertical turret lathe]] || A type of machine tool that is essentially a lathe with its Z-axis turned vertical, allowing the faceplate to sit like a large turntable. The VTL concept overlaps with the vertical boring mill concept.
|-
|}
==See also==
* [[3D printing]]
* [[Canned cycle]]
* [[Coordinate system]]
* [[LinuxCNC]] - a free CNC software with many resources for G-code documentation
* [[Cutter ___location]]
* [[Drill file (disambiguation)|Drill file]]
* [[Direct Numerical Control]] (DNC)
* [[Drill file (disambiguation)]]
* [[Gerber file]]
* [[HP-GL]]
* [[STLKUKA (fileRobot format)Language]]
* [[LinuxCNC]]
* [[MTConnect]]
* [[RAPID]]
* [[Slicer (3D printing)]]
* [[STEP-NC]]
* [[STL (file format)]]
== References ==
{{refs}}
===Extended developments===
*[[Direct Numerical Control]] (DNC)
*[[STEP-NC]]
*[[MTConnect]]
== Bibliography ==
===Similar concepts===
*[[Gerber file]]
===Concerns during application===
*[[Cutter ___location]], cutter compensation, offset parameters
*[[Coordinate system]]s
Industrial robot languages
* [[RAPID]]
* [[KUKA Robot Language]]
==References==
{{Reflist|30em}}
==Bibliography==
* {{MachinerysHandbook25e}}
* {{Smid2008}}
* {{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=.}}
== External links ==
* [http://carlsonmfg.com/cnc-g-code-m-code-programming CNC G-Code and M-Code Programming]
* {{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=[[NIST]] |url=https://www.nist.gov/manuscript-publication-search.cfm?pub_id=823374 |ref=none}}
{{Metalworking navbox|machopen}}
{{DEFAULTSORT:G-Code}}
[[Category:Computer-aided engineering]]
[[Category:Domain-specific programming languages]]
|