PLC Value Is Neither Above Nor Below the Limit? Check for NaN
- PLC Play Ground
- 0
- Posted on
Ordinary range comparisons are not a complete validity test for floating-point data. If a value behaves strangely in both high and low checks, investigate nonfinite values and the status of the calculation that produced it.
Nonfinite behavior and library support are target-specific.
What is happening?
IEEE-style floating-point systems can represent NaN and infinity. Comparisons and conversions involving them need documented handling. Platform libraries may provide explicit classification functions, but their availability and behavior must be verified for the target.
Check these five things
-
Capture the source operation and its diagnostic status.
-
Check supported finite and NaN classification methods.
-
Separate data validity from normal range limits.
-
Test invalid and nonfinite inputs offline.
-
Prevent invalid results from becoming accepted process commands.
Worked example
A teaching calculation produces NaN after an invalid mathematical operation. Tests for value below zero or above one hundred do not establish that it is a normal number. The acceptance path first requires a valid finite result, then applies the operational range.
Quick diagnostic reference
| Test | Purpose |
|---|---|
| Operation status | Calculation succeeded? |
| Finite classification | Ordinary numeric result? |
| Range check | Operationally permitted? |
The mistake to avoid
Converting the result to an integer to make the display look normal can create another fault or misleading value. Preserve the invalid status and diagnose its source.
How to verify the fix
Exercise normal values, invalid operations, infinities where supported, and recovery. Record the expected validity and consumer behavior rather than checking only the displayed digits.
Field-work boundary: These are educational diagnostic guides. Use the exact equipment manuals and approved site procedures. Electrical testing and machinery changes belong to qualified, authorized personnel; control hazardous energy and validate affected functions before release.
Technical reference
ABB Automation Builder: Floating-point classification functions. The examples and diagnostic tables above are original teaching material; they do not replace the product manual.
