Ten Things You Might Not Know About The Fanuc Sub Program

Ten Things You Might Not Know About The Fanuc Sub Program

Sub Program Fanuc

Here are ten things you might not know about Fanuc sub programs,

Fanuc CNC controls are the most common controls in the world so it might be useful to have a good understanding of how sub programs are called and used.

(1) You Can Call a Sub Program By Name.

Yes you heard it here the program can be called by it’s name or it’s number. When calling by name don’t use the P.

Just put the name of the program in these things <> with an M98 and your away.


The only problem with this is that the syntax needs to be spot on so if you have got complicated names for your your sub routines then you might be in the shit.

I always call mine names like ALBERT that are easy to remember.

(2) You can use internal sub routines on a Fanuc Control.

Some people call these local sub programs. It just means it’s tagged on the end of your program which makes them nice n easy to look after. A bit like a pet Goldfish or a pet fly.

I bought mine from the local pet store. I asked the assistant if he sold pet flies and he said no. I said “well there are loads in the window”.

Anyway he sold me one (£15) his name is Paul


This is not him this is Steve.

Internal Sub-Routines

By typing M98 Q500 your control will look for N500 within your current program. This is great because you can add the sub programs to the end of your main program. Don’t forget to leave big gaps so you can clearly see where and what they are. Oh and mind your P’s and Q’s.

M98 P500 (Call O500 externally)

M98Q500 (Call N500 in main program.

Oh and read this too.

Sub Program

Just one other thing. Watch your n numbers it’s easy to get them mixed up. Try and use a convention.

This Is What I Do

N1-N99 (Tool change lines)
N26 M6 T26

N100 to N900 (Local Sub routines)

N1000 to N9999 (Anything else)

(3) You Can Jump Back To a Specific N Number

If you put a P at the end of your sub program next to the M99 after completing the sub program it will return to the main program at the corresponding N number.

M99 P800 will make it return to N800 in the main program it came from.

Sub Program

The above example calls sub program O500 when it gets to M99 it returns to the main program. The P800 means it will return at the line N800

Oh by the way I think this is useless but if you can think of a use please let me know.

(4) There Are Two Ways to Call a Sub Program

M98 P500 L4 (Call program O500 four times.

M98 P40500 (Call program O500 four times) watch out as the digits need to be the correct number.

The last four digits are the program number. The digits before them are the number of repetitions.

There must be four digits for the program number so you need the leading zeros (0500).

Sub Program

This method is a bit convoluted but at least I’ve included it and you never know when you might come across it.

I suggest always use the same method.

(5) M99 Has More Than One Use

M99 normally ends a sub-program but it can also be used in a main program to make it continuous. If you replace M30 (Stop and rewind) with M99 the program will constantly loop around. This is useful for multi pallet machines and barfed lathes.

Oh and don’t forget the EOB or you’ll get an alarm.

M99 ;

(6) You can use M99 to Jump over a Section of Code

M99 P100 will jump to N100

Impress your mates with this one it saves an awful lot of block skips


Sub Program

(7) You Can Call Sub-Programs From The MDI Screen

M98 P500 L6 (Call program O500 six Times)

This will work fine in MDI

(8) You Can Use a G or M Code to Call a Sub-Program

You can use a G Code alias to call a sub program. By setting certain parameters you can create your own G code which will then call a program specified by certain parameters.

Read this article

(9) You Can Have an Movement on the Line That Calls a Sub-Program

Although I have often shit my pants proving out programs, I mean an XY or Z movement not a a bowel movement.

X50. M98 P500 machine will move to X50. then call out the sub program.

(10) On your check screen it will show you how many times you have entered your sub program.

Each time you enter a sub program your control will show you a count down.

(11) You Can Call Sub Programs that are Not in Your Current Folder

When you call sub programs the control will look in your current folder. If it is in a different folder you can still call it.

<//from cnc memory/folder/folder/program>

Sub Program

The format for this is really important.

Also you will get a format error when you try and type it in. Easy fix….. go to CHANGE EDITOR

I have nearly 27,000 followers on LinkedIn and it has some real perks. One is that when I couldn’t get this to work. A quick post on LinkedIn got me some clues many thanks to Volker Hänig.

Shit, that’s 11 things.

Try to ignore one of them so there are only 10, maybe the one you already knew



Log out of this account

Leave a Reply

WP to LinkedIn Auto Publish Powered By : XYZScripts.com