Atn2(source), Avgrun (dest, reps, source, number), Syntax – Campbell Scientific CR9000X Measurement and Control System User Manual
Page 292: Remarks

Section 8. Processing and Math Instructions
ATN
is the inverse trigonometric function of TAN, which takes
an angle as its argument and returns the ratio of two sides of a
right triangle. Do not confuse
ATN
with the cotangent, which is
the simple inverse of a tangent (1/tangent).
NOTE
ATN FunctionExample
The example uses ATN to calculate
π
. By definition, ATN(1) is 45 degrees; 180
degrees equals
π
radians.
Dim Pi
'Declare variables.
Pi = 4 *
ATN
(1)
'Calculate
π
.
ATN2(Source)
The ATN2 function returns the arctangent of y/x.
Syntax
x = ATN2 ( Y, X )
Remarks
ATN2 function calculates the arctangent of Y/X returning a value in the range
from
π
to -
π
radians, using the signs of both parameters to determine the
quadrant of the return value. ATN2 is defined for every point other than the
origin (X = 0 and Y = 0). Y and X can be variables, constants, or expressions.
If it is desired to use degrees instead of radians for the inputs and results of the
trig functions in a program, the "AngleDegrees" declaration instruction can be
used.
To convert degrees to radians, multiply degrees by
π
/180. To convert radians to
degrees, multiply radians by 180/
π
.
π
is approximately 3.141593.
AvgRun (Dest, Reps, Source, Number)
AvgRun is used to calculate a running average of a measurement or calculated
value.
Syntax
AvgRun(
Dest, Reps, Source, Number
)
Remarks
A running average is the average of the last N values where N is the number of
values.
Dest
X
N
i
i
i N
=
=
=
∑
1
X
N
X
N
−1
X
1
Where
is the most recent value of the source variable and
is the
previous value (
is the oldest value included in the average, i.e., N-1 values
back from the most recent). NANs are not included in the processing of the
AvgRun. N (number of values used in the Running Average) will be
reduced by the number of NANs encountered in the current band of
values, reducing the number of values used in the AvgRun calculations
until the NAN(s) are cycled through.
8-6