Posts Tagged ‘block’

the program to another block of the same program is unique to

Tuesday, September 5th, 2017

the program to another block of the same program is unique to macros – it al ways means by pass ing one or more pro gram blocks The by pass has to be done in a


selective and con trolled way, oth er wise all kinds of prob lems will take over The conditional func –


tion IF serves as a de ci sion maker be tween at two op tions The main state ment in a macro is:


Copyright 2005, Industrial Press Inc, New York, NY – FANUC CNC Custom Macros


BRANCHES AND LOOPS


173


plate drilling machine


IF [condition is true] GOTOn


for ex am ple,


IF [#7 LT 0] GOTO65


If the value of variable #7 is less than 0, branch to block N65


If the above condition is true, bypass this section up to N65


N65


Target block of the IF conditional statement


The branch ing will only oc cur if the spec i fied con di tion is true (that means the con di tion is sat is –


fied) If not, the block im me di ately fol low ing the IF state ment will be ex e cuted and no branch ing will take place


It is very cnc equipment im por tant that the tar get block of the branch ing, the one called in the GOTOn state ment


does ex notching machine ist in the same program, and is not du pli cated If nec es sary, it is pos si ble to re place the n in


the GOTOn with a vari able number or the re sult of a pre vi ous cal cu la tion For ex am ple, the fol –


low ing ex am ple is per fectly legitimate:


#33 = 65


IF [#7 LT 0] GOTO#33


If the value of angle shearing machine variable #7 is less than 0, branch to block N65


If the above condition is true, bypass this section up to N65


N65


Target block of the IF function conditional statement


The N-address block can not be used as a vari able statement, for ex am ple N#31 is il le gal


Unconditional Branching


GOTOn


The GOTOn state ment can be pro grammed on its own, with out us ing the IF func tion In this


case, the macro pro gram will branch un con di tion ally, to the n block num ber spec i fied at the


GOTOn With out the IF func tion, the GOTOn state ment has no con di tion (in this case, it is called an un con di tional state ment or un con di tional branch