I know my way around Fanuc custom macro pretty well, but this thing has me befuddled. I'm trying to create a custom G code, and be able to input variables just like you can with normal G codes, i.e. G1 Xnn Ynn Znn. I'm led down the garden path by the manual to believe this is possible. Just write a sequence of commands and stick it in the 4M_SUB.DAT file and away you go. I did this and the command doesn't do anything. No matter what I call the command, G121, G66.1, whatever, I get a "E402: The user G code is not defined" error. I dug around in the 4M directory and found a file called 4M_CODE.H which seems to contain definitions for most of the macros in the 4M_SUB.DAT file, so I dutifully created my definition for the custom G code, and ... nada. Ignores it just like before. I also tried M codes, and this doesn't generate any errors, but it also doesn't execute the macro. I've tried every conceivable variation in syntax, even copying another canned cycle verbatim like G84 and renaming it, no dice. Re the 4m_code.h file, in the software world, a ".h" file is usually implies a source file, in C/C++ it's a header file, I think. That would be tragic if it would require some unobtainable compiler to "bake" the custom code to the .exe. Without this capability, my automatic, customizable probing cycles can't work, because there would be no way to input a definition of what to probe, i.e bore, boss, size of feature, etc. I guess I could run it as a program and manually stuff everything in macro variables, but as someone put it so elegantly in another forum years ago "I'd rather pull nose hairs with pliers".
Just opened the 4m.exe with a hex viewer, and I definitely see references to G codes in there. It's, of course, unintelligible gibberish, just like any executable, so a bit hard to draw any conclusions... Someone with knowledge in this arcane art could probably do a stack trace and figure out what happens when you launch a G84, but that would not be me.
Has anyone out there managed to create a custom G code for a 4M control?
I think the manual is misleading. There is no ability to create your own G/M codes. The terms macro, subprogram, and subroutine are used interchangeably in the Dyna reference materials.
What is allowed (but not well explained), is that subroutines can be included within the current program or in a file called user_sub.DAT that is stored in the C:\PROG directory. The 4M software will not call a separate program from the current program.
For a subroutine that is used frequently by other programs, it can be handy to store it in the user_sub.DAT file rather than having to include it in every main program. For example, if the company logo is to be engraved on numerous different parts, instead of including it inside each part program, it would be contained in the user_sub.DAT file (along with any other commonly used subroutines).