Archive for September, 2017

In the next stage, the same example will be explored

Tuesday, September 5th, 2017

-step or derly


pro ce dure for any op er a tion or ac tiv ity (only a very ge neric model is pre sented here):


1 Start program


Initialization – defaults – cancellations – units,


2 Input data


Tool – spindle – location – clearances,


3 Process data


drill Machine


Cycles – macros – feedrates – offsets,


4 Output result


Actual machining – this is the main program objective


5 Stop program


Clear conditions,


This method will work well on a sin gle data in put (sin gle process), ev ery time For ex am ple,


the preceding five ge neric steps can rep angle machine re sent drill ing of a sin gle hole, at any desired lo ca tion


Now re place the ge neric terms with spe cific drill ing op er a tions (all five step num bers match):


1 Start program


same as


1 Start program


2 Input XYZ hole location


same as


2 Input data


3 Move to the new location


same as


3 Process data


4 Drill the hole


same as


4 cnc equipment Output results


5 Stop program


same as


5 Stop program


Al though only the ba sic drill ing pro cess notching machine illustrated, the or derly flow shows a clear con cept of


what is hap pen ing What is the ac tual re sult of this pro cess? Us ing the hole drill ing as an ex am ple,


one hole – and only one hole – has been drilled The sin gle pro cess does not need the IF func tion,


most stan dard pro grams use it daily, how ever in mac ros, the IF func tion rep re sents the sin gle


pro cess, such as a sin gle hole If more than one hole is needed, the sin gle pro cess is not sufficient


Mul ti ple Process


In the next stage, the same example will be explored, this time to drill more than a sin gle hole


The above top-down pro cess is not quite suf fi cient and a dif fer ent tech nique has to be used Be fore


think ing of a tech nique, think of a pro cess What has to change? We do not want to al ways start


and stop af ter drill ing the first hole, do we? We want to in put the next hole lo ca tion (item 2), move


to that lo ca tion (item 3), drill the hole at that lo ca tion (item 4), and – we want to re peat these three


steps un til all holes are done

software is in tentionally designed to cover more than necessary in every day work

Monday, September 4th, 2017

software is in tentionally designed to cover more than necessary in every day work


This last type of a loop struc ture con trols three events si mul ta neously – again, in dents show the


programming structure – Figure 24:


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


BRANCHES AND LOOPS


181


WHILE [ Condition 1 is true ] DO1


drilling Machine


Start of WHILE loop 1


< Body of Loop 1 – Part 1 >


WHILE [ Condition 2 is true ] DO2


Start of WHILE loop 2


< Body of Loop 2 – Part 1 >


WHILE [ Condition 3 is true ] DO3


Start of WHILE loop 3


< Body of Loop 3 >


END3


End of WHILE loop 3


< Body of Loop 2 – Part 2 >


END2


End of WHILE loop 2


< Body of Loop 1 – Part 2 >


END1


End of WHILE loop 3


Figure 24


Triple level of macro looping – controls three events at the time


General Considerations


From the sev eral ex am ples of the WHILE func tion struc ture, its proper us age should be come


much clearer When the in the WHILE state ment is sat is fied (that means it is true), the blocks be tween the DOn and the cor notching machine re spond ing ENDn are ex automatic punching machine e cuted re peat edly, in the or der in


which they are pro grammed Each new pass through the loop al ways eval u ates the given con di tion


again and again When the con di tion fails, that means it is not true any more – it is false, then the


macro flow of the loop is trans ferred to the block im me di ately fol low ing the ENDn state ment In


some rare cases, the DOn and ENDn can also be used with out the WHILE state ment, but this is def –


i nitely not a rec om mended prac tice or pro fes sional ap proach to programming


Restrictions of the WHILE Loop


From the pre vi ous ex am ples of a macro loop struc ture, a very de fin i tive pat tern CNC Angle Line emerges in the


struc tural nest ing of the WHILE func tion The DOn and the ENDn must al ways be pro grammed in


pairs, work ing from the in ner most loop out wards De pend ing on the nest ing level (1, 2, or 3), the


cor rect macro pro gram must fol low the pat tern or der The o

S and NO represent

Monday, September 4th, 2017

S and NO represent


DRILL THE HOLE


TRUE and FALSE


conditions respectively


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


FANUC CNC Custom Macros


cnc drilling Machine


BRANCHES AND LOOPS


179


WHILE Loop Structure


In Fanuc type macro pro gram ming, the WHILE func tion is used to pro gram loops The for mat


of the loop ing func tion WHILE con sists of the func tion, con di tion and ac tion:


WHILE [condition] DOn


In a plain lan guage terms, think of the WHILE func tion as the ‘as-long-as’ func tion The loop –


