Archive for September, 2017

sep a rate lists for the as sign ment of lo cal vari ables They are called the As sign

sep a rate lists for the as sign ment of lo cal vari ables They are called the As sign –


ment List 1 and the As sign ment List 2 In both lists, a let ter of the Eng lish al pha bet is ar bi trarily as signed a vari able copper busbar bending machine num ber, built into the con trol soft ware For ex am ple, in both as sign ment lists,


the let ter A is as so ci ated with a lo cal vari able #1, let ter B is as so ci ated with a lo cal vari able #2, and punch machine for Head the let ter C is as so ci ated with a lo cal vari able #3


The as sign ments vary greatly be tween the List 1 and the List 2, and the or der of num bers does


not al ways fol low the or der of the let ters as Busway Press Clamp Machine it may appear from A=#1, B=#2, C=#3 example


Assignment List 1 – Method 1


plate drilling machine


The vast ma jor ity of macro ap pli ca tions use the vari ables from the As sign ment List 1 It only


con tains 21 as sign ments for lo cal vari ables, but that is a num ber more than suf fi cient for the ma –


jor ity of mac ros The 21 let ters of the Eng lish al pha bet are as signed lo cal vari ables, as ar gu ments,


de fined in the G65 macro call, and passed to the macro body


The As sign ment List 1 is de fined by Fanuc in the fol low ing ta ble:


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


FANUC CNC Custom Macros


ASSIGNING VARIABLES


95


Argument List 1 Address


Local Variable in a Macro


A


#1


B


#2


C


#3


D


#7


E


#8


F


#9


H


#11


I


#4


J


#5


K


#6


M


#13


Q


#17


R


#18


S


#19


T


#20


U


#21


V


#22


W


#23


X


#24


Y


#25


Z


#26


Assignment List 2 – Method 2


Only a very few macro ap pli ca tions use the As sign ment List 2 It con tains 33 as sign ments of lo –


cal vari ables, in case there is a need for more than the 21 lo cal as sign ments from the As sign ment


List 1 The first three as sign ments, A, B, and C are the same, but that is where the sim i lar ity ends


These as sign ments are sup ple mented by a set of 10 ar gu ment groups, iden ti fied as I1 J1 K1 to I10 J10


K10 This method may be some what harder to im ple ment, par tic u larly by be gin ners

used in side of macro, as al ready es tab lished

used in side of macro, as al ready es tab lished


Al though #10 in di cates a miss ing let ter G, #14 a miss ing let ter N, #15 a miss ing let ter O, and


#16 a miss ing let ter P, #12 is out of or der Try to think of the copper busbar bending machine dis al lowed let ters, not cnc cutter the num –


bers The let ters that can not be used in a vari able as sign ment (G65 block) are:


o


G address Preparatory command


o


L address Number of repetitions (for macros, subprograms, and fixed cycles)


o


N address Block number (sequence number)


o


drilling Machine


O address Program number designation


o


P address Program number call


These are re stricted let ters (try the word GNOPL to re mem ber them) and can not be as signed any


value for any pur pose Of the five, only the let ter G can be used for a spe cial pur pose, such as a


def i ni tion of a new G-code Cus tom G-codes can ac tu ally called a macro, for ex am ple, a spe cially


de vel oped unique cy cle rather than us ing the G65 macro call, the new G-code type macro call


looks like a nor mal G-code, and is of ten eas ier to work with Chap ter 21 cov ers this sub ject


Simple and Modal Macro Calls


The G65 com mand is de fined as a macro call That is cor rect, but it should re ally be de fined as


a sim ple or sin gle macro call The word 鈥榮im ple锟?in this case means 鈥榗alled once锟? or 鈥榥on-modal锟?


In a pro laser cutting gram, G65 can only be used once at a time – as it is not a modal com mand It may be


called any time when needed, but all vari ables must be al ways re de fined This may prove im prac ti –


cal, when a macro should re tain the ar gu ments for more than a sin gle call To sat isfy this need,


Fanuc does also of fers a modal macro call com mand, in fact, it of fers two of them:


G66


Macro is called with an axis movement command only


G661


Macro is called with any command (not available on all controls)


