I'm currently writing a parser / interpreter for a GCode variant that I'd like to be similar to FANUC Macro B. In the absence of an actual FANUC controller (or a friend with one), my main resources so far are:
NIST GCode Spec: Kramer et al. (2000) The NIST RS274NGC Interpreter - Version 3.
Sinha, SK (2010) CNC Programming Using FANUC Custom Macro B.
Gainer and Murphy (2013) Custom Macro Programming, PMPA NTC 2013.
It has been straightforward so far, but I've discovered an ambiguity with SETVN variable names that I'm hoping people here might be able to help with. (Especially anyone who has lots of experience with a real-world FANUC.)
I'm assuming that FANUC Macro B is whitespace insensitive (please let me know if that's wrong).
Given that assumption, I'm wondering: how does a FANUC controller interpret a block like the following: G01X#QY10;
How does the controller determine where the variable name ends, since variable names can contain (at least) letters and numbers? Does it interpret this as: G01X[#Q]Y10;
or as: G01X[#QY10];
or does it depend on whether QY10 has previously been declared as a SETVN variable name?
(I realize that I could write this with brackets, and I certainly would do that if I wanted clarity. But I'm trying to write a parser, so I care about the confusing edge-cases.)
Re: Whitespace and variable names in FANUC Macro B
I have limited experience with SETVN. You cannot define new variables at will, you can only give a name to a certain range of common variables from #500 - #550, that can then be referenced by the name, as well as by their original numbers.
I have found it useful only in the case of writing/reading probing routines. Renishaw macros save various data into the #100-199 range. I simply transferred the values into the #500 range and used SETVN to give them names such as #X_DIM, #Y_DIM, #X_ERR, #MAX_VAL, #MIN_VAL etc. This makes a complicated routine easier to follow if I ever need to revisit it.
To move to a position that would highlight a certain result without trawling through the macro pages, I would need to put it like so:-
G0 G90 X[#X_DIM] Y[#Y_DIM]
M0 (CHECK)
No other syntax would work, at least not on the 31i control I use. Spaces are not required when inputting, and depending on the display mode, spaces are put in automatically if the syntax is valid.
It can be difficult to set a name that doesn't conflict with any other function! System variables also have names as well as numbers, but there is a certain structure to the numbering system which actually makes the numbers easier to work with.