Chapters

6 Actuator Safety: Protection and Fail-Safe Design

actuators
safety

6.1 Start With the Decision

This section: Start With the Decision — A jammed vent can heat its driver, the circuit that supplies power to its motor, while the screen still says closing.

A jammed vent can heat its driver, the circuit that supplies power to its motor, while the screen still says closing. Sensing means checking what the vent actually does. A safe stop must remove the drive on a jam or fault, even if sensing or code fails.

6.2 Route Overview

This section: Route Overview — This is part 1 of 2.

This is part 1 of 2. Continue with Actuator Safety: Watchdogs and Interlocks.

Hands-on lab · 55 min · Cisco Packet Tracer

Test a gateway actuator fail-safe boundary

I have defined safe defaults; now test what remains controllable when the gateway path disappears.

Open the lab

6.3 Part Objectives

This section: Part Objectives

  • Choose flyback, limits, thermal protection, and safe state.
  • Separate high-voltage work from low-voltage control.

6.4 Start With the Story

This section: Start With the Story — Picture a motor closing a greenhouse vent when its shaft jams halfway.

Design the Stop Before the First Motion

Picture a motor closing a greenhouse vent when its shaft jams halfway. The screen may still show “closing” while the driver heats and the plants lose airflow. The safe design begins with what must happen when motion, sensing, software, or power fails.

An actuator is a device that changes the physical world. Firmware is stored device software. Name the moving part, people and equipment within reach, safe resting state, energy source, hardware limit, manual stop, position evidence, and owner of recovery. Put the highest-consequence stop outside the ordinary software path.

Jam the motion, remove position feedback, freeze the firmware, lose communication, interrupt power, and restart. Check that energy is limited or removed, the mechanism reaches or reports a safe state, repeated commands do not create new motion, and the operator can tell a stopped system from a completed action.

This test does not certify machinery or replace local safety law. The deeper sections show driver protection, stored energy, current and heat limits, isolation, watchdogs, emergency stops, and fail-safe review for the full output path.

Start with the uncomfortable version of the demo: the valve sticks open, the motor jams, the relay welds, the firmware freezes, or power disappears while a mechanism is moving. Actuator safety is the plan for that moment, not an afterthought after the circuit works once.

Every output path needs a safe default, a protected driver, and a way to stop or detect unsafe action. The stronger the physical consequence, the more the design must rely on hardware limits and evidence, not just good intentions in code.

In 60 Seconds

Actuator safety involves giving inductive current a rated decay path, preventing overcurrent damage (fuses and current limiters), and ensuring fail-safe behavior when software hangs or power is lost. A diode across a DC relay or solenoid coil is one option; reversible motors and AC coils need protection matched to their driver and switching mode. Watchdog timers, proper isolation, and fail-safe defaults are essential for any IoT system controlling physical actuators.

Key Concepts
  • Inductive current-decay path: A rated path absorbs stored magnetic energy when an inductive load is switched off. A diode can clamp a single-polarity DC relay or solenoid coil; reversible motors use their H-bridge recirculation paths, and AC coils need AC-rated suppression.
  • Current Limiting Resistor: A series resistor protecting LEDs, transistor bases, and low-current loads from excessive current; calculated as R = (Vsupply - Vdrop) / Imax; omitting this for LEDs results in immediate burnout
  • Motor Driver Thermal Management: Heat dissipated in motor driver ICs equals P = I^2 x Rdson (MOSFET) or P = Vce x Ic (transistor); above rated junction temperature, drivers enter thermal shutdown; add heatsinks, thermal pads, or forced airflow for continuous high-current operation
  • Watchdog Timer: A hardware timer reset periodically by firmware; if firmware hangs and fails to reset the watchdog, it triggers an MCU reset; essential for actuator control systems where firmware lockup could leave motors running or solenoids energized indefinitely
  • Emergency Stop Circuit: A hardware circuit (not software) that can immediately de-energize all actuators; typically a normally-closed relay in the power supply path, opened by pressing a large red E-stop button; a legal requirement in many industrial applications
  • Galvanic Isolation: Electrically separating the low-voltage control circuit from high-voltage actuator circuits using optocouplers, transformers, or optical SSRs; prevents mains voltage from reaching the microcontroller through any failure mode
  • Snubber Circuit: An RC network placed across relay or switch contacts to absorb switching transients; prevents contact arcing that degrades contact surfaces and generates RF interference; typically 100 ohm + 100 nF in series across the contact
  • Rate Limiting / Soft Start: Firmware control limiting how fast actuators are commanded to change state; prevents mechanical shock, reduces current spikes, and extends actuator life; implemented as ramp functions for motor speed and position commands

