Skip to main content
Call Eric:863-698-8266
CURRYCONTROLS.COMControls & Automation Knowledge Hub
ReferencePLCTroubleshootingProgrammingFundamentalsControl

Program Faults

Faults the program causes: an index out of range, division by zero, an invalid indirect address, a missing routine, a type mismatch, or task overlap. Reading the fault record, what a fault handler should do, clearing safely, and logic that does not fault.

8 min readUpdated Sep 5, 2026Published Sep 5, 2026By Eric Sullivan

The short answer

Program Faults

A program fault is the controller refusing to execute an instruction it cannot execute safely: an index outside an array, a pointer to memory that does not exist, a divide by zero on a platform that treats it as fatal, a call to a routine that is not there, or a task that could not finish before it was due to run again. The controller records the fault type, the code, the routine, and the rung or line, and either stops with a major fault or logs a minor one and continues, depending on the fault and the platform. The record is the diagnosis; the fault handler is the place to log it and decide whether to keep running; and the prevention is defensive logic that bounds every index, checks every divisor, and validates every value that comes from a screen or a network before using it.

Key points

  • The fault record names the type, the routine, and the rung; read it before clearing anything.
  • Major faults stop the controller and its outputs; minor faults are logged and execution continues.
  • A fault handler routine can clear recoverable faults and log them, but a handler that clears everything hides a program that is broken.
  • Bounds checks on indexes, checks on divisors, and limits on values from screens and networks prevent most program faults.
  • Task overlap is a program fault too: the task took longer than its period.

The common ones

FaultWhat happenedTypical causePrevention
Array index out of rangeAn index addressed beyond the array boundsAn index from a screen, a counter that ran past, an off-by-one loopClamp or check the index before use
Invalid indirect addressA pointer or an indexed address pointed outside memoryUninitialized pointer, a computed address that overflowedValidate computed addresses; avoid pointers where indexes will do
Division by zero, overflowMath produced a value the type cannot hold, or divided by zeroA flow total divided by a runtime of zero; an integer that overflowedCheck the divisor; use floating point for large values
Missing routine or blockA call to a routine that does not existA routine deleted or renamed; a partial downloadVerify the project before downloading
Type mismatchAn instruction received a type it cannot useA tag data type changed after the logic was writtenVerify after any tag change
Task overlapA periodic task was triggered before its previous execution finishedToo much logic in the task, a loop, or communications loadMeasure the task time; move logic; fix loops
WatchdogA task exceeded its watchdog timeAs task overlap, or an infinite loopSee the watchdog article
Stack or nestingSubroutine calls nested too deep, often recursiveA routine that calls itself through anotherRestructure the calls

Reading the record

  1. 1

    The fault type and code

    Major or minor, with a code that the controller manual maps to a description.

  2. 2

    The location

    The program, routine, and rung or line where the instruction faulted.

  3. 3

    The values

    The index, the address, or the operands at the time; the fault record or the tags at fault time show them.

  4. 4

    The history

    Whether this fault has happened before, from the fault log or the controller event log; a fault that recurs on a schedule has a cause on that schedule.

  5. 5

    The trigger

    What changed: a download, an online edit, a screen entry, a network write, a new device.

Fault handlers

Most platforms provide a fault routine that runs when a major fault occurs, and if it clears the fault the controller continues. That is useful for a fault the program can genuinely recover from, such as a bad index from a screen entry, where the handler logs the fault, resets the offending value, and lets the scan continue rather than dropping every output in the plant. It is dangerous as a blanket: a handler that clears every fault turns a broken program into one that silently skips instructions, and the first sign is a process doing something nobody programmed. The handler should log every fault with its code and location to a tag, clear only the fault codes it was written for, and count; a fault that clears more than a few times an hour is escalated to a controlled stop and an alarm.

Writing logic that does not fault

  • Every index that comes from a calculation, a screen, or a network is clamped to the array bounds before it is used.
  • Every divisor is checked for zero, and the result of a zero check is a documented default, not a skipped calculation.
  • Values written from screens and networks land in staging tags, are validated against limits, and are then copied to the working tags.
  • Integer math that can overflow is done in floating point or checked for range; totals use 32-bit or floating point accumulators with documented rollover.
  • Loops have a bounded iteration count and no path that fails to advance the index.
  • Task periods are set from measured execution times with margin, and the measured time is trended.
  • The project is verified, and a full download is preferred to an online edit for structural changes.

After a fault at a running plant

A major fault drops the outputs, which means the pumps stopped or the valves went to their fail position, and the first job is the process: confirm what state it is in and whether local control or manual operation is holding it. Then the fault record is read and saved before anything is cleared, the cause is found in the logic, and the fix is tested offline where the platform allows. The controller is restarted with the operators aware of what the outputs will do on the first scan, which is the moment a poorly designed program restarts every pump at once.

Frequently asked questions

The controller faulted once a week for months and cleared itself. Is that a problem?
Yes. A fault handler is clearing a recurring program fault, and every occurrence skipped some logic. Read the fault log for the code and location and fix the cause; then make the handler count and alarm.
How do I find which screen entry caused an index fault?
The fault record gives the routine and rung, which names the array and the index tag; the index tag value at fault time, and the audit trail on the screen, name the entry. Then clamp the index and limit the screen field.
Can a communications write cause a program fault?
Yes, when the written value is used as an index, a divisor, or a pointer without validation. Every value that enters the controller from a network is treated as untrusted and validated before use, for safety and for security.
Should I raise the task period or fix the logic when tasks overlap?
Fix the logic if the overlap is new or the task time has grown; raise the period if the task genuinely needs the time and the process can tolerate the slower rate. Either way, measure first and document the decision.

Direct contact

Have a controls question?

Reach Eric Sullivan directly about anything on this site, a controls or automation topic, or one of his personal projects.