num ber from the con trol system mem ory In this re spect, all rules of a subprogram

September 2, 2017 · Posted in Uncategorised · Comment 

num ber from the con trol system mem ory In this re spect, all rules of a subprogram


def i ni tion have to be fol lowed in a macro def i ni tion


What is dif fer ent in the macro pro gram de vel op ment, are the vari able def i ni tions, func tions and


log i cal con di tions Vari able def i ni tions use vari ables to store var i ous data Vari ables are tem po –


rary stor age ar eas of the con trol sys tem mem ory – in the macro body they are de fined with a spe –


cial sym bol – the # sign Even at their sim plest level, mac ros will use vari ables, there fore they


will use the # sym bol The up com ing chap ters of fer a lot more in for ma tion and de tails


Variables are the single most important key to macro programming


Macro Call


Vi sually, the ma jor dif fer ence be tween call ing a subprogram and call ing a macro is de fined by


the pro gram ming for mat Logically, both calls are the same copper hole punching machine busbar bending machine and serve the same gen eral pur pose


In both cases, a pre vi ously stored custom processing machine pro gram (a subprogram or a macro) is re trieved from the con –


trol stor age area by a spe cific pro gram code:


M98 P—-


structural fabrication


Calls a subprogram P—-


(additional data are not normally required)


G65 P—-


Calls a macro P—-


(additional data are normally required)


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


FANUC CNC Custom Macros


76


Chapter 6


Fanuc con trol sys tem pro vides a G-code (pre pa ra tory com mand) to call a pre vi ously de fined


macro rather than a mis cel la neous func tion M used for subprograms This com mand is G65, and


rep re sents the call of a macro pro gram by its stored num ber, sup ple mented by ad di tional data


The fol low ing struc ture ex am ples il lus trate the dif fer ences:


2 Example 1 – Main program and a SUBPROGRAM :


O0004 (MAIN PROGRAM)


N1 G21


Startup block


N2 锟?


N15 M98 P8001


Call stored subprogram O8001


N16 锟?


N52 M30


End of main program


%


O8001 (SUBPROGRAM)


N1 锟?


N2 锟?


N14 M99


End of subprogram


%


2 Example 2 – Main program and a MACRO :

ddle of a block See Chapter 24 for details

September 2, 2017 · Posted in Uncategorised · Comment 

ddle of a block See Chapter 24 for details


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


MACRO STRUCTURE


6


De vel op ing macro pro grams is not much dif fer ent from de vel op ment of stan dard CNC pro –


grams, at least not in the gen


eral ap


proach Be


fore macro pro


grams can de


vel


oped, study


CNC Beam Drilling Machine


carefully the many 鈥榯ools of the cnc cutter trade锟?and ask a ques tion – what fea tures do we work with?


Macros have the po ten tial of be ing ex tremely pow er ful and flex i ble Macros can also shorten the


pro gram ming time by many hours, lit er ally Yet, in spite of their great pos si bil i ties, mac ros are


of ten the 鈥榝or got ten gems锟?avail able for CNC pro gram ming Many com pa nies do have macro ca –


pa bil i ties, but avoid ing them, con sid er ing them too dif fi cult and time consuming


Macro tools in clude many func tions, tech niques and pro ce dures Cus tom macro can not be clas –


si fied as a true pro gram ming lan guage, but macros do share many el e ments with lan guages such


as Vi sual Ba sic锟? C++锟? Lisp锟? and many oth ers, in clud ing the custom processing machine de riv a tives of the 鈥榚arly锟?lan –


guages, such as Pascal The most im por tant tool for the start is to know the for mat of the macro,


and its con tents When these two fea tures are con sid ered to gether, in the proper se quen tial or der,


we are talk ing about the macro structure


Basic Tools


Ev ery CNC pro gram ming tech nique that a typ i cal part pro gram mer has already learned can be –


and are – used in mac ros and macro de vel op ment An in-depth knowl edge of CNC pro gram ming,


com bined with a good prac ti cal ex pe ri ence (even ma chin ing helps), is an es sen tial re quire ment to


learn ing mac ros and learn ing them right from the be gin ning Many pro gram ming aids not found


in standard CNC pro gram ming are also avail able in mac ros, but they en hance and best mill drill ex tend the


traditional pro gram ming meth ods – they do not re place them


There are three ba sic ar eas to un

derstand for successful macro development

September 2, 2017 · Posted in Uncategorised · Comment 

derstand for successful macro development:


u


Variables


three types of data


u


Func tions and Con stants


math e mat i cal cal cu la tions


u


Logical Functions


loops and branches


cnc drilling Machine


These three fea ture ar eas of fer many pow er ful spe cial func tions that are used within the body of


a macro, which is very sim i lar to a body of a subprogram, ex cept stan dard subprograms can not


use vari able data, whereby mac ros can (and do so very ex ten sively)


Just like a subprogram, a macro by it self is not much of a use – it has to be custom Drilling Machine in ter wo ven (in ter –


faced) with an other pro gram, called from an other pro gram, by a pre vi ously as signed pro gram


num ber The ad dress (let ter) O is used to store the macro pro grams, the ad dress (let ter) P is used


to call it, ap ply ing the same logic as for subprograms