Like other modal com mands, the modal macro call has to be can celed, when it is no lon ger re –


quired The modal macro can cel com mand is an other G-code:


G67


Modal macro call is canceled (G66 or G66

ment needs an explanation – where are the re maining 12 vari ables?

ment needs an ex pla na tion – where are the re main ing 12 vari ables? Why are


they miss ing? Is there a con nec tion be tween the miss ing num bers and the miss ing five let ters?


In the As sign ment List 1, there are only 21 vari ables (let ter) that can be de fined in the macro call


G65, but the re main ing 12 can only be de fined within the body of a macro Look care fully on the


num bers of those vari ables miss ing in the As sign ment List 1 The fol low ing num bers are only


those not avail able in the List 1:


Vari ables


drilling Machine


#10, #12, #14, #15, #16, #27, #28, #29, #30, #31, #32, and #33


are not part of the As sign ment List 1 Yet, they can be de fined in ter nally, within the macro body only, also as lo cal vari ables They can be re de fined and used again, but they are not tied up to a


let ter ad dress like the ‘nor mal’ 21 vari ables


A good ex am ple to il lus trate the con cept of us ing these vari ables in the macro body is vari able


#33, al though the ex am ple drilling steel ap plies equally to other ‘miss ing’ vari ables Since #33 is the last


avail able vari able num ber, many macro pro gram mers of ten use it as a coun ter def i ni tion for


macro loops (any other vari able can be used for the same pur pose with the same re sult) A coun ter


for loops is of ten re quired within the macro body, but there is no need to de fine it in the G65


macro call state ment, where it would have be de fined by one of the as sign able 21 vari ables


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


FANUC CNC Custom Macros


98


Chapter 8


Disallowed Addresses


The next ‘mys tery’ to solve is the mys tery of the five miss ing let ters – ad dresses Why there are


only 21 of the 26 Eng lish al pha bet let ters that can be used? The five re main ing let ters are miss ing


for a good rea son Just by look ing at the miss ing num bers in the As sign ment List 1 may pro vide a


clue drilling tools These num bers are miss ing in the As sign ment List 1:


#10, #12, #14, #15, and #16


Note – these vari ables can only be

local to the program that called them We use local variables

local to the program that called them We use local variables


to as sign val ues to macro pro gram ar gu ments Lo cal vari ables are also used for a tem po rary stor –


age within the macro body, dur ing cal cu la tions of for mu las and other ex pres sions


In ad di tion to the G65 command, there are also pre pa ra tory com mands G66, G661, and G67, all re lated to mac ros The G65 com mand cnc cutter is most sig nif i cant of them and is cov ered here in depth


93


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


FANUC CNC Custom Macros


94


Chapter 8


Clearing Local Variables


CNC Plastic plate drilling machine


Lo cal vari ables are nor mally cleared (made va cant) by an in ter ven tion from the con trol panel


(usu ally done by the CNC op er a tor), or a pro gram code (usu ally done by the CNC pro gram mer)


Each of the fol low ing hydraulic busbar cutter ac tions will clear the lo cal vari ables and sets them to null:


o


Pressing the control RESET key will set all local variables to null


o


Pressing the external RESET key will set all local variables to null


o


Pressing the EMERGENCY switch will set all local variables to null


o


Programming code M30 custom processing machine (program end) will set all local variables to null


o


Programming code M99 (subprogram end) will set all local variables to null


Any lo cal vari able can be cleared by these means, but it can also be cleared in a macro pro gram,


if re quired In the macro state ment, it must be as signed the value of #0 Some man u als re fer to the pro cess of clear ing vari ables in a pro gram as a pro cess of purg ing vari ables, with the same mean –


ing This ex am ple il lus trates the clear ing (purging) pro cess of lo cal vari ables in a pro gram:


#1 = 1350


Sets a value of variable #1 to 1350


G00 X#1


Uses variable #1 in the macro (X will be equal to X1350)


#1 = #0


Sets #1 variable to #0 (null) – it holds no value – it is called


an empty or null or vacant variable – with the same meaning


A null vari able is always iden ti fied as #0, never as a 0 only !


Assigning Local Variables