Marcio Cunha

Fail-Safe in Automation: How to Design Safe Systems Against Failures

Discover fundamental engineering principles and patterns to design fail-safe automation systems, ensuring any failure leads machinery to a safe state without human risk.

Marcio Cunha12 min
Also available in:EspañolPortuguês
Summary
  • Fail-safe systems prioritize the lowest mechanical and electrical risk state when power interruption or communication loss occurs.
  • Hardware redundancy and sensor diversity prevent a single point of failure from paralyzing or corrupting operational control.
  • Hardwired relay-based emergency stop circuits outperform purely software-based solutions by eliminating latency and operating system crashes.
  • Rigorous exception handling and the watchdog timer prevent infinite loops and freezes in programmable logic controllers.
  • Periodic load testing and extreme failure simulation validate the real resilience of the architecture prior to production deployment.

What Does It Mean to Design for Failure in Automation Systems?

In modern engineering, the fundamental premise is not to prevent failures from happening, but to determine exactly how the system must behave when they occur. In any industrial plant, building automation system, or critical infrastructure, electrical components burn out, cables break, and communication lines suffer interference. The concept of fail-safe operation consists of designing hardware and software architecture so that equipment assumes a predetermined state of lowest risk if it loses power, control signal, or processing capacity.

For a reader without daily experience in the field, think of an elevator: if the main cable snaps, mechanical brakes engage instantly through gravity and springs, preventing free fall. This is a classic fail-safe design. In the universe of digital automation — which encompasses PLCs, or programmable logic controllers, which are robust industrial computers responsible for reading sensors and driving motors — the challenge is translating that same physical safety into electrical circuit logic, network protocols, and control code.

The choice between a fail-safe approach and a fail-secure approach (where the system maintains its locked state, like an electronic door lock that remains locked during a power outage) defines the success of an operation. When dealing with conveyor belts, robotic arms, or high-pressure valves, the primary goal is the preservation of human life and the physical integrity of the environment. If an industrial conveyor stops suddenly, the financial loss is temporary; if it loses control and runs wild, the damage is catastrophic.

The Anatomy of Hardware: Relays, Circuits, and the Dry Contact Philosophy

The foundation of any fail-safe system lies in the physical hardware layer. The most common mistake made by beginners is relying exclusively on software to ensure safety. If a program crashes in an infinite loop, the processor stops updating outputs, and connected actuators can remain stuck in the last sent position — which frequently means running motors and open valves. To prevent this, we use hardware circuits known as physical interlocking circuits and dedicated safety relays.

A relay is an electromechanical switch actuated by electricity. In the context of safety, we employ Normally Open (NO) and Normally Closed (NC) relays interconnected in such a way that the circuit remains energized only if there is a constant flow of current and heartbeat signals coming from the main processor. If a wire is cut, power drops, or a component burns out, the circuit opens immediately due to an internal spring, cutting electrical power to motors and solenoids. In practice, this means safety depends on the absence of energy to turn off danger, rather than the presence of energy to keep it controlled.

Another critical element is the use of redundancy and sensor diversity. Instead of relying on a single pressure sensor to shut down a boiler when a limit is exceeded, a fail-safe design employs two or three sensors of different technologies (for example, a piezoelectric and a mechanical diaphragm sensor). The logic controller only allows continuous operation if there is agreement between the signals. If there is divergence, the system interprets the discrepancy as a potential failure and initiates controlled machine shutdown.

Software Architecture and Protection Against Freezes

On the software side, designing for failures requires extreme discipline and the adoption of deterministic standards. Industrial controllers run continuous cycles called scan cycles, where they read inputs, execute control logic, and update outputs. If the logic contains a programming bug or overly complex calculation that delays the cycle, the system can lose the temporal synchronization required by fast processes.

