16. CUSTOM MACRO
DWhen 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.
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.
G01 X–#2 F300; Moves 2.346 mm.
Since 1.2345 + 2.3456 = 3.5801, 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.
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.
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.
When a function is specified in a program, the first two characters of the
function name can be used to specify the function.
ROUND → RO
FIX → FI
(2) Operations such as multiplication and division (*, /, AND, MOD)
(3) Operations such as addition and subtraction (+, –, OR, XOR)
(1), (2), and (3) indicate the order of operations.
D Rounding up and down
to an integer
D Abbreviations of
arithmetic and logic
D Priority of operations