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

 

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

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     68      69      70      71     ..

 

 

 

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

 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 516 - 

 - Relational operators 

Relational operators each consist of two letters and are used to 
compare two values to determine whether they are equal or one value 
is smaller or greater than the other value.    Note that the equal sign (=) 
and inequality sign (>, <) cannot be used as a relational operator. 
 

Table 16.6 (a)    Relational operators 

Operator Meaning 

EQ Equal 

to(=) 

NE 

Not equal to(

GT Greater 

than(>) 

GE 

Greater than or equal to(

LT Less 

than(<) 

LE 

Less than or equal to(

 

Sample program 

The sample program below finds the total of numbers 1 to 10. 
 

O9500; 

#1=0;................................ Initial value of the variable to hold the sum 

 #2=1;................................ Initial value of the variable as an addend 
N1 IF[#2 GT 10] GOTO 2; ... Branch to N2 when the addend is greater than 
  10 
 #1=#1+#2;........................ Calculation to find the sum 

#2=#2+1;.......................... Next addend 
GOTO 1; .......................... Branch to N1 

N2 M30;............................... End of program 

 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 517 - 

16.6.4 

Repetition (WHILE Statement) 

 
Specify a conditional expression after WHILE.    While the specified 
condition is satisfied, the program from DO to END is executed.    If 
the specified condition is not satisfied, program execution proceeds to 
the block after END. 
 

If the
condition
is not
satisfied

WHILE [conditional expression] DO m ; (m=1,2,3)

END m    ;
    :

Processing

If the
condition
is satisfied

 

 

Explanation 

While the specified condition is satisfied, the program from DO to 
END after WHILE is executed.  If the specified condition is not 
satisfied, program execution proceeds to the block after END.    The 
same format as for the IF statement applies.    A number after DO and 
a number after END are identification numbers for specifying the 
range of execution.    The numbers 1, 2, and 3 can be used.    When a 
number other than 1, 2, and 3 is used, an alarm PS0126 occurs. 
 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 518 - 

 - Nesting 

The identification numbers (1 to 3) in a DO-END loop can be used as 
many times as desired.  Note, however, when a program includes 
crossing repetition loops (overlapped DO ranges), an alarm PS0124 
occurs. 
 

Processing

1. The identification numbers (1 to

3) can be used as many times
as required.

WHILE [ … ] DO 1 ;

END 1 ;
    :

Processing

WHILE [ … ] DO 1 ;

END 1 ;
    :

2. DO ranges cannot

overlap.

Processing

WHILE [ … ] DO 1 ;

END 1 ;

Processing

WHILE [ … ] DO 2 ;
    :

END 2 ;

3. DO loops can be nested to a

maximum depth of three levels.

WHILE [ … ] DO 1 ;
          :

WHILE [ … ] DO 2 ;
          :

WHILE [ … ] DO 3 ;

Processing

END 3 ;
    :

END 2 ;
    :

END 1 ;

4. Control can be transferred

to the outside of a loop.

WHILE [ … ] DO 1 ;

END 1 ;

IF [ … ] GOTO n ;

Nn

5. Branches cannot be made to a

location within a loop.

WHILE [ … ] DO 1 ;
    :

END 1 ;

IF [ … ] GOTO n ;
    :

Nn … ;

 

 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 519 - 

Limitation 
 - Infinite loops 

When DO m is specified without specifying the WHILE statement, an 
infinite loop ranging from DO to END is produced. 
 

 - Processing time 

When a branch to the sequence number specified in a GOTO 
statement occurs, the sequence number is searched for.  For this 
reason, processing in the reverse direction takes a longer time than 
processing in the forward direction.  Therefore, in the case of 
processing in the reverse direction, use the WHILE statement for 
repetition to reduce processing time. 
 

 - Undefined variable 

In a conditional expression that uses EQ or NE, a <null> and zero 
have different effects.  In other types of conditional expressions, a 
<null> is regarded as zero. 
 

Sample program 

The sample program below finds the total of numbers 1 to 10. 
 

O0001; 
#1=0;  
#2=1;  
WHILE[#2 LE 10]DO 1; 
#1=#1+#2;  
#2=#2+1;  
END 1; 
M30;  

 
 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 520 - 

16.7 

MACRO CALL 

 
A macro program can be called using the following methods. The 
calling methods can roughly be divided into two types:    macro calls 
and subprogram calls. 
A macro program can also be called during MDI operation in the same 
way. 
 

Macro call 

 

Simple call (G65) 
Modal call (G66, G66.1, G67) 
Macro call using a G code 
Macro call using an M code 
Subprogram call using an M code 
Subprogram call using a T code 
Subprogram call using an S code 
Subprogram call using a second auxiliary function code
Subprogram call using a specific code 

 

Limitation 
 - Call nesting 

Macro calls can be nested to a depth of up to five levels and 
subprogram calls can be nested to a depth of up to ten levels; calls can 
be nested to a depth of up to 15 levels in total. 
 

  - Differences between macro calls and subprogram calls 

Macro call (G66, G66.1, Ggg, or Mmm) differs from subprogram call 
(for example M98, Mmm, or Ttt) as described below. 

  With a macro call, an argument (data passed to a macro) can be 

specified.    A subprogram call does not have this capability. 

  If a macro call block contains another NC command (such as G01 

X100.0 G65 Pp), an alarm PS0127 occurs. 

  If a subprogram call block contains another NC command (such as 

G01 X100.0 M98 Pp), the subprogram is called after the command 
is executed. 

  In any macro call block, the machine does not stop in the single 

block mode. 

  If a subprogram call block contains another NC command (such as 

G01 X100.0 M98 Pp), the machine stops in the single block mode. 

  With a macro call, the level of local variables changes.  With a 

subprogram call, the level of local variables does not change.  
(See "Local variable levels" in Limitation of Subsection 16.7.1.) 

 

  - Called program and folders to be searched 

The order in which folders are called depends on the method of calling 
a macro or subprogram. 
Folders are searched in sequence and the program found first is called.   
For details, see the "Managing Programs" chapter. 
 

Subprogram call 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 521 - 

16.7.1 

Simple Call (G65) 

 
When G65 is specified, the custom macro specified at address P is 
called.    Data (argument) can be passed to the custom macro program. 
 

P : Number of the program to call

l

: Repetition count (1 by default)

Argument  :  Data passed to the macro

O0001 ;
        :
G65 P9010 L2 A1.0 B2.0 ;
        :
M30 ;

O9010 ;
#3=#1+#2 ;
IF [#3 GT 360] GOTO 9 ;
G00 G91 X#3 ;
N9 M99 ;

G65  P p  L 

l

    <argument-

specification> ;

 

 

Explanation 
 - Call 

  After G65, specify at address P the program number of the custom 

macro to call. 

  When a number of repetitions is required, specify a number from 1 

to 999999999 after address L.    When L is omitted, 1 is assumed. 

 By using argument specification, values are assigned to 

corresponding local variables. 

 

 - Argument specification 

Two types of argument specification are available.  Argument 
specification I uses letters other than G, L, O, N, and P once each.  
Argument specification II uses A, B, and C once each and also uses I, 
J, and K up to ten times.  The type of argument specification is 
determined automatically according to the letters used. 
 

  Argument specification I 

Address

Variable

number

A
B
C
D
E
F
H

#1
#2
#3
#7
#8
#9
#11

I
J
K
M
Q
R
S

#4
#5
#6
#13
#17
#18
#19

T
U
V
W
X
Y
Z

#20
#21
#22
#23
#24
#25
#26

Address

Variable

number

Address

Variable

number

 

 

  Addresses G, L, N, O, and P cannot be used in arguments. 

  Addresses that need not be specified can be omitted.  Local 

variables corresponding to an omitted address are set to null. 

  Addresses do not need to be specified alphabetically.  They 

conform to word address format. 

  I, J, and K need to be specified alphabetically, however. 
  Argument specification I is always used for I, J, and K by setting 

bit 7 (IJK) of parameter No. 6008 to 1 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 522 - 

Example 

-  When bit 7 (IJK) of parameter No. 6008 is 0, 

I_J_K_ means that I = #4, J = #5, and K = #6 while 
K_J_I_ means K = #6, J = #8, and I= #10 because 
argument specification II is used. 

-  When bit 7 (IJK) of parameter No. 6008 is 1, 

K_J_I_ means that I = #4, J = #5, and K = #6, 
which is the same as with I_J_K_, because 
argument specification I is used. 

 

  Argument specification II   

  Argument specification II uses A, B, and C once each and uses I, J, 

and K up to ten times.    Argument specification II is used to pass 
values such as three-dimensional coordinates as arguments. 

 

Address

Variable

number

A
B
C
I

1

J

1

K

1

I

2

J

2

K

2

I

3

J

3

#1
#2
#3
#4
#5
#6
#7
#8
#9
#10
#11

IK

3

I

4

J

4

K

4

I

5

J

5

K

5

I

6

J

6

K

6

I

7

#12
#13
#14
#15
#16
#17
#18
#19
#20
#21
#22

J

7

K

7

I

8

J

8

K

8

I

9

J

9

K

9

I

10

J

10

K

10

#23
#24
#25
#26
#27
#28
#29
#30
#31
#32
#33

Address

Variable

number

Address

Variable

number

 

 

  Subscripts of I, J, and K for indicating the order of argument 

specification are not written in the actual program. 

 

NOTE 

  When bit 7 (IJK) of parameter No. 6008 is 1, 

argument II cannot be used. 

 

Limitation 
 - Format 

G65 must be specified before any argument. 
 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 523 - 

  - Mixture of argument specifications I and II 

The CNC internally identifies argument specification I and argument 
specification II.  If a mixture of argument specification I and 
argument specification II is specified, the type of argument 
specification specified later takes precedence. 

[Example] 
G65  A1.0  B2.0  I-3.0  I4.0  D5.0  P1000 ; 
 
(Variables) 
#1:1.0 
#2:2.0 
#3: 
#4:-3.0 
#5: 
#6: 
#7:4.0         5.0 
 

When both the I4.0 and D5.0 arguments are commanded for variable 
#7 in this example, the latter, D5.0, is valid. 
 

  - Position of the decimal point 

The units used for argument data passed without a decimal point 
correspond to the least input increment of each address.   
 

 CAUTION 

The value of an argument passed without a 
decimal point may vary according to the system 
configuration of the machine.  It is good practice to 
use decimal points in macro call arguments to 
maintain program compatibility. 

 

  - Extended axis name 

The axis address of an extended axis name cannot be specified as an 
argument. If an attempt is made to specify it, alarm PS0129 is issued. 
 

M

 

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 

D, E, H, M, S, or T 

 

Q or R 

α

 

(NOTE 2)

 

 

A, C, I, J, K, X, Y, or Z 

α

 

(NOTE 2)

 

β

 

(NOTE 3)

 

B, U, V

(NOTE 1)

, or W 

β

 

(NOTE 3)

 

Second auxiliary function 

γ

 

(NOTE 4)

 

 

 

 

 

 

 

 

 

 

Content      ..     68      69      70      71     ..