Macro Variables
The addresses a macro reads and writes. For the language they belong to, with arguments, arithmetic and branching, see Custom Macros.
Vacant is not zero
Section titled “Vacant is not zero”A variable that has never been given a value is vacant, written #0. Test for it
before trusting a number:
IF [#5083 EQ #0] GOTO 100 (tool 3 has never been measured)Some variables can never be vacant: the clock, the machine signal bits and the R
parameters always hold a value, so testing those against #0 is dead code.
Your own variables
Section titled “Your own variables”| Range | Are | Live |
|---|---|---|
#1 … #33 | local: arguments and scratch | per call, cleared on return |
#34 … #99 | reserved | reads are vacant; a write is a block error |
#100 … #499 | common | lost at power-down |
#500 … #9999 | common, retained | kept when the machine is switched off |
An argument the caller left out of a G65 reads vacant, so a macro can tell “not given”
from “given as zero”.
Position
Section titled “Position”| Variables | Hold | |
|---|---|---|
#5021 … #5026 | machine position: X, Y, Z, A, B, C | read-only |
#5041 … #5046 | work position, in the active offset | read-only |
#5061 … #5066 | where the probe last triggered | writable |
#5070 | 1 if the last G31 triggered, 0 if it ran to target | writable |
#5161 … #5166 | the position G28 returns to | writable |
#5181 … #5186 | the second reference position, for G30 | writable |
The two read-only pairs are refused rather than ignored: a program that writes to one stops on that block. They read the position as the block executes, not as it is parsed.
Check #5070 before you read a trip position
Section titled “Check #5070 before you read a trip position”A G31 that does not touch leaves #5061 … #5066 holding the previous trip. They
are not cleared on a miss, deliberately. That means a macro that reads #5063 without
testing #5070 first can measure yesterday’s touch and never know.
G31 Z-50. F100.IF [#5070 EQ 0] GOTO 900 (never touched, do not use #5063)#100 = #5063Offsets
Section titled “Offsets”| Variables | Hold |
|---|---|
#5211 … #5216 | the G92 shift, as a report |
#5221 … #5386 | the work offsets: G54 at #5221, and each further system twenty later, six axes each, up to G59.3 at #5381 |
Writing a work offset takes effect on the blocks that follow, the same as
G10 L2. Writing #5211 changes the register
only: the G92 shift the machine is actually using does not move with it.
There is no variable for “which offset is active”. Read the modal state from the program instead of looking for one.
The tool table
Section titled “The tool table”#5081 onwards is the number the control cuts with: geometry plus wear:
| Variables | Hold |
|---|---|
#5081 … #5180 | tool length in use, tool 1 first |
#5500 … | tool length geometry, as measured |
#5600 … | tool length wear |
#5700 … | tool radius geometry, radius and never diameter |
#5800 … | tool radius wear |
#5900 … | tool type, as a number |
Every band is indexed the same way, tool 1 first, and all cover the same tools.
Writing #5081+i sets the geometry and leaves the wear alone, so a correction the
setter made survives a macro that re-measures the tool. It does that by subtracting the
current wear, so read and write in the same breath. A wear value that changes in between
lands in the geometry.
#5081 is vacant while a tool has neither geometry nor wear. Writing a wear value on
its own is enough to stop it being vacant, which is why a probing macro tests the length
rather than the wear.
Machine state
Section titled “Machine state”| Variables | Hold | |
|---|---|---|
#3000 | raise your own alarm: #3000 = 12 (TOOL TOO SHORT) stops the program with that message | write |
#3002 | operating hours: the control adds to it, so a write is a reset | both |
#3011 | date, as YYYYMMDD | read-only |
#3012 | time, as HHMMSS | read-only |
#3026 | the tool in the spindle | read |
#3901 | parts made, machine-wide, counted at M02 / M30 | both |
#3902 | parts required | both |
#9901 | tool changes since the machine was built | both |
#9902 | cutting hours since the machine was built | both |
#1000 … #1031 | machine signals from the PLC, one bit each | read-only |
#1032 | the same 32 signals as one number | read-only |
With #3902 set, cycle start is refused once #3901 reaches it. Clear #3901 or raise
#3902 to carry on. See Production Counts and
PLC Signals in Macros.
What the control publishes for you
Section titled “What the control publishes for you”| Variables | Hold |
|---|---|
#900 … #921 | the last probe cycle’s result: which cycle, its status, what it wrote, and #911 stamped with the run those values belong to |
#800 … | what a block search collected: the tool, speed and position to restart at, and the M codes to replay |
#850 … #856 | the point a feed-held program will return to; #850 says whether there is one, and an axis the machine does not have is vacant |
These are ordinary variables, so a macro can overwrite them. They are also retained, so a
result survives a power cycle: compare #911 against #901 before believing a probe
result, or you may read the run before last.
R parameters
Section titled “R parameters”R0 … R99 are a second set, separate from #, written R1 = 25.4. An R that was
never set reads 0, not vacant.
Where to go next
Section titled “Where to go next”- Custom Macros: the language these belong to.
- Probing from a Program:
G31and the result record in use. - Tool & Work Offsets: the same numbers, from the panel.