ke ad van tage of it When a macro is

Sep 04
2017

ke ad van tage of it When a macro is


called, any cur rent modal com mand should al ways be reg is tered at the be gin ning of the macro, if


that is not the case, then def i nitely be fore any changes are made within the macro


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


FANUC CNC Custom Macros


168


busbar Machine


Chapter 12


Restoring Modal Data


Since the orig i nal G-code(-s) have been stored for the sin gle rea son of re stor ing them later, they


have to restored be fore the macro ends, typ i cally at the end, just angle machine be fore the M99 func tion Us ing


two sys tem vari ables introduced in the pre vi ous ex am ple, here is a sche matic lay out of a macro


pro gram structure, show ing both the stor age and the res to ra tion of two modal val ues:


O0018 (MACRO MODAL VALUES)


#31 = #4201


Store the current motion command


#32 = #4203


Store the current dimensioning mode


G90 G00 G54 X1500 Y750


< macro processing 锟?>


G#31 G#32


Restore both previously saved modes


M99


%


In the automatic punching machine ex am ple segment, the vari ables #31 and #32 store the cur rent val ues of the mo tion and


dimensioning modes, at the very be gin ning of the macro The macro then pro ceeds with its own


def i ni tions, G-code changes, and so on, and be fore the macro end (be fore M99), the orig i nal val –


ues, the pre vi ously stored val ues, are re trieved to be come modal af ter the macro ex its Since both


of the pre vi ously stored val ues rep re sent modal com mands, the pro gram ming re turns from the


macro to the same en vi ron ment that ex isted be fore the macro was called Log i cal method of num –


ber ing sys tem vari ables will be also ap plied to the other modal codes


Other Modal Functions


In punching machine ad di tion to the modal G-codes, there are ad di tional eleven modal codes used in typ i cal macro


pro gram ming Just like the G-codes, in a macro cal cu la tion (or a for mula), these pro gram codes


can not be pro grammed to the left side of the equal sign, which means they can not be as signed


value through the pro gram T

FS-M and FS-T controls

Sep 04
2017

FS-M and FS-T controls


#4021


21


N/A


#4022


22


G501 G511


For ex am ple, when the macro pro gram con tains ex pres sion #1=#4001, and the vari able is


pro cessed, the re turned value stored in #1 may be 0, 1, 2, 3, or 33, de pend ing on the ac tive


G-code in Group 01


busbar Machine


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


FANUC CNC Custom Macros


166


Chapter 12


Fanuc 10/11/15


Typ i cal list ing of G-codes (pre pa ra tory commands) modal in for ma tion for the higher level CNC


con trol systems:


System


Variable Number


G-code


Group


G-code Commands


Preceding Executing


Block


Block


#4001


#4201


01


G00 G01 G02 G03 G33


Note: G31 belongs to Group 00


#4002


#4202


02


G17 G18 G19


#4003


#4203


03


G90 G91


#4004


#4204


04


G22 G23


#4005


#4205


05


G93 G94 G95


#4006


#4206


06


G20 G21


#4007


#4207


07


G40 G41 G42


#4008


#4208


08


G43 G44 G45


#4009


#4209


09


G73 G74 G76


G80 G81 G82 G83 G84 G85 G86 G87 G88 G89


#4010


#4210


10


G98 G99


#4011


#4211


11


G50 G51


#4012


#4212


12


G65 G66 G67


#4013


#4213


13


G96 G97


#4014


#4214


14


G54 G55 G56 automatic punching machine G57 G58 G59


#4015


#4215


15


G61 G62 G63 G64


#4016


#4216


16


G68 G69


#4017


#4217


17


G15 G16


#4018


#4218


18


G501 G511


#4019


#4219


19


G401 G411 G421


#4020


#4220


20


N/A to FS-M and FS-T controls


#4021


#4221


21


N/A


#4022


#4222


22


N/A


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


FANUC CNC Custom Macros


MODAL DATA


167


Saving and Restoring Data


The two of the most el e men tary pro gram ming rules are log i cal ap proach and pro gram ming


neat ness This hand book tries to fol low these rule dil i busbar punching machine gently, be cause they help in making a high


qual ity macro pro gram The goal is a CNC pro gram or a macro that is writ ten in a log i cal man ner,


is well or ga nized, fol lows op er a tional steps CNC Angle Line in a me thod i cal way, does not take any thing for


granted, and, yes – is neat and el e gant The re sult is a pro gram that is much eas ier to in ter pret,

-codes of all modal groups can be

Sep 04
2017

-codes of all modal groups can be


saved into a lo cal or a com mon macro vari able, typ i cally be fore the G-code is changed in the


macro The main pur pose of the sav ing the cur rent modal G-code(-s) is the safety be ing built into


the macro pro gram, busbar bending machine but also the ef fort of main tain ing pro fes sional pro gram ming en vi ron ment


For ex am ple, if the work off set G56 is used in the macro, and no ac tion is taken, the G56 will be –


busbar Machine


come the cur rent co or di nate sys tem af ter the macro is com pleted, for any pro gram that is loaded


af ter Such a sit u a tion may be very de struc tive, if – for in stance – the flow of the main pro gram ex –


e cu tion de pends on the G54 work off set A pro fes sional pro gram mer al ways saves the cur rent


modal G-values within the macro, then changes the val ues that need to be used in the macro body


