Fanuc Macro B reference
Fanuc Macro B quick reference: G65 argument letter to local variable map, common and system variable ranges including work and tool offset addresses, IF, WHILE, GOTO and DPRNT syntax, and a G and M code table across Fanuc, Haas, Mazak, Okuma, Siemens and Heidenhain.
Fanuc Macro B reference
The things you look up every time you write a macro: which #variable an argument lands in, where the offsets live, the control flow syntax, and what the same G or M code is called on the other controls.
| Letter | Variable | Letter | Variable |
|---|---|---|---|
| A | #1 | Q | #17 |
| B | #2 | R | #18 |
| C | #3 | S | #19 |
| D | #7 | T | #20 |
| E | #8 | U | #21 |
| F | #9 | V | #22 |
| H | #11 | W | #23 |
| I | #4 | X | #24 |
| J | #5 | Y | #25 |
| K | #6 | Z | #26 |
| M | #13 | ||
| Not usable as arguments: G, L, N, O, P. Argument values need a decimal point: X1. not X1. | |||
| I/J/K set | I | J | K |
|---|---|---|---|
| 1 | #4 | #5 | #6 |
| 2 | #7 | #8 | #9 |
| 3 | #10 | #11 | #12 |
| 4 | #13 | #14 | #15 |
| 5 | #16 | #17 | #18 |
| 6 | #19 | #20 | #21 |
| 7 | #22 | #23 | #24 |
| 8 | #25 | #26 | #27 |
| 9 | #28 | #29 | #30 |
| 10 | #31 | #32 | #33 |
G65 arguments map to local variables #1 to #33. Letters A to C and D to Z (skipping G, L, N, O, P) use argument specification I. Up to ten I, J, K sets use specification II: set 1 is #4 #5 #6, set 2 is #7 #8 #9, and so on, which is why D is #7 and E is #8.
Work offsets: G54 X is #5221 and each offset is 20 variables apart. G54.1 P1 starts at #7001 (or #14001 with the 300-set option). Tool offset addresses depend on the control's offset memory type, so check one with a known value before you trust it.
Sources: Fanuc Series 0i / 30i operator manuals, Haas mill programming manual, Mazak EIA/ISO programming manual. Controller columns show the usual equivalent, not every option.
Variable addresses and code meanings are the published defaults. OEM parameter settings move some of them, so read one back with a known value on your machine before you write to it.
Related tools
More in CNC programming & probing: G-code explainer & checker, Probing & tool setting cycle finder, Probe result to offset write
Software & Shop Tools
Want one of these built around your parts and your process? I build shop tools.