Archive for September, 2017

S-code – spindle speed value

S-code – spindle speed value


#4120


T-code – tool number


#4130


P-code – additional work offset number


As the ta ble illustrates, the only ex cep tion in the ta ble is the #4130 vari able – it has no cor re –


drilling Machine


spond ing value in the As sign ment List 1 for lo cal vari ables It was added by Fanuc later, when the


CNC tech nol ogy ad vanced, to ac com mo date the ex tended work off set set, also known as the ad di –


tional work off sets – G541 P1 to G541 P48 Vari ables that would ‘fit nat u rally’ in the ta ble, but are miss ing, for ex am ple #4118, are quite le git i mate to use, pro vid ing they are sup ported by


the con trol sys tem for the par tic u lar CNC ma chine tool (not ex actly a likely sce nario)


There are two sys tem vari able num bers that may seem out of or der – they are #4114 (the let ter


N, the ad dress for the se quence num bers), and #4115 (the let ter O, the ad dress for the pro gram


num ber) In the As sign ment List 1, there are no #14 cnc equipment and #15 lo cal vari ables listed These as sign –


ments are phys i cally ex cluded in the list, but notching machine they are im plied by their on-pres ence


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


FANUC CNC Custom Macros


170


Chapter 12


Fanuc 10/11/15


The list ing of sys tem vari ables for the higher group of Fanuc con trols uses both sets of vari ables


– for the pre ced angle shearing machine ing block, and for the ex e cut ing block


System


Variable Number


Program Address


(Code Letter)


Preceding Executing


Block


Block


#4102


#4302


B-code – indexing axis position


#4107


#4307


D-code – cutter radius offset number


#4108


#4308


E-code – feedrate value (if available)


#4109


#4309


F-code – feedrate value


#4111


#4311


H-code – tool length offset number


#4113


#4313


M-code – miscellaneous function


#4114


#4314


N-code – sequence number


#4115


#4315


O-code – program number


#4119


#4319


S-code – spindle speed value


#4120


#4320


T-code – tool number


#4130


#4330


P-code – Additional work offset number

As in the table for the modal G-codes listed earlier

his is sim i lar to the con cept of ead-only and the ead-and-write


type of vari ables in many gen eral com mer cial pro gram ming lan guages, cov ered in the last chap –


ter The listing of the ‘other’ eleven modal ad dresses that can be used in macro pro gram ming, is


pre sented here:


B D E F H M N O S T P


These modal codes are in ad di tion to the modal G-codes On the next two pages are the list ings


drilling Machine


of the sys tem vari ables re lat ing to the ‘other’ modal ad dresses, for the two com mon types of


Fanuc con trols Ob serve angle machine the method of how these vari ables are num bered, again, there is a log i cal


method to it, and a lit tle dif fer ent one from the one used for modal G-codes Also note the last two


dig its of each sys tem vari able num ber They cor re spond to the Lo cal Vari ables As sign ment List 1


For ex am ple, the let ter B is as signed to the lo cal cnc equipment vari able #2, hence the #4102 sys tem vari able,


the let ter D is as signed to the lo cal vari able notching machine #7, hence the #4107 sys tem vari able, and so on


Very valu able ob ser va tion that can come handy


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


MODAL DATA


169


Fanuc 0/16/18/21


As in the table for the modal G-codes listed earlier, the lower level con trols use only sys tem


vari ables ap ply ing to the pre ced ing block The sys tem vari ables re lated to the ex e cut ing block are not avail able for this group of Fanuc con trols (FS-0/16/18/21)


The fol low ing ta ble shows the other modal in for ma tion (eleven com mon ad dresses) fre quently


used in a macro pro gram with their cor re spond ing sys tem vari ables


System


Variable


Program Address


Number


(Code Letter)


#4102


B-code – indexing axis position


#4107


D-code – cutter radius offset number


#4108


E-code – feedrate value (if available)


#4109


F-code – feedrate value


#4111


H-code – tool length offset number


#4113


M-code – miscellaneous function


#4114


N-code – sequence number


#4115


O-code – program numbe

Basic language in its original form is now a his tory

Basic language in its original form is now a his tory, many of its rules and


struc tural forms still do ex ist Ba sic lan guage has de vel oped into the cur rent Vi sual Ba sic, very mod ern, and struc tured, high level lan guage One of the rem nants busbar bending machine of the old Ba sic is the func tion


GOTOn, and GOSUB, both con sid ered to day a very poor way of lan guage based pro gram struc –


ture How ever, the other branch ing func tions (IF, IF-THEN, and WHILE) are avail able to con –


drilling Machine


trol the flow of the macro pro gram


In ei ther form, the de ci sion is al ways based on the re sult of a given con di tion, or given sit u a –


tion De pend ing on this re sult, at least two other op tions must be avail able for fur ther con sid er –


ations As an ex am ple, the ev ery day Eng lish equiv a lent of – f I have money, I will buy a car


has two parts The con di tion here is ‘if I have money’ – ‘to have money’ There are two logical out –


