《数控应用专业英语》课件第15章_第1页
《数控应用专业英语》课件第15章_第2页
《数控应用专业英语》课件第15章_第3页
《数控应用专业英语》课件第15章_第4页
《数控应用专业英语》课件第15章_第5页
已阅读5页,还剩63页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论