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

 

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

 

Search            copyright infringement  

 

 

 

 

 

 

 

 

 

 

 

Content      ..     66      67      68      69     ..

 

 

 

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

 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 500 - 

  - Dynamic reference tool compensation value #118051-#118450 (Attribute:    R/W) 

 

M

 

The dynamic reference tool compensation value in the rotary head 
dynamic tool compensation function can be obtained by reading 
system variables #118051 to #118450.    The dynamic reference tool 
compensation value can also be obtained by assigning values to the 
system variables. 
 

Variable 

number 

Variable name 

Controlled axis 

Dynamic tool 

offset number

#118051 
#118052 

#118100 

[#_DOFS1[1]] 
[#_DOFS1[2]] 

[#_DOFS1[50]] 

1st axis dynamic reference tool compensation value 
2nd axis dynamic reference tool compensation value 

50th axis dynamic reference tool compensation value 

(G43.2H1) 

#118101 
#118102 

#118150 

[#_DOFS2[1]] 
[#_DOFS2[2]] 

[#_DOFS2[50]] 

1st axis dynamic reference tool compensation value 
2nd axis dynamic reference tool compensation value 

50th axis dynamic reference tool compensation value 

(G43.2H2) 

#118151 
#118152 

#118200 

[#_DOFS3[1]] 
[#_DOFS3[2]] 

[#_DOFS3[50]] 

1st axis dynamic reference tool compensation value 
2nd axis dynamic reference tool compensation value 

50th axis dynamic reference tool compensation value 

(G43.2H3) 

#118201 
#118202 

#118250 

[#_DOFS4[1]] 
[#_DOFS4[2]] 

[#_DOFS4[50]] 

1st axis dynamic reference tool compensation value 
2nd axis dynamic reference tool compensation value 

50th axis dynamic reference tool compensation value 

(G43.2H4) 

#118251 
#118252 

#118300 

[#_DOFS5[1]] 
[#_DOFS5[2]] 

[#_DOFS5[50]] 

1st axis dynamic reference tool compensation value 
2nd axis dynamic reference tool compensation value 

50th axis dynamic reference tool compensation value 

(G43.2H5) 

: : 

#118401 
#118402 

#118450 

[#_DOFS8[1]] 
[#_DOFS8[2]] 

[#_DOFS8[50]] 

1st axis dynamic reference tool compensation value 
2nd axis dynamic reference tool compensation value 

50th axis dynamic reference tool compensation value 

(G43.2H8) 

 

NOTE 

 

When variables exceeding the number of control 
axes are specified, the alarm PS0115, “VARIABLE 
NO. OUT OF RANGE” occurs. 

 

 

 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 501 - 

  - Feedrate reduction ratio for rapid traverse overlap #100851-#100900 (Attribute:   

R/W)

 

The feedrate reduction ratio for rapid traverse overlap can also be 
changed by setting values to the system variables #100851 to 
#100900. 
 

Variable number

Variable name 

Controlled axis 

#100851 

 

#100852 

 

#100900 

[#_ROVLP[1]] 

 

[#_ROVLP[2]] 

 

[#_ROVLP[50]] 

1st axis feedrate reduction ratio for rapid 
traverse overlap 
2nd axis feedrate reduction ratio for rapid 
traverse overlap 

50th axis feedrate reduction ratio for rapid 
traverse overlap 

 

  - Switching between P-CODE variables and system variables (#10000 or later) 

#8570 (Attribute:  R/W) 

 
This system variable allows read/write operations of P-CODE 
variables (#10000 to #89999) for the macro executor function.    For 
details on P-CODE variables, refer to the Macro Compiler / Macro 
Executor Programming Manual (B-63943EN-2). 
System variable #8570 can be used to make variables #10000 or later 
correspond to either P-CODE variables or system variables. 
 

#8570 setting

Specified variable

Corresponding variable 

#8570 = 1 

#10000 

#89999 

P-CODE variables (#10000) 

P-CODE variables (#89999) 

#8570 = 0 

#10000 

#89999 

System variables (#10000) 

System variables (#89999) 

 

Example 

 

#8570 = 0 ;   

   #10001 = 123 ; 

  Writing to system variable 

#10001 (tool compensation) 

   #8570 = 1 ; 
 

#10001 = 456 ; 

  Writing to P-CODE variable 

#10001 (tool compensation) 

 

NOTE 

1  Variable #8570 can be used only when the macro 

executor function is enabled. 

2  System variables (#10000 or later) always 

correspond to system variables specified by their 
variable names even when #8570 is 1. 

3  When an attempt is made to access a variable that 

cannot be used with P-CODE variables (#10000 or 
later), an alarm PS0115 occurs. 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 502 - 

16.3 

ARITHMETIC AND LOGIC OPERATION 

 
Various operations can be performed on variables. Program an 
arithmetic and logic operation in the same way as for a general 
arithmetic expression. 
 #i=<expression> 
 

<Expression> 

The expression to the right of the arithmetic and logic operation 
contains constants and/or variables combined by a function or 
operator.    Variables #j and #k below can be replaced with a constant.   
If a constant used in an expression has no decimal point, it is assumed 
to end with a decimal point. 
 

Table 16.3 (a)    Arithmetic and logic operation   

Type of operation 

Operation 

Description 

<1> Definition or 

replacement 

#i=#j 

Definition or replacement of a variable 

<2> Addition-type 

operations 

#i=#j+#k 
#i=#j-#k 
#i=#j OR #k 
#i=#j XOR #k 

Addition 
Subtraction 
Logical OR (bit by bit of 32 bits) 
Exclusive OR (bit by bit of 32 bits) 

<3> Multiplication-type 

operations 

#i=#j*#k 
#i=#j/#k 
#i=#j AND #k 
#i=#j MOD #k 

Multiplication 
Division 
Logical AND (bit by bit of 32 bits) 
Remainder (A remainder is obtained after #j and #k 
are rounded to their nearest whole numbers.    When 
#j is a negative value, #i is assumed to be a negative 
value.) 

<4> Functions 

#i=SIN[#j] 
#i=COS[#j] 
#i=TAN[#j] 
#i=ASIN[#j] 
#i=ACOS[#j] 
#i=ATAN[#j] 
#i=ATAN[#j]/[#k]
#i=ATAN[#j,#k] 
#i=SQRT[#j] 
#i=ABS[#j] 
#i=BIN[#j] 
#i=BCD[#j] 
#i=ROUND[#j] 
#i=FIX[#j] 
#i=FUP[#j] 
#i=LN[#j] 
#i=EXP[#j] 
#i=POW[#j,#k] 
#i=ADP[#j] 

Sine (in degrees) 
Cosine (in degrees) 
Tangent (in degrees) 
Arc sine 
Arc cosine 
Arc tangent (one argument), ATN can also be used. 
Arc tangent (two arguments), ATN can also be used. 
Arc tangent (two arguments), ATN can also be used. 
Square root, SQR can also be used. 
Absolute value 
Conversion from BCD to binary 
Conversion from binary to BCD 
Rounding off, RND can also be used. 
Rounding down to an integer 
Rounding up to an integer 
Natural logarithm 
Exponent using base e (2.718...) 
Power (#j to the #kth power) 
Addition of a decimal point 

 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 503 - 

Explanation 
 - Angle units 

The units of angles used with the SIN, COS, ASIN, ACOS, TAN, and 
ATAN functions are degrees.  For example, 90 degrees and 30 
minutes is represented as 90.5 degrees.   
 

  - ARCSIN #i = ASIN[#j]; 

  The solution ranges are as indicated below: 

When the NAT bit (bit 0 of parameter 6004) is set to 0:    270

°

 to 

90

°

 

When the NAT bit (bit 0 of parameter 6004) is set to 1:    -90

°

 to 

90

°

 

  When #j is beyond the range of -1 to 1, an alarm PS0119 is issued. 

  A constant can be used instead of the #j variable. 

 

  - ARCCOS #i = ACOS[#j]; 

  The solution ranges from 180

°

 to 0

°

  When #j is beyond the range of -1 to 1, an alarm PS0119 is issued. 

  A constant can be used instead of the #j variable. 

 

  - ARCTAN #i = ATAN[#j]/[#k]; (two arguments) 

  ATAN[#j,#k] is equivalent to ATAN[#j]/[#k]. 

  When point (#k,#j) on plane X-Y is given, this function returns the 

value of the arc tangent for the angle made by the point. 

  A constant can be used instead of the #j variable. 

  The solution ranges are as follows: 

  When the NAT bit (bit 0 of parameter 6004) is set to 0:  0

°

 to 

360

°

 

Example: 
 

When #1 = ATAN[-1]/[-1]; is specified, #1 is 225.0.

 

  When the NAT bit (bit 0 of parameter 6004) is set to 1:    -180

°

 to 

180

°

 

Example: 
 

When #1 = ATAN[-1]/[-1]; is specified, #1 is -135.0.

 

 

  - ARCTAN #i = ATAN[#j]; (one argument) 

  When ATAN is specified with one argument, this function returns 

the main value of arc tangent (-90

°

 

 ATAN[#j] 

 90

°

).  In other 

word, this function returns the same value as ATAN in calculator 
specifications. 

  To use this function as the dividend of a division, be sure to 

enclose it with brackets ([]).  If this function is not enclosed, 
ATAN[#j]/[#k] is assumed. 

Example: 
 

#100 = [ATAN[1]]/10 ;  :  Divides ATAN with one argument by 10. 

 

#100 = ATAN[1]/[10] ;  :  Executes ATAN with two arguments. 

 

#100 = ATAN[1]/10 ;  :  Assumes  ATAN  with  two  arguments,  but  issues 

an alarm PS1131 because the X coordinate 
specification is not enclosed with brackets ([]). 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 504 - 

  - Natural logarithm #i = LN[#j]; 

  When the antilogarithm (#j) is zero or smaller, an alarm PS0119 is 

issued. 

  A constant can be used instead of the #j variable. 

 

  - Exponential function #i = EXP[#j]; 

  When the result of the operation overflows, an alarm PS0119 is 

issued. 

  A constant can be used instead of the #j variable. 

 

 - ROUND  function  

  When the ROUND function is included in an arithmetic or logic 

operation command, IF statement, or WHILE statement, the 
ROUND function rounds off at the first decimal place. 

Example: 
 

When #1=ROUND[#2]; is executed where #2 holds 1.2345, the value of 
variable #1 is 1.0.   

  When the ROUND function is used in NC statement addresses, the 

ROUND function rounds off the specified value according to the 
least input increment of the address. 

Example: 
 

Creation of a drilling program that cuts according to the values of variables 
#1 and #2, then returns to the original position   

  Suppose that the increment system is 1/1000 mm, variable #1 holds 

1.2345, and variable #2 holds 2.3456.  Then,  

 

G00 G91 X-#1;  Moves 1.235 mm in negative direction. 

 

G01 X-#2 F300;  Moves 2.346 mm in negative direction. 

 

G00 X[#1+#2];  Since 1.2345 + 2.3456 = 3.5801 in positive direction, the 

travel distance is 3.580, which does not return the tool to 
the original position.   

  This difference comes from whether addition is performed before 

or after rounding off.  G00X-[ROUND[#1]+ROUND[#2]]; must 
be specified to return the tool to the original position. 

 

  - Add decimal point (ADP) function 

  ADP[#n] (n = 1 to 33) can be executed to add a decimal point to an 

argument passed with no decimal point, in the subprogram. 

Example: 
  In the subprogram called with G65 P_X10;, the value of ADP[#24] is a 

value to which a decimal point is added at its end (that is, 10.).    Use this 
function when you do not want to consider the increment system in the 
subprogram.  When bit 4 (CVA) of parameter No. 6007 is set to 1, 
however, the ADP function cannot be used because any argument is 
converted to 0.01 the moment it is passed. 

 

NOTE 

 For  compatibility  among programs, it is 

recommended that the ADP function be not used, 
and decimal points be added in the argument 
specification for a macro call. 

 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 505 - 

  - Rounding up and down to an integer (FUP and FIX) 

With CNC, when the absolute value of the integer produced by an 
operation on a number is greater than the absolute value of the original 
number, such an operation is referred to as rounding up to an integer.   
Conversely, when the absolute value of the integer produced by an 
operation on a number is less than the absolute value of the original 
number, such an operation is referred to as rounding down to an 
integer.  Be particularly careful when handling negative numbers. 

Example: 
 

Suppose that #1=1.2 and #2=-1.2. 

 

When #3=FUP[#1] is executed, 2.0 is assigned to #3. 

 

When #3=FIX[#1] is executed, 1.0 is assigned to #3. 

 

When #3=FUP[#2] is executed, -2.0 is assigned to #3. 

 

When #3=FIX[#2] is executed, -1.0 is assigned to #3. 

 

  - Abbreviations of arithmetic and logic operation commands 

When a function is specified in a program, the first two characters of 
the function name can be used to specify the function. 
 

Example: 
 ROUND 

 RO 

 FIX 

 FI 

 

NOTE 

 

POW cannot be abbreviated. 

 

  - Priority of operations 

<1> Functions 
<2>  Operations such as multiplication and division (*, /, AND) 
<3>  Operations such as addition and subtraction (+, -, OR, XOR) 

Example) #1=#2+#3*SIN[#4];

<1>, <2> and <3> indicate the order of

operations.

<1>

<2>

<3>

 

 

 - Bracket nesting 

Brackets are used to change the order of operations.    Brackets can be 
used to a depth of five levels including the brackets used to enclose a 
function.    When a depth of five levels is exceeded, an alarm PS0118 
occurs. 

  Example) #1=SIN [ [ [#2+#3] *#4 +#5] *#6];

<1> to <5> indicate the order of operations.

<1>

<2>

<3>

<4>

<5>

 

 

16.CUSTOM MACRO

 PROGRAMMING 

B-63944EN/03

 

 

- 506 - 

Limitation 

  Caution concerning decreased precision 

  When bit 0 (F16) of parameter No. 6008 is set to 0 

  Addition and subtraction 

  Note that when an absolute value is subtracted from another 

absolute value in addition or subtraction, the relative error may 
become 10

-15

 or greater. 

  For example, assume that #1 and #2 have the following true values 

in the process of operation. 

  (The following values are examples in the process of operation and 

cannot actually be specified from any program.) 

  

#1=9876543210.987654321 

  

#2=9876543210.987657777 

  You cannot obtain the following result with operation #2-#1: 

  

#2-#1=0.000003456 

  This is because the precision of custom macro variables is 15 

decimal digits.  With this precision, the values of #1 and #2 
become: 

  

#1=9876543210.987650000 

  

#2=9876543210.987660000 

  (Precisely, the actual values are slightly different from the above 

values because they are internally processed in binary.)    Therefore, 
the result is: 

  

#2-1=0.000010000 

  A large error occurs. 

 Logical 

expressions 

  Be aware of errors that can result from conditional expressions 

using EQ, NE, GT, LT, GE, and LE because they are processed 
basically in the same way as addition and subtraction.  For 
example, if the following statement is used to decide whether #1 is 
equal to #2 in the above example, a correct decision may not be 
resulted because errors may occur: 

 

  IF [#1 EQ #2] 

  Evaluate the difference between #1 and #2 with: 

 

  IF [ABS [#1-#2]LT 0.1] 

  Then, assume that the values are equal when the difference does 

not exceed the allowable error range. 

 Trigonometric 

functions 

  The absolute error is guaranteed for trigonometric functions.  

However, the relative error is 10

-15

 or greater.    Carefully perform 

multiplication or division after executing a trigonometric function. 

 FIX 

function 

  When using the FIX function for the result of an operation, be 

careful with the precision.  For example, when the following 
operations are performed, the value of #3 may not always be 2. 

  

N10 

#1=0.002; 

  

N20 

#2=#1*1000; 

  

N30 

#3=FIX[#2]; 

B-63944EN/03

 PROGRAMMING 

16.CUSTOM MACRO

 

 

- 507 - 

  This is because an error may occur in operation N20 and the result 

may not be   

  

#2=2.0000000000000000 

  but a value a little smaller than 2 such as the following: 

  

#2=1.9999999999999997 

  To prevent this, specify N30 as follows: 

  

N30 

#3=FIX[#2+0.001]; 

  Generally, specify the FIX function as follows: 

  

FIX[expression] 

  FIX[expression 

±ε

 (Specify 

+

ε

 when the value of the expression is positive or -

ε

 when 

it is negative, and 0.1, 0.01, 0.001, ... for 

ε

 as required.) 

 

NOTE 

  The operation result of exponential function 

#i=EXP[#j]; overflows when #j exceeds about 790. 

 

When bit 0 (F16) of parameter No. 6008 is set to 1 

 
Errors may occur when operations are performed. 
 

 

 

Table 16.3 (b)    Errors involved in operations 

Operation 

Average 

error 

Maximum 

error 

Type of error 

a = b*c 

1.55

×

10

-10

 4.66

×

10

-10 

a = b / c 

4.66

×

10

-10 

1.88

×

10

-9 

a =   b 

1.24

×

10

-9 

3.73

×

10

-9 

Relative error(*1) 
 

a = b + c 
a = b – c 
 

2.33

×

10

-10

 5.32

×

10

-10 

 (*2)
 

a = SIN [ b ] 
a = COS [ b ] 
 

5.0

×

10

-9 

1.0

×

10

-8 

a = ATAN [ b ] / [ c ] 

1.8

×

10

-6 

3.6

×

10

-6 

Absolute error(*3) 
 
         degrees 

 

NOTE 

1 The relative error depends on the result of the 

operation. 

2  Smaller of the two types of errors is used. 
3 The absolute error is constant, regardless of the 

result of the operation. 

4  Function TAN performs SIN/COS. 
5  Note that, in the case of natural logarithm #i=LN[#j]; 

and exponential function #i=EXP[#j];, the relative 
error may become 10

-8

 or greater. 

The operation result of exponential function 
#i=EXP[#j]; overflows when #j exceeds about 110. 

 

  The precision of variable values is about 8 decimal digits.    When 

very large numbers are handled in an addition or subtraction, the 
expected results may not be obtained.   

ε

a

ε

 

ε

MIN 

b c

ε

 

 

 

 

 

 

 

 

Content      ..     66      67      68      69     ..