Industrial Communication: HART, Modbus, Fieldbus & OPC UA
How instruments, controllers and computers talk. Learn the automation pyramid, HART, Modbus RTU/TCP (function codes, registers, CRC), PROFIBUS/PROFINET, Foundation Fieldbus, EtherNet/IP, EtherCAT, IO-Link, wireless (WirelessHART, ISA100), OPC UA and MQTT for IIoT, determinism, topologies and cybersecurity — with Python that builds a real Modbus frame and decodes a float.
Modern plants have thousands of devices exchanging data: transmitters to controllers, controllers to drives, controllers to HMIs and historians, and the plant to the enterprise and cloud. Different layers need different networks: deterministic milliseconds at the machine, rich information at the top.
Knowing the common protocols lets you commission devices, troubleshoot 'no communication' problems and design secure architectures.
An analogy
Industrial networks are like a city's transport: fast dedicated tram lines (EtherCAT, PROFINET IRT) for time-critical traffic, local buses (Modbus, HART) for simple journeys, and highways (Ethernet, OPC UA, MQTT) carrying large volumes of information to headquarters.
The automation pyramid (ISA-95)
Level 0: sensors and actuators. Level 1: controllers (PLC, DCS). Level 2: supervision (SCADA, HMI, historians). Level 3: manufacturing operations (MES, batch, quality). Level 4: business (ERP). Lower levels need determinism and robustness; upper levels need bandwidth, context and security.
Device-level protocols
Common field protocols:
- HART — digital on top of 4–20 mA; configuration, diagnostics, extra variables
- Modbus RTU (RS-485) / TCP — simple master/slave registers; universal but no data types or security
- PROFIBUS DP/PA — Siemens-world fieldbus; PA for process instruments
- Foundation Fieldbus H1 — digital instruments with function blocks in the field
- IO-Link — point-to-point smart sensor link to a master
- WirelessHART / ISA100.11a — mesh networks for monitoring points
Industrial Ethernet
PROFINET (RT and IRT for motion), EtherNet/IP (CIP, Rockwell), EtherCAT (on-the-fly frame processing, µs cycles for motion), Modbus TCP, and time-sensitive networking (TSN) bring Ethernet to the controller level. Topologies: star, line, ring with redundancy protocols (MRP, DLR, PRP/HSR) for fault tolerance.
OPC UA, MQTT and cybersecurity
OPC UA offers platform-independent, secure (certificates, encryption), information-model-based communication between controllers, SCADA, MES and cloud; companion specifications define standard models (e.g. PA-DIM for process devices). MQTT (often with Sparkplug B) publishes data efficiently to brokers for IIoT. IEC 62443 defines zones and conduits, security levels and secure development: segment networks with firewalls/DMZs, remove default passwords, patch, and monitor — attacks like Stuxnet and TRITON targeted exactly these systems.
Formulas
- Modbus RTU frame:
[address][function][data…][CRC-lo][CRC-hi] - Modbus TCP frame:
[MBAP header 7 bytes][function][data] (port 502, no CRC) - Character time (RTU):
11 bits / baud; inter-frame gap ≥ 3.5 characters - Polling time:
t ≈ Σ (request + response bits) / baud + turnaround - HART:
±0.5 mA FSK on 4–20 mA, 1200 bit/s, ~2–3 updates/s
Worked example: Modbus addressing
Given: Holding register '40108' in documentation
Find: Protocol address.
- 4xxxx = holding registers; 40001 → address 0
Answer: Address 107 (0x006B) — the classic off-by-one
Worked example: Polling time
Given: 19 200 baud, request 8 bytes, response 25 bytes, 11 bits/char
Find: Transfer time.
- 33 × 11 / 19 200
Answer: ≈ 18.9 ms (+ gaps and turnaround ≈ 25 ms per device)
Worked example: HART
Given: Transmitter at 12 mA with HART
Find: Does HART disturb the analog value?
- FSK is ±0.5 mA with zero average
Answer: No — the DC average stays 12 mA
Building a Modbus RTU request and decoding a float
# Build a Modbus RTU "read holding registers" request and its CRC-16
def crc16(data):
crc = 0xFFFF
for b in data:
crc ^= b
for _ in range(8):
crc = (crc >> 1) ^ 0xA001 if crc & 1 else crc >> 1
return crc
req = bytes([0x11, 0x03, 0x00, 0x6B, 0x00, 0x03]) # slave 17, fn 3, addr 107, 3 regs
c = crc16(req)
frame = req + bytes([c & 0xFF, c >> 8]) # CRC sent low byte first
print("request:", frame.hex(" ").upper())
# Decode a 32-bit float spread over two registers (big-endian word order)
import struct
regs = [0x42F6, 0xE979]
value = struct.unpack(">f", struct.pack(">HH", *regs))[0]
print(f"registers {regs[0]:04X} {regs[1]:04X} -> {value:.3f}")
# request: 11 03 00 6B 00 03 76 87
# registers 42F6 E979 -> 123.456The frame matches the example in the official Modbus specification (read 3 holding registers from address 107 of slave 17, CRC 0x8776). Floats span two 16-bit registers, and vendors disagree on word order — the most common Modbus integration bug ('byte/word swap').
Common mistakes
- Wrong: Assuming register numbering and word order. — Right: Check the device map; test with a known value.
- Wrong: RS-485 without termination/biasing. — Right: 120 Ω at both ends, bias resistors, daisy-chain topology.
- Wrong: Flat networks from office to PLC. — Right: Zones and conduits per IEC 62443, firewalls, DMZ.
Applications
- Energy metering: Modbus power meters to BMS/SCADA.
- Process plants: HART asset management, FF/PROFIBUS PA instruments.
- Machine building: EtherCAT/PROFINET drives and I/O.
- IIoT: OPC UA/MQTT to cloud analytics.
Key takeaways
- ISA-95 levels need different networks.
- HART, Modbus, PROFIBUS/FF at the device level.
- Industrial Ethernet for control, OPC UA/MQTT for IT/IIoT.
- Security by design (IEC 62443).
Going further
- TSN: Deterministic standard Ethernet for converged networks.
- APL: Ethernet-APL: 2-wire Ethernet to hazardous-area instruments.
- NAMUR Open Architecture: Second channel from field devices to IT for monitoring.