PROGRAMMING15. CUSTOM MACRO
B–64144EN/01
278
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 F300 ;
When specifying a variable, specify a number sign (#) followed by a
variable number. General–purpose programming languages 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 15.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
operations. When the power is turned off,
local variables are initialized to null. When
a macro is called, arguments are assigned
to local variables.
#100 – #199
#500 – #999
Common
variables
Common variables can be shared among
different macro programs. When the pow-
er is turned off, variables #100 to #1999
are initialized to null. Variables #500 to
#999 hold data even when the power is
turned off.
#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.
Local and common variables can have value 0 or a value in the following
ranges :
–10
47
to –10
–29
0
10
–29
to 10
47
If the result of calculation turns out to be invalid, an P/S alarm No. 111
is issued.
15.1
VARIABLES
Explanation
D Variable representation
D Types of variables
D Range of variable values