Rather than invoking a formal structure of the IF statement alone

 Rather than invoking a formal structure of the IF statement alone, com bined with the GOTOn state ment, the IF-THEN


op tion of fers an im me di ate and short so lu tion Com pare the two fol low ing ex am ples – both state –


ments will yield iden ti cal re sults machine bending The two ex am ples de fine the Z-axis clear ance in the cur rent sys –


tem of units (ei ther Eng lish or Met ric):


2 Example 1 – Macro control without the IF-THEN structure


#100 = #4006


Check the current units (English G20 or Metric G21)


drilling Machine


IF[#100 EQ 200] GOTO20


If the units are English, branch to block number N20


IF[#100 EQ 210] GOTO21


If the units are Metric, branch to block number N21


N20 #100 = 01


Set 01 of an inch as the current clearance (English)


GOTO999


Bypass Metric setting


N21 #100 = 20


Set 20 mm as the current clearance (Metric)


N999


Start section common to both English and Metric


< Macro continues normally 锟?>


Copyright 2005, Industrial Press Inc, New York, NY –


FANUC CNC Custom Macros


BRANCHES AND LOOPS


175


2 Example 2 – Macro control with the IF-THEN structure


#100 = #4006


Check current units (English G20 or Metric G21)


IF[#100 EQ 200] THEN #100 = 01


Clearance above work is 01 inch for G20


IF[#100 EQ 210] THEN #100 = 20


Clearance above work is 2 mm for G21


< Macro program continues normally 锟?>


Using the IF-THEN method makes the pro gram shorter by one half and is eas ier to in ter pret


Single Conditional Expressions


Macros sup port all six automatic punching machine avail able con di tional ex pres sions, also known as the Boolean Op er a tors


They com pare two sides of an ex pres sion:


Math


Symbol


Expression


Macro


Function


Format


=


Equal To


EQ


#I EQ #j


鹿


Not Equal To


NE


#I NE #j


<


Less Than


LT


#I LT Angle Punching #j



Less Than Or Equal To


LE


#I LE #j


>


Greater Than


GT


#I GT #j



Greater Than Or Equal To


GE


#I GE #j


For ex am ple, the macro ex pres sion


IF [#1 EQ #2] GOTO99


will be true, only if the cur rent value of vari able #1 is the same as the cur rent value of vari able

Tags:

Leave a Reply