16. CUSTOM MACRO
An ordinary machining program specifies a G code and the travel distance
directly with a numeric value; examples are G100 and X100.0.
With a custom macro, numeric values can be specified directly or using
a variable number. When a variable number is used, the variable value
can be changed by a program or using operations on the MDI panel.
G01 X#1 F0.3 ;
When specifying a variable, specify a number sign (#) followed by a
variable number. Personal computers allow a name to be assigned to a
variable, but this capability is not available for custom macros.
An expression can be used to specify a variable number. In such a case,
the expression must be enclosed in brackets.
Variables are classified into four types by variable number.
Table 16.1 Types of variables
This variable is always null. No value can be
assigned to this variable.
#1 – #33 Local
Local variables can only be used within a
macro to hold data such as the results of op-
erations. When the power is turned off, local
variables are initialized to null. When a macro
is called, arguments are assigned to local vari-
#100 – #149
#500 – #531
Common variables can be shared among dif-
ferent macro programs. When the power is
turned off, variables #100 to #149 are initial-
ized to null. Variables #500 to #531 hold data
even when the power is turned off. As an op-
tion, common variables #150 to #199 and
#532 to #999 are also available. However,
when these values are using, the length of the
tape that can be used for storage decreases
by 8.5 m.
System variables are used to read and write a
variety of NC data items such as the current
position and tool compensation values.
Common variables #150 to #199 and #532 to #999 are
D Variable representation
D Types of variables