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

 

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

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     72      73      74      75     ..

 

 

 

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

 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 548 - 

16.7.11 

Subprogram Calls Using a T Code 

 
By enabling subprograms to be called with a T code in a parameter, a 
subprogram can be called each time the T code is specified in the 
machining program. 
 

 

O0001 ; 
        : 
T23 ; 
        : 
M30 ;

O9000 ; 
        : 
        : 
        : 
M99 ; 

Bit 5 (TCS) of parameter No. 6001 = 1 

 

 

Explanation 
 - Call 

By setting bit 5 (TCS) of parameter No. 6001 to 1, subprogram O9000 
can be called each time a T code is specified in a machining program.   
A T code specified in a machining program is assigned to common 
variable #149. 
 

 - Repetition 

As with a simple call, a number of repetitions from 1 to 99999999 can 
be specified at address L. 
 

 - Argument specification 

Argument specification is not allowed. 
 

Limitation 

  To call another program in a program called using a T code, only 

G65, M98, G66, or G66.1 can be used normally. 

  When bit 6 (GMP) of parameter No. 6008 is set to 1, a call using a 

G code can be performed in a program called using a T code. 

 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 549 - 

16.7.12 

Subprogram Calls Using an S Code 

 
By enabling subprograms to be called with an S code in a parameter, a 
subprogram can be called each time the S code is specified in the 
machining program. 
 

 

O0001 ; 
        : 
S23 ; 
        : 
M30 ;

O9029 ; 
        : 
        : 
        : 
M99 ; 

Bit 1 (SCS) of parameter No. 6007 = 1 

 

 

Explanation 
 - Call 

By setting bit 1 (SCS) of parameter No. 6007 to 1, subprogram O9029 
can be called each time a S code is specified in a machining program.   
An S code specified in a machining program is assigned to common 
variable #147. 
 

 - Repetition 

As with a simple call, a number of repetitions from 1 to 99999999 can 
be specified at address L. 
 

 - Argument specification 

Argument specification is not allowed. 
 

Limitation 

  To call another program in a program called using an S code, only 

G65, M98, G66, or G66.1 can be used normally. 

  When bit 6 (GMP) of parameter No. 6008 is set to 1, a call using a 

G code can be performed in a program called using an S code. 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 550 - 

16.7.13 

Subprogram Calls Using a Secondary Auxiliary Function   

 
By enabling subprograms to be called with a secondary auxiliary 
function in a parameter, a subprogram can be called each time the 
secondary auxiliary function is specified in the machining program. 
 

 

O0001 ; 
        : 
B23 ; 
        : 
M30 ;

O9028 ; 
        : 
        : 
        : 
M99 ; 

Bit 2 (BCS) of parameter No. 6007 = 1 

 

 

Explanation 
 - Call 

By setting bit 2 (BCS) of parameter No. 6007 to 1, subprogram O9028 
can be called each time a secondary auxiliary function code is 
specified in a machining program.  A secondary auxiliary function 
specified in a machining program is assigned to common variable 
#146. 
 

 - Repetition 

As with a simple call, a number of repetitions from 1 to 99999999 can 
be specified at address L. 
 

 - Argument specification 

Argument specification is not allowed. 
 

Limitation 

  To call another program in a program called using a second 

auxiliary function, only G65, M98, G66, or G66.1 can be used 
normally. 

  When bit 6 (GMP) of parameter No. 6008 is set to 1, a call using a 

G code can be performed in a program called using a second 
auxiliary function. 

 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 551 - 

16.7.14 

Subprogram Call Using a Specific Address 

 
By enabling subprograms to be called with a specific address in a 
parameter, a subprogram can be called each time the specific address 
is specified in the machining program. 
 

O0001 ; 
        : 
B100. ; 
        : 
M30 ;

