PROGRAMMING
16. CUSTOM MACRO
B–62754EN/01
275
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.
#1=#2+100 ;
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.
Example: #1
An expression can be used to specify a variable number. In such a case,
the expression must be enclosed in brackets.
Example: #[#1+#2–12]
Variables are classified into four types by variable number.
Table 16.1 Types of variables
Variable
number
Type of
variable
Function
#0 Always
null
This variable is always null. No value can be
assigned to this variable.
#1 – #33 Local
variables
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-
ables.
#100 – #149
(#199)
#500 – #531
(#999)
Common
variables
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.
#1000 –
System
variables
System variables are used to read and write a
variety of NC data items such as the current
position and tool compensation values.
NOTE
Common variables #150 to #199 and #532 to #999 are
optional.
16.1
VARIABLES
D Variable representation
D Types of variables