73


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


FANUC CNC Custom Macros


74


Chapter 6


Variables


Vari ables are the most no tice able fea ture in mac ros They are the hole punching machine heart and soul of all mac ros


Vari ables give mac ros the nec es sary flex i bil ity, by be ing what they are – stor age units for data


that con stantly changes – the so called vari able data The name 鈥榲ari able锟?is sug ges tive enough –


vari ables are stor age ar eas in the con trol sys tem that can hold a cer tain sup plied value When a


value is as signed to a vari able, it is stored there for fu ture use Stored val ues are called the de fined


val ues, or de fined vari ables


In mac ros, vari ables can be used in stead of real val ues and they can be acted upon, for ex am ple,


by add ing two vari ables to gether, to get yet an other value The pos si bil i ties are enor mous and


greatly de pend on the skill of the part pro gram mer – or the macro pro gram mer


Functions and Constants


There is a sig nif i cant num ber of func tions avail able for mac ros Func tions drilling tools are pro gram fea tures


that cal cu late some thing – they solve a math e mat i cal cal cu la tion or a for mula For ex a

determine further flow of the program

September 2, 2017 · Posted in Uncategorised · Comment 

on ‘while’ the given


con di tion is true – which means ‘as long as’ the con di tion is true) The re sult of the eval u a tion will


determine further flow of the program


Copyright 2005, Industrial Press Inc, New York, copper busbar bending machine NY – wwwindustrialpresscom


FANUC CNC Custom Macros


MACRO STRUCTURE


75


Defining and Calling Macros


Beam Drilling Machine


In es sence, a macro is a much more so phis ti cated subprogram From that view point, it is fair to


make a com par i son be tween a reg u lar subprogram and a typ i cal macro There are al ways at least


two in di vid ual pro grams in volved in this type of pro gram ming en vi ron ment – the main pro gram


and the subprogram This is also true for macros – there is the main pro gram and the macro pro –


gram In both cases, the main pro hydraulic busbar cutter gram calls the subprogram or the macro, by its num ber, which


makes the subprogram or the macro pro gram sub ser vi ent to the higher level pro gram copper busbar bending machine that calls it


Just like a subprogram, a macro can be called not only by the main pro gram (the pro gram at the


top), but also by any other subprogram or macro as well, up to a four-level depth As ex pected,


certain struc tures must be ob served In all cases, the subprogram or the macro con tains spe cially


se lected re pet i tive data, such a con tour ing toolpath or a spe cific hole pat tern, and in all cases these


data are stored as sep a rate pro grams, un der their own unique pro gram num bers


The sin gle ma jor dif fer ence be tween a subprogram and a macro is the flex i bil ity of the in put


data Subprograms al ways use fixed data, these are val ues that can not change Macros use flex i ble


data, us ing vari able val ues, that can be changed (de fined or re de fined) very quickly Of course,


mac ros may use fixed data as well, but that is not their main pur pose


Macro Definition


Struc turally, de fin ing a macro is a very sim i lar to de fin ing a subprogram In both cases, the pro –


gram is as signed a pro gram num ber In its body, the re pet i tive data are stored and ac ces si ble un –

In addition to functions, constants can be defined in a macro as well, for example the p constant

September 2, 2017 · Posted in Uncategorised · Comment 

(plus) func tion will sum two or more val ues to gether The SQRT func tion will cal cu late the square root of a given num ber Many other func tions are avail able, for arith metic, algebraic, trig o no metric, and many other calculations


In addition to functions, constants can be defined in a macro as well, for example the p constant


with the value of 314159265359


Logical Functions


Log i cal func tions – also known as log i cnc plate drilling machine cal op er a tors – are used in a macro pro gram for loop ing and branch ing pur poses, some times called a di ver gence Loop ing and branch ing means a change


in the pro gram flow that is based on – and de pend ent on – a cer tain con di tion that has been pre vi –


ously de fined


cnc drill Machine


We are quite fa mil iar with the con cept of log i cal op er a tors in ev ery day life, we just don鈥檛 call


them that In Eng lish lan guage, there is a short word ‘if’ We use it very fre quently to pres ent a


cer tain state ment based on a con di tional sit u a tion For ex am ple, hole punching machine we may say, 鈥淚f I have time, I will


visit you锟? That state ment means that I can only visit you, if I have time, oth er wise, it will not be pos si ble, and I can not visit you at all These out comes are con di tional The ‘if’ word im plies a choice based on the re sult of a cer tain con di tion


In mac ros, there are two func tions that are used with a given con di tion The given con di tion


may be checked (some pro drilling machine gram mers may say 鈥榯ested锟?or 鈥榚val u ated锟? on sev eral grounds, us ing


the com par i son op er a tors, such as ‘greater than’ , ‘equal to’ , ‘less than or equal to’ , and sev eral oth ers, used to gether with the ‘if’ func tion These op er a tors are called the Boolean op er a tors, named af ter their in ven tor George Boole (1815-1864), an Eng lish math e ma ti cian They are also


called the log i cal op er a tors The given con di tion can be eval u ated (tested) only once, us ing the ‘if’


check It may also be eval u ated many times, pro gres sively, us ing a loop func ti