FANUC Series 30i/300i/300is-MODEL A. Machining Center System. User's manual - page 71

 

  Index      Manuals     FANUC Series 30i/300i/300is-MODEL A. Machining Center System. User's manual (B-63944EN/03)

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     69      70      71      72     ..

 

 

 

FANUC Series 30i/300i/300is-MODEL A. Machining Center System. User's manual - page 71

 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 524 - 

Address 

Metric input 

Inch input 

F (G93 mode) 

F (G94 mode) 

F (G95 mode) 

(NOTE 5)

 4 

(NOTE 5)

 

 

NOTE 

1  When V is used in a call using a specific code, the number of 

decimal places is determined according to the setting for the 
reference axis. 

α

 is determined according to the increment system for the 

reference axis (axis specified with parameter No. 1031) as 
listed in the table in NOTE 3. 

β

 is determined according to the increment system for the 

corresponding axis address as listed in the following table. 

Increment system

Linear axis 

(metric input) 

Linear axis   

(inch input) 

Rotation axis 

IS-A 2  3  2 
IS-B 3  4  3 
IS-C 4  5  4 
IS-D 5  6  5 

 

IS-E 6  7  6 

When bit 7 (IPR) of parameter No. 1004 is set to 1, the above 
values from which 1 is subtracted are used.  When the 
increment system for an axis is IS-A, however, the setting of 
bit 7 (IPR) of parameter No. 1004 is not effective. 
When calculator-type decimal notation for each axis is used 
(bit 0 (ADX) of parameter No. 3455 is set to 1), the number of 
decimal places is 0.    When bit 7 (EAP) of parameter No. 3452 
is set to 1, however, calculator-type decimal notation is not 
effective and the number of decimal places is determined as 
listed in the above table. 

γ

 is determined according to the increment system for the 

reference axis (axis specified with parameter No. 1031) as 
listed in the following table.    (When bit 7 (BDX) of parameter 
No. 3450 is set to 1, 

γ

 is also determined in the same way.) 

