FANUC macro variables #4001 and #4201: why the machine may still be executing another block when G01 is read
The 0i-D system-variable chapter distinguishes the preceding-block modal state at the look-ahead processing position from the executing block. An original timeline explains differing #4001 and #4201 values without treating program-state reads as motion-complete signals.
Contents
A macro may read a G-code state while the block currently being executed on screen shows a different type of motion. This does not necessarily indicate bad data. CNC program interpretation and actual execution may be at different positions; the time reference of each variable must be understood first.
The same group 01, but different program positions
This article is limited to 0i-D / 0i Mate-D machining centers with the applicable macro function. B-64304EN/02, §14.2 system-variable descriptions, pages 184–186 (public mirror of the original manual) defines #4001 as the group 01 modal state of the preceding block relative to the look-ahead processing position, while #4201 refers to the group 01 modal state of the block being executed. “Preceding block” here does not simply mean the last block whose motion the machine completed. Both variables are read-only.
An original timeline: different values can both be valid
Assume an illustrative instant when execution is still on the G02 arc in N200, while interpretation has reached around N910 and the preceding N900 specified G01. The comparison below concerns this assumed state; it does not promise that every program will look ahead by the same number of blocks:
| Observed item | Corresponding position in this example | Group 01 information |
|---|---|---|
| Reference for #4001 | Preceding block N900 on the interpretation side | 1, meaning G01 |
| Reference for #4201 | N200 currently being executed | 2, meaning G02 |
Reading 1 from #4001 therefore does not establish that the N200 arc has finished. Using that inference to trigger another action mistakes interpretation progress for a motion-completion condition. Conversely, when modal information is read to preserve program context at a particular location, it cannot be replaced with execution-side state without analysis.
Define the event to observe before choosing the data
If the question is which motion mode the macro's program position inherits, analyze that position's context. If it is which type of motion block the CNC is executing now, an executing-block reference is needed. If the actual question is whether an axis is in position or an external action has completed, neither of these G-code modal values answers it.
For example, G01 can describe a long feed move or a very short move. The same value 1 contains neither the remaining distance nor confirmation that a device action has completed. Inferring application meaning solely from a variable number can obscure this distinction.
Verify without treating a log as a real-time guarantee
For comparison, retain the program revision, the read statement's position and the executing-block position together, then check whether differences fit the look-ahead assumption. Variables read separately do not become a complete snapshot of one instant merely because they appear in the same log. This article analyzes semantics; it promises no sampling period, synchronization capability or safety-interlock effect. Further macro resources are in the OPTION section.