Learning Objectives

This section: Learning Objectives

  • Select a rated current-decay path for each inductive load
  • Design overcurrent protection circuits with appropriate fuse and current limiter selection
  • Configure watchdog timers for safety-critical applications
  • Apply fail-safe defaults to actuator systems using appropriate relay configurations
  • Diagnose common actuator pitfalls that damage components and select corrective measures

Just like you would not plug a toaster into a power strip rated for phone chargers, actuators need proper protection to work safely. Motors and relays can create dangerous voltage spikes when turned off (like a water hammer when you slam a tap shut), and without simple protective components like diodes and fuses, these spikes can destroy your electronics in an instant.

Chapter Roadmap
  • Start With the Story
  • In 60 Seconds
  • Key Concepts
  • For Beginners: Actuator Safety
  • Actuator Safety Considerations
  • Key Safety Mechanisms
  • Flyback Diode Protection
  • Putting Numbers to It
  • Common Pitfall: Ignoring Back-EMF and Flyback Voltage
  • Checkpoint: Flyback Protection
  • Phoebe’s Field Notes: Why The Clamp Barely Moves At 80 mA
  • Watchdog Timer for Safety
  • Concept Check: Watchdog Timers
  • Checkpoint: Watchdog Timing
  • High-Voltage Safety
  • Knowledge Check: Smart Home Safety Design
  • When to Consult Licensed Electrician
  • Design Scenario: Smart Thermostat Fail-Safe Behavior
  • Checkpoint: Fail-Safe Architecture
  • Common Pitfalls
  • Pitfall: Driving Actuators Directly from Microcontroller Pins
  • Pitfall: Inadequate Heat Sink Design for Motor Drivers

6.5 Actuator Safety Considerations

This section: Actuator Safety Considerations — This list is the safety inventory.

Key Safety Mechanisms
  1. Overcurrent Protection: Use fuses or current limiters
  2. Inductive current-decay paths: Use a diode across a single-polarity DC coil, H-bridge recirculation for reversible motors, and AC-rated suppression for AC coils
  3. Thermal Management: Monitor temperature, use heatsinks
  4. Emergency Stop: Implement hardware/software e-stop mechanisms
  5. Fail-Safe Defaults: Actuators should default to safe state on power loss
  6. Isolation: Use optocouplers for high-voltage actuators
  7. Watchdog Timers: Reset system if actuator control hangs

This list is the safety inventory. The first detailed mechanism is the one every relay, solenoid, and motor driver must answer: where does the stored magnetic energy go when the switch opens?

6.6 Flyback Diode Protection

This section: Flyback Diode Protection — The photographs below make diode (rectifier / protection) a physical comparison: look for changes in package, exposed interfaces, mounting, scale, and service access before treating the forms as interchangeable.

The photographs below make diode (rectifier / protection) a physical comparison: look for changes in package, exposed interfaces, mounting, scale, and service access before treating the forms as interchangeable.

