Chapters

5 Modbus and the Register Contract

protocols
industrial-protocols
modbus

5.1 Start With the Number Behind the Register

Prove What One Industrial Number Means

Picture a heat meter that returns the number 517. The screen should show 51.7 degrees, but only if the team chose the right location, scale, sign, and byte order. A reply is not proof that the value is correct.

Modbus is a small set of request and response rules used by industrial devices. It lets one side read or write bits and groups of 16-bit numbers. A gateway is a bridge that can carry those requests between unlike links. The device manual gives those locations their engineering meaning.

Start with one value the system will trust. Record the manual label, kind of object, number shown to people, number sent on the wire, size, read or write right, scale, unit, and byte order. Read a known physical state and compare it with a trusted check. Test a safe write only where the equipment plan allows it.

Keep transport faults separate from meaning faults. No reply, an error reply, a wrong value, and an unsafe write need different action.

Use Practitioner to build the register and polling record. Use Under the Hood to inspect serial frames, network wrapping, timing, gateways, and security limits.

Imagine a gateway reading “40017” from a heat meter and publishing it as supply temperature. The useful question is not whether Modbus returned bytes. The useful question is whether everyone agrees on the object family, wire address, scaling, byte order, permission, and physical check that prove the number is the right one.

Modbus works best when the register contract is visible. Start with one value a system will trust, then write down how the request, response, conversion, gateway path, and safety boundary preserve its meaning.

5.2 Overview: Modbus Exposes a Register Contract

Modbus is a compact industrial request/response protocol for reading and writing device state. Its stable idea is not a rich device model; it is a client asking a server for coils, discrete inputs, input registers, or holding registers. The engineering meaning comes from the device register map, not from the protocol alone.

That separation is useful and dangerous. It makes Modbus easy to bridge across serial and TCP paths, but it also means a dashboard value is only trustworthy when the object type, address convention, scaling, signedness, byte order, word order, write permission, and polling plan are recorded together.

For example, a heat-meter manual might label a supply temperature as holding register 40017, scale it by 0.1 degrees, and store a 32-bit value across two adjacent 16-bit registers. One client library may expect the human reference number, another may expect zero-based protocol address 16, and a gateway may pass only the function code plus address onward to a serial device. The register contract is the note that keeps those views aligned: it states the documented label, the object family, the address sent on the wire, the conversion rule, and the evidence that a known physical value decodes correctly.

If you only remember one rule, remember this: Modbus does not explain what a value means. The register map and integration record do.

A release decision about the “scada, plc, hmi”–“client” decision needs “requests”, not a slogan. Inspect Figure 5.1 through “SCADA, PLC, HMI” and “Client” to check this claim: Modbus separates the protocol operation from the engineering meaning that a register map supplies.

Modbus fit map separating engineering application, Modbus client, protocol operation, transport mapping, and device register map responsibilities.
Figure 5.1: Modbus separates the protocol operation from the engineering meaning that a register map supplies.

On Figure 5.1, inspect “SCADA, PLC, HMI” before “Client”. The subsequent hand-off from “requests” to “values” explains Modbus separates the protocol operation from the engineering meaning that a register map supplies. Carry that sequence into the “scada, plc, hmi”–“client” decision so “SCADA, PLC, HMI” evidence, “Client” decision, and “values” recheck remain distinguishable.

Coils

Single-bit read/write outputs such as run commands, relay outputs, resets, or binary actuator states.

Discrete inputs

Single-bit read-only inputs such as contact states, alarm bits, limit switches, and status points.

Input registers

Read-only numeric values, commonly used for measurements, meter readings, and device-reported state.

Holding registers

Read/write numeric values, commonly used for setpoints, configuration, control words, and some status maps.

Start the evidence review for the “size and access”–“typical engineering meaning” decision: inspect Figure 5.2. Two labels deserve attention—“Size and access” and “Typical engineering meaning”—because they bound The four object families tell the client how the value can be accessed; the device manual tells the team what the value means.

Modbus register model showing coils, discrete inputs, input registers, and holding registers mapped to function-code families and engineering meanings.
Figure 5.2: The four object families tell the client how the value can be accessed; the device manual tells the team what the value means.

Inspect “Size and access” on Figure 5.2, compare “Typical engineering meaning”, then ask what carries “Function-code family” into “Coils”. Their answers support The four object families tell the client how the value can be accessed; the device manual tells the team what the value means while keeping the “size and access”–“typical engineering meaning” decision connected to observable evidence.

Overview Check

5.3 Practitioner: Build the Integration Record Before Polling

A useful Modbus integration record lets another engineer reproduce the connection without guessing. It identifies the device, each value, the object family, the protocol address expected by the client or gateway, the engineering unit, the scaling rule, byte and word order, read/write permission, and the expected polling behavior.

