PLC Array Fault Only Happens on the Last Item? Check the Boundary
- PLC Play Ground
- 0
- Posted on
An array containing ten elements does not necessarily have an element numbered ten. Confusing a count with the highest valid index creates a classic end-of-list failure. Read the declared bounds and inspect every increment, reset, and indirect access that uses the index.
Zero-based teaching example; declared bounds and fault handling are platform-specific.
What is happening?
Array bounds and fault behavior depend on the platform. In a zero-based ten-element array, the valid indices are zero through nine. Some environments allow explicit lower bounds, so even a familiar zero-based assumption needs confirmation. Startup and prescan behavior can also expose invalid indices before normal correction logic runs.
Check these five things
-
Read the actual declaration and record the lower bound, upper bound, and element count for every dimension.
-
Cross-reference all index writers, including HMI entry, queue operations, startup values, and recipe selection.
-
Validate an index before the relevant access using the platform's supported method; review prescan behavior separately.
-
Check whether increment and reset logic use the count or the upper bound in the intended way.
-
Test empty, first, last, and out-of-range requests in simulation, including a restart with invalid retained data.
Worked example
For a declared array indexed zero through nine, processing index nine is valid. Incrementing to ten and attempting another read is not. A test that stops after the first few records never exercises this boundary.
Quick diagnostic reference
| Ten-element zero-based example | Valid? |
|---|---|
| Index 0 | Yes |
| Index 9 | Yes |
| Index 10 | No |
The mistake to avoid
Do not silence an array fault without finding the invalid access. Fault suppression can let the application continue with incorrect or missing data.
How to verify the fix
Demonstrate that each valid element is processed once and that invalid requests produce the designed diagnostic without an unsafe or unintended action.
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
Rockwell Automation: major, minor, and I/O faults. The examples and diagnostic tables above are original teaching material; they do not replace the product manual.
