Note the use of a fixed and variable feedrates in the same program Also note

September 2, 2017 · Posted in Uncategorised · Comment 

2 Variables applied (used) :


G00 G90 G54 X3500 Y17834 S#19 M03


(VARIABLE SPINDLE SPEED)


G43 Z250 H03 M08


G01 Z-150 F2000


(FIXED FEEDRATE)


X4250 F#9


(VARIABLE FEEDRATE)


Note the use of a fixed and variable feedrates in the same program Also note that no mac ros


have been used at all Many pro gram mers do not re al ize that they may use vari ables in the main


pro gram (stan dard pro gram) only, with out a macro, pro vid ing the macro op tion is sup ported by


the con trol sys tem A com plete ex am ple of such an ap pli ca tion has al ready been shown ear lier, punch machine for Head in


Chap ter 1 – Fig ure 1, and still an other ex am ple Busway Press Clamp Machine is also in cluded in the next chap ter


Decimal Point Usage


High Speed Drilling Machine


A vari able that is de fined in the macro pro gram body must al ways be en tered with the dec i mal


point for all di men sional val ues, such as po si tion lo ca tions, dis tances, feedrates, or any other def i –


ni tions that use met ric or Eng lish units (see next sec tion) If these val ues are en tered with out the


dec i mal point, the in ter pre ta tion by the con trol will use the de fault set tings and could cause some


very se ri ous prob lems For ex am ple,


#11 = 45


may be in ter preted in nu mer ous ways, and not all will yield the same re sult The stored value of


45 may be come 450, 0045, 00045 – or re main just as de clared – 45


In pro gram ming, never count on de fault val ues !


If an in put value ac cepts the dec i mal point, al ways de clare it with the dec i mal point in cluded In


daily ap pli ca tions, typ i cal val ues that re quire dec i mal point are all val ues re lat ing to di men sions –


they are also called di men sional words or di men sional val ues It is im por tant to keep in mind that the de fault val ues may drilling tools work for you, but against you as well For ex am ple, if the X-axis co or di –


nate lo ca tion is de fined as X20, for ex am ple, in met ric sys tem it will be in ter preted as X0020, in


the Eng lish units sys tem as X00020 A significant dif fer ence!


There is also a func tion ADP (Add D

Variables may also use complex expressions

September 2, 2017 · Posted in Uncategorised · Comment 

3750 F#9 will mean G01 X3750 F3000


Variables may also use complex expressions, for ex am ple:


#i = #j + 50, where #j is a pre vi ously de fined vari able, which should be in ter preted as –


add the value of 50 to the copper busbar bending machine cur rent value of vari able con tained in #j, and store the new re sult in


vari able #i


The vari able def i ni tion #9 = 1500 in one part of the pro gram, can be used again later, usu –


ally as a sub punch machine for Head sti tuted state ment, for ex am ple, as a def i ni tion #9 = #9 * 11 in an other part of the


macro pro gram, such as a feedrate in put F#9, with the ac tual mean ing of F1650


In all ap pli ca tions, the rule for ap ply ing the vari ables is sim ple (the cur rent ex am ple is used):


+


Take the stored value of variable #9 and use it as the cur rent value of the pro grammed feedrate


When ex pres sions are used in a macro, they al ways eval u ate a mul ti ple math e mat i cal or log copper busbar bending machine i cal op er a tion Ex pres sions must be en closed in square brackets [ex pres sion]:


#i = #i * [#j + #k]


High Speed Drilling Machine


+


where the brack ets force cal cu la tion of #j+#k to be per formed first, be fore be ing mul ti plied by #i


Any com plex cal cu la tions can be nested within square brack ets, al ways fol low ing the stan dard


math e mat i cal hi er ar chy re lat ing to the or der in which cal cu la tions will be pro cessed


Usage of Variables


Macro vari ables can only be used in a pro gram if they are de fined first Once a vari able is de –


fined, it can be used by pre ced ing it with the de sired Fanuc pro gram re lated ad dress (char ac ter),


which is a cap i tal let ter of the al pha bet, such as F, S, G, M, etc


For ex am ple, the two vari ables de fined ear lier can be used in the body of a pro gram:


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


FANUC CNC Custom Macros


CONCEPT OF VARIABLES


87


2 Variables declared (defined) :


#19 = 1200


Spindle speed defined


#9 = 1500


Cutting feedrate


Vari ables must be de clared (de fined) be fore they can be used, as the ex am ple shows

For all dimensional words used in a CNC program

September 2, 2017 · Posted in Uncategorised · Comment 

ec i mal Point) avail able and de scribed else where, but not


recommended even by Fanuc as the best so lu tion to solve dec i mal point woes


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


FANUC CNC Custom Macros


88


Chapter 7


Metric and English Units


For all dimensional words used in a CNC program (such as X, Y, Z, I, J, K, R, F, etc), the de –


clared vari ables may be ref er enced with the ap pro pri ate di men sional word, for ex am ple:


#1 = 116348


Variable is declared or defined


G00 X#1


Variable is used


drilling Machine


If the se lected units in the pro gram are Eng lish units (pro grammed in the Busway Press Clamp Machine G20 mode), the mo –


tion block G00 X#1 will be in ter preted as G00 X116348 If the pro gram ming units are met ric


