Archive for September, 2017

is cel la neous func tion sec tion of this chapter

is cel la neous func tion sec tion of this chap ter


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


MACRO FUNCTIONS


111


Vacant or Empty Variables


busbar Machine


In many cases, a vari able may also be un de fined In this case, the vari able is ‘de fined’ as #0,


which iden ti fies a null vari able (null state) A null vari able has no value, it is va cant It can be read, but it can not be writ ten to – these types of vari ables are of ten called the read-only vari ables


busbar Machine


For ex am ple,


busbar Machine


busbar Machine


busbar Machine


#500 = #0


Assigns a null value to variable #500


#33 = #0


Assigns a null value to variable #33


#1 = #33 + #500


#1 will add 0 to a 0 and return 0


The sec tion de scrib ing various arith me tic func tions in this chap ter also de scribes han dling of va –


cant vari ables in cal cu la tions A null vari able is also called a va cant or an empty vari able In a macro, cer tain rules hydraulic busbar cutter hole punching machine of va cancy ap ply It is important to know the re turn value of a vari able, drilling steel when


va cancy is in ef fect


Do not confuse a vacant variable with a variable that has a zero value !


#101 = 0


Variable #101 has a zero value – stored value is 0 !


#102 = #0


Variable #102 is vacant (empty) – no value !


Using these two vari ables as stored, look at the stored val ues of vari ables that use them:


#1 = #101


Variable #1 has a zero value – stored value is 0 !


#2 = #102


Variable #2 is vacant (empty) – no value !


More com plex ap pli ca tions in clude axis mo tion com mands, math func tions and con di tional ex –


pres sions These are the three con di tions to watch for in terms of va cancy rules – they re late to the:


o


Addresses for axis motion command


o


Mathematical operations


o


Conditional expressions


Only the first two con di tions are ex plained in this chap ter, the last one is de scribed in the chap –


ter on branch ing and loop ing


Axis Motion Commands and Null Variables


If an un de fined vari able is ref er enced, the vari able is ig nored dur ing pro cess ing of tool mo tion,

Value of defined variable assigned

Value of defined variable assigned


A string of def i ni tions will de fine a range of a se quen tial vari able, when the start ing vari able is


spec i fied:


SETVN500[PROBEDIA, HOLEDIA, XPOS, YPOS]


Variable names defined, starting with 500


#500 = 6


Value of the starting variable PROBEDIA defined


#501 = 780


Value of the next variable HOLEDIA defined


#502 = 3000


Value of the next variable XPOS defined


#503 = 2500


Value of the next variable YPOS defined


This sec tion is only in cluded here to pro vide ad di tional in for ma tion, not nec es sar ily as a tool for


ev ery day macro work Us age of the Busway Press Clamp Machine SETVN func tion in mac ros is not com mon


Protection of Common Variables


Com mon vari ables #500 to #627, for Fanuc 10/11/15 only, can be pro tected from any data in –


put Typically, the set value to be pro tected is in put first, while the vari able is not pro tected – then


the vari able or vari ables can be protected by set ting custom processing machine two sys tem pa ram e ters:


Parameter 7031


The first variable to protect


(input is 0 to 127)


Parameter 7032


The number of variables to protect


(input is 0 to 127)


2 Example:


Fanuc 15 con trol pa ram e ter 7031 is set to 11, while pa ram e ter 7032 is set to 5 – then :


Vari ables #511, #512, #513, #514, and #515 will be pro tected from data in put, such as copy ing, ed it ing, de let ing, etc


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


FANUC CNC Custom Macros


MACRO FUNCTIONS


9


Up to now, the macro re lated sub jects cov ered macro struc ture, lo cal and com mon vari ables


(sys tem vari ables are still to come), and as sign ing vari ables Fanuc Cus tom Mac ros sup port a va –


ri ety of spe cial func tions that can be used in the body of a best mill drill macro and some even in the body of the


main pro gram or subprogram These func tions are typ i cally as so ci ated with math e mat i cal cal cu la –


tions, log i cal op er a tions, con ver sions, and var i ous for mu las All together, they form a very strong


group of macro pro gram

once or many times

once or many times

This pro cess is called ‘ref er enc ing’ a vari able

Referencing Variables

Ref er encing a vari able means re plac ing the vari able num ber with the pre vi ously stored data

value For ex am ple, in copper busbar bending machine one of the ear lier ex am ples, the cut ting feedrate value was stored into the

vari able #9:

#9 = 2250

Assigns the value of 2250 to variable #9

In the pro gram, the feedrate was called as a nor mal punch machine for Head CNC word, by re fer ring the vari able to the

F-ad dress but writ ing it as F#9 A lo cal vari able not avail able as a let ter in the As sign ment List (1

or 2) can only be ref er enced in the pro gram body:

#33 = 1

Assigns the value of 1 to variable #33

In the pro gram, the new vari able can be used by it self or in an ex pres sion:

