Gcode G代码详解.docx
《Gcode G代码详解.docx》由会员分享,可在线阅读,更多相关《Gcode G代码详解.docx(18页珍藏版)》请在冰豆网上搜索。
GcodeG代码详解
reprapwiki上面得Gcode说明
G-code
FromRepRapWiki
(RedirectedfromGcode)
Jumpto:
navigation,search
Contents[hide]
1Introduction
2RepRapGCodeFields
3ments
4Individualmands
4、1Checking
4、1、1Nand*
4、2BufferedGmands
4、2、1G0:
Rapidmove
4、2、2G1:
Controlledmove
4、2、3G28:
MovetoOrigin
4、3UnbufferedGmands
4、3、1G4:
Dwell
4、3、2G20:
SetUnitstoInches
4、3、3G21:
SetUnitstoMillimeters
4、3、4G90:
SettoAbsolutePositioning
4、3、5G91:
SettoRelativePositioning
4、3、6G92:
SetPosition
4、4UnbufferedMandTmands
4、4、1M0:
Stop
4、4、2M17:
Enable/Powerallsteppermotors
4、4、3M18:
Disableallsteppermotors
4、4、4M20:
ListSDcard
4、4、5M21:
InitialiseSDcard
4、4、6M22:
ReleaseSDcard
4、4、7M23:
SelectSDM24:
Start/resumeSDprint
4、4、9M25:
PauseSDprint
4、4、10M26:
SetSDposition
4、4、11M27:
ReportSDprintstatus
4、4、12M28:
BeginwritetoSDcard
4、4、13M29:
StopwritingtoSDcard
4、4、14M40:
Eject
4、4、15M41:
Loop
4、4、16M42:
Stoponmaterialexhausted
4、4、17M43:
Standbyonmaterialexhausted
4、4、18M80:
ATXPowerOn
4、4、19M81:
ATXPowerOff
4、4、20M84:
Stopidlehold
4、4、21M92:
Setaxis_steps_per_unit
4、4、22M101Turnextruder1onForward
4、4、23M102Turnextruder1onReverse
4、4、24M103Turnallextrudersoff
4、4、25M104:
SetExtruderTemperature(Fast)
4、4、26M105:
GetExtruderTemperature
4、4、27M106:
FanOn
4、4、28M107:
FanOff
4、4、29M108:
SetExtruderSpeed
4、4、30M109:
SetExtruderTemperature
4、4、31M110:
SetCurrentLineNumber
4、4、32M111:
SetDebugLevel
4、4、33M112:
EmergencyStop
4、4、34M113:
SetExtruderPWM
4、4、35M114:
GetCurrentPosition
4、4、36M115:
GetFirmwareVersionandCapabilities
4、4、37M116:
Wait
4、4、38M117:
GetZeroPosition
4、4、39M118:
NegotiateFeatures
4、4、40M119:
GetEndstopStatus
4、4、41M126:
OpenValve
4、4、42M127:
CloseValve
4、4、43M128:
ExtruderPressurePWM
4、4、44M129:
Extruderpressureoff
4、4、45M140:
BedTemperature(Fast)
4、4、46M141:
ChamberTemperature(Fast)
4、4、47M142:
HoldingPressure
4、4、48M143:
Maximumhot-endtemperature
4、4、49M160:
Numberofmixedmaterials
4、4、50M203:
RecordZadjustment
4、4、51M226:
GcodeInitiatedPause
4、4、52M227:
EnableAutomaticReverseandPrime
4、4、53M228:
DisableAutomaticReverseandPrime
4、4、54M229:
EnableAutomaticReverseandPrime
4、4、55M230:
Disable/EnableWaitforTemperatureChange
4、4、56M240:
Startconveyorbeltmotor
4、4、57M241:
Stopconveyorbeltmotor
4、4、58M245:
Startcooler
4、4、59M246:
Stopcooler
4、4、60M300:
Playbeepsound
4、4、61T:
SelectTool
5ProposedEEPROMconfigurationcodes
6RepliesfromtheRepRapmachinetothehostputer
7ProposalforsendingmultiplelinesofG-code
7、1Problemtosolve
Introduction
ThispagedescribestheGCodesthattheRepRapfirmwareusesandhowtheywork、
Thelistofwhatcanbedoneisextensible、Butcheckthispagefirst,andaddyourextensionherefirstbeforeyouimplementit、
AtypicalpieceofGCodeassenttoaRepRapmachinemightlooklikethis:
N3T0*57
N4G92E0*67
N5G28*22
N6G1F1500、0*82
N7G1X2、0Y2、0F3000、0*85
N8G1X3、0Y3、0*33
Themeaningofallthosesymbolsandnumbers(andmore)isexplainedbelow、
TOfindoutwhichspecificgcode/sareimplementedinanygivenfirmware,pleaseseetheFirmware_featurespage、
(Forthetechnicallyminded,theendoflineismarkedbybothaanda、IfyouwanttomanuallyenterGCodesinyourreprapusingtheArduinoSerialinterface,makesuretoselect"BothNL&CR"onthebottomofthescreen、)
Thisisn'taccurate,firmwareacceptssingleaswellassingle,orbinationsthereof、Hostsshouldacceptsallfourbinationsaswell、--Traumflug09:
34,20April2011(UTC)
RepRapGCodeFields
Thissectionexplainstheletter-precededfields、Thenumbersinthefieldsarerepresentedbynnn、Numberscanbeintegers,orcancontainadecimalpoint,dependingoncontext、ForexampleanXcoordinatecanbeinteger(X175)orfractional(X17、62),whereastryingtoselectextrudernumber2、76wouldmakenosense、
LetterMeaning
GnnnStandardGCodemand,suchasmovetoapoint
MnnnRepRap-definedmand,suchasturnonacoolingfan
TnnnSelecttoolnnn、InRepRap,toolsareextruders
Snnnmandparameter,suchasthevoltagetosendtoamotor
Pnnnmandparameter,suchasatimeinmilliseconds
XnnnAnXcoordinate,usuallytomoveto
YnnnAYcoordinate,usuallytomoveto
ZnnnAZcoordinate,usuallytomoveto
InnnParameter-notcurrentlyused
JnnnParameter-notcurrentlyused
FnnnFeedrateinmmperminute、(Speedofprintheadmovement)
RnnnParameter-notcurrentlyused
QnnnParameter-notcurrentlyused
EnnnLengthofextrudateinmm、ThisisexactlylikeX,YandZ,butforthelengthoffilamenttoextrude、Itismonfornewerstepperbasedsystemstointerpret、、、Better:
Skeinforge40andupinterpretsthisastheabsolutelengthofinputfilamenttoconsume,ratherthanthelengthoftheextrudedoutput、
NnnnLinenumber、Usedtorequestrepeattransmissioninthecaseofmunicationserrors、
*nnnChecksum、Usedtocheckformunicationserrors、
ments
GCodements:
N3T0*57;Thisisament
N4G92E0*67
;Soisthis
N5G28*22
WillbeignoredbyRepRap,aswillblanklines、Butit'sbettertostriptheseoutinthehostputerbeforethelinesaresent、Thissavesbandwidth、
Individualmands
Checking
Nand*
Example:
N123[、、、GCodeinhere、、、]*71
Thesearethelinenumberandthechecksum、TheRepRapfirmwarechecksthechecksumagainstalocally-putedvalueand,iftheydiffer,requestsarepeattransmissionofthelineofthegivennumber、
Youcanleavebothoftheseout-RepRapwillstillwork,butitwon'tdochecking、Youhavetohavebothorneitherthough、
Thechecksum"cs"foraGCodestring"cmd"(includingitslinenumber)isputedbyexor-ingthebytesinthestringuptoandnotincludingthe*characterasfollows:
intcs=0;
for(i=0;cmd[i]!
='*'&&cmd[i]!
=NULL;i++)
cs=cs^cmd[i];
cs&=0xff;//Defensiveprogramming、、、
andthevalueisappendedasadecimalintegertothemandafterthe*character、
TheRepRapfirmwareexpectslinenumberstoincreaseby1eachline,andifthatdoesn'thappenitisflaggedasanerror、ButyoucanresetthecountusingM110(seebelow)、
BufferedGmands
TheRepRapfirmwarestoresthesemandsinaringbufferinternallyforexecution、Thismeansthatthereisno(appreciable)delaywhileamandisacknowledgedandthenexttransmitted、Inturn,thismeansthatsequencesoflinesegmentscanbeplottedwithoutadwellbetweenoneandthenext、Assoonasoneofthesebufferedmandsisreceiveditisacknowledgedandstoredlocally、Ifthelocalbufferisfull,thentheacknowledgmentisdelayeduntilspaceforstorageinthebufferisavailable、Thisishowflowcontrolisachieved、
G0:
Rapidmove
Example:
G0X12
InthiscasemoverapidlytoX=12mm、Infact,theRepRapfirmwareusesexactlythesamecodeforrapidasitusesforcontrolledmoves(seeG1below),as-fortheRepRapmachine-thisisjustasefficientasnotdoingso、(Thedistinctionesfromsomeoldmachinetoolsthatusedtomovefasteriftheaxeswerenotdriveninastraightline、ForthemG0allowedanymovementinspacetogettothedestinationasfastaspossible、)
G1:
Controlledmove
Example:
G1X90、6Y13、8E22、4
Goinastraightlinefromthecurrent(X,Y)pointtothepoint(90、6,13、8),extrudingmaterialasthemovehappensfromthecurrentextrudedlengthtoalengthof22、4mm、
RepRapdoessubtlethingswithfeedrates、Thus:
G1F1500
G1X90、6Y13、8E22、4
Willsetafeedrateof1500mm/minute,thendothemovedescribedaboveatthatfeedrate、But
G1F1500
G1X90、6Y13、8E22、4F3000
Willsetafeedrateof1500mm/minute,thendothemovedescribedaboveacceleratingtoafeedrateof3000mm/minuteasitdoesso、TheextrusionwillacceleratealongwiththeX,Ymovementsoeverythingstayssynchronized、
RepRapthustreatsfeedrateassimplyanothervariable(likeX,Y,Z,andE)tobelinearlyinterpolated、Thisgivespletecontroloveraccelerationsanddecelerationsinawaythatensuresthateverythingmovestogetherandtherightvolumeofmaterialisextrudedatallpoints、
Thefirstexampleshowshowtogetaconstant-speedmovement、Thesecondhowtoaccelerateordecelerate、Thus
G1F1500
G1X90、6Y13、8E22、4F3000
G1X80Y20E36F1500
Willdothefirstmovementacceleratingasbefore,andtheseconddeceleratingfrom3000mm/minutebackto1500mm/minute、
Toreversetheextruderbyagivenamount(forexampletoreduceitsinternalpressurewhileitdoesanin-airmovementsothatitdoesn'tdribble)simplyuseG1tosendanEvaluethatislessthanthecurrentlyextrudedlength、
G28:
MovetoOrigin
Example:
G28
ThiscausestheRepRapmachinetomovebacktoitsX,YandZzeroendstops,aprocessknownas"homing"、Itdoessoaccelerating,soastogettherefast、Butwhenitarrivesitbacksoffby1mmineachdirectionslowly,thenmovesbackslowlytothestop、Thisensuresmoreaccuratepositioning、
Ifyouaddcoordinates,thenjusttheaxeswithcoordinatesspecifiedwillbezeroed、Thus
G28X0Y72、3
willzerotheXandYaxes,butnotZ、Theactualcoordinatevaluesareignored、
UnbufferedGmands
Thefollowingmandsarenotbuffered、Whenoneisreceiveditisstored,butitisnotacknowledgedtothehostuntilthebufferisexhaustedandthenthemandhasbeenexecuted、Thusthehostwillpauseatoneofthesemandsuntilithasbeendone、Shortpausesbetweenthesemandsandanythatmightfollowthemdonotaffecttheperformanceofthemachine、
G4:
Dwell
Example:
G4P200
Inthiscasesitstilldoingnothingfor200millisecond