Small glass diode with red and black bands and a metal lead at each end, showing the axial package used for circuit protection.
This real example (Diode-closeup) shows a physical form of diode (rectifier / protection). Use the visible package, interfaces, scale, mounting, and surrounding context as evidence; a catalogue label alone does not establish deployment fit. Photo: John Maushammer; The original uploader was Morcheeba at English Wikipedia.; CC BY-SA 2.5
Several small axial diodes and two larger three-lead rectifier packages arranged side by side to compare physical forms.
This real example (Schottky) shows a physical form of diode (rectifier / protection). Use the visible package, interfaces, scale, mounting, and surrounding context as evidence; a catalogue label alone does not establish deployment fit. Photo: Steffen Maisch; Public domain
Cross-section of a diode: a metal lead passes through a cut-away black rectangular body, exposing its internal layers.
This real example (Silicon diode cross section) shows a physical form of diode (rectifier / protection). Use the visible package, interfaces, scale, mounting, and surrounding context as evidence; a catalogue label alone does not establish deployment fit. Photo: TubeTimeUS; CC BY-SA 4.0

Read across the forms as engineering evidence. They share a capability name, but packaging and installation change the electrical, mechanical, environmental, and maintenance constraints.

When you switch off an inductive load (motor, relay, solenoid), the collapsing magnetic field generates a high voltage spike that can destroy transistors and microcontrollers.

6.6.1 Why It Happens

Inductors resist changes in current. The voltage spike follows:

V = -L x (di/dt)

When you suddenly cut current (di/dt is very large), voltage can spike to 100V+ from a 12V supply!

A relay coil with L=100L = 100 mH carrying 80mA switches off in 1 μs. The induced voltage is V=−LdIdt=−0.1×0.080.000001=−8000V = -L \frac{dI}{dt} = -0.1 \times \frac{0.08}{0.000001} = -8000 V (negative indicates reverse polarity). Without a flyback diode, this punches through the transistor’s 60V rating instantly. The stored energy E=12LI2=12×0.1×0.082=0.32E = \frac{1}{2}LI^2 = \frac{1}{2} \times 0.1 \times 0.08^2 = 0.32 mJ must dissipate somewhere. A 1N4148 diode clamps voltage to ~0.7V, dissipating the energy safely over ~10 ms as heat: Pavg=E/t=0.32/0.01=32P_{avg} = E/t = 0.32/0.01 = 32 mW.

Try it yourself:

6.6.2 The Fix

ConnectionComponentSafety role
GPIO to transistor/MOSFET gate/baseDriver stageLets a tiny GPIO signal control a larger coil current
Supply through relay coil to driverRelay or solenoid coilStores magnetic energy while energized
Reverse-biased across the coilFlyback diodeClamps the voltage spike when the coil is switched off
Driver source/emitter to groundCommon groundCompletes the current path and gives signals a reference

DC coil diode specs:

  • Voltage rating above the supply voltage
  • Current rating at least equal to coil current
  • Select recovery and forward-voltage ratings for the DC coil and driver; a diode clamp can slow release

6.6.3 Example Protection Circuits

LoadExample current-decay path
DC relay coil (5V, 50mA)1N4148
Reversible DC motor (12V, 1A)H-bridge recirculation path rated for the motor current
DC solenoid coil (24V, 2A)1N5408 + TVS

Before choosing a part number, inspect Figure 6.1 to connect a DC coil’s ratings to its physical two-terminal clamp. That diode is not a universal motor or AC-coil solution: use the driver’s recirculation path for reversible motors and AC-rated suppression for AC coils.

A diode with two wires extending from opposite ends, designed for reverse-bias installation to protect actuators from voltage spikes.
Figure 6.1: A diode like the ones listed in the table above -- wired in reverse bias directly across the relay, solenoid, or motor coil, ready to clamp the voltage spike the instant the driver switches off. Photo: oomlout, CC BY-SA 2.0

In Figure 6.1, identify the axial leads and the marked cathode end, then map them to a single-polarity DC coil in the protection circuit. When that driver opens, stored magnetic energy drives current through this local loop instead of forcing a destructive voltage across the transistor or GPIO.

The mistake: Omitting a rated current-decay path for an inductive load, leading to voltage spikes that can destroy transistors or microcontrollers.