comes – they are ‘I will buy a car’ and cnc equipment ‘I will not buy a car’ , one or the other, but never both f I


have money, I will buy a car, but notching machine I do not have money, so I will not buy a car Sim ple logic, and very pow er ful when ap plied to mac ros


The sim plic ity of the above ex am ple is very strong when trans ferred into the realm of a macro


pro gram ming Of course, the macro con di tions and macro op tions will al ways be dif fer ent, but


the logic, the eval u a tion, the think ing pro cess, and the de ci sion will not


For ex am ple, one ob jec tive of a macro could be to check if the cut ting tool trav els within the


lim its of the ma chine For each axis to be tested, a very spe cific con di tion will be created – f the


length of travel is greater than the given dis tance, then , and the macro will have to con tain the


de ci sion in it own format If the con di tion spec i fied is true, the CNC op er a tor may be no ti fied


with an alarm mes sage or at least a pro gram com ment If the con di tion is false (not true), the


macro will pro ceed with the pro gram flow

with out in ter rup tion The op er a tor may not even be

with out in ter rup tion The op er a tor may not even be


aware of the eval u a tion and Drilling Machine for Plate de ci sion tak ing place This chap ter cov ers var i ous as pects of con di –


tional test ing, branch ing, and loop ing, de pend ing on the com plex ity of the given con di tion and the


pur pose of such eval u a tion


drilling Machine


The first and the sin gle ma jor func tion in all the above ex am ples is the IF func tion


171


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


FANUC CNC Custom Macros


172


Chapter 13


IF Function


IF


The IF func tion has sev eral names – it is called the de ci sion func tion, the di ver gence func tion, or most com monly, the con di tional func tion The for mat of th IF func tion is:


IF [ CONDITION IS TRUE ] GOTOn


where n is the block num ber to branch to, but only if the eval u ated con di tion (the re turned value) is TRUE If the con di tion is true, all state ments be tween the IF-block and GOTOn-block will be by passed If the eval u ated con di tion is not TRUE, it is FALSE, and the pro gram will con –


tinue pro cess ing the next block fol low ing the block con tain ing the IF func tion We can sche mat i –


cally rep re Dished Head Punching Machine sent the last ex am ple in a sim ple flow chart in Fig ure 19


Figure19


IS


Schematic flowchart representation


TRAVEL


of the


YES


IF conditional branching


TOO


ISSUE ALARM


LONG


???


NO


RUN


PROGRAM


The flowchart only shows the de ci sion mak ing and the re sults, not any com plete pro gram The


di ag o nal box iden ti fies the con di tion to be eval u ated (for ex am ple, ma chine travel lim its), and the


two rect an gu lar boxes iden tify two – and only two – pos si ble out comes (YES or NO) Each out –


come re sults in an ac tion to be taken:


o


If the travel Angle Punching IS too long, gen er ate alarm condition and stop pro cess ing


o


If the travel IS NOT too long, run the rest of the pro gram nor mally


The IF func tion is one of the macro state ments that con trol the or der of pro gram pro cess ing


Conditional Branching


Branching from one block of

What is missing are all system variables that have some thing to do

n that may be valu able from this chap ter re lates to the list It is not what is in –


cluded, but what is miss ing Modal com mands used in the macro pro gram ming have been dis –


cussed ex ten sively, along with the re lated sys tem vari ables An other sub ject dis cussed was the


ma jor group of the modal G-code ad dresses, and eleven other modal ad dresses What is miss ing?


What is missing are all system variables that have some thing to do with a tool po si tion, such as


end point co or di nates in a block, work co or di nates, angle machine ma chine co or di nates, var i ous tool off set po si –


tions, co or di nates re lated to the skip func tion, and so on – even de vi a tion amount of the servo po –


drilling Machine


si tion, etc


In the chap ters that fol low this one, more sys tem vari ables will be cov ered, most listed ear lier in


a de scrip tive form They in clude those re lated to alarms, tim ers, and var i ous axis po si tion in for –


ma tion The next chap ter cov ers an other part of the most im por tant automatic punching machine macro pro gram ming tools –


conditional testing, branch ing and loop ing


Copyright 2005, Industrial Press Inc, New Dished Head Punching Machine York, NY –


FANUC CNC Custom Macros


BRANCHES AND LOOPS


13


About half way through the hand book, now co mes a real pow er house of mac ros At this level of


macro de vel op ment, strong ba sic knowl edge of macro com mand struc ture, off sets, mem o ries, as


well as understanding vari ables, etc, is essential A vari able is as signed a value, macro is pro –


cessed with that value in ef fect, macro ex its This straight for ward ap proach is convenient, and


very com mon, but it can not and does not stand alone It needs some ad di tional forms of data ma –


nip u la tion, forms based on some kind of de ci sion mak ing pro cess


Decision Making in Macros


The struc ture of a typ i cal Fanuc macro pro gram is based on the old est and sim plest of all com –


puter lan guages – Ba sic锟? The Ba sic lan guage proved to be sim ple, yet pow er ful, lan guage for its