




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
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.(ⅰ)WithG65,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)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年5G網(wǎng)絡(luò)通信設(shè)備采購合同標(biāo)準(zhǔn)
- 2025年醋酸乙烯酯項目建議書
- 2025年摻混肥項目合作計劃書
- 2025年本地網(wǎng)傳輸系統(tǒng)項目合作計劃書
- 強化法治教育促進遵紀(jì)守法計劃
- 學(xué)習(xí)困難學(xué)生支持方案計劃
- 水庫管理與調(diào)度方案計劃
- 選擇合適的理財工具計劃
- 2025年金屬門窗及類似制品項目發(fā)展計劃
- 2025年中國顯控系統(tǒng)行業(yè)供需態(tài)勢、競爭格局及投資前景分析報告(智研咨詢)
- DL∕T 5810-2020 電化學(xué)儲能電站接入電網(wǎng)設(shè)計規(guī)范
- ISO9001、ISO14001和ISO45001質(zhì)量環(huán)境及職業(yè)健康安全三個體系的對比
- 大學(xué)生創(chuàng)新創(chuàng)業(yè)基礎(chǔ)教程(高校創(chuàng)新創(chuàng)業(yè)教育課程)全套教學(xué)課件
- 2024年內(nèi)蒙古交通職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫完整
- 天津和平區(qū)2024屆高三一模數(shù)學(xué)試題(解析版)
- 人教版高中物理必修二同步練習(xí)及答案
- 《行政倫理學(xué)教程(第四版)》課件 第7、8章?行政人格、行政組織倫理
- 2024年江蘇蘇??毓杉瘓F有限公司招聘筆試沖刺題(帶答案解析)
- 工商聯(lián)業(yè)務(wù)工作培訓(xùn)
- 商業(yè)街消防安全培訓(xùn)
- 湖北省曾都區(qū)烏鴉山礦區(qū)建筑用輝綠巖礦礦產(chǎn)資源開發(fā)利用與生態(tài)復(fù)綠方案
評論
0/150
提交評論