Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 37 ยท Safety and Troubleshooting

PLC Fault Handling, Watchdogs and Safe States

Learn to design PLC fault handling: fault latching, reset logic, step timeouts, sensor plausibility, the scan watchdog, startup states and a fault log, with runnable C stand-ins.

Things break. Sensors fail, cylinders stick, cables come loose, a pump runs dry. A program that only handles the happy path will either stop with no explanation or, worse, keep running into damage. Good PLC software detects faults, puts the machine into a safe state, tells the operator what happened and allows a controlled restart.

(This is about ordinary fault handling. Functions that protect people follow the stricter rules of safety design.)

Real PLC runtimes are not available here, so the lesson uses read-only concepts and C stand-ins that model the logic.

Types of faults

  • Process faults: the process leaves its limits (over-temperature, low pressure).
  • Equipment faults: a motor overload trips, a drive reports an error.
  • Sequence faults: a step waits too long for a sensor (a timeout).
  • Signal faults: a transmitter reads below 4 mA (wire break), two sensors disagree, a value is out of range.
  • Communication faults: a device or network stops answering.
  • Controller faults: a program error, watchdog expiry, battery or memory problem.

The fault latch

A fault should latch: once it occurs, it stays active until the operator acknowledges and resets it, even if the condition disappears. Otherwise an intermittent fault flashes by unnoticed. The standard ladder pattern is a set/reset (SR) latch: set by the fault condition, reset by a reset button that is only effective when the condition is gone.

TEXT
fault := SR(SET1 := overTemp OR wireBreak, RESET := resetButton AND NOT overTemp AND NOT wireBreak);

The machine's run permission depends on NOT fault.

Detecting a timeout

Every waiting step needs a timeout. This model of a sequence step waits for a cylinder sensor; if the sensor does not respond within the limit, the step faults.

C C stand-in: step timeout and latched fault with reset

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Notice that the reset at scan 12 does nothing because the cause is not cleared. Allowing a reset while the cause persists would immediately re-trip or, worse, restart a dangerous condition.

Plausibility checks

A sensor value can be wrong without anything looking broken. Check plausibility:

  • Range: a 4-20 mA signal below 3.6 mA means a broken wire; above 21 mA means a short or a sensor fault.
  • Rate of change: a tank temperature cannot jump 200 degrees in one scan.
  • Cross-check: two level sensors that differ by more than an allowed margin indicate a problem.
  • Command versus feedback: if you commanded the valve open and the limit switch does not confirm within the time, there is a fault.
C C stand-in: range and rate-of-change checks on an analog input

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

When the check fails, the program should not use the bad value for control. Switch to a safe default or stop, and raise an alarm (see alarms).

Watchdogs

A watchdog detects a program that is stuck. Two kinds matter:

  1. Scan-time watchdog (inside the PLC). If one scan takes longer than the set limit (for example 150 ms), the CPU declares a fault and usually stops. This catches infinite loops. Some systems let you handle it in a fault OB or routine, others stop the CPU and set outputs to their fail-safe values.
  2. Application watchdog (your logic). A counter or heartbeat that a partner must update periodically. If your PLC stops seeing the SCADA heartbeat, it can switch to local mode. Conversely, SCADA watches the PLC (see SCADA tags).
C C stand-in: heartbeat watchdog between PLC and a remote system

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Startup and recovery

What happens at power-up matters as much as what happens in a fault:

  • Outputs off at start. Initialize everything to a known safe state, and do not restart a sequence in the middle.
  • Retentive data with care. Retained step numbers and counters can resume a cycle that no longer matches the machine's real state. Many programs reset to "home" and require a homing routine.
  • Detect first scan. Most PLCs offer a first-scan bit for initialization.
  • Stagger starts. Starting many motors at once can trip the supply; add short delays.
  • Soft recovery. After a fault is cleared, resume from a defined step, not blindly.

A fault log

Keep a record of faults: code, text, time of occurrence and clearance, and the step in progress. A small ring buffer in the PLC (or in the SCADA historian) shows what happened before and after a failure. Use fault codes and a lookup table on the HMI so texts are easy to maintain and translate.

Finding the cause of a fault is the subject of troubleshooting methods.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why should a fault latch until reset instead of following the condition?

    A latched fault remains visible and keeps the machine stopped until a person has looked and reset it.
  2. 2. A 4-20 mA transmitter suddenly reads 0 mA. What is the most likely cause?

    Live-zero signals never go below 4 mA in normal operation, so 0 mA signals a broken wire or power loss.
  3. 3. What does the scan-time watchdog of a PLC detect?

    If a scan exceeds its limit, the CPU assumes the program is stuck and goes to a fault or stop state.
  4. 4. What should the reset do when the fault cause is still present?

    Resetting while the cause remains hides the problem or restarts a dangerous state.

Summary

  • Design for faults: detect, latch, report, reach a safe state, then allow a controlled reset.
  • Add timeouts to every waiting step and plausibility checks to every important signal.
  • Use the scan watchdog and application heartbeats to detect stuck programs and lost links.
  • Define startup behavior, keep a fault log, and use fault codes.
  • The C programs are stand-ins modelling the logic.

Next: PLC Troubleshooting Methods