P
ar
t
1: P
rog
ra
m
ming
Moog Animatics SmartMotor™ Developer's Guide, Rev. L
Page 198 of 909
FSQRT(x)
Floating Point Square Root (x = float, where x>= 0)
FABS(x)
Floating Point Absolute Value (x = float)
SIN(x)
Floating Point Sine (x = float in degrees)
COS(x)
Floating Point Cosine (x = float in degrees)
TAN(x)
Floating Point Tangent (x = float in degrees)
ASIN(x)
Floating Point Arc Sine in degrees on [-90,90],
(x = float on the interval [-1,1])
ACOS(x)
Floating Point Arc Cosine in degrees on [0,180],
(x = float on the interval [-1,1])
ATAN(x)
Floating Point Arc Tangent in degrees on [-90,90] ,
(x = float)
PI
Floating Point representation of PI =
3.14159265359…
Math Operation Details and Examples
In any operation, if the input is an integer then the result remains an integer. A result is
promoted to a float once the operation includes a float. Functions that require a floating-point
argument implicitly promote integer arguments to float. In converting a floating-point number
to an integer result, the floating-point number is truncated toward zero. Although the floating
point variables and their standard binary operations conform to IEEE-754 double-precision
results, the floating-point square root and trigonometric functions only produce IEEE-754
single-precision results. The following are some examples:
a=(b+c/d)*e
'Standard hierarchical rules apply
a=2^3
'a=8
c=123%12
'Modulo, c=3, remainder of 123/12
b=(-10<a)&(a<10)
'b=0 if "a" not in range, b=1 otherwise
x=ABS(EA)
'Set x to the abs value of pos error
r=SQRT(a)
'if a=64, r=8,; if a=63, r=7
Array Variables
An array variable has a numeric index component that specifies the variable a program is to
access. This memory space is flexible because it can hold fifty-one 32-bit integers, or one-
hundred-two 16-bit integers, or two-hundred-four 8-bit integers (all signed). The array
variables use the following form:
ab[i]=formula
Set variable to a signed 8-bit value where index i=0...203
aw[i]=formula
Set variable to a signed 16-bit value where index i=0...101
al[i]=formula
Set variable to a signed 32-bit value where index i=0...50
NOTE:
The index i may be a number, a variable or an expression.
Part 1: Programming: Math Operation Details and Examples