Symptoms:

  • Random microcontroller resets
  • Brown-out resets during motor switching
  • Transistor driver fails after days/weeks of operation
  • Scope shows large negative voltage spikes when load switches off

The fix: Give every inductive load a rated current-decay path. A diode across a DC relay or solenoid coil is one option; reversible motors and AC coils need protection matched to their driver and switching mode. Add protection during initial prototyping, not as an afterthought.

Motor Max, Actuation and safe-control domain expertCheckpoint: Flyback Protection

You now know:

  • The spike comes from V = -L x (di/dt), so faster current interruption makes the voltage larger.
  • The worked relay example stores 0.32 mJ and can calculate an 8000 V ideal spike from 100 mH, 80mA, and 1 us.
  • The protection choice is physical: give every inductive load a rated decay path before the first live driver test. Use a diode only where the driver and load polarity allow it.

The mathematical gist. For the same diode at fixed temperature, V2−V1=nVTln⁡(I2/I1)V_2-V_1=nV_T\ln(I_2/I_1). Using the labelled 0.650 V at 10.0 mA reference, n=1n=1, and VT=25.85V_T=25.85 mV, this chapter’s 80 mA case adds 53.8 mV and predicts 0.704 V. That is 8.3% above the reference voltage, or 7.6% of the final clamp; the logarithm, not a fixed ideal constant, explains “about 0.7 V.”

Math Bridge · guided foundationsWhy does eight times the current add only about 54 mV?Let Max unpack the logarithm behind the chapter's 0.7 V flyback clamp.

Once the driver is protected electrically, the next failure is liveness. The controller must not keep an actuator energized just because firmware stopped making progress.

6.7 Watchdog Timer for Safety

This section: Watchdog Timer for Safety — Read the example from watchdog configuration to periodic reset, actuator command, and forced restart.

Read the example from watchdog configuration to periodic reset, actuator command, and forced restart. The reset is useful only when startup code immediately establishes the defined safe output state; a watchdog complements local interlocks and current protection rather than replacing them.

If your control software hangs, actuators could be left in dangerous states. A watchdog timer automatically resets the system.

#include <esp_task_wdt.h>

void setup() {
  Serial.begin(115200);

  // Configure watchdog timer
  esp_task_wdt_config_t cfg = { .timeout_ms = 3000, .idle_core_mask = 0, .trigger_panic = true };
  esp_err_t wdt_result = esp_task_wdt_init(&cfg);  // ESP-IDF 5.x; setup runs after the scheduler starts
  if (wdt_result == ESP_ERR_INVALID_STATE) {
    wdt_result = esp_task_wdt_reconfigure(&cfg);  // Already initialized
  }
  if (wdt_result != ESP_OK) {
    Serial.printf("WDT configuration failed: %s\n", esp_err_to_name(wdt_result));
    return;
  }
  wdt_result = esp_task_wdt_add(NULL);
  if (wdt_result != ESP_OK) {
    Serial.printf("WDT task subscription failed: %s\n", esp_err_to_name(wdt_result));
    return;
  }

  pinMode(RELAY_PIN, OUTPUT);
}

void loop() {
  // Reset watchdog timer (must be called every <3 seconds)
  esp_task_wdt_reset();

  // Control actuators
  controlActuators();

  delay(1000);
}

void controlActuators() {
  // If this function hangs, watchdog will reset the system
  digitalWrite(RELAY_PIN, HIGH);
  delay(500);
  digitalWrite(RELAY_PIN, LOW);
}
Concept Check: Watchdog Timers
Motor Max, Actuation and safe-control domain expertCheckpoint: Watchdog Timing

You now know:

  • A watchdog is a hardware deadline, not a patient software monitor.
  • If a normal loop is 80 ms, a 100 ms watchdog can still be too tight when one iteration takes 150 ms.
  • Slow logging, networking, and storage work should be decoupled so the critical control loop can feed the watchdog before the actuator hazard time expires.

Software recovery still cannot make high voltage safe by itself. The next section shifts from firmware liveness to isolation, ratings, wiring, and code compliance.

