Industrial PLC telemetry gateway and safety interlock controller
Industrial automation and SCADA gateways · Real-time, fault-tolerant plant control
An edge gateway for industrial plants and energy facilities that collects telemetry from PLCs and field sensors and enforces safety interlocks before any actuator changes state.
The challenge
Industrial manufacturing plants and energy facilities depend on continuous telemetry from programmable logic controllers (PLCs) and field transducers. Edge gateways must poll heterogeneous fieldbuses at predictable cycle intervals and enforce strict safety interlocks before permitting any actuator state change.
In harsh electrical environments subject to serial bus noise, network drops, and abrupt power loss, the gateway must reject corrupted or out-of-sequence commands and persist every telemetry sample locally before upstream dispatch.
- Fieldbus protocols
- Native Modbus RTU, Modbus TCP, and OPC UA binary framing
- Cycle determinism
- Constant-memory O(1) polling with zero runtime heap allocation
- Safety interlocks
- State transitions gated by checksum-validated sensor quorum
- Power-loss resilience
- Local non-volatile ring-buffer commit prior to network dispatch
Architecture
Zero-dependency protocol engine
Byte-level parsers and frame serializers for Modbus RTU, Modbus TCP, and the OPC UA binary protocol are implemented entirely in-house, removing external fieldbus library dependencies and unpredictable execution paths.
Constant-memory acquisition loop
All frame buffers and register tables are pre-allocated at gateway startup. The polling loop executes in constant memory without dynamic allocations, preventing garbage-collection or allocator jitter on industrial edge hardware.
Table-driven safety interlock machine
Plant control logic is governed by a strictly typed Mealy finite-state machine—progressing through idle, pre-charge, active run, fault lockout, and safe drain states. Every transition requires a validated multi-sensor quorum and rejects out-of-sequence actuator commands.
Sensors reach the gateway over RS-485, Modbus TCP and OPC UA. Inside it, the protocol engine feeds a constant-memory acquisition loop, signal conditioning and the interlock state machine, which alone sends actuator commands. Readings go to a ring buffer and write-ahead log before network dispatch.
Hardware and protocols
Serial RS-485 and multiplexed TCP I/O
Serial fieldbuses are driven through non-blocking POSIX serial interfaces with hardware direction control and table-driven CRC-16 verification, while fragmented TCP protocol chunks are reassembled across edge-triggered non-blocking sockets.
Memory-mapped non-volatile ring buffer
High-frequency transducer readings are written into a page-aligned circular buffer mapped directly to local non-volatile storage with atomic pointer updates and write-ahead logging, so each reading is committed locally before dispatch, to limit data loss when power fails abruptly.
Fixed-point signal conditioning
Raw analog transducer inputs pass through a fixed-point exponential moving average and a Schmitt-trigger hysteresis filter to suppress electrical transients before reaching the safety interlock evaluator.
Verification
The gateway ships with an in-process software PLC and fieldbus emulator, bound to local UNIX domain sockets and virtual pseudo-terminals.
Automated regression tests inject split TCP frames, single-bit CRC errors, RS-485 bus collisions and simulated thermal runaway, and require the controller to reach its fault lockout state within its cycle tolerance.