Trigonometric operators – Rockwell Automation 1771-DB BASIC MODULE User Manual
Page 120

Chapter
Expressions, Variables and Operators
9
9 -10
The BASIC module contains a complete set of trigonometric operators.
These operators are one-operand operators. The SIN, COS, and TAN
operators use a Taylor series to calculate the function. These operators
first reduce the argument to a value between 0 and PI/2. This reduction is
accomplished with the equation:
reduced argument=(user arg/PI - INT(user arg/PI) *PI
The reduced argument, from the above equation, is between 0 and PI.
The reduced argument is then tested to see if is greater than
PI/2
. If it is,
then it is subtracted from
PI
to yield the final value. If it is not, then the
reduced argument is the final value.
Although this method of angle reduction provides a simple and economical
means of generating the appropriate arguments for a Taylor series, there is
an accuracy problem associated with this technique. The accuracy
problem is noticed when the user argument is large (ex:
greater than
1000
). This is because significant digits in the decimal (fraction) portion
of the reduced argument are lost in the expression shown above.
Important: As a general rule, keep the arguments for the trigonometric
functions as small as possible.
SIN
Use the SIN operator to return the sine of the argument. The argument is
expressed in radians. Calculations are carried out to 7 significant digits.
The argument must be between +200000.
>PRINT SIN(PI/4)
Result:
.7071067
>PRINT SIN(0)
Result:
0
COS
Use the COS operator to return the cosine of the argument. The argument
is expressed in radians. Calculations are carried out to 7 significant digits.
The argument must be between +200000.
>PRINT COS(PI/4)
Result:
.7071067
>PRINT COS(0)
Result:
1
TAN
Use the TAN operator to return the tangent of the argument. The argument
is expressed in radians. The argument must be between +200000.
>PRINT TAN(PI/4)
Result:
1
>PRINT TAN(0)
Result:
0
Trigonometric Operators