Alarms & Timers
Generating Alarms (#3000)
Writing to system variable #3000 immediately halts program execution and displays an alarm on the CNC screen. The syntax is #3000=nnn(MESSAGE TEXT), where nnn is an alarm number from 1 to 9999. The alarm number and message text appear on the CNC alarm page.
After an alarm is triggered, the operator must press RESET to clear it. The primary use of #3000 is input validation at the start of macros -- checking that required arguments were passed and that values are within expected ranges before any cutting begins.
IF [#1 EQ #0] THEN #3000=100(MISSING DIAMETER)
IF [#1 LT 0] THEN #3000=101(DIAMETER MUST BE POSITIVE)
IF [#2 GT 100] THEN #3000=102(DEPTH EXCEEDS MAX)
Recommended alarm number ranges:
| Range | Suggested Use |
|---|---|
| 100–199 | Argument validation errors |
| 200–299 | Runtime errors (tool breakage, out of tolerance) |
| 300–399 | Machine/fixture errors |
Operator Messages (#3006)
Writing to #3006 displays a message and stops execution, similar to an M00 optional stop. The syntax is #3006=1(MESSAGE TEXT). Unlike #3000, this does not generate an alarm -- it pauses the program and waits for the operator.
The operator must press CYCLE START to continue (not RESET). This makes #3006 ideal for tool change prompts, measurement verification steps, and any point where an operator decision or action is needed mid-program.
#3006=1(FLIP PART AND PRESS CYCLE START)
#3006=1(VERIFY CLAMP PRESSURE)
#3006=1(INSERT TOOL 5 AND PRESS START)
Clock Variables (#3001 / #3002)
Fanuc provides two clock-related system variables for timing and machine hour tracking:
| Variable | Function | Resolution | Reset |
|---|---|---|---|
#3001 | Millisecond timer | 1 ms | Cleared by writing #3001=0, or power cycle |
#3002 | Hour meter | 1 hour | Tracks total powered-on time, read-only |
#3001 is useful for measuring cycle time within a macro. Reset it to zero before the operation, then read it afterward to get elapsed milliseconds:
#3001=0 (RESET TIMER)
(... machining operations ...)
#100=#3001 (READ ELAPSED MS)
#500=#100/1000 (CONVERT TO SECONDS)
#3002 reads the total machine hours (like an odometer). It cannot be reset by the program.
Date and Time Variables (#3011 / #3012)
These read-only system variables provide the current date and time from the CNC controller's internal clock:
| Variable | Format | Example |
|---|---|---|
#3011 | YYYYMMDD | 20260224 = Feb 24, 2026 |
#3012 | HHMMSSss | 14302500 = 2:30:25.00 PM |
These are useful for timestamping parts (with DPRNT), logging cycle start/end times, and shift tracking. Example extracting individual date components:
#100=#3011 (GET DATE AS YYYYMMDD)
#101=FIX[#100/10000] (EXTRACT YEAR)
#102=FIX[#100/100]-#101*100 (EXTRACT MONTH)
#103=#100-FIX[#100/100]*100 (EXTRACT DAY)
Practical Patterns
Input Validation Block
Validate all arguments up front before any cutting begins. Use #3000 for hard errors and default assignments for optional arguments:
(VALIDATE ALL ARGUMENTS UP FRONT)
IF [#1 EQ #0] THEN #3000=100(A= DIAMETER REQUIRED)
IF [#2 EQ #0] THEN #3000=101(B= DEPTH REQUIRED)
IF [#3 EQ #0] THEN #3=#9 (DEFAULT FEED IF NOT GIVEN)
IF [#1 LE 0] THEN #3000=102(DIAMETER MUST BE POSITIVE)
Cycle Time Measurement
Use #3001 to measure elapsed time and #3006 to alert the operator if a threshold is exceeded:
#3001=0 (START TIMER)
(... machining operations ...)
#100=#3001 (ELAPSED MS)
IF [#100 GT 60000] THEN #3006=1(CYCLE EXCEEDED 60 SEC)
Conditional Operator Prompt
Combine variable comparison with #3006 to pause only when an out-of-tolerance condition is detected:
IF [#500 GT #501] THEN #3006=1(PART OUT OF TOL - CHECK)
See also: Feed Hold & Auto Mode for #3003/#3004 auto mode control, External Output / DPRNT for logging data to files, and Macro Structure for macro template with validation.
References
- Peter Smid, Fanuc CNC Custom Macros, Industrial Press, 2004.
- Fanuc, Operator’s Manual / Parameter Manual, FANUC Corporation.
Have a question or want to contribute?
Contact us with corrections, additions, or topics you'd like covered.
Get in Touch