Welcome to the Fanuc Macro Variable Encyclopedia.
This is the most complete reference guide for Fanuc Macro B variables, system variables, common variables, local variables, machine data variables, position variables, alarm variables, and automation programming.
Macro variables are the foundation of advanced CNC programming.
They allow calculations, automation, adaptive machining, intelligent decision making, probing, setup automation, and reusable manufacturing systems.
This encyclopedia documents the most important Fanuc variables used in real machining environments.
════════════════════════════════════════════════════════════
SECTION 1 — VARIABLE FUNDAMENTALS
════════════════════════════════════════════════════════════
Variables store values.
Examples
1
2
3
100
500
1000
Variables can store
Coordinates
Tool offsets
Measurements
Counters
Logic values
Calculations
Automation parameters
Benefits
Automation
Reusable programs
Reduced code
Adaptive machining
════════════════════════════════════════════════════════════
SECTION 2 — LOCAL VARIABLES (#1–#33)
════════════════════════════════════════════════════════════
Purpose
Temporary storage.
Common Usage
Macro arguments
Mathematical calculations
Loop counters
Conditional logic
Examples
1
2
3
4
5
Typical Applications
Bolt circles
Hole arrays
Pattern generation
Reusable macros
════════════════════════════════════════════════════════════
SECTION 3 — COMMON VARIABLES (#100–#199)
════════════════════════════════════════════════════════════
Purpose
Shared program values.
Examples
100
101
102
103
Applications
Machining dimensions
Feedrate calculations
Part dimensions
Reusable manufacturing data
Benefits
Persistent within machining operations.
════════════════════════════════════════════════════════════
SECTION 4 — PERMANENT VARIABLES (#500–#999)
════════════════════════════════════════════════════════════
Purpose
Retain values after power-off.
Examples
500
501
502
503
Applications
Tool life tracking
Production counters
Maintenance counters
Part tracking
Automation systems
Benefits
Persistent storage.
Critical for production environments.
════════════════════════════════════════════════════════════
SECTION 5 — POSITION VARIABLES
════════════════════════════════════════════════════════════
Common Variables
5001
5002
5003
5021
5022
5023
Applications
Current position monitoring
Part alignment
Adaptive machining
Automatic probing
Verification systems
Benefits
Real-time machine awareness.
════════════════════════════════════════════════════════════
SECTION 6 — TOOL OFFSET VARIABLES
════════════════════════════════════════════════════════════
Applications
Read tool offsets
Adjust offsets
Compensation systems
Tool management
Automatic correction
Benefits
Adaptive manufacturing.
Reduced setup time.
════════════════════════════════════════════════════════════
SECTION 7 — SYSTEM STATUS VARIABLES
════════════════════════════════════════════════════════════
Examples
4001
4003
4006
4120
Applications
Read machine status
Detect active modes
Safety verification
Controller monitoring
Benefits
Program awareness.
Operational control.
════════════════════════════════════════════════════════════
SECTION 8 — ALARM VARIABLES
════════════════════════════════════════════════════════════
Examples
3000
3006
Applications
Custom alarms
Operator messages
Automated warnings
Process control
Example
3000 = 1 (TOOL CHECK REQUIRED)
Benefits
Advanced automation.
Improved safety.
════════════════════════════════════════════════════════════
SECTION 9 — TIMER VARIABLES
════════════════════════════════════════════════════════════
Applications
Cycle monitoring
Runtime tracking
Tool life analysis
Machine utilization
Benefits
Manufacturing analytics.
Process optimization.
════════════════════════════════════════════════════════════
SECTION 10 — COUNTER VARIABLES
════════════════════════════════════════════════════════════
Applications
Part counting
Production monitoring
Tool usage tracking
Batch control
Benefits
Automated reporting.
Production control.
════════════════════════════════════════════════════════════
SECTION 11 — MATHEMATICAL FUNCTIONS
════════════════════════════════════════════════════════════
Functions
ABS
ROUND
FIX
FUP
SQRT
SIN
COS
TAN
ATAN
Applications
Bolt circles
Coordinate calculations
Pattern generation
Complex geometry
Benefits
Parametric programming.
Intelligent machining.
════════════════════════════════════════════════════════════
SECTION 12 — LOGIC AND DECISION MAKING
════════════════════════════════════════════════════════════
IF Statements
WHILE Loops
GOTO Commands
Conditional Execution
Applications
Automation
Adaptive machining
Decision systems
Benefits
Smart programs.
Reduced operator intervention.
════════════════════════════════════════════════════════════
SECTION 13 — ADVANCED MACRO APPLICATIONS
════════════════════════════════════════════════════════════
Bolt Circle Generator
Automatic Hole Patterns
Pocket Calculators
Probing Systems
Tool Life Monitoring
Part Family Programming
Fixture Automation
Smart Setup Systems
Adaptive Machining
════════════════════════════════════════════════════════════
SECTION 14 — MOST IMPORTANT VARIABLES
════════════════════════════════════════════════════════════
1–#33
Local variables
100–#199
Common variables
500–#999
Permanent variables
3000
Custom alarms
3006
Messages
4001
Active G-code group
4120
Current tool number
5001–#5003
Machine coordinates
5021–#5023
Current work coordinates
════════════════════════════════════════════════════════════
SECTION 15 — TROUBLESHOOTING MACRO VARIABLES
════════════════════════════════════════════════════════════
Problem
Unexpected values
Cause
Variable overwritten
Solution
Verify assignments
────────────────────────────────────────
Problem
Wrong calculations
Cause
Incorrect formulas
Solution
Verify equations
────────────────────────────────────────
Problem
Infinite loops
Cause
WHILE condition never satisfied
Solution
Review loop logic
────────────────────────────────────────
Problem
Alarm failures
Cause
Incorrect #3000 usage
Solution
Verify alarm structure
════════════════════════════════════════════════════════════
SECTION 16 — REAL-WORLD PRODUCTION EXAMPLES
════════════════════════════════════════════════════════════
Automatic bolt circle generation
Automatic fixture compensation
Adaptive tool offsets
Production counters
Maintenance tracking
Part family automation
Smart probing systems
Lights-out machining support
════════════════════════════════════════════════════════════
FINAL PRINCIPLE
Fanuc Macro Variables are the foundation of intelligent CNC programming.
Understanding local variables, common variables, permanent variables, position variables, tool offset variables, system variables, alarms, timers, counters, mathematical functions, and logic structures allows programmers to create powerful automation systems that dramatically reduce programming effort and increase manufacturing efficiency.
Mastering variables is the point where CNC programming evolves into CNC automation.
The programmer stops writing code.
The programmer starts building systems.
Leave a comment