版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
15CUSTOMMACRO
15.1VARIABLES15.2SYSTEMVARIABLES15.3ARITHMETICANDLOGICOPERATION15.4MACROSTATEMENTSANDNCSTATEMENTS15.5BRANCHANDREPETITION15.6MACROCALL
Althoughsubprogramsareusefulforrepeatingthesameoperation,thecustommacrofunctionalsoallowsuseofvariables,arithmeticandlogicoperations,andconditionalbranchesforeasydevelopmentofgeneralprogramssuchaspocketinganduserdefinedcannedcycles.Amachiningprogramcancallacustommacrowithasimplecommand,justlikeasubprogram.Fig.15.0Custommacro15.1VARIABLES
AnordinarymachiningprogramspecifiesaGcodeandthetraveldistancedirectlywithanumericvalue;examplesareG100andX100.0.
Withacustommacro,numericvaluescanbespecifieddirectlyorusingavariablenumber.Whenavariablenumberisused,thevariablevaluecanbechangedbyaprogramorusingoperationsontheMDIpanel.#1=#2+100;
G01X#1F300;Explanation·Variablerepresentation
Whenspecifyingavariable,specifyanumbersign(#)followedbyavariablenumber.Personalcomputersallowanametobeassignedtoavariable,butthiscapabilityisnotavailableforcustommacros.[Example]#1
Anexpressioncanbeusedtospecifyavariablenumber.Insuchacase,theexpressionmustbeenclosedinbrackets.[Example]#[#1+#2-12]
·Typesofvariables
Variablesareclassifiedintofourtypesbyvariablenumber.NOTE
Commonvariables#150to#199and#532to#999areoptional.·Rangeofvariablevalues
Localandcommonvariablescanhavevalue0oravalueinthefollowingranges:
-10E47to-10E-29
10E-29to10E47
Iftheresultofcalculationturnsouttobeinvalid,anP/SalarmNo.111isissued.
·Omissionofthedecimalpoint
Whenavariablevalueisdefinedinaprogram,thedecimalpointcanbeomitted.[Example]
When#1=123;isdefined,theactualvalueofvariable#1is123.000.·Referencingvariables
Toreferencethevalueofavariableinaprogram,specifyawordaddressfollowedbythevariablenumber.Whenanexpressionisusedtospecifyavariable,enclosetheexpressioninbrackets.[Example]G01X[#1+#2]F#3;
Areferencedvariablevalueisautomaticallyroundedaccordingtotheleastinputincrementoftheaddress.[Example]
WhenG00X#1;isexecutedona1/1000mmCNCwith12.3456assignedtovariable#1,theactualcommandisinterpretedasG00X12.346;.
Toreversethesignofareferencedvariablevalue,prefixaminussign(-)to#.[Example]G00X-#1;
Whenanundefinedvariableisreferenced,thevariableisignoreduptoanaddressword.[Example]
Whenthevalueofvariable#1is0,andthevalueofvariable#2isnull,executionofG00X#1Y#2;resultsinG00X0;.·Commoncustommacrovariablesfortowpaths(twopathcontrol)
Fortwopathcontrol,macrovariablesareprovidedforeachpath.Somecommonvariables,however,canbeusedforbothpaths,bysettingparametersNo.6036and6037accordingly.·Undefinedvariable
Whenthevalueofavariableisnotdefined,suchavariableisreferredtoasa“null”variable.Variable#0isalwaysanullvariable.Itcannotbewrittenin,butitcanberead.
Ⅰ.Quotation
Whenanundefinedvariableisquotated,theaddressitselfisalsoignored.[Example]When#1is0and#2isnull,theresultofexecutingG00X#1Y#2;willbethesameaswhenG00X0;isexecuted.
Ⅱ.Operation<vacant>isthesameas0exceptwhenreplacedby<vacant>Ⅲ.Conditionalexpressions<vacant>differsfrom0onlyforEQandNEFig.15.1VariablesonCRTpage
(ⅰ)Whenthevalueofavariableisblank,thevariableisnull.
(ⅱ)Themark********indicatesanoverflow(whentheabsolutevalueofavariableisgreaterthan99999999)oranunderflow(whentheabsolutevalueofavariableislessthan0.0000001).Limitations
Programnumbers,sequencenumbers,andoptionalblockskipnumberscannotbereferencedusingvariables.[Example]Variablescannotbeusedinthefollowingways:
O#1;
/#2G00X100.0;
N#3Y200.0;15.2SYSTEMVARIABLES
SystemvariablescanbeusedtoreadandwriteinternalNCdatasuchastoolcompensationvaluesandcurrentpositiondata.Note,however,thatsomesystemvariablescanonlyberead.Systemvariablesareessentialforautomationandgeneralpurposeprogramdevelopment.Explanations·Interfacesignals
Signalscanbeexchangedbetweentheprogrammablemachinecontroller(PMC)andcustommacros.
Fordetailedinformation,refertotheconnectionmanual.·Toolcompensationvalues
Toolcompensationvaluescanbereadandwrittenusingsystemvariables.Usablevariablenumbersdependonthenumberofcompensationpairs,whetheradistinctionismadebetweengeometriccompensationandwearcompensation,andwhetheradistinctionismadebetweentoollengthcompensationandcuttercompensation.Whenthenumberofcompensationpairsisnotgreaterthan200,variables#2001to#2400canalsobeused.·Macroalarms·Timeinformation[Example]#3000=1(TOOLNOTFOUND);
Thealarmscreendisplays“3001TOOLNOTFOUND.”
Timeinformationcanbereadandwritten.15.3ARITHMETICANDLOGICOPERATION
TheoperationslistedinTable15.8canbeperformedonvariables.Theexpressiontotherightoftheoperatorcancontainconstantsand/orvariablescombinedbyafunctionoroperator.Variables#jand#kinanexpressioncanbereplacedwithaconstant.Variablesontheleftcanalsobereplacedwithanexpression.Explanations·Angleunits
TheunitsofanglesusedwiththeSIN,COS,TAN,andATANfunctionsaredegrees.Forexample,90degreesand30minutesisrepresentedas90.5degrees.·ATANfunction
AftertheATANfunction,specifythelengthsoftwosidesseparatedbyaslash.Aresultisfoundwhere0-result-360.[Example]When#1=ATAN[1]/[-1],thevalueof#1is135.0.·ROUNDfunction
(ⅰ)WhentheROUNDfunctionisincludedinanarithmeticorlogicoperationcommand,IFstatement,orWHILEstatement,theROUNDfunctionroundsoffatthefirstdecimalplace.[Example]When#1=ROUND[#2];isexecutedwhere#2holds1.2345,thevalueofvariable#1is1.0.
(ⅱ)WhentheROUNDfunctionisusedinNCstatementaddresses,theROUNDfunctionroundsoffthespecifiedvalueaccordingtotheleastinputincrementoftheaddress.[Example]Creationofadrillingprogramthatcutsaccordingtothevaluesofvariables#1and#2,thenreturnstotheoriginalposition.
Supposethattheincrementsystemis1/1000mm,variable#1holds1.2345,andvariable#2holds2.3456.Then,
G00G91X-#1;Moves1.235mm
G01X-#2F300;Moves2.346mm
G00X[#1+#2];Since1.2345+2.3456=3.5801,
thetraveldistanceis3.580,which
doesnotreturnthetooltothe
originalposition
Thisdifferencecomesfromwhetheradditionisperformedbeforeorafterroundingoff.
G00X-[ROUND[#1]+ROUND[#2]]mustbespecifiedtoreturnthetooltotheoriginalposition.·Roundingupanddowntoaninteger
WithCNC,whentheabsolutevalueoftheintegerproducedbyanoperationonanumberisgreaterthantheabsolutevalueoftheoriginalnumber,suchanoperationisreferredtoasroundinguptoaninteger.
Conversely,whentheabsolutevalueoftheintegerproducedbyanoperationonanumberislessthantheabsolutevalueoftheoriginalnumber,suchanoperationisreferredtoasroundingdowntoaninteger.
Beparticularlycarefulwhenhandlingnegativenumbers.[Example]Supposethat#1=1.2and#2=-1.2.
When#3=FUP[#1]isexecuted,2.0isassignedto#3.
When#3=FIX[#1]isexecuted,1.0isassignedto#3.
When#3=FUP[#2]isexecuted,-2.0isassignedto#3.
When#3=FIX[#2]isexecuted,-1.0isassignedto#3.·Abbreviationsofarithmeticandlogicoperationcommands
Whenafunctionisspecifiedinaprogram,thefirsttwocharactersofthefunctionnamecanbeusedtospecifythefunction.[Example]
ROUND→RO
FIX→FI·Priorityofoperations
Ⅰ.Functions
Ⅱ.Operationssuchasmultiplicationanddivision(*,/,AND)
Ⅲ.Operationssuchasadditionandsubtraction(+,-,OR,XOR)Fig.15.3(a)Priorityofoperations·Bracketnesting
Bracketsareusedtochangetheorderofoperations.Bracketscanbeusedtoadepthoffivelevelsincludingthebracketsusedtoencloseafunction.
Whenadepthoffivelevelsisexceeded,P/SalarmNo.118occurs.Fig.15.3(b)BracketnestingLimitations·Brackets
Brackets([,])areusedtoencloseanexpression.Notethatparenthesesareusedforcomments.·Operationerror
Errorsmayoccurwhenoperationsareperformed.NOTE
(*1)Therelativeerrordependsontheresultoftheoperation.
(*2)Smallerofthetwotypesoferrorsisused.
(*3)Theabsoluteerrorisconstant,regardlessoftheresultoftheoperation.
(*4)FunctionTANperformsSIN/COS.
(ⅰ)Theprecisionofvariablevaluesisabout8decimaldigits.Whenverylargenumbersarehandledinanadditionorsubtraction,theexpectedresultsmaynotbeobtained.[Example]Whenanattemptismadetoassignthefollowingvaluestovariables:#1and#2:#1=9876543210123.456#2=9876543277777.777
thevaluesofthevariablesbecome:#1=9876543200000.000#2=9876543300000.000
Inthiscase,when#3=#2-#1;iscalculated,#3=100000.000results.
(Theactualresultofthiscalculationisslightlydifferentbecauseitisperformedinbinary.)
(ⅱ)AlsobeawareoferrorsthatcanresultfromconditionalexpressionsusingEQ,NE,GE,GT,LE,andLT.[Example]IF[#1EQ#2]iseffectedbyerrorsinboth#1and#2,possiblyresultinginanincorrectdecision.Therefore,insteadfindthedifferencebetweenthetwovariableswithIF[ABS[#1-#2]LT0.001].
Then,assumethatthevaluesofthetwovariablesareequalwhenthedifferencedoesnotexceedanallowablelimit(0.001inthiscase).
(ⅲ)Also,becarefulwhenroundingdownavalue.[Example]When#2=#1*1000;iscalculatedwhere#1=0.002;,theresultingvalueofvariable#2isnotexactly2but1.99999997.
Here,when#3=FIX[#2];isspecified,theresultingvalueofvariable#1isnot2.0but1.0.
Inthiscase,rounddownthevalueaftercorrectingtheerrorsothattheresultisgreaterthantheexpectednumber,orrounditoffasfollows:#3=FIX[#2+0.001]#3=ROUND[#2]
·Divisor
WhenadivisorofzeroisspecifiedinadivisionorTAN[90],P/SalarmNo.112occurs.15.4MACROSTATEMENTSANDNCSTATEMENTS
Thefollowingblocksarereferredtoasmacrostatements:
(ⅰ)Blockscontaininganarithmeticorlogicoperation(=).
(ⅱ)Blockscontainingacontrolstatement(suchasGOTO,DO,END).
(ⅲ)Blockscontainingamacrocallcommand(suchasmacrocallsbyG65,G66,G67,orotherGcodes,orbyMcodes).
AnyblockotherthanamacrostatementisreferredtoasanNCstatement.EXPLANATIONS·DifferencesfromNCstatements
(ⅰ)Evenwhensingleblockmodeison,themachinedoesnotstop.Note,however,thatthemachinestopsinthesingleblockmodewhenbit5ofparameterSBMNo.6000is1.
(ⅱ)Macroblocksarenotregardedasblocksthatinvolvenomovementinthecuttercompensationmode.·NCstatementsthathavethesamepropertyasmacrostatements
(ⅰ)NCstatementsthatincludeasubprogramcallcommand(suchassubprogramcallsbyM98orotherMcodes,orbyTcodes)andnotincludeothercommandaddressesexceptanO,NorLaddresshavethesamepropertyasmacrostatements.
(ⅱ)TheblocksnotincludeothercommandaddressesexceptanO,N,PorLaddresshavethesamepropertyasmacrostatements.15.5BRANCHANDREPETITION
Inaprogram,theflowofcontrolcanbechangedusingtheGOTOstatementandIFstatement.Threetypesofbranchandrepetitionoperationsareused.Fig.15.5(a)Branchandrepetition15.5.1UnconditionalBranch(GOTOStatement)
Abranchtosequencenumbernoccurs.Whenasequencenumberoutsideoftherange1to99999isspecified,P/SalarmNo.128occurs.Asequencenumbercanalsobespecifiedusinganexpression.
GOTOn;n:Sequencenumber(1to99999)[Example]
GOTO1;
GOTO#10;15.5.2ConditionalBranch(IFStatement)
SpecifyaconditionalexpressionafterIF.Ifthespecifiedconditionalexpressionissatisfied,abranchtosequencenumbernoccurs.Ifthespecifiedconditionisnotsatisfied,thenextblockisexecuted.Fig.15.5(b)Conditionalbranch(IFstatement)EXPLANATIONS·Conditionalexpression
Aconditionalexpressionmustincludeanoperatorinsertedbetweentwovariablesorbetweenavariableandconstant,andmustbeenclosedinbrackets([,]).Anexpressioncanbeusedinsteadofavariable.·Operators
Operatorseachconsistoftwolettersandareusedtocomparetwovaluestodeterminewhethertheyareequaloronevalueissmallerorgreaterthantheothervalue.Notethattheinequalitysigncannotbeused.Sampleprogram
Thesampleprogrambelowfindsthetotalofnumbers1to10.
O9500;#1=0;Initialvalueofthevariabletoholdthesum#2=1;Initialvalueofthevariableasanaddend
N1IF[#2GT10]GOTO2;BranchtoN2whentheaddendisgreaterthan10#1=#1+#2;Calculationtofindthesum#2=#2+1;Nextaddend
GOTO1;BranchtoN1
N2M30;Endofprogram15.5.3Repetition(WHILEStatement)
SpecifyaconditionalexpressionafterWHILE.Whilethespecifiedconditionissatisfied,theprogramfromDOtoENDisexecuted.Ifthespecifiedconditionisnotsatisfied,programexecutionproceedstotheblockafterEND.Fig.15.5(c)Repetition(WHILEstatement)EXPLANATIONS
Whilethespecifiedconditionissatisfied,theprogramfromDOtoENDafterWHILEisexecuted.Ifthespecifiedconditionisnotsatisfied,programexecutionproceedstotheblockafterEND.ThesameformatasfortheIFstatementapplies.AnumberafterDOandanumberafterENDareidentificationnumbersforspecifyingtherangeofexecution.Thenumbers1,2,and3canbeused.Whenanumberotherthan1,2,and3isused,P/SalarmNo.126occurs.·Nesting
Theidentificationnumbers(1to3)inaDOENDloopcanbeusedasmanytimesasdesired.Note,however,whenaprogramincludescrossingrepetitionloops(overlappedDOranges),P/SalarmNo.124occurs.Fig.15.5(d)NestingLIMITATIONS·Infiniteloops
WhenDOmisspecifiedwithoutspecifyingtheWHILEstatement,aninfinitelooprangingfromDOtoENDisproduced.·Processingtime
WhenabranchtothesequencenumberspecifiedinaGOTOstatementoccurs,thesequencenumberissearchedfor.Forthisreason,processinginthereversedirectiontakesalongertimethanprocessingintheforwarddirection.UsingtheWHILEstatementforrepetitionreducesprocessingtime.·Undefinedvariable
InaconditionalexpressionthatusesEQorNE,a<vacant>andzerohavedifferenteffects.Inothertypesofconditionalexpressions,a<vacant>isregardedaszero.Sampleprogram
Thesampleprogrambelowfindsthetotalofnumbers1to10.
O0001;#1=0;#2=1;
WHILE[#2LE10]DO1;#1=#1+#2;#2=#2+1;
END1;
M30;15.6MACROCALL
Amacroprogramcanbecalledusingthefollowingmethods.Fig.15.6(a)MacrocallLIMITATIONS·Differencesbetweenmacrocallsandsubprogramcalls
Macrocall(G65)differsfromsubprogramcall(M98)asdescribedbelow.(?。¦ithG65,anargument(datapassedtoamacro)canbespecified.M98doesnothavethiscapability.
(ⅱ)WhenanM98blockcontainsanotherNCcommand(forexample,G01X100.0M98Pp),thesubprogramiscalledafterthecommandisexecuted.Ontheotherhand,G65unconditionallycallsamacro.
(ⅲ)WhenanM98blockcontainsanotherNCcommand(forexample,G01X100.0M98Pp),themachinestopsinthesingleblockmode.Ontheotherhand,G65doesnotstopsthemachine.
(ⅳ)WithG65,theleveloflocalvariableschanges.WithM98,theleveloflocalvariablesdoesnotchange.Sampleprogram(boltholecircle)
AmacroiscreatedwhichdrillsHholesatintervalsofBdegreesafterastartangleofadegreesalongtheperipheryofacirclewithradiusI.
Thecenterofthecircleis(X,Y);Commandscanbespecifiedineithertheabsoluteorincrementalmode.Todrillintheclockwisedirection,specifyanegativevalueforB.Fig.15.6(b)Sampleprogram(boltholecirc
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 《基礎化學綜合實驗A》教學大綱
- 幼兒園0的意義課件
- 交通工程設施設計教案
- 玉溪師范學院《網(wǎng)絡思想政治教育》2022-2023學年第一學期期末試卷
- 玉溪師范學院《商務談判》2022-2023學年第一學期期末試卷
- 玉溪師范學院《籃球主項》2021-2022學年第一學期期末試卷
- 房地產(chǎn)營銷策劃 -雅安國際旅游度假區(qū) 2023-2024年度系列營銷活動策劃方案
- 2023年水路貨物運輸服務項目評估分析報告
- 2019湘美版 高中美術 選擇性必修6 現(xiàn)代媒體藝術《第一單元 攝影》大單元整體教學設計2020課標
- 2024屆河北省定州市全國統(tǒng)一招生高考押題卷數(shù)學試題(一)
- 古代茶具的演變課件
- 商業(yè)購物中心運營管理培訓課件
- 55三相異步電動機的銘牌與型號電機與變壓器勞動第五版課件
- 華為校招硬件技術工程師機考試題
- 蘇科版九上數(shù)學專題 隱圓問題課件
- 食品制作工藝流程圖
- 開放水域潛水員理論知識考試試題與答案
- 遼寧省地圖課件介紹
- 《設計三大構成》第四章課件
- 公共機構節(jié)能工作培訓課件-課件
- (部編版)二年級語文上冊第四單元知識點復習課件
評論
0/150
提交評論