AUP(3450#0) = 1 

AUX (No.3405#0) = 0  AUX (No.3405#0) = 1

Increment system 

for the reference 

axis 

AUP 

(No.3450#0)

= 0 

Metric Inch Metric  Inch 

IS-A 2 

IS-B 3 

IS-C 4 

IS-D 5 

 

IS-E 

6 6 

 

5  When bit 1 (FR3) of parameter No. 1405 is 1, the values in the 

table need to be incremented by 1. 

6 When calculator-type decimal notation is used (bit 0 (DPI) of 

parameter No. 3401 is set to 1), the number of decimal places 
is 0. 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 525 - 

 

 

T

 

When a value is specified with no decimal point, the number of 
decimal places is determined as follows. 
 

Address 

For a non-axis 

address 

For an axis 

address 

H, M, Q, S, or T 

 

D or R 

α

 

(NOTE 1)

 

 

A, B, C, I, J, K, U, V, W, X, Y, or Z 

α

 

(NOTE 1)

 

β

 

(NOTE 2)

 

Second auxiliary function 

γ

 

(NOTE 3)

 

 

 

Address 

Metric input 

Inch input 

E, F (G98 mode) 

(NOTE 4)

 2 

(NOTE 4)

 

E, F (G99 mode) 

4 6 

 

NOTE 

1  

α

 is determined according to the increment system for the 

reference axis (axis specified with parameter No. 1031) as 
listed in the table in NOTE 2. 

2  

β

 is determined according to the increment system for the 

corresponding axis address as listed in the following table. 

Increment system 

Linear axis 

(metric input) 

Linear axis 

(inch input) 

Rotation axis

IS-A 2 

IS-B 3 

IS-C 4 

IS-D 5 

 

IS-E 6 

When bit 7 (IPR) of parameter No. 1004 is set to 1, the above 
values from which 1 is subtracted are used.  When the 
increment system for an axis is IS-A, however, the setting of 
bit 7 (IPR) of parameter No. 1004 is not effective. 
When calculator-type decimal notation for each axis is used 
(bit 0 (ADX) of parameter No. 3455 is set to 1), the number of 
decimal places is 0.  When bit 7 (EAP) of parameter No. 
3452 is set to 1, however, calculator-type decimal notation is 
not effective and the number of decimal places is determined 
as listed in the above table. 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 526 - 

NOTE 

3  

γ

 is determined according to the increment system for the 

reference axis (axis specified with parameter No. 1031) as 
listed in the following table.    (When bit 7 (BDX) of parameter 
No. 3450 is set to 1, 

γ

 is also determined in the same way.) 

AUP(3450#0) = 1 

AUX (No.3405#0) = 0  AUX (No.3405#0) = 1

Increment system 

for the reference 

axis 

AUP 

(No.3450#0) 

= 0 

Metric Inch Metric Inch 

IS-A 2 

IS-B 3 

IS-C 4 

IS-D 5 

 

IS-E 

6 6 

4  When bit 2 (FM3) of parameter No. 1404 is 1, the values in the 

table need to be incremented by 3. 

5 When calculator-type decimal notation is used (bit 0 (DPI) of 

parameter No. 3401 is set to 1), the number of decimal places 
is 0. 

 

 

 - Call nesting 

Macro calls can be nested to a depth of up to five levels including 
simple calls (G65) and modal calls (G66/G66.1).  Subprogram calls 
can be nested to a depth of up to 15 levels including macro calls. 
A macro program can also be called during MDI operation in the same 
way. 
 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 527 - 

  - Local variable levels 

  Local variables from level 0 to 5 are provided for nesting. 

  The level of the main program is 0. 

  Each time a macro is called (with G66, G66.1, Ggg, or Mmm), the 

local variable level is incremented by one.    The values of the local 
variables at the previous level are saved in the CNC. 

  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. 

 

Macro 
(level 4) 

 O0006 
        : 
        : 
        : 
        : 
        : 
 M99 ;

Local variables 
(level 0) 

(Level 1)

#1 
 : 
 : 
#33 

#1 
 : 
 : 
#33 

2

:

(Level 2)

#1 
 : 
 : 
#33

3

:

(Level 3)

#1
 : 
 : 
#33

4

(Level 4) 

#1 
  :
  :
#33 

Common variables 

#100-, #500- 

Variables that can be read from and written to by macros at different levels

O0001 ; 
      : 
#1=1 ; 
G65 P2 A2 ; 
      : 
      : 
M30 ;

Main program   
(level 0) 

Macro 
(level 1) 

Macro 
(level 2) 

Macro 
(level 3) 

O0002 ; 
      : 
      : 
G65 P3 A 3;
      : 
      : 
M99 ; 

O0003 ; 
      : 
      : 
G65 P4 A4 ;
      : 
      : 
M99 ;

O0004 ; 
      : 
      : 
G65 P5 A5 ;
      : 
      : 
M99 ;

O0005 ; 
      : 
      : 
G65 P6 A6 ; 
      : 
      : 
M99 ; 

(Level 5)

#1 
 : 
 : 
#33 

:

6

Macro 
(level 5) 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 528 - 

Sample program (bolt hole circle) 

 

M

 

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 programming.     
To drill in the clockwise direction, specify a negative value for B. 
 

 

 - Calling format 

G65  P9100  Xx  Yy  Zz  Rr  Ff  Ii  Aa  Bb  Hh ; 

 
X  :  X coordinate of the center of the circle   
    (absolute or incremental programming) ................................ (#24) 
Y  :  Y coordinate of the center of the circle   
    (absolute or incremental programming) ................................ (#25) 
Z : Hole depth.............................................................................. (#26) 
R  :  Coordinates of an approach point.......................................... (#18) 
F : Cutting feedrate ....................................................................... (#9) 
I  :  Radius of the circle .................................................................. (#4) 
A  :  Drilling start angle ................................................................... (#1) 
B : Incremental angle  
    (clockwise when a negative value is specified) ....................... (#2) 
H  :  Number of holes .................................................................... (#11) 
 

  - Program calling a macro program 

O0002; 
G90 G92 X0 Y0 Z100.0; 
G65 P9100 X100.0 Y50.0 R30.0 Z-50.0 F500 I100.0 A0 B45.0 H5; 
M30;   

H=

H=

H=

H=

A

B

B

Center 

Radius 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 529 - 

  - Macro program (called program) 

O9100; 
#3=#4003;

................................ Stores G code of group 3. 

G81 Z#26 R#18 F#9 K0; 

(Note)

... Drilling cycle. 

.................................................. Note:  L0 can also be used. 

IF[#3 EQ 90]GOTO 1;

.............. Branches to N1 in the G90 mode. 

#24=#5001+#24;

...................... Calculates the X coordinate of the center. 

#25=#5002+#25; 

..................... Calculates the Y coordinate of the center. 

N1 WHILE[#11 GT 0]DO 1;

...... Until the number of remaining holes reaches 0 

#5=#24+#4*COS[#1];

............... Calculates a drilling position on the X-axis. 

#6=#25+#4*SIN[#1];

................. Calculates a drilling position on the Y-axis. 

G90 X#5 Y#6;

........................... Performs  drilling after moving to the target 

position. 

#1=#1+#2;

................................ Updates the angle. 

#11=#11-1;

............................... Decrements the number of holes. 

END 1; 
G#3 G80;

.................................. Returns the G code to the original state. 

M99; 

 

Meaning of variables: 

#3:    Stores the G code of group 3. 
#5:  X coordinate of the next hole to drill 
#6:    Y coordinate of the next hole to drill 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 530 - 

Sample program (Drill cycle) 

 

T

 

Move the tool beforehand along the X- and Z-axes to the position 
where a drilling cycle starts.    Specify Z or W for the depth of a hole, 
K for the depth of a cut, and F for the cutting feedrate to drill the hole. 
 

Z

W

K

Cutting

Rapid traverse

 

 

 - Calling format 

 
G65 P9100           Kk Ff ; 

Z  :  Hole depth (absolute programming) 
W :  Hole depth (incremental programming) 
K  :  Cutting amount per cycle 
F : Cutting feedrate 
 

  - Program calling a macro program 

O0002; 
G50 X100.0 Z200.0 ; 
G00 X0 Z102.0 S1000 M03 ; 
G65 P9100 Z50.0 K20.0 F0.3 ; 
G00 X100.0 Z200.0 M05 ; 
M30 

 

Zz

Ww

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 531 - 

  - Macro program (called program) 

 

O9100; 

 

#1=0 ;

............................... Clear the data for the depth of the current hole. 

 

#2=0 ;

............................... Clear the data for the depth of the preceding 

hole. 

 

IF [#23 NE #0] GOTO 1 ;

. If incremental programming, specifies the jump 

to N1. 

 

IF [#26 EQ #0] GOTO 8 ;

. If neither Z nor W is specified, an error occurs. 

 

#23=#5002-#26 ;

.............. Calculates the depth of a hole. 

N1 #1=#1+#6 ;

....................... Calculates the depth of the current hole. 

 

IF [#1 LE #23] GOTO 2 ;

. Determines whether the hole to be cut is too 

deep? 

 

#1=#23 ;

........................... Clamps at the depth of the current hole. 

N2 G00 W-#2 ;

...................... Moves the tool to the depth of the preceding 

hole at the cutting feedrate. 

 

G01 W- [#1-#2] F#9 ;

....... Drills the hole. 

 

G00 W#1 ;

........................ Moves the tool to the drilling start point. 

 

IF [#1 GE #23] GOTO 9 ;

. Checks whether drilling is completed. 

 

#2=#1 ;

............................. Stores the depth of the current hole. 

 

GOTO 1 ; 

N9 M99   
N8 #3000=1 (NOT Z OR W COMMAND) 

Issues an alarm. 

 

 

 

 

 

 

 

 

Content      ..     69      70      71      72     ..