FANUC - Create your own custom G and M-Codes

Started by CNCAppsJames, February 13, 2024, 07:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

CNCAppsJames

I don't think anyone will find anything groundbreaking in this topic. It's basically going to just be a more detailed explanation of the reasons and process of creating your own custom G or M-Code.

*LEGAL - I'm not responsible for any changes you make to your machine. CAREFULLY consult your machine tool's programming/operating manual(s) to make sure you do not create any conflicts (i.e. duplicating FACTORY G or M-Codes).

1st Order of business; decide if you want to create a custom G-Code or a custom M-Code

2nd If you want to create a custom M-Code, decide if you want to have the ability to pass arguments (i.e. M1234A1.B2.C3.... etc...) or if you just want the M-Code.

3rd, Comb ALL programs in the machine's CNC_MEM and make note of the following ranges of macros/programs;
O9000-O9009, O9010-O9019, and O9020-O9029. Any programs in those 3 ranges will exclude those programs from further use. Just like we do not want to create G or M-Code-Code overlap, we also do not want to create MACRO/Program overlap. It's entirely possible the consequences could be catastrophic.

On 0i-F Series and 30i Series controls, folders exist;
//CNC_MEM/                      *Typically nothing resides here. Nothing prohibits that, it's just bad form IMHO.
//CNC_MEM/MTB1/              *Typically Machine Tool Builder MACROs/Programs reside here
//CNC_MEM/MTB2/              *Typically Machine Tool Builder MACROs/Programs reside here
//CNC_MEM/SYSTEM/          *Typically Machine Tool Builder MACROs/Programs reside here
//CNC_MEM/USER/              *Typically you will find programs here. I do not reccommend putting them here. Personal pref.
//CNC_MEM/USER/LIBRARY  *Typically Machine Tool Builder and 3rd Party Vendor MACROs/Programs reside here
//CNC_MEM/USER/PATH1/    *This and any sub-folders is the recommended part program loc. if no Dataserver is present
//CNC_MEM/USER/PATH2/    *This is the recommended part program loc.that must only run on PATH2

aaaaaaaaand, depending on the machine like a multitasking lathe for example you could have the following;

//CNC_MEM/USER/PATH3/    *This is the recommended part program loc.that must only run on PATH3
//CNC_MEM/USER/PATH4/    *This is the recommended part program loc.that must only run on PATH4

There are technically no hard and fast rules as to where programs/MACROs can reside. Personally I typically will place them in one fo two locations depending on what they are/do.

In //CNC_MEM/SYSTEM/ I will put machine functions. Like say I want to create an M-Code to bring me the spindle tool to the door, this is where I will put it.

In //CNC_MEM/USER/LIBRARY/ I'll put MACROS, Like say I want to create a Serialization G or M-Code, this is where I will put it.

Program Ranges;
O9001-O9009 = Sub-Call M-Codes (Not passing Arguments)
O9010-O9019 = MACRO-Call G-Codes
O9020-O9099 = MACRO-Call M-Codes (Passing Arguments)

Parameters;
#6071 - #6079 = Sub-Call M-Codes calling Programs O9001-O9009
#6050 - #6059 = MACRO Call G-Codes calling Programs O9010-O9019
#6080 - #6089 = MACRO Call M-Codes calling Programs O9020-O9029

Sub-Call M-Code;
If I make parameter #6071 = 6, when M6/M06 is executed it will execute program O9001.
...
If I make parameter #6079 = 306, when M306 is executed it will execute program O9009.

MACRO-Call G-Code;
If I make parameter #6050 = 100, when G100 is executed it will execute program O9010.
......
If I make parameter #6059 = 983, when G983 is executed it will execute program O9019.

MACRO-Call M-Code;
If I make parameter #6080 = 301, when M301A1. is executed it will execute program O9020 and pass the value of A to #1.
...
If I make parameter #6089 = 891, when M891C3. is executed it will execute program O9020 and pass the value of C to #3.

Note;
Argument specifications... there are two argument specifications; Type I and Type II.
Specification I = You can use all the letters of the alphabet except L, O, N, G, and P. You can any letter besides the exceptions, and use them once. This is the most common specification.
Specification II = You can use A, B, and C once each, and you can use I, J, and K up to 10x each.

Hope you found this helpful.

Happy G/M-Coding! :cheers:

:coffee:
Like Like x 6 Thank  You Thank You x 2 View List
"That bill for your 80's experience...yeah, it's coming due. Soon." Author Unknown

Inventor Pro 2026 - CAD
CAMplete TruePath 2026 - CAV and Post Processing
Fusion360 and Mastercam 2026 - CAM

JakeL

Want to take a minute and say a huge thank you James. These last few posts you've done are PACKED with super useful information and I really appreciate you sharing. :cheers:
Like Like x 2 Thank  You Thank You x 2 View List