subprogram is to call it only once and pro cess it only once


Af ter that, the pro gram of or i gin (usu ally the main pro gram) con tin ues nor mally Al cnc bending machine manufacturers though sev –


eral subprogram calls can be made from the main straightening press pro gram, once the subprogram is com pleted,


the pro cess ing con tin ues in the main pro gram This is called a sin gle level nest ing, and is also the


most com mon ap pli ca tion of subprograms


Fanuc con trols al low for up to four lev els of subprogram nest ing (also called four lev els fold)


Nest ing means that one subprogram may call an other subprogram, which may call still an other


subprogram, up to four lev els deep As the num ber of call ing lev els in crease, the pro gram ming


be comes in creas ingly more com plex as well and can be quite dif fi cult to de velop It is very un –


usual to pro gram more than two lev els deep nest ing In all cases, there is one im por tant rule in


pro gram ming to observe:


In a nested program environment, a subprogram


will always return to the program it originated band saw machine from


CNC Drilling Boring Machine


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


FANUC CNC Custom Macros


28


Chapter 3


The pro gram of or i gin may be the main pro gram or an other subprogram All four il lus tra tions


that follow show a graph i cal pro gram flow for the four lev els of subprogram nest ing:


START


Figure 4


Single level of a subprogram


O0001


O1001


nesting


(MAIN)


(SUB)


M98P1001


M30


%


M99


%


END


The il lus tra tion in Fig ure 4 shows a gen eral sche matic rep re sen ta tion of the pre vi ous ex am ple –


a sin gle level of a subprogram nest ing This is the most com mon ap pli ca tion of subprograms


More com plex (multi-level) subprogram nest ing brings an ex tra power to the CNC pro gram –


ming process, but at the price of more time re quired for de vel op ment, as well as some clar ity and


con ve nience built into the program That is not to say the multi-level subprogram nest ing should


be dis cour aged or even avoided al to gether It sim ply means that al