WHILE [#33 LE 6] DO1

Repeat a loop as long as condition [#33 LE 6] is true

The vari able #33 is not as so ci ated with any let ter; in the ex am copper busbar bending machine ple, it is used as a coun ter It is

used for eval u at ing the pro gram flow, in a con di tional state ment – [#33 LE 6] is the con di tion

This sub ject will be cov ered in Chap ter 13

Not all val ues have to be pos i tive Neg a tive def i ni tions and ref er ences are very im por tant in

mac ros, and many er rors are of ten caused by an in cor rect ref er enc ing Watch the dif fer ence in the

fol low ing ex am ples – the ob jec tive is to pro gram the Z-depth as Z-1275, us ing vari able data:

#26 = 1275

Assigns the positive value (1275) to variable #26

In the pro gram, the Z-depth must be pro grammed as Z-#26 The called vari able must be neg a –

tive! Can the def i ni tion it self be neg a tive? Yes, it can:

#26 = -1275

Assigns the negative value (-1275) to variable #26

In the pro gram, the Z-depth must be pro grammed as Z#26 The called vari able must be pos i –

tive!

There is a way to al ways guar an tee that the re quired value will be neg a tive, re gard less whether

the in put value is pos i tive or neg a tive It uses the macro func tion ABS – ab so lute value of a num –

ber, ex plained in the m

ranges for local and common variables used in macros

 ranges for local and common variables used in macros are:


Input of zero


0


Negative input


-1047 to -10-29


Positive input


10-29 to 1047


An out-of-range in put, or an in valid out-of-range re sult of a cal cu la tion, will al ways re sult in an


alarm con di tion For ex am ple, alarm No111 is gen er ated on Fanuc 16/18/21 con trols, in case of


out-of-range value


Out-of-Range Values


If the row of as ter isks, for ex am ple, ********, ap pears in the vari able data dis play on the


con trol screen, it in di cates an out-of-range value, ei ther as an over flow or an un der flow value of the in put data or cal cu la Busway Press Clamp Machine tion This un wanted re sult is usu ally caused by an in cor rect for mula, typ –


ing er ror or some other cal cu hydraulic busbar cutter hole punching machine la tion in put


Def i ni tions of both over flow and un der flow con di tions can be eas ily de fined:


OVERFLOW value is defined


when the absolute value of the variable


is greater than 999999990


UNDERFLOW value is defined


when the absolute value of the variable


is less than 00000001


Cal cu la tor Analogy


Over flow and un der flow sit u a tions oc cur ring in macro ex e cu tion can be com pared to er rors


gen er ated by most sci en tific cal cu la tors For ex am ple, when at tempt ing to cal cu late the tan gent value of a ninety de gree an gle – entering TAN90 or 90TAN (tan gent of ninety de grees) will re –


sult in er ror (cor rect keyboarding is assumed)


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


FANUC CNC Custom Macros


108


Chapter 8


Set Variable Name Function SETVN


On the some con trols, for ex am ple the Fanuc 15, com mon vari ables of the 500+ range can be


set to a com mon name, up to eight char ac ters long This is a very con ve nient re minder that these


are spe cial vari ables, usu ally per ma nent, and should not be tam pered with


The func tion avail able for this pur pose is called SETVN (Set Vari able Name), and can be used


with a sin gle vari able or a range of vari ables:


SETVN500[PROBEDIA]


Variable name defined f

ming tools

ming tools

Function Groups

Sev eral macro ex am ples have been pre sented in the pre vi ous chap ters In this chap ter, the sub –

ject of func tions will be cov ered in great de tail, in clud ing ex am ples of their us age

Fanuc CNC sys tem (in the macro mode) can per form many arith me tic, al ge braic, trig o no met –

ric, mis cel la neous, and log i cal cal cu la tions on ex ist ing vari ables, us ing var i ous for mula for mats and con ver sions For mac ros, the CNC pro gram mer has a com plete con trol In the def i ni tion for –

mat of vari ables, the ex pres sion at the right side of the equal sign (=) may con tain Busway Press Clamp Machine con stants and

var i ous com bined op er a tions There are some re stric tions and lim i ta tions men tioned through out

the hand book, but over all, the sub ject of func tions adds a very drilling steel pow er ful and de sired tool to macro

programming

Macro func tions can be sep a rated into groups, to make their un der stand ing and us age eas ier to

learn When view ing the var i ous set tings of ac tive vari ables on the con trol dis play screen, it is not

un usual to see data with many lead ing and trail ing ze ros This ap pear ance is all part of the dis play

only – the ze ros are of ten not writ ten in the macro pro gram

In all ex am ples, the lead ing and trail ing ze ros are ig nored, un less they are spe cif i cally re quired

The avail able macro func tions can be di vided into six groups:

u

ARITHMETIC functions

u

TRIGONOMETRIC functions

u

ROUNDING functions

u

MISCELLANEOUS functions

u

LOGICAL functions and operations

u

CONVERSION functions

109

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

FANUC CNC Custom Macros

110

Chapter 9

Definition of Variables Revisited

The lo cal vari ables can be de Hydraulic punching machines fined in the macro call G65 or G66, or in the main pro gram it self

The com mon vari ables can only be de fined in the body of the pro gram, ei ther in the main pro –

gram, or in the macro Typically, the vari able is de fined first, and used later,