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).

✓ Computed from published ISO / ASME / NIST formulas by our open calculation engine (formulas.py) · Formula-checked October 2026

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.

Fanuc 0i / 31i & Haas NGC
Resolved Fanuc System Variable Register
#5223 — G54 Work Offset Z-Axis Coordinate
Equivalent across Fanuc 0i/31i & Haas NGC | Access: Read / Write (Retained)
Ready-to-Run Macro B G-Code Block
#5223 = #5223 - 0.050 (SHIFT G54 Z DOWN 0.05MM)
Safety Guard: Always bracket conditional expressions [ ] and terminate with EOB (;)

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).

Table 1: Fanuc 0i / 31i & Haas NGC Custom Macro B System Variable Architecture (#0 to #5324) — Verified October 2026.
Variable Range Variable Classification Retention Across Reset / Power Off Read / Write Access Primary CNC Programming Function
#0Null / Empty VariableAlways Undefined (Empty)Read-OnlyCompare uninitialized G65 arguments (IF [#24 EQ #0])
#1 – #33Local Macro VariablesCleared on M99 Return / ResetRead / WritePass G65/G66 letter arguments (A=#1, B=#2, C=#3 ... Z=#26)
#100 – #199Volatile Common VariablesCleared at Power OffRead / WriteTemporary counters, probe math & inter-program flags
#500 – #999Non-Volatile Permanent VariablesRetained Across Power OffRead / WriteMaster fixture calibration, tool life counters & part totals
#3000Macro Alarm GeneratorTriggers Immediate Feed Hold + AlarmWrite#3000=1 (PROBE OUT OF TOLERANCE) displays alarm 3001
#3001 – #3002Millisecond & Hour Timers#3001 Resets; #3002 RetainedRead / WriteMeasure actual cycle time and spindle run hours
#3006Operator Message Stop (M00)Halts Execution with MessageWrite#3006=1 (INSPECT BORE WITH PIN GAGE)
#4001 – #4022Modal G-Code Group StatusUpdated Block-by-BlockRead-OnlyRead active G90/G91 (#4003), G54–G59 (#4014) before macro moves
#5021 – #5024Machine Coordinate Position (G53)Real-Time Servo PositionRead-OnlyRead current X (#5021), Y (#5022), Z (#5023), 4th (#5024)
#5041 – #5044Work Coordinate Position (G54–G59)Real-Time Active WCS PositionRead-OnlyRead current active work X (#5041), Y (#5042), Z (#5043)
#5061 – #5064G31 Skip Signal Probe TriggerLatched at Touch Probe ContactRead-OnlyCapture exact X/Y/Z coordinate when Renishaw probe triggers G31
#5201 – #5204G52 / External Workshift OffsetRetained Across Power OffRead / WriteGlobal X/Y/Z shift applied across all G54–G59 coordinate systems
#5221 – #5324G54 to G59 Work Offset RegistersRetained Across Power OffRead / WriteG54 (#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.

Table 2: Fanuc G65 Argument Specification I Letter-to-Local Variable Mapping (#1–#26) and Tool Offset Registers (Memory Type C) — Verified October 2026.
G65 Letter Address Local Variable # G65 Letter Address Local Variable # Tool Offset Register (Fanuc Memory C) System Variable Range (T1–T200)
A#1M#13Length Wear Offset (H)#10001 – #10200
B#2Q#17Length Geometry Offset (H)#11001 – #11200
C#3R#18Cutter Radius Wear Offset (D)#12001 – #12200
D / E / F#7 / #8 / #9S / T / U#19 / #20 / #21Cutter Radius Geometry Offset (D)#13001 – #13200
H / I / J / K#11 / #4 / #5 / #6V / W / X / Y / Z#22 / #23 / #24 / #25 / #26Haas NGC Tool Length Geometry#2001 – #2200