Most CNC programmers understand basic macro variables but very few explore Fanuc system variables deeply. These variables allow programs to read machine status, modal commands, offsets, and even operator actions.
Professional programmers use these variables to create intelligent programs that prevent crashes and automate production decisions.
────────────────────────────────────────
1) What System Variables Are
────────────────────────────────────────
System variables allow a CNC program to read internal machine information.
Examples include:
- Active tool.
- Work offset.
- Current position.
- Modal commands.
- Feedrate modes.
Programs become adaptive instead of fixed.
────────────────────────────────────────
2) Modal State Detection (#4000 Series)
────────────────────────────────────────
Example:
4003 → positioning mode.
Check absolute mode:
IF[#4003 NE 90] THEN #3000=1 (SET G90)
Prevents incremental positioning crashes.
Extremely powerful restart protection.
────────────────────────────────────────
3) Active Tool Verification (#4120)
────────────────────────────────────────
Reads active tool number.
Example:
IF[#4120 NE 20] THEN #3000=1 (WRONG TOOL)
Used heavily in aerospace machining.
Prevents wrong-tool scrap.
────────────────────────────────────────
4) Current Machine Position (#5021–#5023)
────────────────────────────────────────
Machine coordinates.
5021 X
5022 Y
5023 Z
Example:
IF[#5023 LT -40] THEN #3000=1
Stops unsafe Z travel.
Invisible crash protection.
────────────────────────────────────────
5) Work Offset Values (#5200 Series)
────────────────────────────────────────
Example:
5221 = G54 X offset.
Program can verify offset exists.
IF[#5223 EQ 0] THEN #3000=1 (OFFSET ERROR)
Stops production before scrap begins.
────────────────────────────────────────
6) Persistent Counters (#500 Series)
────────────────────────────────────────
Stored after power off.
Example:
500=#500+1
Counts parts automatically.
Used in unattended machining.
────────────────────────────────────────
7) Operator Messaging (#3006)
────────────────────────────────────────
Display message without alarm.
Example:
3006=1 (CHECK CLAMP)
Operator warning appears.
Perfect setup reminder.
────────────────────────────────────────
8) Custom Alarm Logic (#3000)
────────────────────────────────────────
Stops program intentionally.
Example:
3000=1 (PROBE ERROR)
Machine halts safely.
Clear communication improves shop safety.
────────────────────────────────────────
9) Professional Automation Example
────────────────────────────────────────
Before finish pass:
Verify tool and offset.
IF[#4120 NE 30] THEN #3000=1
IF[#5223 EQ 0] THEN #3000=1
Program verifies environment before cutting.
────────────────────────────────────────
10) Final Takeaway
────────────────────────────────────────
System variables give CNC programs awareness.
Modern machining relies on programs that verify conditions automatically.
Macro intelligence reduces human error dramatically.
Leave a comment