(pro grammed in the G21 mode), the G00 X#1 will be in ter preted as G00 X11635 This is a


very im por tant dif fer ence A vari able that is called in the macro will be au to mat i cally rounded to


the least in cre ment custom processing machine (small est unit) of the pro gram ad dress


Least Increment


All CNC pro grams can use val ues within an al lowed range – up to a cer tain max i mum, and


down to a cer tain min i mum Max i mum val ues are sel dom an is sue, but ev ery pro gram mer should


un der stand the min i mum val ues They are of ten called the min i mum in cre ment or the least in cre –


ment These fancy ex pres sions can be trans lated to a much more prac ti cal state ment – the small est


amount of mo tion the ma chine can pro vide Re gard less of how they are called, they are dis tin –


guished by the num ber of dec i mal places:


Units system


Number of decimal places


Least increment


Metric


G21


3


xxxxxxxx


0001 mm


English


G20


4


xxxxxxxx


00001 inch


Bear in mind that as a rule, many Fanuc con drilling tools trols do not con vert from one unit of mea sure ment


to an other, only shift the dec i mal point Some fea tures in the con trol may be con verted, but never


count on such con ver sion in any pro gram de vel op ment If the dec i mal point is only shifted dur ing


units change, an Eng li

the vari able num ber – for example:

September 2, 2017 · Posted in Uncategorised · Comment 

the vari able num ber – for example:


#19 = 1200


Value of 1200 is assigned to variable number 19


it can be spindle speed (rev/min)


#9 = 1500


Value of 1500 is assigned to variable number 9


it can be feedrate (mm/min, m/min, ft/min, in/min, etc)


These two macro state ments store val ues – the value of 1200 is stored into the vari able #19 and


the value of 1500 into the vari able #9 Both val ues shown in the ex am ple are num bers, but they


are two dif fer ent types of a num ber


Real Num bers and Integers


There are two ba sic types of nu merical val ues used in punch machine for Head macros – a num ber can be ei ther:


u


High Speed Drilling Machine


REAL number


real number always requires a decimal point


u


INTEGER number


integer numbers cannot use decimal point


When per form ing math e mat i cal cal cu la tions, the type of every nu mer i cal value is im por tant In sim ple drilling steel terms, real num bers are typ i cally used for cal cu la tions, whereby in te ger num bers are used


for count ing and other ap pli ca tions that do not re quire a dec i mal point When a vari able num ber is


used in the macro pro gram, its value can be changed as re quired at any time, two or more vari –


ables may be used for math e mat i cal cal cu la tions, etc


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


FANUC CNC Custom Macros


86


Chapter 7


Variable as an laser cutting Expression


Vari ables can also be de fined by us ing an ex pres sion, where the ex pres sion is typ i cally a math e –


mat i cal for mula or a gen eral cal cu la tion The sim plest ex pres sion is nor mally a di rect value as –


sign ment within the macro body, for ex am ple:


#9 = 2500


Vari able #9 in the ex am ple con tains an as signed value of 2500 mm This ac tual value may be


used to re place a vari able value in the macro, for ex am ple, the cut ting feedrate:


G01 X3750 F#9


The F#9 macro state ment will be in ter preted as F2500 (mm/min) ac tual state ment Re def i ni –


tion of the vari able, for ex am ple #9=3000, will pass on the new def i ni tion to the macro body, so

ain val ues that can – and do – change

September 2, 2017 · Posted in Uncategorised · Comment 

ain val ues that can – and do – change


with each macro use For ex am ple, in stan dard pro gram ming, a macro may be used for re peat ing


the same toolpath for dif fer ent ma te ri als of the part Al though the toolpath it self may not change,


the spin dle speeds and the feedrates will be dif fer ent for each ma te rial For three ma te ri als, for ex –


am ple, three in di vid ual and sep a rate pro grams with many rep e ti tions would have to be writ ten


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


FANUC CNC Custom Macros


CONCEPT OF VARIABLES


85


Quite likely, the only dif fer ence be tween Busway Press Clamp Machine the three pro grams will be the S-ad dress for spin dle


speed in rev/min and the F-ad dress for feedrate value in mm/min (in/min) With a macro, both ad –


dresses S and F can be de fined as vari ables (be cause they will change for each of the three ma te ri –


als), then sup ply the suit able speed and feedrate val ues for dif fer custom processing machine ent ma te ri als, as needed By


chang ing only those two val ues, the pro gram can be used for many more dif fer ent ma te ri als, not


just three The main pro gram ming ben e fit is that the body of the macro pro gram does not change


at all, once it is ver i fied


drilling Machine


Variable Declaration


Be fore they can be used, vari ables have to be de fined – macro ex pres sion re fers to this ac tiv ity


as dec la ra tion of vari ables – vari ables have to be de clared Just like the data en try into the mem ory of a cal cu la tor, the ba sic rules gov ern ing the dec la ra tion of vari ables is that a vari able must be de –


fined first, and only then it can be used in a pro gram or a macro In the pro gram that uses the vari –


able, the form of def i ni tion is rep re sented by the # sym drilling tools bol (com monly called the pound sign or the sharp sign or the num ber sign) This num ber sign will be used in all mac ros The def i ni tion of a


vari able can take sev eral forms, the first of them is the vari able value:


#i = assigned current value


+


where the let ter ‘i’ represents