Rockwell-automation 1746-BAS BASIC LANGUAGE User Manual Page 31

  • Download
  • Add to my manuals
  • Print
  • Page
    / 280
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 30
Publication 1746-RM001A-US-P
Expressions and Operators 3-9
Comments on Trigonometric Functions
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 by the following 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 (example:
greater than 1000). This is because significant
digits in the decimal (fraction) portion of the reduced argument are lost in the
(user arg/PI - INT (user arg/PI)) expression. As a general rule, keep the
arguments for the trigonometric functions as small as possible.
Functional Operators
The module contains a complete set of functional operators. These operators are
single-operand operators.
ABS([expr])
Use the ABS operator to return the absolute value of the expression.
NOT([expr])
Use the NOT operator to return a 16-bit ones complement of the expression. The
expression must be a valid integer (example:
between 0 and 65535 (0FFFFH)
inclusive
). Non-integers are truncated, not rounded.
Example Result
>PRINT ABS(5) 5
>PRINT ABS(–5) 5
Example Result
>PRINT NOT(65000) 535
>PRINT NOT(0) 65535
Page view 30
1 2 ... 26 27 28 29 30 31 32 33 34 35 36 ... 279 280

Comments to this Manuals

No comments