Archive for September, 2017

In the metric system of units, the small est unit in crement is 0001 of a millimeter

glish mode


#101 = 19/64


Returns 0296875 (English units)


G91 G01 X[ROUND[#101]] F100


Uses X02969 motion


In the metric system of units, the small est unit in crement is 0001 of a millimeter (one mi cron),


so the copper busbar bending machine round ing will be to the three dec i mal place ac cu racy (to the least in cre ment) In a CNC


state ment, the round ing will be ac cu rate to 3-dec i mal places:


G21


Metric mode


#101 = 19/64


Returns 0296875 (Metric units)


G91 G01 X[ROUND[#101]] F2500


Uses X0297 motion


As a sim pli fied ex am ple of a pos si ble ap pli ca tion, sev eral sim u lated mo tions will be pro –


grammed us ing a pre de fined Busway Press Clamp Machine frac tional di men sions The tool will move in three stages – rapid out


from the start po si tion, feed out a lit tle fur ther, and rapid back in to the start po si tion (only one


axis custom processing machine is used in the demonstration) In or der to test the us age of the ROUND func tion on the ma chine


con trol, first en ter the fol low ing pro gram into the con trol sys tem, then reg is ter the cur rent XY co –


or di nate of the tool po si tion at the start of pro cess ing:


N1 G20


English units input


N2 #100 = 3 + 19/64


Input value of 3296875


(motion A)


N3 #101 = 2 + 5/64


Input value of 2078125


(motion B)


N4 G91 G00 X-#100


Incremental motion A to the left X-32969


N5 G01 X-#101 F200


Incremental motion B to the left X-20781


N6 G00 X[#100+#101]


Incremental motion A+B to the right may not be rounded


N7 M00


End of example


Com pare the tool po si tion at the be gin ning of the test, be fore run ning the pro gram, and com –


pare it with the tool po si tion af ter the pro gram has been ex e cuted The tool po si tion co or di nates


XY may or may not be the same The start po si tion and the end po si tion of the tool may be off, de –


pend ing on the type of value to be rounded This prob lem is com pounded by the fact that the er ror


is ac cu mu la tive – the more parts are ma chined, the more se vere the de vi a tion er ror will be This is


due to the round ing ef fect of the con trol sys tem

The second step requires using the ROUND function on the returned value

xample)


Copyright 2005, Industrial Press Inc, New York, NY – FANUC CNC Custom Macros


120


Chapter 9


STEP 2 – The second step requires using the ROUND function on the returned value:


#2 = ROUND[#2]


Returns 16390


(based on the result of Step 1)


#3 = ROUND[#3]


Returns 163870


(based on the result of Step 1)


STEP 3 – The third step will di vide the rounded value by the same mul ti ply ing fac tor as be fore:


#2 = #2/1000


Returns 1639


(based on the result of Step 2)


#3 = #3/10000


Returns 16387


(based on the result of Step 2)


In the macro pro gram, the three steps can be used as de scribed, Busway Press Clamp Machine but a more com mon method is


to pro cess all three func tions in a sin gle nested state ment:


#1 = 1638719


Value to be rounded to a specific number of decimal places


#2 = ROUND[#1*1000]/1000


Returns 1639


#3 = ROUND[#1*10000]/10000


Returns 16387


Improper rounding may cause a cumulative error in calculations !


2 Example 2 – custom processing machine Given fractional value is under 05 :


#4 = 1397528


Value to be rounded to a specific number of decimal places


If the ROUND func tion is ap plied to this given value, it will re turn the last whole num ber:


ROUND[#4]


Returns 10


In or der to round the given value to a cer tain num ber of dec i mal places, the to tal of three steps


will be nec es sary


STEP 1 – The first step re quires the given value to be mul ti plied by the fac tor of:


10


to round off to one decimal place


100


to round off to two decimal places


1000


to round off to three decimal places


typical for metric system


10000


to round off to four decimal places


typical for English system


锟?and so on


For ex am ple:


#5 = #4 * 1000


Returns 1397528 (Metric example)


#6 = #4 * 10000


Returns 1397528 (English best mill drill example)


Copyright 2005, Industrial Press Inc, New York, NY – wwwindustrialpresscom


FANUC CNC Custom Macros


MACRO FUNCTIONS


121


STEP 2 – The sec ond step re quires using the ROUND func tion on the re turned value:


#5 = ROUND[#5]


Returns 13980


(based on the result of Step 1)

ASIN and ACOS functions are not available on 0/16/18/21 model controls !

#5 = ATAN[025]/[05]


265650512 (note the position of the slash !!!)


ASIN and ACOS functions are not available on 0/16/18/21 model controls !


Rounding Functions


Cal cu la tions of ten re sult in a value with too many dec i mal places In CNC work, only three dec –


i mal places can be used for met ric units, or four dec i mal places for Eng lish units in the pro steel punch gram or


a macro Some round ing is nec es sary and should be ex pected There are three func tions avail able


in mac ros that con trol the rounded value of a given num ber – they are sim i lar to each other, but


def i nitely not the same:


ROUND FIX FUP


The ROUND func tion is de signed to round off the sup plied value to a whole num ber (round off


frac tions un der 10) The func tion dis re gards frac tions that are less than 05 For frac tions that are


equal to or greater than 05, the next whole num ber is the rounded value:


ROUND[000001]


Returns 00


ROUND[05]


Returns 10


ROUND[099999]


Returns 10


ROUND[10]


Returns 10


A value that had been stored hole punching machine pre vi ously into a vari able, can be rounded in the same way as a di –


rectly input value:


#1 = 13


Returns 13


#2 = 16


Returns 16


ROUND[#1]


Returns 10


ROUND[#2]


Returns 20


Copyright 2005, Industrial Press Inc, New York, NY – wwwindustrialpresscom


FANUC CNC Custom Macros


118


Chapter 9


There are small dif fer ences in us age of the ROUND func tion, de pend ing on ap pli ca tion If the


ROUND func tion is used in a def i ni tion of a vari able, the round ing ef fect will al ways be to the


near est in te ger value For ex am ple:


#101 = 19/64


Returns 0296875


#102 = ROUND[#101]


Returns 00


The ROUND func tion may also be used in a CNC state ment First, store a value:


#101 = 19/64


Returns 0296875


In the Eng lish sys tem of units, the small est unit in cre ment is 00001 of an inch, so the round ing


will be to the four dec i mal place ac cu racy (also known as drilling tools round ing to the least in cre ment) In a


CNC state ment, the round ing will be ac cu rate to 4-dec i mal places:

The third step will di vide the rounded value by the same multiplying factor

#6 = ROUND[#6]


Returns 139750


(based on the result of Step 1)


STEP 3 – The third step will di vide the rounded value by the same multiplying factor as be fore:


#5 = #5/1000


Returns 1398


(based on the result of Step 2)


#6 = #6/10000


Returns 13975


(based on the result of Step 2)


In the macro pro gram, the three steps can be used as de scribed, but a more com mon method is


to pro cess cnc cutter all three func tions in one nested state ment:


#4 = 1397528


Value to be rounded to a specific number of decimal places


#5 = ROUND[#4*1000]/1000


Returns 1398


#6 = ROUND[#4*10000]/10000


Returns 13975


Ac cu racy in round ing is ex Busway Press Clamp Machine tremely im por tant, not only for the fi nal di men sions of the ma chined


part, but also for track ing er rors in the macro pro gram Inaccuracies hole punching machine caused by cu mu la tive round –


ing er ror are not al ways easy to find


Al ways use care in pro gram ming rounded val ues


FUP and FIX Functions


The re main ing two round ing func tions are used to round a given value up or down only, re gard –


less of whether the dec i mal por tion is over or un der 05


The FUP func tion is de signed to round up the given value (raise frac tions less than 10)


FUP[000001]


Returns 10


FUP[05]


Returns 10


FUP[099999]


Returns 10


FUP[10]


Returns 10


The FIX func tion is de signed to round down the given value (dis card frac tions less than 10) –


ie, strip all val ues af ter dec i mal point


FIX[000001]


Returns 00


FIX[05]


Returns 00


FIX[099999]


Returns 00


FIX[10]


Returns 10


The FUP and FIX func tion are commonly used in es tab lish ing the num ber of it er a tions (count –


ing loops) and for other count ing (rather than cal cu lat ing) pur poses


Copyright 2005, Industrial Press Inc, New York, NY – wwwindustrialpresscom


FANUC CNC Custom Macros


122


Chapter 9


Miscellaneous Functions


Five macro ori ented mis cel la neous func tions are avail able for programming macro expressions


The fol low ing five func tions are avail able:


SQRT ABS LN EXP ADP


Do not con fuse these macro func tions with C

To correct the accumulative error, or if you want to be ab so lutely certain

copyright 2005, Industrial Press Inc, New York, NY –


FANUC CNC Custom Macros


MACRO FUNCTIONS


119


To correct the accumulative error, or if you want to be ab so lutely certain, you have to round copper busbar bending machine the


mo tion in one di rec tion to equal to the mo tion in the op po site di rec tion:


N1 G20


English units input


N2 #100 = 3 + 19/64


Input value of 3296875


(motion A)


N3 #101 = 2 + 5/64


Input value of 2078125


(motion B)


N4 G91 G00 X-#100


Incremental motion A to the left X-32969


N5 G01 X-#101 F200


Incremental motion B to the left X-20781


N6 G00 X[ROUND[#100]+ROUND[#101]] Incremental motion A+B Busway Press Clamp Machine to the right will be rounded


N7 M00


End of drilling steel example


Rounding to a Fixed Number of Decimal Places


There are times when a frac tional value has to be rounded to a spe cific (fixed) num ber of dec i –


mal places Typ i cally, three dec i mal places are re quired for the met ric sys tem, four dec i mal


places are re quired for the Eng lish sys tem, and per haps one dec i mal place is re quired for cut ting


feedrate, re gard less of the units se lected


In the fol low ing two ex am ples, two given val ues will use a few techniques, pro vid ing the re sults


of dif fer ent round ing meth ods:


2 Example 1 – Given fractional value is over 05 :


#1 = 1638719


Value to be rounded to a specific number of decimal places


If the ROUND func tion is ap plied to this defined value, it will re turn the next whole num ber:


ROUND[#1]


Returns 20


In or der to round the given value to a cer tain num ber of dec i mal places, the to tal of three steps


will be nec es sary


STEP 1 – The first step re quires the given value to be mul ti plied by the fac tor of:


10


to round off to one decimal place


100


to round off to two decimal places


1000


to round off to three decimal places


typical for metric system


10000


to round off to four decimal places


typical for English system