Archive for September, 2017

When either variable is called in the macro body

s signed to ar gu ment B


When either variable is called in the macro body, it will be re placed by the value as signed in that


ar gu ment In the case il lus trated, the macro block G00 X#1 Y#2 will be in ter preted as G00


X1200 Y800 In this case, the ar gu ments rep re sent tool mo tion as a lo ca tion or dis tance, but


could have hun dreds of other mean ings The ‘se cret’ of mac ros is that cnc cutter while the ar gu ments in the


macro call will change from job to job, the macro re mains the same For ex am ple, if the ar gu ment


is changed to G65 P8001 A2000 B1500, the rapid mo tion block in the macro will be in ter –


preted as G00 X2000 Y1500


Drilling Machine Steel Beam


This short il lus tra tion does not ex plain all de tails, but should serve as the first step to full and


com plete un der stand ing of macro con cepts and their development


In re gards to the macro def i ni tion, one may ask where the pro gram num ber O8001 came from


Is it a man da tory num ber? Why this num ber and not other? These, and many ques tions need some


ex pla na tion, which is pro vided in the next sec tion It is im por tant to keep in mind that all CNC


pro grams custom processing machine (subprograms and mac ros in cluded) may use any num ber within the pro vided range


(O0001 to O9999 or O00001 to O99999) So the first ques tion can be an swered neg a tively No,


this num ber is not man da tory To an swer the sec ond ques tion ad di tional knowl edge is re quired In


short, Fanuc con trols pro vide a se lected range of pro gram num bers that can have im por tant at trib –


utes at tached to them, for ex am ple, whether they can be ed ited or de leted Se lect ing macro pro –


gram num ber O8001 se lects a pro gram num ber that be long to such a range


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


FANUC CNC Custom Macros


MACRO STRUCTURE


79


Macro Program Numbers


Al though any 1 to 4 digit num ber within a range of O0001 to O9999 can drilling tools be as signed as a macro


pro gram num ber, cer tain ranges can be ma nip u lated to pro vide use ful ben e fits By def i

Parameter set tings of the bit type always de fine one of two possible states

UC CNC Custom Macros


80


Chapter 6


Parameter set tings of the bit type always de fine one of two possible states – never more and


never less When we ap ply these states to the ed it ing and displaying pro gram num bers, only two


pos si bil i ties ex ist for each set tings:


o


Pro gram editing is ALLOWED


or


o


Pro gram editing is NOT ALLOWED


o


Pro gram display during execution is ALLOWED


or


o


CNC H-Beam Drilling


Pro gram display during execution is NOT ALLOWED


In their man u als, Fanuc used ex pres sions such as per mit ted, pro hib ited, per formed, in hib ited,


pro punch machine for Head tected, all along with their op po sites There is noth ing Busway Press Clamp Machine wrong with these ex pres sions, ex cept


when drilling steel used at ran dom, they hardly pro vide con ve nience, easy in ter pre ta tion or con sis tency – and


they fail to pro vide user’s con fi dence The de scrip tion of each pro gram num ber range that fol lows


will use con sis tent and easy to un der stand ex pres sions


Program Numbers – Range O0001 to O7999


Stan dard pro grams (even subprograms) can be stored in the con trol sys tem un der any le git i mate


pro gram num ber, within the pro gram num ber range of O0001 to O7999 These pro grams can be


dis played and viewed at will, they can be reg is tered into the sys tem mem ory with out re stric tions,


and they can be ed ited at will at any time, also with out any re stric tions


If us ing mac ros, re strict standard program numbers within the range of O0001 to O7999


Program Numbers – Range O8000 to O8999


Two groups of pro gram num bers are re stricted by a pa ram e ter set ting The first group (Group


1) is in the range of pro gram num bers O8000 to O8999 It cov ers pro grams within the range of


O8000 to O8999 only Pro grams us ing num bers from Group 1 can not be ed ited, reg is tered, or de –


leted, with out a pa ram e ter set ting The pa ram e ter ac cess num ber de pends on the con trol sys tem:


Parameters related to EDITING – O8000-O8999 program range


Control System Parameter Bit Bit ID


Setting


0 = Program editing is ALLOWED

The data de fined with the macro call

AIN PROGRAM)


N1 G21


Startup block


N2


N15 G65 P8002 F1500