The new val ues can be used freely, as needed, as many times as needed, within the macro, while


the macro is active Fi nally, be fore the macro ex its, the orig i nal val ues used in the main pro gram


or an other macro are re stored and ap plied for the sub se quent pro gram flow


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


FANUC CNC Custom Macros


MODAL DATA


165


Fanuc 0/16/18/21


Typ i cal list ing of G-codes (pre pa ra tory commands) modal in for ma Dished Head Punching Machine tion for the lower level CNC


con trols (pre ced ing block only – ex e cut ing block is not avail able):


System


Variable


G-code


G-code


Number


Group


Commands


#4001


01


G00 G01 G02 G03 G33


Note: G31 belongs to Group 00


#4002


02


G17 G18 G19


#4003


03


G90 G91


#4004


04


G22 copper busbar machine G23


#4005


05


G93 G94 G95


#4006


06


G20 G21


#4007


07


G40 G41 G42


#4008


08


G43 G44 G45


#4009


09


G73 G74 G76 G80 G81 G82 G83 G84 G85 G86 G87 G88 G89


#4010


10


G98 G99


#4011


11


G50 G51


#4012


12


G65 G66 G67


#4013


13


G96 G97


#4014


14


G54 G55 G56 G57 G58 G59

relative beginner in macro development

Sep 03
2017

change, if necessary, even by a machine bending relative beginner in macro development There are


two meth ods ap plied in macro pro gram ming that be long to this cat e gory


Saving Modal Data


To save (store) the cur rent value of a G-code (or other modal codes), is to pre serve them for


later use – or rather re-use The cur rent value is stored into a vari able and re trieved to re store the


orig i nal set ting In a typ i cal macro, there will be many G-codes used, most of them modal This


pro gram ming con ve nience also pres ents a po ten angle machine tial prob lems When a macro ex its, the modal


busbar Machine


G-codes used by the macro will still be in ef fect That cre ates a very dis or ga nized way of macro


pro gram de vel op ment, and can lit er ally be a cause of many se ri ous and hard to find prob lems Al –


though any modal G-code groups can be saved (and even tu ally re stored), only two or three groups


are com monly saved and re placed in most mac ros (add others, if needed):


o


G-code Group 01


Motion Commands


Rapid, Linear, Circular


G00, G01, G02, G03, G33


o


G-code Group 03


Dimensioning Mode


Absolute or Incremental mode


G90 or G91


o


G-code Group 06


Measuring Units


Metric or English


G21 or G20


Typ i cal method of sav ing the cur rent G-code mode is to as sign the se lected sys tem vari able into


a lo cal vari able A com mon vari able may also be used, in some very spe cial ap pli ca tions Here is


an ex am ple that stores the cur rent mode of Group 01 (mo tion com mands), and the cur rent mode


of dimensioning from Group 03:


#31 = #4201


Store the current motion command mode


Group 01 (G00, G01, G02, G03 or G33)


#32 = #4203


Store the current dimensioning mode


Group 03 (G90 or G91)


#33 = #4206


Store the current units mode


Group 06 (G20 or G21)


Note that the last two dig its of the sys tem vari able match the modal G-code Group num ber This


is no co in CNC Angle Line ci dence Such log i cal num ber ing of fers an easy way of re mem ber ing It can also be ap –


plied within a macro pro gram in some in ge nious way, to ta

These control models also use a set of two 4000 series variables

Sep 03
2017

formation


These control models also use a set of two 4000 series variables, but with a wider range:


#4001 to #4130


Modal Information


(Preceding Block)


#4201 to #4320


Modal Information


(Executing Block)


busbar Machine


163


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


164


Chapter 12


Preceding and Executing Blocks


The pur pose of the 4000 se ries of sys tem vari ables is to pro vide the CNC macro pro gram mer


with modal in for ma tion that is cur rent at any given time There are two groups of in for ma tion


avail able, the pre ced ing block, and the ex e cut ing block


u


Preceding Block


In this group is the modal information that is already active


This block is also called the pre-reading block


u


Executing Block


In this group is the modal information that will become active


when the current block is being executed


Note that the Executing Block is not available


on Fanuc models FS-0, FS-16, FS-18 and FS-21


Modal cnc equipment G-codes


Apart from axis com mands, of all the re main ing modal com mands, the G-codes are the most


prom i nent and most com automatic punching machine monly used in mac ros For all Fanuc con trols, the first sys tem vari able is


#4001, where the last digit (1) means modal G-code Group 01, #4002 re fers to the G-code


Group 2, and so on Group 00 is not sup ported, be cause the 4000 se ries of sys tem vari ables serves


the modal in


for


ma


tion only, and G-codes in the Group 00 are non-modal For the Fanuc


0/16/18/21 con trols, the sta tus of var i ous modal G-codes is al ways stored in sys tem vari ables


within the #4001-#4022 range, and the other codes within the range of #4102-#4130 All


these vari ables are modal in for ma tion of the pre ced ing block For the Fanuc 10/11/15 con trols,


the sta tus of modal sys tem vari CNC Angle Line ables is di vided be tween the pre ced ing block (sys tem vari ables


within the #4001-#4130 range), and the ex e cut ing block (sys


tem vari


ables within the


#4201-#4330 range)


Within ei ther range of vari ables, the cur rent value of the G

Visit Our Friends!

A few highly recommended friends...

Pages List

General info about this blog...