Troubleshooting expressions, E troubleshooting expressions – Delta RMC151 User Manual
Page 355
5 Programming
When performing mathematical calculations in the RMC, keep in mind that the numbers are
32-bit numbers. 32-bit numbers do not provide infinite resolution or range. This topic
describes some of these limitations and how to work around them.
DINT Numbers
DINT numbers are 32-bit integers. DINTs range from -2,147,483,648 to +2,147,483,647.
If a result exceeds these limits, the number will wrap.
REAL Numbers
The RMC's REAL data type conforms to the IEEE-754 Floating-Point specification. Real
numbers do not have infinite accuracy. They are limited to a certain number of significant
digits. The primary effect is that adding a small number to a large number does not result
in great accuracy.
In the RMC75E, RMC75S, RMC75P, and RMC150, the 32-bit REAL numbers range is -
340.28235E+36 to 340.28235E+36. The smallest number that can be represented is
1.4013E-45.
The RMC75E and RMC150E support Inf, -Inf, and NaN as described below.
Incrementing a Value
Continually incrementing a value by some small amount in a loop can cause problems.
For example, incrementing a variable i by 0.001 will eventually cause resolution
problems. After reaching a large value, such as 1000, adding 0.001 will not result in
exactly 1000.001 due to the resolution limitation.
To avoid this problem, it is possible to increment an integer by 1, then multiply by 1000.
Or, if possible, use algorithms that restart the counter periodically, wrap integers, or
employ modulo arithmetic.
Not a Number (NaN)
NaN is a symbol that is produced as the result of an operation on invalid input operands.
The RMCs will fault the task if an invalid input to the following functions and operands is
detected: SQRT, LN, LOG, ASIN, ACOS, /, and MOD.
Otherwise, the RMC75E and RMC150E will generate NaN when the result is truly unknown
or undefined, which includes the following:
•
Any operation where NaN is in at least one operand.
•
The divisions ∞/∞, -∞/∞, ∞/-∞, and -∞/-∞.
•
The multiplications 0x∞ and 0x-∞.
•
The additions ∞+(-∞) and (-∞)+∞ and equivalent subtractions.
•
Applying a function arguments outside of its domain, including taking the tangent of
an odd multiple of 90 degrees.
The RMC75S and RMC75P do not have NaN. These controllers will return a saturated
value (such as -340.28235E+36 for log10(-50)) or 0 when they have an invalid result.
Infinity (Inf)
The RMC75E and RMC150E will generate Inf or -Inf when the result is infinity or negative
infinity or the result overflows the 32-bit limits. Examples: division by zero, multiplication
by infinity
The RMC75S and RMC75P do not have Inf or -Inf. These controllers will return a
saturated value, either 340.28235E+36 or -340.28235E+36 when the result is infinity or
negative infinity.
5.13.13. Troubleshooting Expressions
deltamotion.com
335