PROGRAMMING15. CUSTOM MACRO
B–63614EN/01
312
S The level of the main program is 0.
S Each time a macro is called (with G65 or G66), the local variable level
is incremented by one. The values of the local variables at the previous
level are saved in the CNC.
S When M99 is executed in a macro program, control returns to the
calling program. At that time, the local variable level is decremented
by one; the values of the local variables saved when the macro was
called are restored.
O0001 ;
:
#1=1 ;
G65 P2 A2 ;
:
:
M30 ;
O0002 ;
:
#1=2;
G65 P3 A3 ;
:
:
M99 ;
O0003 ;
:
#1=3;
G65 P4 A4 ;
:
:
M99 ;
O0004 ;
:
#1=4;
G65 P5 A5 ;
:
:
M99 ;
O0005 ;
:
#1=5;
:
:
:
M99 ;
#1 1
::
#33
#1 2
::
#33
#1 3
::
#33
#1 4
::
#33
#1 5
::
#33
#100–, #500–
Main program
(level 0)
Macro (level 1) Macro (level 2) Macro (level 3)
Macro
(level 4)
Local variables
(level 0)
(Level 1) (Level 2) (Level 3) (Level 4)
Common variables
Variables that can be read from and written to by
macros at different levels
A macro is created which drills H holes at intervals of B degrees after a
start angle of A degrees along the periphery of a circle with radius I.
The center of the circle is (X,Y). Commands can be specified in either
the absolute or incremental mode. To drill in the clockwise direction,
specify a negative value for B.
H=3
H=4
H=2
H=1
A
B
B
Center (X,Y)
Radius I
Sample program
(bolt hole circle)