I have a 0i-MC where I can use the Q argument to address a line number in the current program. No need to make an external program for subprogram. Example:
Actually this isn't explained in the FANUC manual, only the P argument is. I don't know how this was set up. But now I have a 18i where this "trick" doesn't work. Anyone knows something about this subject? I didn't find anything on the net. Some parameter to change?
Also it would be AWESOME to be able to do it with G65/G66 as well (but this does NOT work even on my 0i-MC)
Please don't tell me to use M99Nxx or some other spaghetti code workaroud
The point is that I can just put subprogrs in the main prog instead of making lots of additional files. Potentially tens of them for each main program. I use a lot of subs and macros (even modal ones) for most of my programs, so M98 Qxx was a godsend. I wish it was possible to use this trick also with G65-66 but I've achieved something very close with my own subprogram-calling macros. Just for the record, it looks something like this:
O9000(M985 CALL LOCAL MACRO);
IF[#18 NE #0] THEN #500=#18 (REMEMBER PROGRAM NUMBER);
M98 P#500 Q#17;
Yes it's possible to specify P and Q. And the arguments used when calling M985 are mantained when the control passes to the subprogram, bacause it's called with a M98 not a G65, which means the level of local variables doesn't change. Example:
M98 Q works just as M98 P. The difference is the subprogram in part of the current program instead of an additional external program. It can also be repeated with L. I'ts also possible to use P and Q in the same call. GOTO has nothing to do with it.
The "M985" I posted is a custom macro made by me.
All code examples I posted work perfectly, I'm not making up random stuff.
It seems this subject is rather obscure. Thanks for the help so far anyway. Next week I'll look for differences in the parameters 6000s between the 0i and 18i and maybe I'll find out what enables it.
It looks for sequence number Q in program number P. Probably not very useful in everyday programming (but my "local macro call" custom needs it).
I got a look at the parameter manuals for both models. In the 0i, it says:
6005: bit 0 (SQC) Calling a subprogram with its sequence number by the subprogram function is: 0=disabled 1=enabled
The 18i manual doesn't mention those parameters but IIRC the parameter screen DID show all the same that are on the 0i... next week we'll see.
This issue needs investigation.
If a sub can be called by sequence number, it perhaps is a part of the calling program, not an external program. But, logically, it should still be a P-word only, not a Q-word.
I've been told that if setting 6005.0 doesn't work, then an option must be installed by fanuc.
I could dump the option params form a machine that had it enabled, but had no luck finding which one needs to be changed (or maybe changing params isn't enough truly, but it's hard to believe).
So I set my machine to achieve the same result using G65 instead. A program looks like this:
Parameter CLV (6001 was it?) should be zero so #17 is cleared upon reset, which will cause the GOTO statement to jump to N0 on program start.
It can be simplified further using custom M/G codes (but the limitation of such calls not working when nested can be annoying)