O9004 ;(#146=100.) 
        : 
        : 
        : 
M99 ; 

Parameter No.6090=66(B) 

 

 

Explanation 

 - Call 

By setting the code (ASCII code converted to decimal) corresponding 
to a specific address in parameter No. 6090 or No. 6091, the custom 
macro program, O9004 or O9005, corresponding to each parameter 
can be called when the specific address is specified in a machining 
program.  The code value corresponding to a specific address 
specified in a machining program is assigned to the common variables 
(#146, #147).  The table below indicates the addresses that can be 
set. 
 

M

 

Address Parameter 

setting 

A 65 
B 66 
D 68 
F 70 
H 72 

I 73 

J 74 

K 75 

L 76 

M 77 

P 80 

Q 81 
R 82 

S 83 
T 84 
V 86 
X 88 
Y 89 
Z 90 

 

NOTE 

  When address L is set, the number of repetitions 

cannot be set. 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 552 - 

T

 

Address Parameter 

setting 

A 65 
B 66 
F 70 
H 72 

I 73 

J 74 

K 75 

L 76 

M 77 

P 80 

Q 81 
R 82 

S 83 
T 84 

 

NOTE 

  When address L is set, the number of repetitions 

cannot be set. 

 

 

 

  - Correspondence between parameter numbers and program numbers and 

between the parameter numbers and common variables 

Parameter number 

Program number 

Common variable

6090 
6091 

O9004 
O9005 

#146 
#147 

 

 - Repetition 

As with a simple call, a number of repetitions from 1 to 99999999 can 
be specified at address L. 
 

 - 

Argument specification 

Argument specification is not allowed. 
 

Limitation 

  To call another program in a program called using a specific code, 

only G65, M98, G66, or G66.1 can be used normally. 

  When bit 6 (GMP) of parameter No. 6008 is set to 1, a call using a 

G code can be performed in a program called using a specific code. 

 

Sample program 

By using the subprogram call function that uses M codes, the 
cumulative usage time of each tool is measured. 
 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 553 - 

Conditions 

  The cumulative usage time of each of tools T01 to T05 is 

measured.   

  No measurement is made for tools with numbers greater than T05. 

  The following variables are used to store the tool numbers and 

measured times: 

 

#501 

Cumulative usage time of tool number 1 

#502 

Cumulative usage time of tool number 2 

#503 

Cumulative usage time of tool number 3 

#504 

Cumulative usage time of tool number 4 

#505 

Cumulative usage time of tool number 5 

 

  Usage time starts being counted when the M03 command is 

specified and stops when M05 is specified.  System variable 
#3002 is used to measure the time during which the cycle start 
lamp is on.  The time during which the machine is stopped by 
feed hold and single block stop operation is not counted, but the 
time used to change tools and pallets is included. 

 

Operation check 
 - Parameter setting 

Set 3 in parameter No.6071, and set 5 in parameter No.6072. 
 

  - Variable value setting 

Set 0 in variables #501 to #505. 
 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 554 - 

  - Program that calls a macro program   

O0001; 
T01 M06;   
M03;  

        : 

M05;

......................................... Changes #501. 

T02 M06;   
M03;  

        : 

M05;

......................................... Changes #502. 

T03 M06; 
M03; 
        : 
M05;

......................................... Changes #503. 

T04 M06; 
M03;  
        : 
M05;

......................................... Changes #504. 

T05 M06; 
M03;  

        : 

M05;

......................................... Changes #505. 

M30; 

 

  -  Macro program (program called) 

O9001(M03);

...................................................Macro to start counting 

 M01; 
  IF[#4120 EQ 0]GOTO 9;

..............................No tool specified 

 

IF[#4120 GT 5]GOTO 9;

...............................Out-of-range tool number 

 

#3002=0;

.......................................................Clears the timer. 

N9 M03;

...........................................................Rotates the spindle in the   

 M99;

 forward 

direction. 

 
O9002(M05);

...................................................Macro to end counting 

 M01; 
  IF[#4120 EQ 0]GOTO 9;

..............................No tool specified 

 

IF[#4120 GT 5]GOTO 9;

...............................Out-of-range tool number 

 

#[500+#4120]=#3002+#[500+#4120];

..........Calculates cumulative time. 

 

N9 M05;

...........................................................Stops the spindle. 

 

M99; 

 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 555 - 

16.8 

PROCESSING MACRO STATEMENTS 

 
For smooth machining, the CNC prereads the NC statement to be 
performed next.  This operation is referred to as buffering. For 
example, many NC statements are buffered during look-ahead by AI 
contour control and so forth. 
In the cutter compensation mode (G41 or G42), the CNC prereads the 
NC statements at least three blocks ahead to find intersections even if 
look-ahead by AI contour control and so forth is not applied. 
Macro statements for arithmetic expressions and conditional branches 
are processed as soon as they are read into the buffer. Therefore, the 
timing of the macro statement execution is not always the specified 
order.  
At the blocks containing M00, M01, M02 or M30, blocks containing 
M-codes for which buffering is suppressed by setting parameters Nos. 
3411 to 3420 and No.3421 to 3432, and blocks containing prevention 
buffering G codes such as G31 or G53, the CNC stops to preread the 
NC statement after that.  Then, the stop of the macro statement 
execution is guaranteed until such M codes or G codes complete its 
execution. 
 

Explanation 
  - When the next block is not buffered (M codes that are not buffered, G31, etc.) 

>

N1 G31 X100.0 ;
N2 #100=1

:

> :Block being executed

NC statement
execution

Macro statement execution

Buffer

N1

N2

 

 

CAUTION 

  In case that you need to execute the macro 

statement after completing the block just before the 
macro statement, specify M code or G code that is 
not buffered just before the macro statement. 
Specially, in case of reading/writing the system 
variables to control signals, coordinates, offset 
value, etc., it may different system variable data by 
the timing of the NC statement execution. To avoid 
this phenomenon, specify such M codes or G 
codes before the macro statement, if necessary. 

 

 

 

 

 

 

 

 

Content      ..     72      73      74      75     ..