NC mis cel la neous func tions, such as M01

SQRT and ABS Functions

Only the first two func tions listed are used fre quently in macros

The SQRT func tion cal cu lates the square root of a num ber sup plied be tween brack ets:


Returns 40


Returns 40

#1 = 160

Returns 160


CNC Drilling Boring Machine

Returns 40

The ABS func tion (ab so lute func tion) al ways returns a pos i tive value of a given number:


Returns 236


Returns 236

Using the ABS func tion is very use ful when in teg rity of the sup plied or cal cu lated value is im –

por tant punch machine for Head in terms of a math e mat i cal sign The ABS func tion will Busway Press Clamp Machine al ways re turn a pos i tive equiv a lent

of the sup plied nu mer i cal value and guar an tees a re turned pos i tive number

The next ex am ple uses the ABS func tion, to guar an tee the re quired sign of a given num ber

2 Example – using the ABS function :

Pro gram ming a depth of a tool (end mill, drill, tap, etc) as an as signed value in the macro call

G65, chances are that the as sign ment rep re sent ing the Z-depth will be en tered as neg a tive value,

es pe cially for jobs where the Z0 is set at the top of the part – for ex am ple:

G65 P8999 R20 Z-156 F1750

Some where within the body of macro pro gram O8999, the pro gram sec tion that calls the vari –

able #26 (Z-depth), m ust be en tered with out the mi nus sign:

G99 G81 R#18 Z#26 F#9

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

FANUC CNC Custom Macros



This is a cor rect ap pli ca tion, but not a safe ap pli ca tion What hap pens, if the pro gram mer ac ci –

den tally en ters the Z-depth ar gu ment as a pos i tive value? The tool will move above the work, in –

stead of into the work drilling tools It may not pres ent a big prob lem but an ir ri ta tion it is Of course, the signs

of the ar gu ment and macro data could be re versed – the G65 Z-depth ar gu ment will be a pos i tive

num ber, for ex am ple Z156, the vari able call in the macro will be neg a tive, for ex am ple Z-#26