Fanuc Custom Macro B System Variables Chart: #100–#5000+ Offsets & G65 Guide
In Fanuc Custom Macro B (and Haas NGC), variables span four tiers: #1–#33 Local Variables (passed via G65 arguments), #100–#199 Volatile Common Variables, #500–#999 Non-Volatile Retained Variables, and #1000+ System Variables that read/write live G54–G59 work offsets (#5221–#5324), tool offsets (#10001+), skip probe coordinates (#5061–#5063), and macro alarms (#3000).
Fanuc Custom Macro B System Variables (#100–#5000+) & Work/Tool Offset Code Generator
Lookup exact Fanuc 0i/31i & Haas NGC system variable numbers for G54–G59 work offsets, tool length/radius wear & geometry registers, G31 skip probing, and #3000 alarms.
How Fanuc Custom Macro B Transforms Static G-Code Into Closed-Loop Metrology
Standard EIA/ISO G-code (RS-274D) is open-loop and static: it executes hardcoded coordinates blindly regardless of thermal growth, insert wear, or casting shift. By enabling Custom Macro B parametric programming under ISO International Metrology Standard and NIST (National Institute of Standards and Technology) automated inspection architectures, CNC engineers embed real-time arithmetic (SIN, COS, ATAN, SQRT), conditional branching (IF [... GT ...] GOTO / THEN), loops (WHILE [... LE ...] DO1 ... END1), and direct read/write access to the CNC controller's internal offset registers.
When a spindle touch probe executes a G31 skip-signal move against a bore wall, the exact machine trigger coordinate is latched instantaneously into system variables #5061 (X), #5062 (Y), and #5063 (Z). A macro subprogram can compute the 3-point bore center (see our 3-Point Circle Center Calculator), update the active G54 work offset register (#5221, #5222), adjust the boring bar wear offset (#10001+), or halt the machine with a descriptive operator alarm via #3000 = 1 (BORE OVERSIZE).
| Variable Range | Variable Classification | Retention Across Reset / Power Off | Read / Write Access | Primary CNC Programming Function |
|---|---|---|---|---|
| #0 | Null / Empty Variable | Always Undefined (Empty) | Read-Only | Compare uninitialized G65 arguments (IF [#24 EQ #0]) |
| #1 – #33 | Local Macro Variables | Cleared on M99 Return / Reset | Read / Write | Pass G65/G66 letter arguments (A=#1, B=#2, C=#3 ... Z=#26) |
| #100 – #199 | Volatile Common Variables | Cleared at Power Off | Read / Write | Temporary counters, probe math & inter-program flags |
| #500 – #999 | Non-Volatile Permanent Variables | Retained Across Power Off | Read / Write | Master fixture calibration, tool life counters & part totals |
| #3000 | Macro Alarm Generator | Triggers Immediate Feed Hold + Alarm | Write | #3000=1 (PROBE OUT OF TOLERANCE) displays alarm 3001 |
| #3001 – #3002 | Millisecond & Hour Timers | #3001 Resets; #3002 Retained | Read / Write | Measure actual cycle time and spindle run hours |
| #3006 | Operator Message Stop (M00) | Halts Execution with Message | Write | #3006=1 (INSPECT BORE WITH PIN GAGE) |
| #4001 – #4022 | Modal G-Code Group Status | Updated Block-by-Block | Read-Only | Read active G90/G91 (#4003), G54–G59 (#4014) before macro moves |
| #5021 – #5024 | Machine Coordinate Position (G53) | Real-Time Servo Position | Read-Only | Read current X (#5021), Y (#5022), Z (#5023), 4th (#5024) |
| #5041 – #5044 | Work Coordinate Position (G54–G59) | Real-Time Active WCS Position | Read-Only | Read current active work X (#5041), Y (#5042), Z (#5043) |
| #5061 – #5064 | G31 Skip Signal Probe Trigger | Latched at Touch Probe Contact | Read-Only | Capture exact X/Y/Z coordinate when Renishaw probe triggers G31 |
| #5201 – #5204 | G52 / External Workshift Offset | Retained Across Power Off | Read / Write | Global X/Y/Z shift applied across all G54–G59 coordinate systems |
| #5221 – #5324 | G54 to G59 Work Offset Registers | Retained Across Power Off | Read / Write | G54 (#5221–#5224), G55 (#5241–#5244) ... G59 (#5321–#5324) |
Decoding G65 Argument Specification I (#1–#26) and Tool Offset Memory Type C
When calling a parametric subprogram with G65 P9010 X25.0 Y50.0 Z-12.5 D8.0 F250.0, the Fanuc control maps each letter address (except G, L, N, O, and P) into local variables #1 through #26 inside subprogram O9010. Note carefully that letters I, J, and K are mapped to #4, #5, and #6 (shifting D, E, F to #7, #8, #9) because I/J/K also serve as ordered triplet arguments in Argument Specification II as documented in ASME Geometric & Mechanical Standards and Machinery's Handbook (Industrial Press) CNC references.
To prevent look-ahead buffer pre-execution errors when reading real-time machine axis coordinates (#5021–#5044) or writing dynamic G54–G59 work offsets mid-cycle, experienced CNC applications engineers always insert a standalone G31, G04 P1 dwell, or buffering stop macro call immediately before the variable assignment block so the Fanuc CNC multi-block look-ahead preprocessor evaluates the system register only after physical axis servo motion comes to a complete in-position stop.
Similarly, on modern Fanuc 0i-MF/TF and 31i controls configured with Tool Offset Memory Type C (separate Geometry and Wear columns for both Length H and Radius D), tool offsets are addressed in blocks of 1000: Length Wear is #10000 + Tool#, Length Geometry is #11000 + Tool#, Radius Wear is #12000 + Tool#, and Radius Geometry is #13000 + Tool#. Combine Custom Macro B closed-loop spindle probing and automated offset compensation with our Fanuc G76 Threading Cycle Calculator, Fanuc G83 & G73 Peck Drilling Calculator, CNC Lathe G96 CSS & G50 Clamp Calculator, and CNC Thread Milling Calculator to eliminate manual operator data-entry mistakes on high-value aerospace components.
| G65 Letter Address | Local Variable # | G65 Letter Address | Local Variable # | Tool Offset Register (Fanuc Memory C) | System Variable Range (T1–T200) |
|---|---|---|---|---|---|
| A | #1 | M | #13 | Length Wear Offset (H) | #10001 – #10200 |
| B | #2 | Q | #17 | Length Geometry Offset (H) | #11001 – #11200 |
| C | #3 | R | #18 | Cutter Radius Wear Offset (D) | #12001 – #12200 |
| D / E / F | #7 / #8 / #9 | S / T / U | #19 / #20 / #21 | Cutter Radius Geometry Offset (D) | #13001 – #13200 |
| H / I / J / K | #11 / #4 / #5 / #6 | V / W / X / Y / Z | #22 / #23 / #24 / #25 / #26 | Haas NGC Tool Length Geometry | #2001 – #2200 |