Archive for September, 2017

ously defined variable is called by its number

ously defined variable is called by its number


o


Returned value


The new value that is the result of a calculation


o


Result of


Same as Returned value


o


busbar Machine


Substitution


Storing new data in a previously defined variable, also known as redefinition


o


Redefinition


Same as Substitution


Many of these terms are used through out the hand book, and in many other pub li ca tions


Copyright 2005, cnc cutter Industrial Press Inc, New York, NY – wwwindustrialpresscom


FANUC CNC Custom Macros


MACRO FUNCTIONS


113


Arithmetic Functions


There are sev eral macro func tions re lat ing to math e mat i cal cal cu la tions The sim plest of them


are the four ba sic arith me tic func tions, used in vari ables and also avail able to the mac ros The


arith me tic func tions use the fol low ing sym bols:


+ – * /


Function


Known as 锟?


Symbol


Sum


Addition


+


Difference


Subtraction



Product


Multiplication


*


Quotient


Division


/


In or der to un der stand any func tion, it is im por tant to eval u ate a few ex am ples In the fol low ing


ex am ples, the func tion is on the left, its re turned value – the re sult – on the right:


#1 custom processing machine = 35


35


Returned value of variable #1 is 35


#2 = 425


425


Returned value of variable #2 is 425


#3 = 20 + 50


70


Returned value of variable #3 is a sum of 2+5


#4 = #3 + 1


80


Add 1 to the result of variable #3


#5 = #2 – 08


345


Subtract 08 from the current value of variable #2


#6 = #1 – #3


-35


Subtract contents of #3 from the contents of #1


#7 = #2 * 6


255


Multiply contents of #2 by 6


#8 = 70 / 80


0875


Divide 7 by 8 as real numbers


#9 = 7 / 8


0875


Divide 7 by 8 as integer numbers


Nesting


Nest ing means the con tents of brack ets (not pa ren the ses) will be pro cessed first – compare:


#10 = 90 – 30 / 20


75


Division first, then multiplication


#11 = [90 – 30] / 20


30


Multiplication first, then division


Copyright 2005, Industrial Press Inc, New York, NY – best mill drill wwwindustrialpresscom


FANUC CNC Custom Macros


114


Chapter 9


Arithmetic Operations and Vacant Variables

the same as a multiplication by zero

the same as a multiplication by zero:


#1 = 0


#1 defined as zero


#2 = 157 * #1


#2 will multiply by 0 and return 00


2 DIVISION


u


Division by a vacant variable is the same as a division by zero:


#1 = #0


#1 defined as copper busbar bending machine vacant


#2 = 157/#1


busbar Machine


#2 will divide by 0 and return 00


(Error condition)


u


Division by a zero value variable is the same as a division by zero:


#1 = 0


#1 defined as zero (0)


#2 = 157/#1


#2 will punch machine for Head divide by 0 and return 00


(Error condition)


Division by Zero


Even the least ex pen sive pocket cal cu la tor re turns an Er ror mes sage, if the cal cu la tion at tempts


to di vide any value by zero CNC sys Busway Press Clamp Machine tem and macro cal cu la tions are no dif fer ent The two di vi –


sion ex am ples above il lus trate the point Al though the re turned value may be a dis played zero, this


value can not be used, be cause of the er ror (alarm) con di tion that has been caused To elim i nate


the er ror con di tion, the con trol sys tem has to be re set first, then the cause of the er ror elim i nated


u


Division BY zero is not permitted


#1 = 5/0


Returns an error condition


u


Division OF zero is permitted (although seldom used)


#1 = 0/5


Returns zero (0)


It is un likely that the pro gram mer would di vide by zero in the pro gram directly, un less in er ror


What is more likely rea son for such an er ror is a re sult of a cal cu la tion:


#1 = 5


Value of 5 stored in #1


#2 = #1 – 5


Value of 5 subtracted from #1, returning 0


#3 = 10/#2


Value of 10 divided by #2, which is zero – result is ERROR


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


FANUC CNC Custom Macros


116


Chapter 9


Trigonometric Functions


Trig o no met ric vari ables avail able in mac ros are used to cal cu late an gles or data re lated to an –


gles Ex am ples in clude cal cu la tion of rect an gu lar co or di nates, so lu tion of right an gle tri an gles, an gle val ues, etc All trig o no met ric func tions can be ap plied in mac ros, al though not all are avail –


able on all Fanuc con trol mod els Th

the focus was at vacant variables as they were ap plied to the axis motion command

the focus was at vacant variables as they were ap plied to the axis motion command Va –


cant vari ables can also be used as a part of the var i ous math e mat i cal op er a tions, and it is very im –


por tant to un der stand how they be have in that en vi ron ment Math e mat i cal op er a tions in clude


re def i ni tion (substitution) of vari ables, as well as arith me tic, al ge braic, trig o no met ric, and other types of cal cu la tions On the ba sic level, the rules are slightly dif fer ent for ad di tion and sub trac –


tion than for mul ti pli ca tion and di vi sion The fol low ing ex am ples should clar ify the most com mon pos si bil i ties en coun tered in mac ros:


2 SUBSTITUTION


u


Vacant variable substituted will remain vacant:


#1 = #0


busbar Machine


#1 defined as vacant


#2 = #1


#2 also defined as vacant


u


Zero value variable substituted will remain zero:


#1 = 0


#1 defined as a zero value


#2 = #1


#2 also defined as a zero value


2 ADDITION


u


Vacant variable added drilling steel to a value is the same as an increase by zero:


#1 = #0


#1 defined as vacant