6.8 High-Voltage Safety

This section: High-Voltage Safety

Knowledge Check: Smart Home Safety Design

Real-World Scenario:

You’re designing a smart home automation system for a client’s house. The system needs to control a 1500W electric space heater (120V AC, 12.5A) using an ESP32-based controller.

Critical Safety Trade-Offs:

Electrical Isolation: The most critical safety concern is complete galvanic isolation between the low-voltage control circuit (3.3V ESP32) and high-voltage AC load (120V/240V).

Without proper isolation:

  • AC voltage can backfeed into the ESP32, destroying it and potentially energizing the metal enclosure
  • User touching exposed contacts while relay is energized = electric shock (potentially fatal)
  • Improper wire gauge for 12.5A continuous load = overheating leading to fire hazard

Safety Specification Stack:

  1. Relay selection for this worked heater case: A 1.5× planning margin on 12.5 A gives 18.75 A, suggesting a 20 A contact rating; confirm the relay’s rating for the actual load, switching duty, voltage, and applicable installation requirements.
  2. Isolation: Optocoupler isolation between ESP32 and relay coil (2500V isolation typical)
  3. Wiring: Use 12 AWG wire minimum for 12.5A continuous (20A capacity at 75C)
  4. Enclosure: All AC connections must be inside insulated, grounded metal enclosure
  5. Protection: Install 15A fuse or circuit breaker on AC hot wire before relay
  6. Fail-Safe: If ESP32 crashes, relay defaults to OFF (heater disabled)
  7. Compliance: Follow NEC (National Electrical Code) or IEC standards for AC wiring

Always consult a licensed electrician for:

  • Any permanent AC wiring (120V/240V) in walls or buildings
  • Loads >500W or >5A continuous current
  • Outdoor installations or wet locations
  • Commercial, medical, or industrial applications
  • Whenever local electrical codes require permit/inspection
  • If you’re unsure about any aspect of AC safety

DIY acceptable (with proper knowledge):

  • Plug-in relay modules with UL-listed wall adapters
  • Low-voltage DC loads (<50V, <5A)
  • Prototyping and testing with proper isolation

6.9 Design Scenario: Smart Thermostat Fail-Safe Behavior

This section: Design Scenario: Smart Thermostat Fail-Safe Behavior — Consider a connected thermostat that controls a heating relay, runs from a low-voltage control supply, and has a small backup battery for short interruptions.

Consider a connected thermostat that controls a heating relay, runs from a low-voltage control supply, and has a small backup battery for short interruptions. A firmware bug, weak battery, loose terminal, or failed power supply can still leave the thermostat unable to command the heating system. The safety issue is not the brand of controller; it is the architecture: one smart device has become the only path between a cold building and a working furnace.

What can go wrong:

If the controller loses power, the display goes dark, the network connection disappears, and cloud notifications stop. If the relay coil is normally open, the relay opens when the thermostat is dead. That is usually safe for an electric heater because “off” prevents overheating, but it can be unsafe for a freeze-protection load where a minimum temperature must be maintained.

Why the damage can be severe — a fail-safe design failure:

The thermostat is the sole controller for the HVAC system. When it loses power:

System ComponentExpected BehaviorActual Behavior
Thermostat displayShow temperatureDead — blank screen
Wi-Fi connectionReport status to appDead — no alerts sent
Heating relayDefault to safe stateStayed OFF (relay not energized)
User notificationPush alert to phoneNone — device was offline
Manual overrideUser presses buttonNon-functional — no power

The fundamental problem is that “safe” depends on the hazard. A normally open heating relay makes loss of control equal to furnace OFF. In summer, that prevents overheating. In a freeze-protection application, it can be the wrong safe state because the building needs enough heat to protect pipes and occupants.

