Modbus TCP: Registers, Coils, and Holding Registers
📡 Module 2: Industrial Protocols
Modbus TCP: Registers, Coils, and Holding Registers
Modbus is the most widely deployed industrial protocol in the energy sector. Originally created by Modicon in 1979 for PLCs, the TCP/IP variant (Modbus TCP) runs on standard Ethernet and uses port 502 by default.
Data Model
Modbus organizes data into four address spaces:
| Type | Address Range | Access | Size | Description |
|---|---|---|---|---|
| Coils | 00001-09999 | Read/Write | 1 bit | Digital outputs (breaker commands, relay contacts) |
| Discrete Inputs | 10001-19999 | Read-only | 1 bit | Digital inputs (status indicators, alarm contacts) |
| Input Registers | 30001-39999 | Read-only | 16-bit | Analog inputs (sensor readings, metered values) |
| Holding Registers | 40001-49999 | Read/Write | 16-bit | Configuration and setpoint values |
Function Codes
Common Modbus function codes you will use:
- FC 01 Read Coils: Read 1-2000 contiguous coils
- FC 02 Read Discrete Inputs: Read 1-2000 contiguous inputs
- FC 03 Read Holding Registers: Read 1-125 contiguous registers
- FC 04 Read Input Registers: Read 1-125 contiguous registers
- FC 05 Write Single Coil: Write one coil (0x0000 = OFF, 0xFF00 = ON)
- FC 06 Write Single Register: Write one 16-bit holding register
- FC 16 Write Multiple Registers: Write 1-123 contiguous holding registers
Modbus TCP Frame
A Modbus TCP frame consists of:
[Transaction ID: 2 bytes] [Protocol ID: 2 bytes (0x0000)] [Length: 2 bytes] [Unit ID: 1 byte] [Function Code: 1 byte] [Data: N bytes]There is no CRC in Modbus TCP (TCP provides its own error checking). The Transaction ID lets you match requests to responses when pipelining.
Real-World Register Maps
A typical battery inverter (e.g., SMA Sunny Central Storage) might expose:
Holding Register 40001: Active Power Setpoint (INT16, W, scale factor 10)
Holding Register 40002: Reactive Power Setpoint (INT16, VAr, scale factor 10)
Input Register 30001: AC Power Output (INT16, W, scale factor 10)
Input Register 30003: DC Bus Voltage (UINT16, V, scale factor 10)
Input Register 30005: SOC (UINT16, %, scale factor 100)
Input Register 30007: Battery Temperature (INT16, °C, scale factor 10)A power meter (e.g., Schneider PM5350) might expose:
Input Register 30001-30002: Voltage Phase A-N (FLOAT32, V)
Input Register 30003-30004: Voltage Phase B-N (FLOAT32, V)
Input Register 30005-30006: Voltage Phase C-N (FLOAT32, V)
Input Register 30007-30008: Current Phase A (FLOAT32, A)
Input Register 30013-30014: Total Active Power (FLOAT32, W)
Input Register 30019-30020: Total Reactive Power (FLOAT32, VAr)
Input Register 30025-30026: Power Factor (FLOAT32)
Input Register 30071-30072: Frequency (FLOAT32, Hz)Data Types and Byte Order
Modbus registers are 16 bits. For 32-bit values (FLOAT32, INT32), two consecutive registers are used. The byte order can be:
- Big-endian (AB CD): Most common, SunSpec standard
- Little-endian (CD AB): Some older devices
- Mid-endian (BA DC or DC BA): Rare but exists
Always check the device documentation for byte order. Misinterpreting byte order gives nonsensical readings.
SunSpec Alliance Standard
The SunSpec standard defines standardized Modbus register maps for solar inverters, meters, and batteries. A SunSpec-compliant device starts at register 40000 with the "SunS" identifier (0x53756E53) followed by model blocks. This eliminates the need for per-manufacturer register map integration.
Log in to track your progress and earn certifications.