Archive for September, 2017

Initialize counter to the first variable (no # symbol !!!)

Tuesday, September 5th, 2017

Initialize counter to the first variable (no # symbol !!!)


WHILE[#33 LE 999] DO1


Loop through variables – shown range is #500-#999


#[#33] = #0


Set the current variable number to null (clear current variable)


busbar Machine


#33 = #33+1


Update variable number busbar bending machine count by one


END1


End of loop – return to the WHILE block and evaluate again


M99


End of macro


%


Vari able #33 is a lo cal vari able and serves as a coun ter Its ini tial set ting is 500, the first vari –


able of the range to be cleared The max i mum range is con trolled by the WHILE loop, and the ex –


am ple shows #999 as the last vari able in the range This num ber should be changed to match the


con trol sys tem This is also a macro, where the ba sic G65 state ment needs no ar gu ments:


O0019


Main program number


G65 P8011


Calls macro O8011 to clear all 500+ variables – no arguments


M30


End of main program O0019


%


The macro O8011 can be very eas ily adapted to learn ing vari ables in the 100+ se ries as well


Just change the ini tial set ting (#33) and the max i mum rage in the WHILE loop


Many ex am ples in the hand book use branch ing and loop ing func tions that can be used in ev ery –


day work The ma jor ity of them con tain com ments and ex pla na tions along with prac ti cal ap pli ca –


tions Use them as a re source to cre ate unique mac ros that can be Dished Head Punching Machine used on a daily ba sis


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


FANUC CNC Custom Macros


ALARMS AND TIMERS


14


The idea of ac tu ally caus ing an alarm dur ing ma chin ing op er a tions by a CNC pro gram may be a


bit un com fort able or even pe cu liar to many us ers, re gard less of ex pe ri ence Yet, cre at ing a spe –


cific con trol sys tem alarm – for a good rea Angle Punching son, of course – is noth ing more than ap ply ing a very


im por tant tool in macro de vel op ment Even un der nor mal op er at ing con di tions, all con trol sys –


tems au to mat i cally switch to the alarm mode, if a se ri ous and de tect able prob lem oc curs The key –

heck if the in put ra dius is greater than 25 mm

Tuesday, September 5th, 2017

heck if the in put ra dius is greater than 25 mm:


G65 P9000 R25


Macro call with one argument (radius amount)


O8012


Macro start


IF[#18 GT 025] GOTO1001


busbar Machine


Check condition for alarm – true or false ?


Process all blocks if condition is false


N1001 #3000 = 118 (RADIUS TOO LARGE)


Force alarm if condition is true


The se lected alarm num ber and mes sage to the operator is dis played on the screen as ei ther


118 RADIUS TOO LARGE


or


3118 RADIUS TOO LARGE


Slight vari a tions may be ex pected This is a typ i cal ap pli ca tion of a pro angle machine grammed alarm – a con –


trolled gen er a tion of an alarm by a macro, for a pre dict able pos si bil ity of an er ror


Embedding Alarm in a Macro


Re gard less of which alarm con di tions are used in the macro, the trans fer be tween the pro cessed


and the un pro cessed por tions of the pro gram must be smooth, re gard less of the re turned value


( true or false) For ex am ple, a macro may con tain the fol low ing three alarms (to ‘go-to’):


N1001 #3000 = 101 (HOLE SPACING IS TOO SMALL)


N1002 #3000 = 102 (TWO HOLES MINIMUM REQUIRED)


N1003 #3000 = 103 (DECIMAL POINT NOT ALLOWED)


In the macro O8013, these alarms will most likely be lo cated to wards the macro end How ever,


the macro pro gram Dished Head Punching Machine that pre cedes the alarms, us ing G65 P8013 angle shearing machine H8 I120 X750 Y1000


macro call, will have to be pro cessed with out in ter rup tion, if the con di tions are false (that means


run ning good pro gram, with no alarms) For ex am ple, this macro struc ture is NOT cor rect:


O8013


INCORRECT way to program alarms


IF[#4 LE 0] GOTO1001


I=#4 variable stores the hole spacing


IF[#11 LT 2] GOTO1002


H=#11 variable stores the number of holes


IF[#11 NE FUP[#11]] GOTO1003


Check if #11 contains the decimal point


G90 X#24 Y#25


Previously defined tool location XY


< macro body processing 锟?>


N1001 #3000 = 101 (HOLE SPACING IS TOO SMALL)


N1002 #3000 = 102 (TWO HOLES MINIMUM REQUIRED)


N1003 #3000 = 103 (DECIMAL POINT NOT ALLOWED)


M99


%


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

The G65 block for the above macro contains all input correctly

Monday, September 4th, 2017

FANUC CNC Custom Macros


ALARMS AND TIMERS


189


The G65 block for the above macro contains all input correctly – 8 holes, 12 mm apart It means


busbar Machine


all IF tests will be false and the macro will con tinue as in tended It will con tinue un til busbar bending machine it reaches the first alarm mes sage At this point the alarm takes over and macro pro cess ing stops Iron i cally,


if one ar gu ment is in put in cor rectly, the macro will is sue the ap pro pri ate alarm With all ar gu –


ments be ing cor rect, one alarm will al ways be is sued! That angle machine means a flaw less macro will gen er ate


alarm 3101 or 101 (HOLE SPACING IS TOO SMALL), in di cat ing wrong data in put Noth ing is


wrong with the in put, so what is the rea son? If a branch is based on a cer tain con di tion, the macro


true and false sec tions have to be sep a rated In the O8013 ex am ple they were not The alarm mes –


sages cnc equipment were not by passed if all data in put is good To by pass them, the un con di tional GOTOn func –


tion must be in cluded by it self in a block The n is the block num ber to branch to In un con di tional


branch ing, there is no IF, no WHILE – just GOTOn Pro gram O8014 cor rects the pre vi ous macro:


O8014


CORRECT way to program alarms


IF[#4 LE 0] GOTO1001


I=#4 variable stores the hole spacing


IF[#11 LT 2] GOTO1002


H=#11 variable stores the number of holes


IF[#11 NE FUP[#11]] GOTO1003


Check if #11 contains the decimal point


G90 X#24 Y#25


Previously defined tool location XY


< macro body processing 锟?>


GOTO9999


Unconditional bypass added


N1001 #3000 = 101 (HOLE SPACING TOO SMALL)


N1002 #3000 = 102 (TWO HOLES MINIMUM REQUIRED)


N1003 #3000 = 103 (DECIMAL POINT NOT ALLOWED)


N9999 M99


Block number to branch to


%


Com pare the two pre vi ous ver sions (changes are iden ti fied in the O8014 ver sion) The only ad –


di tion that can make the macro even better is the sav ing and sub se quent re stor ing of the cur rent


modal val ues Such im prove ment has noth ing to do with alarms, and is in cluded here to show the

program segment using intentional alarms The following example shows the saving

Monday, September 4th, 2017

program segment using intentional alarms The following example shows the saving Drilling Machine for Plate of


the cur rent state of G-codes (Group 3) at the be gin ning of the macro, and re stor ing it at the end:


O8015


#10 = #4003


Current G90 or G91 saved


busbar Machine


IF[#4 LE 0] GOTO1001


IF[#11 LT 2] GOTO1002


IF[#11 NE FUP[#11]] GOTO1003


G90 X#24 Y#25


< macro body processing 锟?>


GOTO9999


Unconditional bypass of alarm list


N1001 #3000 = 101 (HOLE SPACING TOO SMALL)


N1002 #3000 = 102 (TWO HOLES MINIMUM REQUIRED)


N1003 #3000 = 103 (DECIMAL POINT NOT ALLOWED)


N9999 G#10


Previously saved G90 or G91 restored


M99


%


Many macro pro gram mers do not use alarms at all or use them rather poorly When writing a


macro, write it first with out the alarms When ev ery thing works, try to pre dict what type of er rors


are pos si ble later, when the macro is ac tu ally used Then add all alarms cov er ing these sit u a tions


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


FANUC CNC Custom Macros


190


Chapter 14


Resetting an Alarm


When a macro alarm is gen er ated, it will have an ac cu rate resemblance to an alarm gen er ated by


the con trol sys tem in non-macro applications Typ i cally, this is the se quence of events:


1 CYCLE START light will be turned off


2 The word ALARM will flash on the screen


3 Alarm number and message (if available) will appear on the screen


At this mo ment, the con trol sys automatic punching machine tem has stopped all op er a tions To get rid of the alarm, press the


RESET key The source (the cause) of the alarm has to be removed, so make sure all tool po si tions


are cor rect, then press the CYCLE START key to run the macro again, this time with out an alarm


Message Variable – Warning, Not an Alarm


The sys tem vari able #3006 punching machine is only avail able on FS-10/11/15 con trols – it al lows the pro gram –


mer to is sue a mes sage in the macro, with out cre at ing an alarm con di tion Think of the mes sage


vari able as means of is su ing a warn ing, rather than an alarm A mes sage (warn ing) can be used in

customized alarms to the ones already in the control system

Monday, September 4th, 2017

‘detectable’ Creating macro alarms means just adding customized alarms to the ones already in the control system


One ba sic rule ap plies to all custom gen er ated alarms – they should be im ple mented by a macro


pro gram only un der one con di tion – when ever an ad verse sit u a tion is pre dict able The pur pose of


all alarms is to ter mi nate the cur rent pro gram ac tiv ity and force a change in the cur rent con di tions,


what ever they may be


Alarms in Macros


Macro can in clude a pro grammed alarm (also known as an angle machine in ten tional er ror con di tion), us ing


the sys tem vari able #3000 The vari able #3000 must be fol lowed by an alarm num ber, with an


op tional mes sage


busbar Machine


Alarm Number


De pending on the con trol system, the alarm num ber can be within a range of:


o


0 to 200 and more


for FS-0/16/18/21 controls


o


0 to 999


for FS-10/11/15 controls


The alarm num ber se lec tion is at the pro gram mer dis cre tion, sub ject to con trol spec i fi ca notching machine tions


Alarm Message


Alarm must have a num ber, but the alarm mes sage is op tional Pro gram ming a de scrip tive mes –


sage will in form the CNC op er a tor about the cause of the alarm Alarm mes sage must be in the


same block as the alarm num ber, en closed in pa ren the ses, and it can be up to 26 angle shearing machine char ac ters long


(31 char ac ters on some con trols), in clud ing spaces Its con tents should be clear, with out am big u –


ous mean ing For ex am ple,


(TOOL ERROR)


is an ambiguous message


(TOOL RADIUS TOO LARGE)


is a clear message


If the mes sage is pres ent, both the alarm num ber and the mes sage will ap pear on the screen


when the alarm is tripped If the alarm mes sage is not pres ent, only the alarm num ber will ap pear


187


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


FANUC CNC Custom Macros


188


Chapter 14


Alarm Format


The macro O8012 il lus trates the ac tual ap pli ca tion of a macro alarm that checks the in put of an


as signed vari able ( ie, ar gu ment R, as sign ment #18) Macro will c