To combat software freezes, the feature known as a watchdog timer is employed. This is an independent hardware circuit or a low-level operating system routine that monitors whether the main program is running correctly. The software is forced to send an electrical pulse to the watchdog every few milliseconds. If the software freezes due to a bug and stops sending this pulse, the watchdog forcibly restarts the controller or triggers the emergency stop circuit, preventing the machine from continuing to operate unsupervised.

Furthermore, the code must provide explicit error states for each communication channel. If the PLC loses connection with the operation panel via industrial network, such as Modbus or Profinet, the control variables must not keep their old values. The firmware must immediately force a reset of these variables to zero, ensuring no phantom commands are executed in the absence of the operator.

// Conceptual example of watchdog and fail-safe handling in embedded C
#include <stdint.h>

#define WATCHDOG_TIMEOUT_MS 100
uint32_t last_heartbeat = 0;

void trigger_emergency_stop() {
// Turn off all actuators and motors immediately
set_output_pins(0x00);
activate_mechanical_brake();
}

void control_loop_iteration() {
uint32_t current_time = get_system_tick();

// Check if the cycle exceeded the safe time limit
if ((current_time - last_heartbeat) > WATCHDOG_TIMEOUT_MS) {
trigger_emergency_stop();
return;
}

// Read critical safety sensors
if (read_safety_sensor() == SENSOR_TRIPPED) {
trigger_emergency_stop();
return;
}

// Refresh watchdog and proceed with normal operation
refresh_watchdog();
last_heartbeat = current_time;
}

Network Topologies and Fault-Tolerant Industrial Communication

Communication between PLCs, frequency drives, and HMI (Human-Machine Interface) is the nervous system of modern automation. In industrial networks, the loss of a twisted-pair cable or optical fiber cannot result in the total loss of operational control. For this reason, ring network topologies with redundant recovery (such as MRP - Media Redundancy Protocol) are widely adopted in critical environments.

When a data packet is sent from a controller to an actuator, the protocol ensures there is an alternative physical path if the main cable is broken. In practice, the signal travels simultaneously in two directions through the network ring. If one side of the ring suffers a break, the infrastructure reconstructs the route in less than twenty milliseconds, time insufficient to cause mechanical instability in the controlled motors.

Additionally, modern industrial protocols implement Cyclic Redundancy Check (CRC) mechanisms, which are mathematical codes attached to data packets to check if bit corruption occurred due to electromagnetic interference in the factory environment. If the controller detects a corrupted packet, it discards the message immediately and requests retransmission, rather than executing a potentially dangerous command based on noisy data.

Common Errors and Pitfalls in Safety Design

Even experienced engineers can fall into subtle traps when implementing safety logic. The most dangerous error is the assumption that modern electronic components never fail in a short circuit. If an output transistor burns out and remains permanently closed, it will continue sending power to a motor even when software orders a complete shutdown.

Another frequent misconception is excessive reliance on wireless networks for critical emergency stop functions. While industrial Wi-Fi and Bluetooth Low Energy offer high convenience, they are subject to radio frequency interference, shadowing by metal structures, and variable latency. Real safety stop systems always require dedicated and shielded physical cabling, ensuring immunity to external noise.

It is also common to neglect the ergonomics of physical emergency stop buttons. They must be of the mushroom head type, with mechanical retention requiring manual rotation for unlocking, and must cut power directly at the actuator power supply source, bypassing any intermediate logic processor.

Final Considerations for Engineers and Designers

Designing fail-safe systems requires a profound mindset shift: the engineer stops thinking solely about how to make the system work perfectly and begins planning with surgical rigor how it must fail with elegance and safety. The harmonious integration between robust hardware, physical interlocking relays, software with watchdog, and redundant network topologies forms the backbone of any modern industrial infrastructure that prioritizes life and operational continuity.

Ultimately, the maturity of an automation project is measured by the ease and safety with which it handles the unexpected. By investing time in designing redundant protection layers and rigorous failure simulation tests, engineering teams prevent catastrophes, reduce long-term corrective maintenance costs, and deliver truly reliable and resilient technological solutions for the real world.