Troubleshooting
Search a CompactLogix INT array for one fault code with FSC
Short answer
Search the received array with one FSC instruction: set the length to the element count, index the compare expression with the control structure's position, and drive Engine_coolant_low from the found bit of a finished pass. Reset the control structure above the search rung each scan so a stale found bit cannot hold the alarm on after the code clears.
On this page
If a fault code can arrive in any element of a received integer array, one FSC instruction tests the whole array in a single rung. Set the search length to the element count, write the compare expression so it indexes the array with the control structure's position, and drive Engine_coolant_low from the found bit after a completed search. The pattern fails in two predictable ways: a fixed index in the expression, which tests one element every scan no matter where the search points, and a stale found bit from a previous pass, which holds the alarm on after the code has cleared. Both are fixed by rung order and by resetting the control structure before each new search, and both are far cheaper to fix before commissioning than after the call from the floor.
Prove the code reaches the array first #
Go online in Studio 5000 Logix Designer and watch the array while the sending device reports the fault. You are reading values in controller memory, not the alarm, so check three things before editing any logic:
- The destination tag is an integer array of the size you expect, and the code sits in one element. Note which one.
- The message instruction that reads the Modbus TCP registers completed without an error and landed the data at the offset you expect, not shifted by a register count.
- The value matches what the sender means: the same digits read as decimal and as hexadecimal are different numbers, so an encoding or word-order mismatch shows up as a wrong code rather than no code.
If the code is in the array, build the search rung. If it is not, the search is not yet your problem: an FSC instruction compares values already in controller memory and cannot recover a code that never arrived. Missing or shifted data is a receive problem, meaning register mapping, offset or data type, and one receive-side failure of exactly this class is two Modbus TCP client instances stopping reads from one server, so prove the receive path before tuning a rung that depends on it.
Freshness is part of the same check. An array that stopped updating still matches numerically, so treat communication health as its own condition and let the machine's alarm scheme, not the search rung, decide what stale data means.
If you also need the array at a supervisor, that is a different read path: reading PLC tag arrays in one block request moves the whole array in one request instead of one read per element.
Set up one FSC instruction #
Create a control-type tag for the search, for example Search_ctl, and dedicate it to this instruction so nothing else in the program writes its position or status bits. Point the FSC instruction at the Fault array, attach that control tag, and set the length to the element count: 20 here, because the array runs from Fault[0] through Fault[19] and the length is a count of elements, not the last index.
Choose the mode that completes the entire search in one scan (All). The incremental setting spreads comparisons across several scans, which earns its keep on very large arrays and costs you a settled result here: a found bit read mid-search says nothing yet.
Keep the length inside the array. If the search is allowed to evaluate an index past the last element, the expression reaches memory that is not yours and can fault the processor. The same applies if the length is edited while the controller runs: bound-check any value before it reaches the length field, or leave the length fixed in the project.
Write the expression so the index follows the search #
The expression is an ordinary compare with one twist: the element index must be the control structure's own position. For this search that reads Fault[.POS] = 2005, which tests the coolant code against element 0, then element 1, then element 2, and so on as the position advances.
The mistake to avoid is a fixed index such as Fault[0] = 2005. The position still advances, but the expression keeps testing element 0, so the search reports a match at position 0 immediately and never tests the rest of the array. Most reports of the array holding the code while FSC finds nothing trace to this, usually alongside a length shorter than the element count or a control structure that was never reset.
FSC halts at the first element whose comparison is true: the found bit (.FD) sets and the position holds the matching index. For a presence test that is all you need, because one match proves the code is in the array and where the rest would be does not matter. If you ever need every occurrence, the documented continuation is to clear the halt bit (.IN), which resumes the search from the next element.
Drive the alarm from the finished search #
Rung the three lines in scan order, top to bottom, so each pass does reset, then search, then output:
- Reset rung: run every scan and clear the control's found bit (.FD), halt bit (.IN) and position, so each new search begins at element 0.
- Search rung: condition true continuously, FSC over the full length with the indexed expression.
- Output rung:
XIC Search_ctl.FDfeedingOTE Engine_coolant_low.
With the one-scan mode the search completes inside the scan, so the output rung always reads a settled result: found means the code is in the array in this pass, clear means a completed pass found no match. A clear found bit only means that after a completed pass, which is why the one-scan mode is the right choice for an alarm.
Clearing the control bits each scan also answers the second-trigger failure. The instruction halts when it finds a match and keeps its position and status until something resets them, so a trigger pulse without a reset finds the search still halted and nothing happens on the second edge. Reset above, search in the middle, output below, every scan keeps the result current with the data and costs a handful of compares per scan on a CompactLogix.
Two details finish the rung. An OTE follows its rung condition; if the requirement is an acknowledged or latched alarm, that is separate logic with its own clear rule, and cross-reference Engine_coolant_low to be sure no later rung overwrites it. And if the receive logic writes elements while the search is mid-array, one pass can mix old and new values, so sequence the search after a completed receive or search a copy the receiver does not touch. Note that Engine_coolant_low drives an operator indication; a protective response to low coolant needs its own safety-rated design, not this search rung.
Match the symptom to the cause #
| What you see | Likely cause | Fix |
|---|---|---|
| Array holds the code, search reports none | Fixed index in the expression, length below the element count, or a control that was never reset | Check the indexed expression, the length and the reset rung |
| Match always reported at the first position | Expression compares a fixed element | Index the element with the control's position |
| Search runs once, then never again | Control still halted from the first pass | Clear the found bit, halt bit and position before each new search |
| Alarm stays on after the code clears | Stale found bit, or another rung writes the output tag | Reset every pass and cross-reference the output |
| Alarm flickers or mixes old and new values | Search spread over scans, or receive writes mid-search | Use the one-scan mode and sequence the search after a complete receive |
A worked pass through the array #
Take a received array in which the code sits in Fault[13], with the other elements holding zeros and unrelated codes. The search begins at position 0. Comparisons 1 through 13 test elements 0 through 12 and are all false. Comparison 14, at position 13, finds Fault[13] equal to 2005: the found bit sets, the halt bit sets, the position holds 13, and the search stops. The six elements after it are never evaluated, and for a presence test they do not need to be; the output rung sees the found bit and Engine_coolant_low turns on.
The next pass shows the off path. The reset rung clears the found bit, the halt bit and the position; the receive logic has since written 0 into Fault[13]; the search now runs all 20 comparisons, positions 0 through 19, without one true compare, stops because the position has reached the length, and leaves the found bit clear. Engine_coolant_low drops.
The arithmetic that protects the controller: the highest index the search evaluates is one less than the length, and 20 minus 1 gives 19, the last valid element of this array. That relation is exactly what disappears when the length is set past the array, because nothing then stops the expression from evaluating Fault[20] and beyond, which is the path that faults the processor.
Prove it before you trust it #
Do the first passes with the machine not running, forcing array values directly, and record the array contents, the found bit, the position and the output for each pass:
- Put the code in the first element and run one pass; expect a match at the first position and the alarm on.
- Move the code to a middle element and repeat; expect the reported position to follow it.
- Move the code to the last element and repeat; expect the search to reach it.
- Clear every element and repeat; expect a finished pass with the found bit clear and the alarm off.
- Put the code in several elements and repeat; expect the first occurrence in the position and a steady alarm.
- Stop the sender or break the communication on purpose and decide the behavior: the array still holds the last code and the search still matches it, so whether the alarm may stay on with stale data belongs in the machine's alarm scheme, decided before the search rung is trusted.
The decision #
Search with one FSC rung: length at the element count, expression indexed by the control's position, alarm taken from the found bit of a finished pass, control reset above the search every scan. Code in the array: found bit sets, alarm on. Code absent: a completed pass leaves the bit clear and the alarm off. Code never arrives: fix the receive path, because no expression finds data that is not in memory. Search fires only once: reset the control structure before each trigger. Length that must ever change with the array: bound-check it or fix it in the project, since an unchecked length past the last element is the documented path to a processor fault.
Questions asked
Does FSC report every element that matches?
No. The instruction stops at the first element whose comparison is true, sets the found bit and leaves the position at that element. The documented way to continue is clearing the halt bit, which resumes the search from the next element. Counting every occurrence therefore needs repeated passes or a different construct; for a presence alarm the first match is all the logic needs.
Why does the alarm stay on after the fault code clears?
The found bit is retained in the control structure until something clears it. If the reset rung is missing or the search does not run again on fresh data, the output keeps reading the previous pass. Rung order matters too: an output rung placed above the search rung reads the previous scan's result. Also cross-reference the output tag, because a second rung writing the same tag keeps the alarm on regardless of the search.
Can I just OR compare contacts instead of using FSC?
You can, and it works, because every branch tests one fixed element. The cost shows up later: each branch hard-codes an index, a length change means editing the rung, and a branch count that does not match the real array silently skips elements. One FSC rung follows the array through a single expression and one control tag, which is why it scales better.
Why does my FSC execute only the first time?
The instruction halts when it finishes or finds a match and keeps its position and status bits, so a second trigger finds the control still halted: the rung looks true and the search simply never restarts. Clear the found bit, the halt bit and the position in a rung above the search rung, and the instruction arms again on the next trigger.