FANUC macro program programming 1 . Variable General workpiece program appoints G code and ship distance with numerical value directly; for example, GO1 and X100.0. hen user macro is used, numerical value can !e appointed directly or !y varia!le. hen varia!le is used, varia!le value can !e changed !y program or operation in "#$ panel.
%1= %1=%&+ %&+100 G01 X%1 '(00 illustration : Variable expression
)aria!le is permitted !y computer, !ut user macro is not. )aria!le is appointed !y varia!le num!er ( % ) and latter varia!le num!er. 'or example : %1 *xpression can !e used to appoint varia!le num!er. +ere, expression must !e closed in !racket. 'or example : %%1-%&1&/ Variable type
)aria!le can !e divided into four types according to varia!le num!er . )aria! )aria!le le O. )aria! )aria!le le type type 'uncti 'unction on %0
dummy varia!le
%1%((
2ocal varia!le is only used to store data in macroprogram, such as operation outcome hen power is cut, local varia!le is initiali3ed to local varia!le empty. 4nd when macroprogram is called, independent varia!le assign local varia!le.
%100%155 %600%555
common varia!le
7ommon varia!le has the same meaning in different macro program. when power is cut, varia!le %100%155 are initiali3ed to empty. #ata of varia!le %600%555 is stored even if power is cut.
%1000
system varia!le
8ystem varia!le is used to read and write transformation of all kinds of data when 77 is running, such as tool current position and compensation value.
he varia!le is always empty, no value is assigned to the varia!le.
variable value range
2ocal varia!le and common varia!le can have value 0 or values as following shows9 10: to 10&5 or 10& to 10: $f output oversteps effective range, <=8 warning O.111 is issued. Decimal omission
hen varia!le value is defined in program, decimal can !e ignored. 'or example : hen define %1 = 1&( ; actual value of varia!le %1 is 1&(.000. Variable citation
o use varia!le value in program, varia!le num!er follows it after appointing. when using expression to specify varia!le, put expression in !racket. 'or example : G01X%1-%&/'%(; 7ited varia!le value is rounded automatically according to minimum setting unit. 'or example : hen G00X% is executed as 1= 1000mm , 77 assign 1&(:6> to %1, and actual a ctual instruction value is G00X1&(:>. o change the sign of cited varia!le, put negative sign !efore %. 'or example : G00X - %1 hen you cite undefined varia!le, varia!le and address are all ignored. 'or example : hen value of varia!le %1 is 0 and value of %& is empty, the executing outcome of G00X%1 ?% & is G00X0. Common variable of double locus(double locus control
'or dou!le locus control, system provides every locus individual macro varia!le. @ut, some common varia!les can use two locus at one time according to the setting of parameter 0.>0(> and >0(. Undefined variable
hen varia!le value is undefined, this varia!le !ecomes empty varia!le. )aria!le %0 is always empty. 4nd it can not !e written !ut only !e read. Citation
hen an undefined varia!le is cited, address itself is ignored. hen %1AB empty C
hen%1=0
G50 X100 ?%1
G50 X100 ?%1
G50 X100
G50 X100 ?0
D!E Operation B empty C is the same with 0 except the condition that use B empty C to assign. when %1AB empty C
when %1=0
%&=%1
%&=%1
%&=B empty C
%&=0
%&=%F6
%&=%F6
%&=0
%&=0
%&=%1-%1
%&=%1-%1
%&=0
%&=0
DcE7ondition expression $n * and * B empty C is differ from 0. when %1AB empty C
hen%1=0 时
%1*%0 true
%1*%0 false
%1*%0 true
%1*%0 false
%1G*%0 true
%1G*%0 false
%1G%0 false
%1G%0 false
!imitation
Function Definition Addition
'ormat %iA%I %iA%I-%k;
$ubtraction %ultiplication Division $in Arcsine Cos
%iA%I%k; %iA%IF%k; %iA%I=%k; %iAsin%I; %iAasin%I/; %iAcos%I/;
Jemark
4ngle is appointed with degree. 50o(0K denote 50.6 degree. Arccosine &angent Arc tangent $'uare root
%iAacos%I/; %iAtan%I/ %iAatan%I/=%k/ %iA8J%I/;
Absolute value ounding Up rounding Do)n rounding Natural logarit#m *xponential function +r ,or
%iA4@8%I/; %iAJOLG%I/; %iA'$X%I/; %iA'L<%I/; %iA2%I/;
And C#ange -CD to -N
%iA%I4#%k; %iA@$%I/;
%iA*X<%I/; %iA%IOJ%k; %iA%IXOJ%k;
2ogic operation is executed one !it !y one !it according to !inary num!er.
Lsed for handshaking with <"7. C#ange -N to -CD
%iA@7#%I/;
$llustration : Angle unit 4ngle unit of function 8$ ,7O8,48$,47O8,4 and 44 is degree, for example 50M (0K denote 50.6 degree. 4J78$ % iA 48$%I/ (1) umeric area : hen parameter ( O.>00:%0 ) 4 !it place is set to 0, &0M ~ 50M hen parameter ( O.>00:%0 ) 4 !it place is set to 1, - 50M ~ 50M (&) hen %I overstep the range of - 1 to 1, <=8 warning O.111 is issued. (() )aria!le %I can !e replaced !y constant. 4J77O8 %i=47O8%I/ numeric area is from 1N0M to 0M . hen %I overstep the range of - 1 to 1, <=8 warning O.111 is issued. )aria!le %I can !e replaced !y constant. / . 0rogram example a
%ill ellipse
&ool 0at# for mill ellipse
0rogram code for %ill ellipse
10 G6: G50 G0 81600 "0( 1& X0 ?0 &0. 1: G0 1 1> G1 6. '160. 1N G:1 #1 &0 %1A0 && %&A(: &: %(A&: &> %:A%&F7O8%1/ b
%ill rectangular c#annel
&ool 0at# for mill rectangular c#annel
&N %6A%(F8$%1/ (0 %10A%:F7O8:6/%6F8$:6/ (& %11A%:F8$:6/-%6F7O8:6/ (: G1 X%10 ?%11 (> %1A%1-1 (N $' %1 2 (0/ GOO&> :0 G:0 G1 X0 ?0 :& G0 100 :: "(0
Code for milling rectangular c#annel
%10&A0. (%100A0. %101A0. %10(A&00. %10:A:00. G51G&N0. G0G50G6:X0.?0. G:(+1&0. "(8&000. :G0X%100?%101 G01%10&'&00. %10&A%10&&. $'%10&*60./GOO1 GOO& & :X%10:'600. c
%ill surface inclining to / degree
&ool 0at# for mill surface inclining to / degree
?%10( X%100 ?%101 %100A%100-10. %101A%101-10. %10(A%10(10. %10:A%10:10. $'%100*100./GOO( GOO: ( 1 "6 "5 G51G&N0. G&N?0. "(0
Code for milling surface inclining to / degree
O0001 %%1-1F&/A1 G>6<
[email protected]:$100P(Q0 "(0 %acro +21" code 3
G6: G50 G00 X%(/ ?0 100 8600 "( G01 0 '(00 +$2*%12*10/#O1 %A %1=4%6/-%( G1%1 X% d
%ill semisp#ere
&ool 0at# for mill semisp#ere
%NA%>=&JOL#%>=&/ $'%N*0/GOO10 G1?0 GOO&0 10 ?%: &0%1A%1-%& %>A%>-1 *#1 G0 100
Code for milling semisp#ere
G50G0G6:X10.?0"(8:600 G:(60.+1"N %1A0.6 +$2*%12*60./#O1 %&A60.%1 %(A8J&600.%&F%&// G1%1'&0 e
%ill trumpet
&ool 0at# for mill trumpet
X%('600 G&$%( %1A%1-0.6 *#1 G060."6 "(0
Code for milling trumpet
"0( 8600 "0> 01 %1A0 %&A0 G0 16 X160 ?0 11 %&A(0F8$%1/ %(A(0-(0F17O8%1//
G01 %& ':0 G:1 X%( #01 G0( $%( G:0 G01 X160 ?0 %1A%1-1 $' %1 2* 50/ GOO 11 G0 (0 "(0
f FANUC &ool compensation system parameter macro application
&ool 0at# for tool compensation
Code for tool compensation
O1&(: %1&00A: G5&X0?00 1G50G1G00G:1#0X&6.0?66.0 &G01?50.0'160 (X:6.0 :G0(X60.0?116.0J>6.0 6G0&X50.0J&6.0
>G0(X56.0?50.0J>6.0 G01X116.0 N?66.0 5X0.0?>6.0 10X&6.0?66.0 11G00G:0X0?0