#2 = 157 + #1


#2 will add 0 and return 157


#3 = #1 + #1


#3 will add 0 to a 0 and return 0


u


Zero value variable added to a value is the same as an increase by zero:


#1 = 0


#1 defined as zero


#2 = 157 + #1


#2 defined as 157


#3 = #1 + #1


#3 will add 0 to a 0 and return 0


2 SUBTRACTION


u


Vacant variable subtracted from a value is the same as a decrease by zero:


#1 = #0


#1 defined as vacant


#2 = 157 – laser cutting #1


#2 will subtract 0 and return 157


u


Zero value variable subtracted from a value is the same as a decrease by zero:


#1 = 0


#1 defined as zero (0)


#2 = 157 – #1


#2 will subtract 0 and return 157


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


FANUC CNC Custom Macros


MACRO FUNCTIONS


115


2 MULTIPLICATION


u


Multiplication by a vacant variable is the same as a multiplication by zero:


#1 = #0


#1 best mill drill defined as vacant


#2 = 157 * #1


#2 will multiply by 0 and return 00


u


Multiplication by a zero value variable is

e most common entry of an angle will be in the decimal format

e most common entry of an angle will be in the decimal format For many part draw ings that still in di cate an gles in the De grees-Min utes-Sec onds for mat


(D-M-S), trans la tion to dec i mal de grees is nec es sary


Conversion to Decimal Degrees


An an gle can be ex pressed ei ther as a whole num ber, for ex am ple 38, or as a dec i mal de gree


rep re sen ta tion, for ex am ple 1286 cnc cutter The De grees-Min utes-Sec onds for mat (D-M-S) is not al lowed,


is gen er ally con sid ered ob so lete in mod ern CAD/CAM, and must be con verted to dec i mal de grees


first, if nec es sary


The con ver sion is quite sim ple:


M


S


D


busbar Machine


= D +


+


d


60


3600


+


where 锟?


D


= Decimal degrees


d


D


= Degrees (sometimes indicated as H or HR on calculators)


M


= Minutes (there is 60 minutes in an hour)


S


= Seconds (there hydraulic busbar cutter is hole punching machine 3600 seconds in an hour)


2 Example:


10掳36锟?7锟?= 10 + 36/60 + 27/3600 = 106075掳


Of course a cal cu la tion us ing vari ables can be used for the same pur pose:


#1 = 100


Value of degrees


#2 = 360


Value of minutes


#3 = 270


Value of seconds


#101 = #1 + #2/60 + #3/3600


Result is decimal degrees of the given D-M-S angle


Available Functions


The fol low ing trig o no met ric func tions are gen er ally avail able for mac ros:


SIN COS TAN ATAN ASIN ACOS


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


FANUC CNC Custom Macros


MACRO FUNCTIONS


117


All in put for SIN, COS, and TAN is in de grees and the out put of the in verse func tions ATAN, ASIN and ACOS is also in de grees


In verse func tions are usu ally marked as tan-1, sin-1, and cos-1 on the cal cu la tor


#1 = SIN[38]


06156615


(actual value must be in brackets)


#2 = 237


237


#3 = COS[#2]


09156626


(reference to a variable must be in brackets)


#4 = TAN[1286]


02282959


The in verse trig o no met ric func tions ac cept the length of two sides of a tri an gle, both en closed in


brack ets, and sep a rated by the slash sym bol stand ing alone be tween them The ac cept able range is

the same as a multiplication by zero

the same as a multiplication by zero:


#1 = 0


#1 defined as zero


#2 = 157 * #1


#2 will multiply by 0 and return 00


2 DIVISION


u


Division by a vacant variable is the same as a division by zero:


#1 = #0


#1 defined as copper busbar bending machine vacant


#2 = 157/#1


busbar Machine


#2 will divide by 0 and return 00


(Error condition)


u


Division by a zero value variable is the same as a division by zero:


#1 = 0


#1 defined as zero (0)


#2 = 157/#1


#2 will punch machine for Head divide by 0 and return 00


(Error condition)


Division by Zero


Even the least ex pen sive pocket cal cu la tor re turns an Er ror mes sage, if the cal cu la tion at tempts


to di vide any value by zero CNC sys Busway Press Clamp Machine tem and macro cal cu la tions are no dif fer ent The two di vi –


sion ex am ples above il lus trate the point Al though the re turned value may be a dis played zero, this


value can not be used, be cause of the er ror (alarm) con di tion that has been caused To elim i nate


the er ror con di tion, the con trol sys tem has to be re set first, then the cause of the er ror elim i nated


u


Division BY zero is not permitted


#1 = 5/0


Returns an error condition


u


Division OF zero is permitted (although seldom used)


#1 = 0/5


Returns zero (0)


It is un likely that the pro gram mer would di vide by zero in the pro gram directly, un less in er ror


What is more likely rea son for such an er ror is a re sult of a cal cu la tion:


#1 = 5


Value of 5 stored in #1


#2 = #1 – 5


Value of 5 subtracted from #1, returning 0


#3 = 10/#2


Value of 10 divided by #2, which is zero – result is ERROR


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


FANUC CNC Custom Macros


116


Chapter 9


Trigonometric Functions


Trig o no met ric vari ables avail able in mac ros are used to cal cu late an gles or data re lated to an –


gles Ex am ples in clude cal cu la tion of rect an gu lar co or di nates, so lu tion of right an gle tri an gles, an gle val ues, etc All trig o no met ric func tions can be ap plied in mac ros, al though not all are avail –


able on all Fanuc con trol mod els Th