Macro call of O8002 with the F argument (= variable #9)


N16


N52 M30


End of main program


%


O8002 (MACRO)


N1


N2


cnc drilling Machine


N8 G01 X1500 Y2000 F#9


Variable #9 applied to feedrate


N14 M99


End of macro program


%


The two ex am ples are in cluded only to show the dif fer ences in struc ture Note, that the macro


ex am ple con tains two new types of data, data that has no equiv a lent in a subprogram – one called


vari ables, the other called ar gu ments


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


MACRO Busway Press Clamp Machine STRUCTURE


77


Arguments


The data de fined with the macro call, that is with the G65 P- com mand, are called ar gu ments


Ar gu ments con tain the ac tual pro gram val ues re quired for a drilling steel par tic u lar macro ap pli ca tion only


They are al ways passed to the macro it self Vari able data in the macro are re placed with the sup –


plied ar gu ments and the toolpath or other ac tiv ity is based on the cur rent def i ni tions (arguments)


passed to the macro


A typ


i


cal pro gram sam


ple of a G65 macro us


ing three ar


gu ments will have the fol


low


ing


schematic for mat:


G65 P- L-


+


where 锟?


G65


Macro call command


P-


Program number containing the macro (stored as O—-)


L-


Number of macro repetitions ( L1 is assumed as a default)


ARGUMENTS


Definition of local variables to be passed to the macro


An ac tual sam ple pro gram macro call may be de fined as:


G65 P8003 H6 A300 F1500


+


where 锟?


G65


Macro call command


P1234


Program number containing the macro (stored as O8003)


H6


Assignment of local variable H (#11) argument to be passed to the macro O8003


A300


Assignment of best mill drill local variable A (#1)


argument to be passed to the macro O8003


F1500


Assignment of local variable F (#9)


argument to be passed to the macro O8003


As sign ments of vari ables is a sep a rate sub ject cov ered in a sep a rate chap ter An as sign ment sim –


ply means giv ing the

Fanuc programs can be separated into the following program number groups

Fanuc programs can be separated into the following program number groups:


Program Number Range


Description


O0001 to O7999


Standard program numbers (typically for the main programs)


O8000 to O8999


Macro program number Group 1


Can be locked by a setting


Macro program numbers for special applications


O9000 to O9049


Can be locked by a parameter


(used with G, M, S, and T functions)


O9000 to O9999


Macro program number Group 2


Can be locked by a parameter


drilling Machine


There are sev eral good rea sons why mac ros de serve spe cial con sid er ation and or der punch machine for Head when


macro pro gram sys tem is considered By se lect ing a macro pro gram num ber from within a par tic –


u lar range, cer tain ben e fits be come ev i dent, as shown in the ta ble and ex plained in more de tail


Macro Pro gram Pro tec tion


The ma jor ity of stan dard CNC pro grams do not need pro tec tion of any kind When the word


pro tec tion is ap plied to these pro grams, it means one or both of the fol low ing at trib utes can be as –


so ci ated with the pro gram num ber:


o


Visibility of the pro gram on the control screen (pro gram di rec tory display)


o


Ed it ing of the pro gram contents (also in clud ing pro gram de le tion)


Macro pro grams need pro tec tion more than subprograms, and subprograms need more pro tec –


tion than the stan dard pro grams When plan ning a macro pro gram, it is im por tant to un der stand


the dif fer ence be tween the pro gram num ber se lec tion, par tic u larly in the avail able range of O8000


to O9999


Set ting Def i ni tions


In or der to se lect any level of pro tec tion, the ac tual set ting of an ap pro pri ate pa ram e ter must be


known and con trolled Since all set tings re lat ing to pro tec tion of pro grams are of the bit type, they


can only have a set value of 0 or 1 In this re spect, some us ers may ex pe ri ence dif fi culty in the Hydraulic punching machines ac –


tual in ter pre ta tion as drilling tools pro vided in a Fanuc Pa ram e ter Man ual


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

variable a value required at the time of call From the example

variable a value required at the time of call From the example, it is evident


that cus tom macro call G65 is only sim i lar to, but def i nitely not the same as, the subprogram call


M98 When two dif fer ent calls (M98 and G65) of a pre vi ously stored re pet i tive pro gram are com –


pared, there are sev eral very im por tant dif fer ences:


u


In the G65 command, argument is passed to the macro in the form of variable


data In M98 only the subprogram can be called No data passing is possible


u


In a subprogram call M98, the block may include another data ( ie, a motion to a


tool location) In this case, the processing can be stopped in a single block


mode This is not possible in the G65 mode


u


CNC Steel Structural Drilling Machine


In a subprogram call M98, the block may include another data ( ie, a motion to a


tool location) In this case, the processing of the macro starts only after the


other data is completed The G65 copper hole punching machine busbar bending machine command calls a macro unconditionally


u


Local variables are not changed with M98 but they are changed with G65


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


FANUC CNC Custom Macros


78


Chapter 6


Vi sual Rep re sen ta tion


Fig ure 16 shows a sche matic rep re sen ta tion of a macro def i ni tion and a macro call Note that the gen eral struc ture is iden ti cal with the one shown ear lier (Fig ure 4) – a sin gle level subprogram


nest ing struc ture


START


Figure 16


Macro definition and


O0001


O8001


macro call


(MAIN)


(MACRO)


Basic structure


G00 X#1 Y#2


G65 P8001 A1200 B800


M30


%


M99


%


END


In the main CNC pro gram, the macro call com mand G65 P8001 re trieves pre vi ously stored


macro O8001 and passes two ar gu ments to the macro – ar gu ment A and ar gu ment B Ar gu ment A


passes the cur rent value of 1200 best mill drill to the macro O8001, ar gu ment B passes the cur rent value of


800 to the same macro


Ar gu ments A and B have fixed vari able num bers as signed to them (see Chap ter 8 for de tails)


By def i ni tion, vari able #1 is as signed to ar gu ment A, vari able #2 is a