The record also explains the transport path. Modbus RTU carries requests over a serial segment with device addresses, timing boundaries, and frame error checks. Modbus TCP carries the same application operation through a TCP connection with an application header. Gateways are the place where many mistakes hide because they translate an Ethernet request into a downstream serial request.

In a small pump-skid integration, the record should make each assumption testable before the polling loop is left unattended. Start with three or four points that operators can verify from the local panel: run status, commanded start, measured pressure, and a writable setpoint if writes are allowed. Capture the raw register values, decoded engineering values, function codes used, exception responses if a write is blocked, and the exact gateway route. Only then scale up the poll list, because a fast scan of badly mapped registers produces confident but misleading telemetry.

Use Figure 5.3 with “are only half the integration record” to inspect the next step in the “are only half the integration record”–“1 | the on-wire frame” decision. The relationship between “are only half the integration record” and “1 | The on-wire frame” is what makes Modbus RTU framing becomes integration evidence only when captured bytes, address convention, device-map meaning, and observed response agree reviewable.

Modbus RTU integration record showing address, function code, data, and CRC fields, while separating protocol register addresses from vendor labels and requiring captured request-response evidence.
Figure 5.3: Modbus RTU framing becomes integration evidence only when captured bytes, address convention, device-map meaning, and observed response agree.
  1. Gateway Gus: In a boiler room, Gus carries a request from the gateway to one selected heat meter.

    Gus sends one addressed read request to the meter.

  2. Gateway Gus: The meter sends a sealed group of raw word blocks back to Gus.

    The meter returns a framed reply or a clear error.

  3. Gateway Gus: At a register-map desk, Gus matches the address and object family to one documented row.

    Gus maps the reply to the vendor register.

  4. Gateway Gus: Gus flips two word blocks into the documented order and runs them through a scale wheel.

    He orders the words and applies the stated scale.

  5. Gateway Gus: The converted temperature card travels through one gateway path to the plant dashboard.

    The gateway sends the named value onward.

  6. Gateway Gus: Gus compares the dashboard value with a trusted probe on the same pipe before approval.

    A physical check proves the number means the right thing.

CW-0027 walkthrough: A trustworthy industrial value needs an addressed request, valid reply, correct register map, word order and scale, gateway path, and a physical cross-check.

Follow Figure 5.3 through four named stops: “are only half the integration record”, “1 | The on-wire frame”, “Silent”, and “before”. Their order turns Modbus RTU framing becomes integration evidence only when captured bytes, address convention, device-map meaning, and observed response agree into a reviewable path. In the “are only half the integration record”–“1 | the on-wire frame” decision, use the same stops to locate evidence and assign the recheck.

Record field
Why it matters
Common mistake
Review evidence
Address convention
Device manuals and client libraries may describe the same register differently.
Sending the documented reference number directly when the client expects a protocol address.
A small tested map that shows documented label, object type, client address, and observed value.
Encoding
Multi-register values need scaling, signedness, byte order, and word order.
Blaming the network when the value is present but decoded incorrectly.
Known-good sample values, units, limits, and conversion notes from the device documentation.
Gateway boundary
A TCP client may be talking through a gateway to a serial device behind it.
Confusing gateway IP, transaction tracking, Unit Identifier, and downstream serial address.
Gateway configuration, downstream device list, timeout rules, and error translation behavior.

Use Figure 5.4 with “MODBUS TCP/IP ADU (APPLICATION DATA UNIT)” to inspect the next step in the “modbus tcp/ip adu (application data unit)”–“mbap header (7 bytes)” decision. The relationship between “MODBUS TCP/IP ADU (APPLICATION DATA UNIT)” and “MBAP HEADER (7 BYTES)” is what makes Modbus TCP Frame Structure reviewable.

Modbus TCP Frame Structure: MBAP Header + PDU, MODBUS TCP/IP ADU (APPLICATION DATA UNIT), MBAP HEADER (7 BYTES), PDU, Transaction ID, 2 Bytes, Protocol ID, 2 Bytes, Length
Figure 5.4: Modbus TCP Frame Structure

Map the responsibilities in Figure 5.4: “MODBUS TCP/IP ADU (APPLICATION DATA UNIT)” comes first, “MBAP HEADER (7 BYTES)” follows, and “PDU” resolves at “Transaction ID”. This division makes Modbus TCP Frame Structure inspectable and tells the the “modbus tcp/ip adu (application data unit)”–“mbap header (7 bytes)” decision record what to preserve after release.

Use Figure 5.5 with “port 502” to inspect the next step in the “port 502”–“gateway” decision. The relationship between “port 502” and “Gateway” is what makes Gateway boundaries need explicit mapping records so Ethernet clients do not hide serial timing and addressing assumptions reviewable.

