Independent CNC repair and technical reference Contact

FANUC macro null and zero: why adding “+0” changes the meaning of an omitted argument

Published Updated

The 16i/18i-MB macro rules distinguish undefined variables, numeric zero, direct assignment and arithmetic conversion. An original position example and condition table show why omission must be detected before calculation, rather than using a nonzero test for argument presence.

Contents
  1. Rules in this edition: null is not another spelling of 0
  2. Calculating first may lose the information “not supplied”
  3. The path consequences can be substantial

Allowing a macro input to be omitted is different from allowing a numeric input of 0. If a program conflates them, a null input originally meaning that an axis does not participate can become a target coordinate of zero for that axis.

Rules in this edition: null is not another spelling of 0

The FANUC 16i/18i-MB operator's manual B-63534EN/02, §15.1, pages 394–395, and §15.5, page 414 (public mirror of the original manual) explains that #0 is always null. When a null variable is used directly as an axis-address value, the address is ignored. Direct assignment can preserve null, whereas arithmetic treats it as 0. EQ and NE distinguish null from 0; other comparisons treat null as 0. This article concerns Custom Macro semantics in this edition only and does not assume identical variable lifetimes in other series.

Calculating first may lose the information “not supplied”

In this original example, input variable #1 represents an optional absolute Y coordinate. If input is copied directly with #2=#1, a null #1 leaves #2 null. Changing this to #2=#1+0 for apparent format consistency makes #2 numeric 0. The arithmetic may appear not to change a number, yet it has already changed the input state.

Input state#1 EQ #0#1 NE 0Result of #1+0
UndefinedTrueTrueNumeric 0
Explicit input 0FalseFalseNumeric 0
Explicit input 12FalseTrueNumeric 12

A true NE 0 condition therefore does not prove that the caller supplied a nonzero input: an undefined input also satisfies it. Detect omission before multiplying by a scale, adding an offset or applying a mathematical function. After calculation, 0 no longer shows whether it came from omission or explicit input.

The path consequences can be substantial

This is offline geometry, not a cutting program. Assume current XY=(10,37) mm, a linear move in absolute coordinates, target X of 32 and Y taken from #2, without other coordinate transforms or tool compensation. With #2 null, Y is unspecified: the endpoint is (32,37) and the path length 22 mm. With #2 equal to 0, the endpoint becomes (32,0), with length √(22²+37²)≈43.046 mm.

The difference is not only a longer path but an additional 37 mm of Y travel. A macro interface should distinguish omitted input, explicit zero and other numeric values before deciding whether each is allowed for that input's purpose. Do not simply prohibit 0 in an interface that legitimately accepts a zero coordinate, or silently turn omission into a valid coordinate by adding 0. Further macro topics are in the OPTION section.

Related technical articles

FANUC optional rotary-axis control: how the sign of an absolute command selects directionFANUC direction-dependent high-speed position switches: why one coordinate can give different outputsFANUC flexible synchronization: matching speed and aligning phase are separate conditions