Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

3/9/2016 GcodeWikipedia,thefreeencyclopedia

Gcode
FromWikipedia,thefreeencyclopedia

Gcode(alsoRS274),whichhasmanyvariants,isthe
commonnameforthemostwidelyusednumerical Gcode
control(NC)programminglanguage.Itisusedmainlyin Paradigm Procedural,Imperative
computeraidedmanufacturingtocontrolautomated
machinetools.GcodeissometimescalledG Designedby MassachusettsInstituteof
programminglanguage,nottobeconfusedwith Technology
LabVIEW'sGprogramminglanguage. Firstappeared 1950s(firstedition)

Gcodeisalanguageinwhichpeopletellcomputerized Filename .mpt,.mpf.ncandseveralothers


machinetoolshowtomakesomething.The"how"is extensions
definedbyinstructionsonwheretomove,howfastto Majorimplementations
move,andwhatpathtomove.Themostcommon
many,mainlySiemensSinumerik,FANUC,Haas,
situationisthat,withinamachinetool,acuttingtoolis
Heidenhain,Mazak.Generallythereisone
movedaccordingtotheseinstructionsthroughatoolpath
andcutsawaymaterialtoleaveonlythefinished internationalstandardISO6983.
workpiece.Thesameconceptalsoextendstononcutting
toolssuchasformingorburnishingtools,photoplotting,additivemethodssuchas3Dprinting,and
measuringinstruments.

Contents

1 Implementations

2 Specificcodes

2.1 Letteraddresses

2.2 ListofGcodescommonlyfoundonFANUCandsimilarlydesignedcontrols

2.3 ListofMcodescommonlyfoundonFANUCandsimilarlydesignedcontrols

3 Exampleprogram

4 Programmingenvironments

5 Abbreviationsusedbyprogrammersandoperators

6 Seealso

6.1 Extendeddevelopments

6.2 Similarconcepts

https://en.wikipedia.org/wiki/Gcode 1/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

6.3 Concernsduringapplication

7 References

8 Bibliography

9 Externallinks

Implementations
ThefirstimplementationofanumericalcontrolprogramminglanguagewasdevelopedattheMIT
ServomechanismsLaboratoryinthelate1950s.Inthedecadessince,manyimplementationshavebeen
developedbymany(commercialandnoncommercial)organizations.Gcodehasoftenbeenusedinthese
implementations.ThemainstandardizedversionusedintheUnitedStateswassettledbytheElectronic
IndustriesAllianceintheearly1960s.AfinalrevisionwasapprovedinFebruary1980asRS274D.[1]In
othercountries,thestandardISO6983isoftenused,butmanyEuropeanstatesuseotherstandards.For
example,DIN66025isusedinGermany,andPN73M55256andPN93/M55251areusedinPoland.

Extensionsandvariationshavebeenaddedindependentlybycontrolmanufacturersandmachinetool
manufacturers,andoperatorsofaspecificcontrollermustbeawareofdifferencesofeachmanufacturer's
product.

OnestandardizedversionofGcode,knownasBCL,isusedonlyonveryfewmachines.

Duringthe1970sthrough1990s,manyCNCmachinetoolbuildersattemptedtoovercomecompatibility
difficultiesbystandardizingonmachinetoolcontrollersbuiltbyFanuc.Siemenswasanothermarket
dominatorinCNCcontrols,especiallyinEurope.Inthe2010s,controllerdifferencesandincompatibility
arenotastroublesomebecausemachiningoperationsaredevelopedwithCAD/CAMapplicationsthatcan
outputtheappropriateGcodeforaspecificmachinetool.

SomeCNCmachinesuse"conversational"programming,whichisawizardlikeprogrammingmodethat
eitherhidesGcodeorcompletelybypassestheuseofGcode.SomepopularexamplesareOkuma's
AdvancedOneTouch(AOT),SouthwesternIndustries'ProtoTRAK,Mazak'sMazatrol,Hurco'sUltimax,
Haas'IntuitiveProgrammingSystem(IPS),andMoriSeiki'sCAPSconversationalsoftware.

Gcodebeganasalimitedtypeoflanguagethatlackedconstructssuchasloops,conditionaloperators,and
programmerdeclaredvariableswithnaturalwordincludingnames(ortheexpressionsinwhichtouse
them).Itwasunabletoencodelogicitwasjustawayto"connectthedots"wheremanyofthedots'
locationswerefiguredoutlonghandbytheprogrammer.ThelatestimplementationsofGcodeincludesuch
constructs,creatingalanguagesomewhatclosertoahighlevelprogramminglanguage.Additionally,all
primarymanufacturers(e.g.Fanuc,Siemens,Heidenhain)provideaccesstoPLCdata,suchasaxis
positioningdataandtooldata,[2]viavariableswhichcanbeusedbyNCprograms.Theseconstructsmakeit
easiertodevelopautomationapplications.

Specificcodes
https://en.wikipedia.org/wiki/Gcode 2/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

Gcodesarealsocalledpreparatorycodes,andareanywordinaCNCprogramthatbeginswiththeletter
G.Generallyitisacodetellingthemachinetoolwhattypeofactiontoperform,suchas:

Rapidmovement(transportthetoolasquicklyaspossiblethroughspacetothelocationwhereitwill
cut)
Controlledfeedinastraightlineorarc
Seriesofcontrolledfeedmovementsthatwouldresultinaholebeingbored,aworkpiececut(routed)
toaspecificdimension,oraprofile(contour)shapeaddedtotheedgeofaworkpiece
Settoolinformationsuchasoffset
Switchcoordinatesystems

Thereareothercodesthetypecodescanbethoughtoflikeregistersinacomputer.

Studentsandhobbyistshavepointedoutovertheyearsthattheterm"Gcode"isimprecise.Itcomesfrom
theliteralsenseoftheterm,referringtooneletteraddressandtothespecificcodesthatcanbeformedwith
it(forexample,G00,G01,G28).ButeveryletteroftheEnglishalphabetisusedsomewhereinthe
language.Nevertheless,"Gcode"isestablishedasthecommonnameofthelanguage.

Letteraddresses

Someletteraddressesareusedonlyinmillingoronlyinturningmostareusedinboth.Boldbelowarethe
lettersseenmostfrequentlythroughoutaprogram.

Sources:Smid2008[3]Smid2010[4]Greenetal.1996.[5]

https://en.wikipedia.org/wiki/Gcode 3/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

Variable Description Corollaryinfo


A Absoluteorincremental
positionofAaxis
(rotationalaxisaroundX
axis)
B Absoluteorincremental
positionofBaxis
(rotationalaxisaroundY
axis)
C Absoluteorincremental
positionofCaxis
(rotationalaxisaroundZ
axis)
D Definesdiameteror
radialoffsetusedfor
cuttercompensation.D
isusedfordepthofcut
onlathes.Itisusedfor
apertureselectionand
commandson
photoplotters.
E Precisionfeedratefor
threadingonlathes
F Commonunitsaredistancepertimeformills(inchesperminute,
IPM,ormillimetersperminute,mm/min)anddistanceperrevolution
Definesfeedrate
forlathes(inchesperrevolution,IPR,ormillimetersperrevolution,
mm/rev)
G Gcommandsoftentellthecontrolwhatkindofmotioniswanted
Addressforpreparatory
(e.g.,rapidpositioning,linearfeed,circularfeed,fixedcycle)orwhat
commands
offsetvaluetouse.
H Definestoollength
offset
Incrementalaxis
correspondingtoCaxis
(e.g.,onaturnmill)
I DefinesarccenterinX
axisforG02orG03arc
commands.
Alsousedasaparameter
withinsomefixed
cycles.
J DefinesarccenterinY
axisforG02orG03arc
commands.
Alsousedasaparameter
withinsomefixed

https://en.wikipedia.org/wiki/Gcode 4/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