What good fail-safe design would have done:

  1. Battery health monitoring with early warning: Alert locally and remotely while there is still enough energy to communicate, not only after complete failure.

  2. Independent low-temperature fallback: A simple mechanical or independent electronic thermostat can be wired so heating starts at a low protective setpoint even if the smart controller is offline.

  3. Last-gasp communication: Before the battery dies, use remaining power to send one final local or network alert: “Battery critical — heating control may be disabled.”

  4. Relay selection: For heating-critical installations in cold climates, use a latching relay that maintains its last state without power. If the thermostat was calling for heat when it died, the furnace continues running until manual intervention. Trade-off: risk of overheating vs. risk of freezing.

Outcome: The design review changes from “does the app control heat?” to “what protects the building if the app, controller, supply, or network is gone?”. That answer often requires an independent fallback, not just better firmware.

Key design lesson for IoT actuator systems: Never make a smart controller the single point of failure for a safety-critical system. Always provide a mechanical or independent electronic fallback that maintains minimum safe conditions when software, power, or connectivity fails.

This section:

Motor Max, Actuation and safe-control domain expertCheckpoint: Fail-Safe Architecture

You now know:

  • The safe state depends on the hazard: heater OFF can prevent overheating, while a freeze-protection load may need independent low-temperature fallback.
  • For the 1500W, 120V, 12.5A heater example, the relay, wiring, fuse, enclosure, and 2500V isolation are part of the safety case.
  • A controller, cloud link, or app must never be the only path to a safe physical state.

This section:

6.10 Common Pitfalls

This section: Common Pitfalls

Quick Check: Safe State Depends on the Hazard
Pitfall: Driving Actuators Directly from Microcontroller Pins

The mistake: Connecting motors, relays, or solenoids directly to GPIO pins without driver circuits, expecting the microcontroller to provide sufficient current.

Why it happens: Beginners see simple wiring diagrams that omit driver circuits, or assume that if a small LED works directly, larger actuators will too.

The fix: Always use appropriate driver circuits between microcontrollers and actuators. GPIO pins typically provide only 10-40mA; most motors need 100mA-2A. Use motor drivers (L298N, DRV8833), transistors (for DC loads), or relay modules (for AC loads).

Pitfall: Inadequate Heat Sink Design for Motor Drivers
  1. Motor Max points to a motor driver without a heat sink under a large red cross; in the same panel, a time arrow leads to a hot stopped driver and Max fits cooling.

    Wrong: A short test proves the driver needs no cooling. Heat can build until it shuts down.

Misconception buster: Using motor driver ICs (L298N, DRV8825, TMC2209) without heat sinks or adequate thermal management, then wondering why the driver shuts down after 10-15 minutes of operation.

The Mistake: Using motor driver ICs (L298N, DRV8825, TMC2209) without heat sinks or adequate thermal management, then wondering why the driver shuts down after 10-15 minutes of operation.

Why It Happens: Driver boards work fine during short bench tests. The thermal protection kicks in only after sustained operation when the junction temperature exceeds 150C.

The Fix: Always calculate driver power dissipation:

P_loss = V_drop x I_motor x duty_cycle

For L298N at 2A: P = 2V x 2A = 4W

Mount adequate heat sinks (thermal resistance < 10C/W for high-current applications). Use modern MOSFET drivers (DRV8833, TB6612) with lower resistance for less heat.

6.11 Continue to the Next Part

This section: Continue to the Next Part — Carry this evidence into Actuator Safety: Watchdogs and Interlocks, which begins with Watchdog Timeout Sizing.

Carry this evidence into Actuator Safety: Watchdogs and Interlocks, which begins with Watchdog Timeout Sizing.

Find help

3 reviewed answers.

Where should I start in a module?

Open the module page from the sidebar to see its chapters in order. Use the module map to return to a topic you need.

Modules and paths

Reviewed

What can I try when a project does not work?

Check the symptom, then work through the diagnostic steps. Keep the error message and the smallest example that reproduces it.

When you are stuck

Reviewed

How do interactive examples work?

Use the interactive guide to check how examples and simulations work before changing your project.

Interactive examples guide

Reviewed