Posts Tagged ‘xample’

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)