95
96-8000 rev R June 2007
Macros
Functions
Functions are built-in routines that the programmer has available to use. All functions have the form
<function_name>[argument] and return floating-point decimal values. The functions provided in the Haas control
are as follows:
Function Argument Returns Notes
SIN[ ] Degrees Decimal Sine
COS[ ] Degrees Decimal Cosine
TAN[ ] Degrees Decimal Tangent
ATAN[ ] Decimal Degrees Arctangent Same as FANUC ATAN[ ]/[1]
SQRT[ ] Decimal Decimal Square root
ABS[ ] Decimal Decimal Absolute value
ROUND[ ] Decimal Decimal Round off a decimal
FIX[ ] Decimal Integer Truncate fraction
ACOS[ ] Decimal Degrees Arccosine
ASIN[ ] Decimal Degrees Arcsine
#[ ] Integer Integer Variable Indirection
DPRNT[ ] ASCII text External Output
Notes on Functions
The function “Round” works differently depending on the context that it is used. When used in arithmetic expres-
sions, any number with a fractional part greater than or equal to .5 is rounded up to the next whole integer; other-
wise, the fractional part is truncated from the number.
#1= 1.714 ;
#2= ROUND[#1] ; (#2 is set to 2.0)
#1= 3.1416 ;
#2= ROUND[#1] ; (#2 is set to 3.0)
When round is used in an address expression, then the argument “Round” is rounded to the significant precision.
For metric and angle dimensions, three-place precision is the default. For inch, four-place precision is the default.
#1= 1.00333 ;
G0 X[ #1 + #1 ] ;
(Table moves to 2.0067) ;
G0 X[ ROUND[ #1 ] + ROUND[ #1 ] ] ;
(Table moves to 2.0066) ;
G0 A[ #1 + #1 ] ;
(Axis moves to 2.007) ;
G0 A[ ROUND[ #1 ] + ROUND[ #1 ] ] ;
(Axis moves to 2.006) ;
D[1.67] (Diameter 2 is made current) ;
Fix vs. Round
#1=3.54; #2=ROUND[#1]; #3=FIX[#1]. #2 will be set to 4. #3 will be set to 3.
Operators
Operators can be classified into three categories: Arithmetic operators, Logical operators and Boolean operators.
Arithmetic Operators
Arithmetic operators consist of unary and binary operators. They are:
+ - Unary plus +1.23
- - Unary minus -[COS[30]]
+ - Binary addition #1=#1+5
- - Binary subtraction #1=#1-1
* - Multiplication #1=#2*#3
/ - Division #1=#2/4
MOD - Remainder #1=27 MOD 20 (#1 contains 7)