Modbus TCP gateway boundary showing Ethernet client, gateway, Unit Identifier mapping, serial address, and downstream RTU devices.
Figure 5.5: Gateway boundaries need explicit mapping records so Ethernet clients do not hide serial timing and addressing assumptions.

Inspect “port 502” on Figure 5.5, compare “Gateway”, then ask what carries “MBAP Unit ID” into “maps to serial”. Their answers support Gateway boundaries need explicit mapping records so Ethernet clients do not hide serial timing and addressing assumptions while keeping the “port 502”–“gateway” decision connected to observable evidence.

Practitioner Check

5.4 Under the Hood: Separate Protocol Failure from Data Meaning Failure

Good Modbus troubleshooting separates symptoms before changing configuration. A timeout, a serial frame error, an exception response, and a wrong engineering value point to different parts of the system. Treating every symptom as a generic network failure usually adds retries while leaving the real defect in the register map, gateway boundary, or security envelope.

Classic Modbus also lacks built-in user authentication, authorization, and encryption. That does not automatically force replacement, but it does require an explicit security boundary: allowed clients, blocked write paths where possible, controlled remote access, monitoring for unexpected function codes, and a documented plan for secure gateways or protocol alternatives when exposure or risk changes.

A useful triage pattern is to preserve the first failing request and classify it before tuning. No bytes back suggests reachability, serial settings, address, timeout, or gateway routing. A Modbus exception response means the server answered but rejected the operation, so function code, address range, permission, or device mode is the next evidence. A plausible response with an impossible value means decoding work: offset convention, scaling, signed interpretation, endian order, stale point mapping, or a wrong adjacent register. Keeping those buckets separate prevents a security or data-quality issue from being hidden behind more retries.

Start the evidence review for the “timeout, or intermittent failure”–“keep evidence categories separate before changing settings” decision: inspect Figure 5.6. Two labels deserve attention—“timeout, or intermittent failure” and “Keep evidence categories separate before changing settings”—because they bound Troubleshooting is faster when the evidence ladder separates link, address, function, encoding, gateway, and security questions.

Troubleshooting ladder for Modbus moving from link evidence to addressing, function code, data encoding, gateway behavior, and security controls.
Figure 5.6: Troubleshooting is faster when the evidence ladder separates link, address, function, encoding, gateway, and security questions.

Inspect “timeout, or intermittent failure” on Figure 5.6, compare “Keep evidence categories separate before changing settings”, then ask what carries “1. Link path” into “IP reachability”. Their answers support Troubleshooting is faster when the evidence ladder separates link, address, function, encoding, gateway, and security questions while keeping the “timeout, or intermittent failure”–“keep evidence categories separate before changing settings” decision connected to observable evidence.

No response

Check physical path, IP reachability, serial settings, device address, gateway route, timeout, and retry behavior.

Exception response

Compare function code, object type, address, value range, write permission, and device mode against the register map.

Wrong value

Review offset notation, scaling, decimal position, signedness, byte order, word order, and engineering units.

Unexpected write

Review allowed clients, firewall rules, write-code blocking, change logs, remote-access path, and device mode.

The claim that The security boundary should make allowed clients, write paths, monitoring, and remote access explicit before data is exposed upstream needs “Workstation” as a concrete check beside “authorized user”. Inspect Figure 5.7 before continuing the “workstation”–“authorized user” decision, especially “Workstation” beside “authorized user”.

Modbus security boundary showing engineering workstation, controlled access point, firewall, gateway, monitoring, and protected devices inside an OT segment.
Figure 5.7: The security boundary should make allowed clients, write paths, monitoring, and remote access explicit before data is exposed upstream.

Inspect “Workstation” against “authorized user” on Figure 5.7, then test the link between “Jump host” and “session control”. The two comparisons clarify The security boundary should make allowed clients, write paths, monitoring, and remote access explicit before data is exposed upstream. They also keep “Workstation” in the running decision about the “workstation”–“authorized user” decision, tied to labelled evidence.

Under-the-Hood Check

5.5 Summary

Modbus is useful because it is small and predictable, but that simplicity shifts responsibility into engineering records. The protocol defines object families, function operations, and transport mappings. The device register map defines meaning, scaling, write safety, and decoding. RTU, TCP, and gateway paths all need different evidence, and classic Modbus deployments need an explicit security envelope before values are exposed upstream.

5.6 Key Takeaway

Modbus integration succeeds when the register map, address convention, encoding rule, transport path, gateway mapping, troubleshooting evidence, and security boundary are reviewed as one contract.

5.7 See Also

OPC UA Fundamentals

Study how information models and built-in security change industrial integration design.