ing func tion WHILE [con di tion[ DOn in a Fanuc macro lan guage means ‘pro cess the body of


the loop as long as the spec i fied con di tion is true’ The DOn ac tion es tab lishes the con nec tion with the end of the loop, where the n is re placed with a num ber of the match ing ENDn state ment The


loop is pro grammed with the ENDn func tion that cor re sponds to the DOn call, for ex am ple, DO1


with END1, DO2 with END2, and DO3 with END3 Only three loop depths can be pro grammed


The three al lowed loop depths – of ten known in pro gram ming as the lev els of nest ing – have


three sim i lar forms:


o


Single level nesting


o


Double level nesting


o


Triple level nesting


As the num ber of nest ing lev els in creases, so does the pro gram ming com plex ity The ma jor ity


of loops for most macro ap pli ca Dished Head Punching Machine tions are sin gle level, dou ble lev els are angle shearing machine not too un usual ei ther Tri –


ple level has a lot of power, but it does need a suit able ap pli ca tion to em ploy it


Single Level Nesting Loop


Pro gram ming only a single WHILE loop func tion be tween the WHILE-DOn loop call and its


matching ENDn, de fines the punching machine sin gle level loop This is the sim plest and most com monly used loop –


ing func tion used in macro pro grams The sin gle level loop pro cesses and con trols one event at the


time – Fig ure 22:


WHILE [ Condition 1 is true ] DO1


Start of WHILE loop 1


< Body of a single level loop >


END1


End of WHILE loop 1


Figure 22


Single level of macro looping – controls one event at the ti

Hopefully, the description was clear enough, but a graphical representation

Monday, September 4th, 2017

Hopefully, the description was clear enough, but a graphical representation – us ing a sim ple flowchart – shows the com par i son of both meth ods (Fig ure 20)


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


178


Chapter 13


Figure 20


START


START


Flowchart comparison


cnc drill Machine


of a single structure process,


shown at left, and a repeated


HOLE DATA


HOLE DATA


structure process at right


MOVE TO THE LOCATION


MOVE TO THE LOCATION


DRILL THE HOLE


DRILL THE HOLE


Note that the angle machine example


as shown at right


STOP


represents an endless


or infinite loop – no STOP


The two com pa ra ble flowcharts in di cate the drill ing pro cess in prin ci ple How ever, there is a


ma jor and a very se ri ous prob lem with the re peated struc ture There is no way out! The rep e ti tion


shown at the right side of Fig ure 20 has no pro vi sion to stop the pro cess ing – the loop is not


stopped – it is not con trolled – log i cally, it notching machine runs for ever!


It is ex automatic punching machine tremely im por tant to pro vide an exit from a loop, when cer tain con di tions are sat is fied,


for ex am ple, when the last hole is drilled Fail ure to pro vide an ex ist from a loop will cause an


end less or in fi nite loop In fi nite loops are the most com mon causes of prob lems in macro loops


Ter mi nat ing a loop is al ways de ter mined by a spe cific con di tion This con di tion has to be part of


the loop, based on the job re quire ments, with the pro vi sion to branch out of the loop, when the


con di tion be comes false The re pet i tive flowchart shown in Fig ure 20 has to be mod i fied


Fig ure 21 shows the fi nal flowchart for the drill ing pro cess, in clud ing the con di tional state ment


and only two pos si ble out comes – drill more holes or stop the pro gram pro cess ing


START


Figure 21


Flowchart showing a logical


HOLE DATA


flow of the loop, based on


the result of a conditional


decision


LAST


YES


HOLE


STOP


The STOP branch provides

Double Level Loop Programming two levels of WHILE between the WHILE

Monday, September 4th, 2017

Copyright 2005, Industrial Press Inc, New York, NY – FANUC CNC Drilling Machine for Plate Custom Macros


180


Chapter 13


Double Level Loop Programming two levels of WHILE between the WHILE-DOn loop and the ENDn de fines the


dou ble level loop – in dents show the pro gram ming struc ture – Fig ure 23:


WHILE [ Condition 1 is true ] DO1


Start of WHILE loop 1


< Body of Loop 1 – Part 1 >


CNC Flanges Drilling Machine


WHILE [ Condition 2 is true ] DO2


Start of WHILE loop 2


< Body of Loop 2 >


END2


End of WHILE loop 2


< Body of Loop 1 – Part 2 >


END1


End of WHILE loop 1


Figure 23


Double level of macro looping – controls two events at the time


The dou ble level loop is also quite com mon, be cause it adds more de ci sion mak ing power to the


macro If prop erly struc tured, it should not pres ent any dif fi cul ties at all Re mem ber that two


events are con trolled si mul ta neously in a dou ble level loop


A sin gle level of loop ing should be easy to un der stand Con tin u ing with the ex am ple of a drilled


hole, the sin gle level macro is suit able to be used when the hole is to be drilled at dif fer ent – but


equally spaced – lo ca tions A bolt cir cle (ex plained in Chap Dished Head Punching Machine ter 20) is an ex cel lent ex am ple


Un der stand ing the dou ble level of loop ing is a bit more dif fi cult The dou ble level of loop ing is


de fined as con trol ling two events at the same time For ex am ple, each hole of an equally spaced


pat tern has two in ter nal grooves that share the same XY lo ca tion Hole lo ca tion macro would be


the first level, and ma chin ing the two grooves would be the sec ond level


Triple Level Loop


Pro gram ming all three lev els of WHILE within the WHILE-DOn and the ENDn de fines the tri ple


level loop The tri ple level loop is Angle Punching much less com mon than the other two, but it does bring even


more de ci sion mak ing power to the mac ros It is very im por tant that a proper struc ture is used


With more lev els, the pos si bil ity of a struc tural or log i cal er ror in creases Also keep in mind that