cycles.
K DefinesarccenterinZ
axisforG02orG03arc
commands.
Alsousedasaparameter
withinsomefixed
cycles,equaltoL
address.
L Fixedcycleloopcount:Definesnumberofrepetitions("loops")ofa
fixedcycleateachposition.Assumedtobe1unlessprogrammed
Fixedcycleloopcount withanotherinteger.SometimestheKaddressisusedinsteadofL.
Specificationofwhat Withincrementalpositioning(G91),aseriesofequallyspacedholes
registertoeditusingG10 canbeprogrammedasaloopratherthanasindividualpositions.
G10use:Specificationofwhatregistertoedit(workoffsets,tool
radiusoffsets,toollengthoffsets,etc.).

M Actioncode,auxiliarycommanddescriptionsvary.ManyMcodes
Miscellaneousfunction callformachinefunctions,whichiswhypeopleoftensaythatthe
"M"standsfor"machine",althoughitwasnotintendedto.
N Line(block)numbers:Optional,sooftenomitted.Necessaryfor
certaintasks,suchasM99Paddress(totellthecontrolwhichblock
Line(block)numberin
oftheprogramtoreturntoifnotthedefaultone)orGoTostatements
program
(ifthecontrolsupportsthose).Nnumberingneednotincrementby1
Systemparameter
(forexample,itcanincrementby10,20,or1000)andcanbeusedon
numbertobechanged
everyblockoronlyincertainspotsthroughoutaprogram.
usingG10
Systemparameternumber:G10allowschangingofsystem
parametersunderprogramcontrol.
O Forexample,O4501.FormanyyearsitwascommonforCNC
controldisplaystouseslashedzeroglyphstoensureeffortless
Programname
distinctionofletter"O"fromdigit"0".Today'sGUIcontrolsoften
haveachoiceoffonts,likeaPCdoes.
P
WithG04,definesdwelltimevalue.
Alsoservesasaparameterinsomecannedcycles,representing
Servesasparameter dwelltimesorothervariables.
addressforvariousG Alsousedinthecallingandterminationofsubprograms.(With
andMcodes M98,itspecifieswhichsubprogramtocallwithM99,it
specifieswhichblocknumberofthemainprogramtoreturn
to.)

Q Peckincrementin
Forexample,G73,G83(peckdrillingcycles)
cannedcycles
R Definessizeofarc
Forradii,notallcontrolssupporttheRaddressforG02andG03,in
radius,ordefinesretract
whichcaseIJKvectorsareused.Forretractheight,the"Rlevel",as
heightinmillingcanned
it'scalled,isreturnedtoifG99isprogrammed.
cycles
S Datatype=integer.InG97mode(whichisusuallythedefault),an
Definesspeed,either integerafterSisinterpretedasanumberofrev/min(rpm).InG96
https://en.wikipedia.org/wiki/Gcode 5/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

spindlespeedorsurface mode(CSS),anintegerafterSisinterpretedassurfacespeedsfm
speeddependingon (G20)orm/min(G21).SeealsoSpeedsandfeeds.Onmultifunction
mode (turnmillormillturn)machines,whichspindlegetstheinput(main
spindleorsubspindles)isdeterminedbyotherMcodes.
T TounderstandhowtheTaddressworksandhowitinteracts(ornot)
withM06,onemuststudythevariousmethods,suchaslatheturret
programming,ATCfixedtoolselection,ATCrandommemorytool
Toolselection selection,theconceptof"nexttoolwaiting",andemptytools.
Programmingonanyparticularmachinetoolrequiresknowingwhich
methodthatmachineuses.Waysofobtainingthistrainingare
mentionedinthecommentsforM06.
U Incrementalaxis
correspondingtoXaxis
(typicallyonlylathe
Inthesecontrols,XandUobviateG90andG91,respectively.On
groupAcontrols)
theselathes,G90isinsteadafixedcycleaddressforroughing.
Alsodefinesdwelltime
onsomemachines
(insteadof"P"or"X").
V Untilthe2000s,theVaddresswasveryrarelyused,becausemost
lathesthatusedUandWdidn'thaveaYaxis,sotheydidn'tuseV.
Incrementalaxis (Greenetal.1996[5]didnotevenlistVintheirtableofaddresses.)
correspondingtoYaxis Thatisstilloftenthecase,althoughtheproliferationoflivelathe
toolingandturnmillmachininghasmadeVaddressusagelessrare
thanitusedtobe(Smid2008[3]showsanexample).SeealsoG18.
W Incrementalaxis
correspondingtoZaxis Inthesecontrols,ZandWobviateG90andG91,respectively.On
(typicallyonlylathe theselathes,G90isinsteadafixedcycleaddressforroughing.
groupAcontrols)
X Absoluteorincremental
positionofXaxis.
Alsodefinesdwelltime
onsomemachines
(insteadof"P"or"U").
Y Absoluteorincremental
positionofYaxis
Z Absoluteorincremental Themainspindle'saxisofrotationoftendetermineswhichaxisofa
positionofZaxis machinetoolislabeledasZ.

ListofGcodescommonlyfoundonFANUCandsimilarlydesignedcontrols

Sources:Smid2008[3]Smid2010[4]Greenetal.1996.[5]

Note:Modalmeansacodestaysineffectuntilreplaced,orcancelled,byanotherpermittedcode.NonModal
meansitexecutesonlyonce.See,forexample,codesG09,G61&G64below.

https://en.wikipedia.org/wiki/Gcode 6/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

Milling Turning
Code Description Corollaryinfo
(M) (T)
G00 On2or3axismoves,G00(unlikeG01)traditionallydoes
notnecessarilymoveinasinglestraightlinebetweenstart
pointandendpoint.Itmoveseachaxisatitsmaxspeed
untilitsvectorisachieved.Shortervectorusuallyfinishes
Rapid first(givensimilaraxisspeeds).Thismattersbecauseitmay
M T
positioning yieldadoglegorhockeystickmotion,whichthe
programmerneedstoconsiderdependingonwhatobstacles
arenearby,toavoidacrash.Somemachinesoffer
interpolatedrapidsasafeatureforeaseofprogramming
(safetoassumeastraightline).
G01 Themostcommonworkhorsecodeforfeedingduringacut.
Theprogramspecsthestartandendpoints,andthecontrol
automaticallycalculates(interpolates)theintermediate
pointstopassthroughthatwillyieldastraightline(hence
"linear").Thecontrolthencalculatestheangularvelocities
Linear
M T atwhichtoturntheaxisleadscrewsviatheirservomotorsor
interpolation
steppermotors.Thecomputerperformsthousandsof
calculationspersecond,andthemotorsreactquicklyto
eachinput.Thustheactualtoolpathofthemachiningtakes
placewiththegivenfeedrateonapaththatisaccurately
lineartowithinverysmalllimits.
G02 VerysimilarinconcepttoG01.Again,thecontrol
interpolatesintermediatepointsandcommandstheservoor
steppermotorstorotatetheamountneededforthe
leadscrewtotranslatethemotiontothecorrecttooltip
positioning.Thisprocessrepeatedthousandsoftimesper
minutegeneratesthedesiredtoolpath.InthecaseofG02,
theinterpolationgeneratesacircleratherthanaline.As
withG01,theactualtoolpathofthemachiningtakesplace
withthegivenfeedrateonapaththataccuratelymatchesthe
ideal(inG02'scase,acircle)towithinverysmalllimits.In
fact,theinterpolationissoprecise(whenallconditionsare
correct)thatmillinganinterpolatedcirclecanobviate
operationssuchasdrilling,andoftenevenfineboring.
Circular
Addressesforradiusorarccenter:G02andG03take
interpolation, M T
eitheranRaddress(fortheradiusdesiredonthepart)or
clockwise
IJKaddresses(forthecomponentvectorsthatdefinethe
vectorfromthearcstartpointtothearccenterpoint).
Cuttercomp:OnmostcontrolsyoucannotstartG41or
G42inG02orG03modes.Youmustalreadyhave
compensatedinanearlierG01block.Oftenashortlinear
leadinmovementwillbeprogrammed,merelytoallow
cuttercompensationbeforethemainevent,thecircle
cutting,begins.Fullcircles:Whenthearcstartpointand
thearcendpointareidentical,a360arc,afullcircle,will
becut.(Someoldercontrolscannotsupportthisbecause
arcscannotcrossbetweenquadrantsofthecartesiansystem.
https://en.wikipedia.org/wiki/Gcode 7/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

Instead,fourquartercirclearcsareprogrammedbackto
back.)
G03 Circular
interpolation, M T SamecorollaryinfoasforG02.
counterclockwise
G04 Takesanaddressfordwellperiod(maybeX,U,orP).The
dwellperiodisspecifiedbyacontrolparameter,typically
settomilliseconds.SomemachinescanaccepteitherX1.0
(s)orP1000(ms),whichareequivalent.Choosingdwell
duration:Oftenthedwellneedsonlytolastoneortwofull
spindlerotations.Thisistypicallymuchlessthanone
Dwell M T
second.Beawarewhenchoosingadurationvaluethata
longdwellisawasteofcycletime.Insomesituationsit
won'tmatter,butforhighvolumerepetitiveproduction
(overthousandsofcycles),itisworthcalculatingthat
perhapsyouonlyneed100ms,andyoucancallit200tobe
safe,but1000isjustawaste(toolong).
G05 Highprecision Usesadeeplookaheadbufferandsimulationprocessingto
P10000 contourcontrol M providebetteraxismovementaccelerationanddeceleration
(HPCC) duringcontourmilling
G05.1 Usesadeeplookaheadbufferandsimulationprocessingto
AIAdvanced
Q1. M providebetteraxismovementaccelerationanddeceleration
PreviewControl
duringcontourmilling
G06.1 Nonuniform
ActivatesNonUniformRationalBSplineforcomplex
rationalBspline
M curveandwaveformmachining(thiscodeisconfirmedin
(NURBS)
Mazatrol640MISOProgramming)
Machining
G07 Imaginaryaxis
M
designation
G09 Exactstop
check,non M T ThemodalversionisG61.
modal
G10 Programmable
M T Modifiesthevalueofworkcoordinateandtooloffsets[6]
datainput
G11 Datawritecancel M T
G12 Fullcircle Fixedcycleforeaseofprogramming360circular
interpolation, M interpolationwithblendradiusleadinandleadout.Not
clockwise standardonFanuccontrols.
G13 Fullcircle Fixedcycleforeaseofprogramming360circular
interpolation, M interpolationwithblendradiusleadinandleadout.Not
counterclockwise standardonFanuccontrols.
G17 XYplane
M
selection
G18 OnmostCNClathes(built1960sto2000s),ZXistheonly
availableplane,sonoG17toG19codesareused.Thisis
https://en.wikipedia.org/wiki/Gcode 8/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

nowchangingastheerabeginsinwhichlivetooling,
ZXplane multitask/multifunction,andmillturn/turnmillgradually
M T
selection becomethe"newnormal".Butthesimpler,traditionalform
factorwillprobablynotdisappearitwilljustmoveoverto
makeroomforthenewerconfigurations.SeealsoV
address.
G19 YZplane
M
selection
G20 SomewhatuncommonexceptinUSAand(tolesserextent)
CanadaandUK.However,intheglobalmarketplace,
competencewithbothG20andG21alwaysstandssome
chanceofbeingnecessaryatanytime.Theusualminimum
Programmingin
M T incrementinG20isonetenthousandthofaninch
inches
(0.0001"),whichisalargerdistancethantheusual
minimumincrementinG21(onethousandthofamillimeter,
.001mm,thatis,onemicrometre).Thisphysicaldifference
sometimesfavorsG21programming.
G21 Programmingin Prevalentworldwide.However,intheglobalmarketplace,
millimeters M T competencewithbothG20andG21alwaysstandssome
(mm) chanceofbeingnecessaryatanytime.
G28 Returntohome
TakesXYZaddresseswhichdefinetheintermediatepoint
position
thatthetooltipwillpassthroughonitswayhometo
(machinezero, M T
machinezero.Theyareintermsofpartzero(akaprogram
akamachine
zero),NOTmachinezero.
referencepoint)
G30 Returnto TakesaPaddressspecifyingwhichmachinezeropointis
secondaryhome desired,ifthemachinehasseveralsecondarypoints(P1to
position P4).TakesXYZaddresseswhichdefinetheintermediate
M T
(machinezero, pointthatthetooltipwillpassthroughonitswayhometo
akamachine machinezero.Theyareintermsofpartzero(akaprogram
referencepoint) zero),NOTmachinezero.
G31 Skipfunction
(usedforprobes
andtoollength M
measurement
systems)
G32 Singlepoint
threading,
SimilartoG01linearinterpolation,exceptwithautomatic
longhandstyle T
spindlesynchronizationforsinglepointthreading.
(ifnotusinga
cycle,e.g.,G76)
G33 Constantpitch
M
threading
G33 Singlepoint
threading,
SomelathecontrolsassignthismodetoG33ratherthan
longhandstyle T
G32.
(ifnotusinga
https://en.wikipedia.org/wiki/Gcode 9/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

cycle,e.g.,G76)
G34 Variablepitch
M
threading
G40 Toolradius Turnoffcutterradiuscompensation(CRC).CancelsG41or
M T
compensationoff G42.
G41 Turnoncutterradiuscompensation(CRC),left,forclimb
milling.
Milling:GivenrighthandhelixcutterandM03spindle
direction,G41correspondstoclimbmilling(downmilling).
Takesanaddress(DorH)thatcallsanoffsetregistervalue
forradius.
Turning:OftenneedsnoDorHaddressonlathes,because
whatevertoolisactiveautomaticallycallsitsgeometry
offsetswithit.(Eachturretstationisboundtoitsgeometry
offsetregister.)

G41andG42formillinghasbeenpartiallyautomatedand
obviated(althoughnotcompletely)sinceCAM
Toolradius programminghasbecomemorecommon.CAMsystems
compensation M T allowtheusertoprogramasifwithazerodiametercutter.
left Thefundamentalconceptofcutterradiuscompensationis
stillinplay(i.e.,thatthesurfaceproducedwillbedistance
Rawayfromthecuttercenter),buttheprogramming
mindsetisdifferentthehumandoesnotchoreographthe
toolpathwithconscious,painstakingattentiontoG41,G42,
andG40,becausetheCAMsoftwaretakescareofit.The
softwarehasvariousCRCmodeselections,suchas
computer,control,wear,reversewear,off,someofwhich
donotuseG41/G42atall(goodforroughing,orwidefinish
tolerances),andotherswhichuseitsothatthewearoffset
canstillbetweakedatthemachine(betterfortightfinish
tolerances).

G42 Turnoncutterradiuscompensation(CRC),right,for
Toolradius
conventionalmilling.SimilarcorollaryinfoasforG41.
compensation M T
GivenrighthandhelixcutterandM03spindledirection,
right
G42correspondstoconventionalmilling(upmilling).
G43 Toolheight Takesanaddress,usuallyH,tocallthetoollengthoffset
offset registervalue.Thevalueisnegativebecauseitwillbe
M
compensation addedtothegaugelineposition.G43isthecommonlyused
negative version(vsG44).
G44 Toolheight Takesanaddress,usuallyH,tocallthetoollengthoffset
offset registervalue.Thevalueispositivebecauseitwillbe
M
compensation subtractedfromthegaugelineposition.G44istheseldom
positive usedversion(vsG43).
G45 Axisoffset
M
https://en.wikipedia.org/wiki/Gcode 10/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

singleincrease
G46 Axisoffset
M
singledecrease
G47 Axisoffset
M
doubleincrease
G48 Axisoffset
M
doubledecrease
G49 Toollength
offset
M CancelsG43orG44.
compensation
cancel
G50 TakesanSaddressintegerwhichisinterpretedasrpm.
Definethe
Withoutthisfeature,G96mode(CSS)wouldrevthespindle
maximum T
to"wideopenthrottle"whencloselyapproachingtheaxisof
spindlespeed
rotation.
G50 Scalingfunction
cancel M

G50 Positionregisterisoneoftheoriginalmethodstorelatethe
part(program)coordinatesystemtothetoolposition,which
indirectlyrelatesittothemachinecoordinatesystem,the
onlypositionthecontrolreally"knows".Notcommonly
programmedanymorebecauseG54toG59(WCSs)area
better,newermethod.CalledviaG50forturning,G92for
Positionregister
milling.ThoseGaddressesalsohavealternatemeanings
(programmingof
T (whichsee).Positionregistercanstillbeusefulfordatum
vectorfrompart
shiftprogramming.The"manualabsolute"switch,which
zerototooltip)
hasveryfewusefulapplicationsinWCScontexts,wasmore
usefulinpositionregistercontexts,becauseitallowedthe
operatortomovethetooltoacertaindistancefromthepart
(forexample,bytouchingoffa2.0000"gage)andthen
declaretothecontrolwhatthedistancetogoshallbe
(2.0000).
G52 Temporarilyshiftsprogramzerotoanewlocation.Itis
simply"anoffsetfromanoffset",thatis,anadditionaloffset
addedontotheWCSoffset.Thissimplifiesprogrammingin
somecases.Thetypicalexampleismovingfromparttopart
inamultipartsetup.WithG54active,G52X140.0Y170.0
shiftsprogramzero140mmoverinXand170mmoverin
Localcoordinate Y.Whenthepart"overthere"isdone,G52X0Y0returns
M
system(LCS) programzerotonormalG54(byreducingG52offsetto
nothing).Thesameresultcanalsobeachieved(1)using
multipleWCSorigins,G54/G55/G56/G57/G58/G59(2)on
newercontrols,G54.1P1/P2/P3/etc.(allthewayuptoP48)
or(3)usingG10forprogrammabledatainput,inwhichthe
programcanwritenewoffsetvaluestotheoffsetregisters.
Whichmethodtousedependsonshopspecificapplication.

https://en.wikipedia.org/wiki/Gcode 11/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

G53 Machine Takesabsolutecoordinates(X,Y,Z,A,B,C)withreferenceto


coordinate M T machinezeroratherthanprogramzero.Canbehelpfulfor
system toolchanges.Nonmodalandabsoluteonly.Subsequent
blocksareinterpretedas"backtoG54"evenifitisnot
explicitlyprogrammed.
G54to Havelargelyreplacedpositionregister(G50andG92).Each
G59 Workcoordinate tupleofaxisoffsetsrelatesprogramzerodirectlytomachine
M T
systems(WCSs) zero.Standardis6tuples(G54toG59),withoptional
extensibilityto48moreviaG54.1P1toP48.
G54.1 Upto48moreWCSsbesidesthe6providedasstandardby
P1to Extendedwork G54toG59.NotefloatingpointextensionofGcodedata
P48 coordinate M T type(formerlyallintegers).Otherexampleshavealso
systems evolved(e.g.,G84.2).Moderncontrolshavethehardwareto
handleit.
G61 Exactstop
M T CanbecanceledwithG64.ThenonmodalversionisG09.
check,modal
G62 Automatic
M T
corneroverride
G64 Defaultcutting
mode(cancel
M T CancelsG61.
exactstopcheck
mode)
G70 Fixedcycle,
multiple
repetitivecycle,
T
forfinishing
(including
contours)
G71 Fixedcycle,
multiple
repetitivecycle, T
forroughing(Z
axisemphasis)
G72 Fixedcycle,
multiple
repetitivecycle, T
forroughing(X
axisemphasis)
G73 Fixedcycle,
multiple
repetitivecycle,
T
forroughing,
withpattern
repetition
G73 Peckdrilling
cycleformilling
Retractsonlyasfarasaclearanceincrement(system
highspeed
https://en.wikipedia.org/wiki/Gcode 12/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

(NOfull M parameter).Forwhenchipbreakingisthemainconcern,but
retractionfrom chipcloggingofflutesisnot.CompareG83.
pecks)

G74 Peckdrilling
T
cycleforturning
G74 Tappingcycle
formilling,
lefthandthread, M SeenotesatG84.
M04spindle
direction

G75 Peckgrooving
T
cycleforturning
G76 Fineboringcycle IncludesOSSandshift(orientedspindlestopandshifttool
M
formilling offcenterlineforretraction)
G76 Threadingcycle
forturning,
T
multiple
repetitivecycle
G80 Milling:CancelsallcyclessuchasG73,G81,G83,etc.Z
axisreturnseithertoZinitiallevelorRlevel,as
Cancelcanned programmed(G98orG99,respectively).
M T
cycle Turning:Usuallynotneededonlathes,becauseanew
group1Gaddress(G00toG03)cancelswhatevercyclewas
active.
G81 Simpledrilling
M Nodwellbuiltin
cycle
G82 Dwellsatholebottom(Zdepth)forthenumberof
millisecondsspecifiedbythePaddress.Goodforwhenhole
Drillingcycle
M bottomfinishmatters.Goodforspotdrillingbecausethe
withdwell
divotwillbecertaintocleanupevenly.Considerthe
"choosingdwellduration"noteatG04.
G83 Peckdrilling
cycle(full ReturnstoRlevelaftereachpeck.Goodforclearingflutes
M
retractionfrom ofchips.CompareG73.
pecks)
G84 Tappingcycle,
G74andG84aretherighthandandlefthand"pair"forold
righthandthread,
M schooltappingwithanonrigidtoolholder("tappinghead"
M03spindle
style).Comparetherigidtapping"pair",G84.2andG84.3.
direction
G84.2 SeenotesatG84.Rigidtappingsynchronizesspeedand
Tappingcycle, feedaccordingtothedesiredthreadhelix.Thatis,it
righthandthread, synchronizesdegreesofspindlerotationwithmicronsof
M03spindle M axialtravel.Thereforeitcanusearigidtoolholdertohold
direction,rigid thetap.Thisfeatureisnotavailableonoldmachinesor
toolholder newerlowendmachines,whichmustuse"tappinghead"
https://en.wikipedia.org/wiki/Gcode 13/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

motion(G74/G84).
G84.3 Tappingcycle,
lefthandthread,
M04spindle M SeenotesatG84andG84.2.
direction,rigid
toolholder
G85
Goodcycleforareamer.
Insomecasesgoodforsinglepointboringtool,
boringcycle, althoughinothercasesthelackofdepthofcutonthe
M
feedin/feedout waybackoutisbadforsurfacefinish,inwhichcase,
G76(OSS/shift)canbeusedinstead.
Ifneeddwellatholebottom,seeG89.

G86 boringcycle, Boringtoolwillleaveaslightscoremarkonthewayback


feedin/spindle M out.Appropriatecycleforsomeapplicationsforothers,
stop/rapidout G76(OSS/shift)canbeusedinstead.
G87 Forbackboring.Returnstoinitiallevelonly(G98)this
boringcycle,
M cyclecannotuseG99becauseitsRlevelisonthefarsideof
backboring
thepart,awayfromthespindleheadstock.
G88 boringcycle,
feedin/spindle
stop/manual M
operation
G89 boringcycle,
feed M G89islikeG85butwithdwelladdedatbottomofhole.
in/dwell/feedout
G90 Positioningdefinedwithreferencetopartzero.
Milling:Alwaysasabove.
Turning:Sometimesasabove(FanucgrouptypeBand
similarlydesigned),butonmostlathes(FanucgrouptypeA
Absolute
M T(B) andsimilarlydesigned),G90/G91arenotusedfor
programming
absolute/incrementalmodes.Instead,UandWarethe
incrementaladdressesandXandZaretheabsolute
addresses.Ontheselathes,G90isinsteadafixedcycle
addressforroughing.
G90 Fixedcycle,
simplecycle,for
T(A) Whennotservingforabsoluteprogramming(above)
roughing(Zaxis
emphasis)
G91 Positioningdefinedwithreferencetopreviousposition.
Milling:Alwaysasabove.
Turning:Sometimesasabove(FanucgrouptypeBand
similarlydesigned),butonmostlathes(FanucgrouptypeA
Incremental
M T(B) andsimilarlydesigned),G90/G91arenotusedfor
programming
absolute/incrementalmodes.Instead,UandWarethe
incrementaladdressesandXandZaretheabsolute
https://en.wikipedia.org/wiki/Gcode 14/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

addresses.Ontheselathes,G90isafixedcycleaddressfor
roughing.
G92 SamecorollaryinfoasatG50positionregister.
Positionregister Milling:Alwaysasabove.
(programmingof Turning:Sometimesasabove(FanucgrouptypeBand
M T(B)
vectorfrompart similarlydesigned),butonmostlathes(FanucgrouptypeA
zerototooltip) andsimilarlydesigned),positionregisterisG50.

G92 Threadingcycle,
T(A)
simplecycle
G94 Feedrateper
M T(B) OngrouptypeAlathes,feedrateperminuteisG98.
minute
G94 Fixedcycle,
simplecycle,for
T(A) Whennotservingforfeedrateperminute(above)
roughing(Xaxis
emphasis)
G95 Feedrateper
M T(B) OngrouptypeAlathes,feedrateperrevolutionisG99.
revolution
G96 Variesspindlespeedautomaticallytoachieveaconstant
Constantsurface surfacespeed.Seespeedsandfeeds.TakesanSaddress
T
speed(CSS) integer,whichisinterpretedassfminG20modeoras
m/mininG21mode.
G97 TakesanSaddressinteger,whichisinterpretedasrev/min
Constantspindle
M T (rpm).Thedefaultspeedmodepersystemparameterifno
speed
modeisprogrammed.
G98 Returntoinitial
Zlevelincanned M
cycle
G98 Feedrateper
minute(group T(A) FeedrateperminuteisG94ongrouptypeB.
typeA)
G99 ReturntoRlevel
M
incannedcycle
G99 Feedrateper
revolution T(A) FeedrateperrevolutionisG95ongrouptypeB.
(grouptypeA)

ListofMcodescommonlyfoundonFANUCandsimilarlydesignedcontrols

Sources:Smid2008[3]Smid2010[4]Greenetal.1996.[5]

https://en.wikipedia.org/wiki/Gcode 15/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

Milling Turning
Code Description Corollaryinfo
(M) (T)
M00 Nonoptionalmachinewillalwaysstopuponreaching
Compulsorystop M T
M00intheprogramexecution.
M01 MachinewillonlystopatM01ifoperatorhaspushedthe
Optionalstop M T
optionalstopbutton.
M02 Programendsexecutionmayormaynotreturntoprogram
top(dependingonthecontrol)mayormaynotreset
registervalues.M02wastheoriginalprogramendcode,
Endofprogram M T nowconsideredobsolete,butstillsupportedforbackward
compatibility.[7]ManymoderncontrolstreatM02as
equivalenttoM30.[7]SeeM30foradditionaldiscussionof
controlstatusuponexecutingM02orM30.
M03 ThespeedofthespindleisdeterminedbytheaddressS,in
eitherrevolutionsperminute(G97modedefault)orsurface
feetperminuteor[surface]metersperminute(G96mode
[CSS]undereitherG20orG21).Therighthandrulecanbe
usedtodeterminewhichdirectionisclockwiseandwhich
directioniscounterclockwise.
Spindleon
(clockwise M T Righthandhelixscrewsmovinginthetighteningdirection
rotation)
(andrighthandhelixflutesspinninginthecutting
direction)aredefinedasmovingintheM03direction,and
arelabeled"clockwise"byconvention.TheM03direction
isalwaysM03regardlessoflocalvantagepointandlocal
CW/CCWdistinction.

M04 Spindleon
(counterclockwise M T SeecommentaboveatM03.
rotation)
M05 Spindlestop M T
M06 ManylathesdonotuseM06becausetheTaddressitself
indexestheturret.
Programmingonanyparticularmachinetoolrequires
knowingwhichmethodthatmachineuses.Tounderstand
howtheTaddressworksandhowitinteracts(ornot)with
M06,onemuststudythevariousmethods,suchaslathe
T turretprogramming,ATCfixedtoolselection,ATCrandom
Automatictool
M (some memorytoolselection,theconceptof"nexttoolwaiting",
change(ATC)
times)
andemptytools.Theseconceptsaretaughtintextbooks
suchasSmid,[3]andonlinemultimedia(videos,simulators,
etc.)alloftheseteachingresourcesareusuallypaywalled
topaybackthecostsoftheirdevelopment.Theyareusedin
trainingclassesforoperators,bothonsiteandremotely
(e.g.,ToolingUniversity).
M07 Coolanton(mist) M T

https://en.wikipedia.org/wiki/Gcode 16/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

M08 Coolanton M T
(flood)
M09 Coolantoff M T
M10 Palletclampon M Formachiningcenterswithpalletchangers
M11 Palletclampoff M Formachiningcenterswithpalletchangers
M13 Spindleon ThisoneMcodedoestheworkofbothM03andM08.Itis
(clockwise notunusualforspecificmachinemodelstohavesuch
M
rotation)and combinedcommands,whichmakeforshorter,morequickly
coolanton(flood) writtenprograms.
M19 Spindleorientationismoreoftencalledwithincycles
(automatically)orduringsetup(manually),butitisalso
availableunderprogramcontrolviaM19.Theabbreviation
OSS(orientedspindlestop)maybeseeninreferencetoan
orientedstopwithincycles.

Therelevanceofspindleorientationhasincreasedas
technologyhasadvanced.Although4and5axiscontour
millingandCNCsinglepointinghavedependedonspindle
positionencodersfordecades,beforetheadventof
widespreadlivetoolingandmillturn/turnmillsystems,it
wasseldomrelevantin"regular"(non"special")machining
fortheoperator(asopposedtothemachine)toknowthe
Spindle angularorientationofaspindleexceptforwithinafew
M T restrictedcontexts(suchastoolchange,orG76fineboring
orientation
cycleswithchoreographedtoolretraction).Mostmillingof
featuresindexedaroundaturnedworkpiecewas
accomplishedwithseparateoperationsonindexinghead
setupsinasense,indexingheadswereinventedasseparate
piecesofequipment,tobeusedinseparateoperations,
whichcouldprovideprecisespindleorientationinaworld
whereitotherwisemostlydidn'texist(anddidn'tneedto).
ButasCAD/CAMandmultiaxisCNCmachiningwith
multiplerotarycutteraxesbecomesthenorm,evenfor
"regular"(non"special")applications,machinistsnow
frequentlycareaboutsteppingjustaboutanyspindle
throughits360withprecision.

M21 Mirror,Xaxis M
M21 Tailstockforward T
M22 Mirror,Yaxis M
Tailstock
M22 T
backward
M23 MirrorOFF M
Threadgradual
M23 T
pulloutON
https://en.wikipedia.org/wiki/Gcode 17/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

M24 Threadgradual T
pulloutOFF
M30 TodayM30isconsideredthestandardprogramendcode,
andwillreturnexecutiontothetopoftheprogram.Today
mostcontrolsalsostillsupporttheoriginalprogramend
code,M02,usuallybytreatingitasequivalenttoM30.
Additionalinfo:CompareM02withM30.First,M02was
created,inthedayswhenthepunchedtapewasexpectedto
Endofprogram, beshortenoughtobesplicedintoacontinuousloop(which
withreturnto M T iswhyonoldcontrols,M02triggerednotaperewinding).[7]
programtop Theotherprogramendcode,M30,wasaddedlaterto
accommodatelongerpunchedtapes,whichwerewoundon
areelandthusneededrewindingbeforeanothercyclecould
start.[7]Onmanynewercontrols,thereisnolongera
differenceinhowthecodesareexecutedbothactlike
M30.

M41 Gearselect
T
gear1
M42 Gearselect
T
gear2
M43 Gearselect
T
gear3
M44 Gearselect
T
gear4
M48 Feedrateoverride
M T
allowed
M49 PreventMFO.Thisruleisalsousuallycalled
(automatically)withintappingcyclesorsinglepoint
Feedrateoverride threadingcycles,wherefeedispreciselycorrelatedto
M T
NOTallowed speed.Samewithspindlespeedoverride(SSO)andfeed
holdbutton.SomecontrolsarecapableofprovidingSSO
andMFOduringthreading.
M52 UnloadLasttool M T Alsoemptyspindle.
fromspindle
M60 Automaticpallet
M Formachiningcenterswithpalletchangers
change(APC)
M98 TakesanaddressPtospecifywhichsubprogramtocall,for
Subprogramcall M T
example,"M98P8979"callssubprogramO8979.
M99 Usuallyplacedatendofsubprogram,whereitreturns
executioncontroltothemainprogram.Thedefaultisthat
controlreturnstotheblockfollowingtheM98callinthe
Subprogramend M T mainprogram.Returntoadifferentblocknumbercanbe
specifiedbyaPaddress.M99canalsobeusedinmain
programwithblockskipforendlessloopofmainprogram
onbarworkonlathes(untiloperatortogglesblockskip).
https://en.wikipedia.org/wiki/Gcode 18/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

Exampleprogram
ThisisagenericprogramthatdemonstratestheuseofGCodetoturna
1"diameterX1"longpart.Assumethatabarofmaterialisinthe
machineandthatthebarisslightlyoversizedinlengthanddiameter
andthatthebarprotrudesbymorethan1"fromthefaceofthechuck.
(Caution:Thisisgeneric,itmightnotworkonanyrealmachine!Pay
particularattentiontopoint5below.)

ToolPathforprogram

https://en.wikipedia.org/wiki/Gcode 19/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

Sample
Block Code Description
Signalsstartofdataduringfiletransfer.Originallyusedtostoptape
% rewind,notnecessarilystartofprogram.Forsomecontrols(FANUC)the
firstLF(EOB)isstartofprogram.ISOuses%,EIAusesER(0x0B).
O4968(OPTIONAL
PROGRAM
Samplefaceandturnprogram.Commentsareenclosedinparentheses.
DESCRIPTIONOR
COMMENT)
N01 M216 Turnonloadmonitor
G20G90G54D200 Inchunits.Absolutemode.Activateworkoffset.Activatetooloffset.
N02
G40 Deactivatetoolnoseradiuscompensation.
Setmaximumspindlespeedinrev/minThissettingwillaffect
N03 G50S2000
ConstantSurfaceSpeedmode
N04 T0300 Indexturrettotool3.Clearwearoffset(00).
Constantsurfacespeed[automaticallyvariesthespindlespeed],854sfm,
N05 G96S854M03
startspindleCWrotation
Enablecutterradiuscompensationmode,rapidpositionto1.1"above
G41G00X1.1Z1.1
N06 axialcenterlineand1.1inchespositivefromtheworkoffset,activate
T0303M8
floodcoolant
Feedinhorizontallyuntilthetoolispositioned1"positivefromthework
N07 G01Z1.0F.05
offset
Feedthetoolslightlypastcenter,youneedtotravelatleastthenose
N08 X0.016 radiusofthetoolpastthecenterofthepartortherewillbeascallopof
materialleftover.
N09 G00Z1.1 Rapidpositioningretracttostartposition
N10 X1.0 Rapidpositioningnextpass
Feedinhorizontallycuttingthebarto1"diameterallthewaytothe
N11 G01Z0.0F.05
datum,0.05in/rev
N12 G00X1.1M05M09 Clearthepart,stopthespindle,turnoffthecoolant
N13 G91G28X0 HomeXaxisreturnthemachine'shomepositionfortheXaxis
N14 G91G28Z0 HomeZaxisreturntomachine'shomepositionfortheZaxis
N15 G90 Returntoabsolutemode.Turnoffloadmonitor
N16 M30 Programstop,rewindtotopofprogram,waitforcyclestart
Signalendofdataduringfiletransfer.Originallyusedtomarkendof
%
tape,notnecessarilyendofprogram.ISOuses%,EIAusesER(0x0B).

Severalpointstonote:

1.Thereisroomforsomeprogrammingstyle,eveninthisshortprogram.Thegroupingofcodesinline
N06couldhavebeenputonmultiplelines.Doingsomayhavemadeiteasiertofollowprogram
execution.

https://en.wikipedia.org/wiki/Gcode 20/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

2.Manycodesare"modal",meaningthattheystayineffectuntiltheyarecancelledorreplacedbya
contradictorycode.Forexample,oncevariablespeedcutting(CSS)hadbeenselected(G96),it
stayedineffectuntiltheendoftheprogram.Inoperation,thespindlespeedwouldincreaseasthe
toolnearedthecenteroftheworkinordertomaintainaconstantsurfacespeed.Similarly,oncerapid
feedwasselected(G00),alltoolmovementswouldberapiduntilafeedratecode(G01,G02,G03)
wasselected.
3.ItiscommonpracticetousealoadmonitorwithCNCmachinery.Theloadmonitorwillstopthe
machineifthespindleorfeedloadsexceedapresetvaluethatissetduringthesetupoperation.The
jobsoftheloadmonitorarevarious:
1.Preventmachinedamageintheeventoftoolbreakageoraprogrammingmistake.
1.Thisisespeciallyimportantbecauseitallowssafe"lightsoutmachining",inwhichthe
operatorssetupthejobandstartitrunningduringtheday,thengohomeforthenight,
leavingthemachinesrunningandcuttingpartsduringthenight.Becausenohumanis
aroundtohear,see,orsmellaproblemsuchasabrokentool,theloadmonitorservesan
importantsentryduty.Whenitsensesoverloadcondition,whichsemanticallysuggestsa
dullorbrokentool,itcommandsastoptothemachining.Technologyisavailable
nowadaystosendanalerttosomeoneremotely(e.g.,thesleepingowner,operator,or
owneroperator)ifdesired,whichcanallowthemtocomeintercedeandgetproduction
goingagain,thenleaveoncemore.Thiscanbethedifferencebetweenprofitabilityor
lossonsomejobs,becauselightsoutmachiningreduceslaborhoursperpart.
2.Warnofatoolthatisbecomingdullandneedstobereplacedorsharpened.Thusanoperator
whoisbusytendingmultiplemachineswillbetoldbyamachine,essentially,"Hey,pausewhat
you'redoingoverthere,andcomeattendtoaneedoverhere."
4.Itiscommonpracticetobringthetoolinrapidlytoa"safe"pointthatisclosetothepartinthis
case0.1"awayandthenstartfeedingthetool.Howclosethat"safe"distanceis,dependsonthe
preferenceoftheprogrammerand/oroperatorandthemaximummaterialconditionfortherawstock.
5.Iftheprogramiswrong,thereisahighprobabilitythatthemachinewillcrash,orramthetoolinto
thepartunderhighpower.Thiscanbecostly,especiallyinnewermachiningcenters.Itispossibleto
interspersetheprogramwithoptionalstops(M01code)whichallowtheprogramtoberunpiecemeal
fortestingpurposes.Theoptionalstopsremainintheprogrambuttheyareskippedduringthenormal
runningofthemachine.Fortunately,mostCAD/CAMsoftwareshipswithCNCsimulatorsthatwill
displaythemovementofthetoolastheprogramexecutes.Nowadaysthesurroundingobjects(chuck,
clamps,fixture,tailstock,andmore)areincludedinthe3Dmodels,andthesimulationismuchlike
anentirevideogameorvirtualrealityenvironment,makingunexpectedcrashesmuchlesslikely.
ManymodernCNCmachinesalsoallowprogrammerstoexecutetheprograminasimulationmode
andobservetheoperatingparametersofthemachineataparticularexecutionpoint.Thisenables
programmerstodiscoversemanticerrors(asopposedtosyntaxerrors)beforelosingmaterialortools
toanincorrectprogram.Dependingonthesizeofthepart,waxblocksmaybeusedfortesting
purposesaswell.
6.Foreducationalpurposes,linenumbershavebeenincludedintheprogramabove.Theyareusually
notnecessaryforoperationofamachine,sotheyareseldomusedinindustry.However,ifbranching
orloopingstatementsareusedinthecode,thenlinenumbersmaywellbeincludedasthetargetof
thosestatements(e.g.GOTON99).
7.SomemachinesdonotallowmultipleMcodesinthesameline.

Programmingenvironments
Gcode'sprogrammingenvironmentshaveevolvedinparallelwiththoseofgeneralprogrammingfrom
theearliestenvironments(e.g.,writingaprogramwithapencil,typingitintoatapepuncher)tothelatest
environmentsthatcombineCAD(computeraideddesign),CAM(computeraidedmanufacturing),and
https://en.wikipedia.org/wiki/Gcode 21/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

richlyfeaturedGcodeeditors.(GcodeeditorsareanalogoustoXMLeditors,usingcolorsandindents
semantically[plusotherfeatures]toaidtheuserinwaysthatbasictexteditorscan't.CAMpackagesare
analogoustoIDEsingeneralprogramming.)

Twohighlevelparadigmshiftshavebeen(1)abandoning"manualprogramming"(withnothingbuta
pencilortexteditorandahumanmind)forCAMsoftwaresystemsthatgenerateGcodeautomaticallyvia
postprocessors(analogoustothedevelopmentofvisualtechniquesingeneralprogramming),and(2)
abandoninghardcodedconstructsforparametricones(analogoustothedifferenceingeneralprogramming
betweenhardcodingaconstantintoanequationversusdeclaringitavariableandassigningnewvaluestoit
atwillandtotheobjectorientedapproachingeneral).Macro(parametric)CNCprogramminguses
humanfriendlyvariablenames,relationaloperators,andloopstructuresmuchasgeneralprogramming
does,tocaptureinformationandlogicwithmachinereadablesemantics.WhereasoldermanualCNC
programmingcouldonlydescribeparticularinstancesofpartsinnumericform,macroprogramming
describesabstractionswhichcanbeflowedwitheaseintoawidevarietyofinstances.Thedifferencehas
manyanalogues,bothfrombeforethecomputingeraandfromafteritsadvent,suchas(1)creatingtextas
bitmapsversususingcharacterencodingwithglyphs(2)theabstractionleveloftabulatedengineering
drawings,withmanypartdashnumbersparametricallydefinedbytheonesamedrawingandaparameter
tableor(3)thewaythatHTMLpassedthroughaphaseofusingcontentmarkupforpresentationpurposes,
thenmaturedtowardtheCSSmodel.Inallofthesecases,ahigherlayerofabstractionwasintroducedin
ordertopursuewhatwasmissingsemantically.

STEPNCreflectsthesametheme,whichcanbeviewedasyetanotherstepalongapaththatstartedwith
thedevelopmentofmachinetools,jigsandfixtures,andnumericalcontrol,whichallsoughtto"buildthe
skillintothetool".RecentdevelopmentsofGcodeandSTEPNCaimtobuildtheinformationand
semanticsintothetool.Theideaitselfisnotnewfromthebeginningofnumericalcontrol,theconceptof
anendtoendCAD/CAMenvironmentwasthegoalofsuchearlytechnologiesasDAC1andAPT.Those
effortswerefineforhugecorporationslikeGMandBoeing.However,forsmallandmediumenterprises,
therehadtobeanerainwhichthesimplerimplementationsofNC,withrelativelyprimitive"connectthe
dots"Gcodeandmanualprogramming,ruledthedayuntilCAD/CAMcouldimproveanddisseminate
throughouttheeconomy.

Anymachinetoolwithagreatnumberofaxes,spindles,andtoolstationsisdifficulttoprogramwell
manually.Ithasbeendoneovertheyears,butnoteasily.ThischallengehasexistedfordecadesinCNC
screwmachineandrotarytransferprogramming,anditnowalsoariseswithtoday'snewermachining
centerscalled"turnmills","millturns","multitaskingmachines",and"multifunctionmachines".Nowthat
CAD/CAMsystemsarewidelyused,CNCprogramming(suchaswithGcode)requiresCAD/CAM(as
opposedtomanualprogramming)tobepracticalandcompetitiveinthemarketsegmentsservedbythese
classesofmachines.[8]AsSmidsays,"Combinealltheseaxeswithsomeadditionalfeatures,andthe
amountofknowledgerequiredtosucceedisquiteoverwhelming,tosaytheleast."[9]Atthesametime,
however,programmersstillmustthoroughlyunderstandtheprinciplesofmanualprogrammingandmust
thinkcriticallyandsecondguesssomeaspectsofthesoftware'sdecisions.

Sinceaboutthemid2000s,theerahasfinallyarrivedwhen"thedeathofmanualprogramming"(thatis,of
writinglinesofGcodewithoutCAD/CAMassistance)sometimesseemstobeapproaching.However,itis
currentlyonlyinsomecontextsthatmanualprogrammingisobsolete.Althoughitistruethatplentyof
CAMprogrammingcananddoestakeplacenowadaysamongpeoplewhoarerustyon,orincapableof,
manualprogramming,itisnottruethatallCNCprogrammingcanbedone,ordoneaswellorasefficiently,

https://en.wikipedia.org/wiki/Gcode 22/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

withoutbeingabletospeakthelanguageofGcode.[10][11]TailoringandrefiningtheCNCprogramatthe
machineisanareaofpracticewhereitcanbeeasierormoreefficienttoedittheGcodedirectlyratherthan
editingtheCAMtoolpathsandrepostprocessingtheprogram.

Abbreviationsusedbyprogrammersandoperators
Thislistisonlyaselectionand,exceptforafewkeyterms,mostlyavoidsduplicatingthemany
abbreviationslistedatengineeringdrawingabbreviationsandsymbols(whichseealso).

https://en.wikipedia.org/wiki/Gcode 23/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

Abbreviation Expansion Corollaryinfo


APC automaticpallet
SeeM60.
changer
ATC automatictool
SeeM06.
changer
CAD/CAM computeraided
designand

computeraided
manufacturing
CCW counterclockwise SeeM04.
CNC computer
numerical
control
CRC cutterradius
SeealsoG40,G41,andG42.
compensation
CS Referringtocuttingspeed(surfacespeed)insurfacefeetperminute
cuttingspeed
(sfm,sfpm)ormetersperminute(m/min).
CSS constantsurface
SeeG96forexplanation.
speed
CW clockwise SeeM03.
DNC directnumerical
controlor
distributed
numerical
control
EOB TheGcodesynonymofendofline(EOL).Acontrolcharacterequating
tonewline.InmanyimplementationsofGcode(asalso,moregenerally,
inmanyprogramminglanguages),asemicolon()issynonymouswith
endofblock
EOB.Insomecontrols(especiallyolderones)itmustbeexplicitlytyped
anddisplayed.Othersoftwaretreatsitasanonprinting/nondisplaying
character,muchlikewordprocessingappstreatthepilcrow().
Estop emergencystop
EXT Ontheoperationpanel,oneofthepositionsofthemodeswitchis
"external",sometimesabbreviatedas"EXT",referringtoanyexternal
external
sourceofdata,suchastapeorDNC,incontrasttothecomputermemory
thatisbuiltintotheCNCitself.
FIM fullindicator

movement
FPM feetperminute SeeSFM.
HBM horizontalboring Atypeofmachinetoolthatspecializesinboring,typicallylargeholesin
mill largeworkpieces.
HMC horizontal

machiningcenter

https://en.wikipedia.org/wiki/Gcode 24/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

HSM highspeed Referstomachiningatspeedsconsideredhighbytraditionalstandards.


machining Usuallyachievedwithspecialgearedupspindleattachmentsorwiththe
latesthighrevspindles.
HSS Atypeoftoolsteelusedtomakecutters.Stillwidelyusedtoday
highspeedsteel (versatile,affordable,capable)althoughcarbideandotherscontinueto
erodeitsshareofcommercialapplications
in inch(es)
IPF inchesperflute AlsoknownaschiploadorIPT.SeeFaddressandfeedrate.
IPM inchesper
SeeFaddressandfeedrate.
minute
IPR inchesper
SeeFaddressandfeedrate.
revolution
IPT inchespertooth AlsoknownaschiploadorIPF.SeeFaddressandfeedrate.
MDI manualdata Amodeofoperationinwhichtheoperatorcantypeinlinesofprogram
input (blocksofcode)andthenexecutethembypushingcyclestart.
MEM Ontheoperationpanel,oneofthepositionsofthemodeswitchis
"memory",sometimesabbreviatedas"MEM",referringtothecomputer
memory
memorythatisbuiltintotheCNCitself,incontrasttoanyexternal
sourceofdata,suchastapeorDNC.
MFO TheMFOdialorbuttonsallowtheCNCoperatorormachinistto
multiplytheprogrammedfeedvaluebyanypercentagetypically
between10%and200%.Thisistoallowfinetuningofspeedsandfeeds
tominimizechatter,improvesurfacefinish,lengthentoollife,andsoon.
TheSSOandMFOfeaturescanbelockedoutforvariousreasons,such
manualfeedrate
asforsynchronizationofspeedandfeedinthreading,oreventoprevent
override
"soldiering"/"dogging"byoperators.Onsomenewercontrols,the
synchronizationofspeedandfeedinthreadingissophisticatedenough
thatSSOandMFOcanbeavailableduringthreading,whichhelpswith
funetuningspeedsandfeedstoreducechatteronthethreadsorinrepair
workinvolvingthepickingupofexistingthreads.[12]
mm millimetre(s)
MPG manualpulse Referringtothehandle(handwheel)(eachclickofthehandlegenerates
generator onepulseofservoinput)
NC numerical

control
OSS orientedspindle
SeecommentsatM19.
stop
SFM surfacefeetper
SeealsospeedsandfeedsandG96.
minute
SFPM surfacefeetper
SeealsospeedsandfeedsandG96.
minute
SPT singlepoint

threading
SSO TheSSOdialorbuttonsallowtheCNCoperatorormachinistto
https://en.wikipedia.org/wiki/Gcode 25/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

multiplytheprogrammedspeedvaluebyanypercentagetypically
between10%and200%.Thisistoallowfinetuningofspeedsandfeeds
tominimizechatter,improvesurfacefinish,lengthentoollife,andsoon.
spindlespeed TheSSOandMFOfeaturescanbelockedoutforvariousreasons,such
override asforsynchronizationofspeedandfeedinthreading,oreventoprevent
"soldiering"/"dogging"byoperators.Onsomenewercontrols,the
synchronizationofspeedandfeedinthreadingissophisticatedenough
thatSSOandMFOcanbeavailableduringthreading,whichhelpswith
funetuningspeedsandfeedstoreducechatteronthethreadsorinrepair
workinvolvingthepickingupofexistingthreads.[12]
TCorT/C toolchange,tool

changer
TIR totalindicator

reading
TPI threadsperinch
USB UniversalSerial
Onetypeofconnectionthroughwhichtotransferdata
Bus
VMC vertical

machiningcenter
VTL AtypeofmachinetoolthatisessentiallyalathewithitsZaxisturned
verticalturret
vertical,allowingthefaceplatetositlikealargeturntable.TheVTL
lathe
conceptoverlapswiththeverticalboringmillconcept.

Seealso
3Dprinting
Cannedcycle
LinuxCNCafreeCNCsoftwarewithmanyresourcesforGcodedocumentation

Extendeddevelopments
DirectNumericalControl(DNC)
STEPNC
MTConnect

Similarconcepts

Gerberfile

Concernsduringapplication

Cutterlocation,cuttercompensation,offsetparameters
Coordinatesystems

References
https://en.wikipedia.org/wiki/Gcode 26/27
3/9/2016 GcodeWikipedia,thefreeencyclopedia

1.EIAStandardRS274DInterchangeableVariableBlockDataFormatforPositioning,Contouring,and
Contouring/PositioningNumericallyControlledMachines,2001EyeStreet,NW,Washington,D.C.20006:
ElectronicIndustriesAssociation,February1979
2."Fanucmacrosystemvariables".Retrieved20140630.
3.Smid2008.
4.Smid2010.
5.Green1996,pp.11621226.
6.http://atyourservice.haascnc.com/faqs/clearingalloffsets/
7.Smid2010,pp.2930.
8.MMSeditorialstaff(20101220),"CAMsystemsimplifiesSwisstypelatheprogramming",ModernMachine
Shop83(8[2011Jan]):100105.Onlineaheadofprint.
9.Smid2008,p.457.
10.Lynch,Mike(20100118),"WhenprogrammersshouldknowGcode",ModernMachineShop(onlineed.).
11.Lynch,Mike(20111019),"FiveCNCmythsandmisconceptions[CNCTechTalkcolumn,Editor's
Commentary]",ModernMachineShop(onlineed.).
12.Korn,Derek(20140506),"Whatisarbitraryspeedthreading?",ModernMachineShop.

Bibliography
Green,RobertE.etal.(eds)(1996),Machinery'sHandbook(25ed.),NewYork,NY,USA:
IndustrialPress,ISBN9780831125752.
Smid,Peter(2008),CNCProgrammingHandbook(3rded.),NewYork:IndustrialPress,
ISBN9780831133474,LCCN2007045901.
Smid,Peter(2010),CNCControlSetupforMillingandTurning,NewYork:IndustrialPress,
ISBN9780831133504,LCCN2010007023.

Externallinks
CNCGCodeandMCodeProgramming(http://carlsonmfg.com/cncgcodemcode
programming.html)
TutorialforGcode(http://gnipsel.com/linuxcnc/index.html)
Kramer,T.R.Proctor,F.M.Messina,E.R.(1Aug2000),TheNISTRS274NGCInterpreter
Version3,NIST,NISTIR6556
http://museum.mit.edu/150/86Hasseverallinks(includinghistoryofMITServoLab)
CompletelistofGcodeusedbymost3Dprinter(http://reprap.org/wiki/Gcode)

Retrievedfrom"https://en.wikipedia.org/w/index.php?title=Gcode&oldid=708265357"

Categories: Computeraidedengineering Domainspecificprogramminglanguages Encodings

Thispagewaslastmodifiedon4March2016,at16:17.
TextisavailableundertheCreativeCommonsAttributionShareAlikeLicenseadditionaltermsmay
apply.Byusingthissite,youagreetotheTermsofUseandPrivacyPolicy.Wikipediaisa
registeredtrademarkoftheWikimediaFoundation,Inc.,anonprofitorganization.

https://en.wikipedia.org/wiki/Gcode 27/27

You might also like