Skip to content

5 Modbus.Net.Modbus(E)

OpenClaw edited this page May 25, 2026 · 3 revisions
classDiagram
    class ModbusMachine~TKey,TUnitKey~ {
        +AddressFormater: AddressFormaterModbus
        +AddressCombiner: AddressCombinerContinus
        +ModbusMachine(id, alias, type, connectionString, addresses, ...)
    }
    class ModbusUtility {
        +Endian: Endian
        +GetDatasAsync(startAddress, count, originalCount)
        +SetDatasAsync(startAddress, contents, originalCount)
        -wrapper: ModbusProtocol
    }
    class ModbusProtocol {
        <<abstract>>
        +ProtocolLinker: IProtocolLinker
        +ConnectAsync() Task~bool~
    }
    class ModbusTcpProtocol
    class ModbusUdpProtocol
    class ModbusRtuProtocol
    class ModbusAsciiProtocol
    class ModbusRtuInTcpProtocol
    class ModbusAsciiInTcpProtocol
    class ModbusRtuInUdpProtocol
    class ModbusAsciiInUdpProtocol
    class ModbusController
    class ModbusTcpController
    class ModbusRtuController

    BaseMachine <|-- ModbusMachine
    BaseUtility <|-- ModbusUtility
    ModbusMachine --> ModbusUtility
    ModbusUtility --> ModbusProtocol
    ModbusProtocol <|-- ModbusTcpProtocol
    ModbusProtocol <|-- ModbusUdpProtocol
    ModbusProtocol <|-- ModbusRtuProtocol
    ModbusProtocol <|-- ModbusAsciiProtocol
    ModbusProtocol <|-- ModbusRtuInTcpProtocol
    ModbusProtocol <|-- ModbusAsciiInTcpProtocol
    ModbusProtocol <|-- ModbusRtuInUdpProtocol
    ModbusProtocol <|-- ModbusAsciiInUdpProtocol
    ModbusController <|-- ModbusTcpController
    ModbusController <|-- ModbusRtuController
Loading

Basic Concept

Modbus in the serial port communication protocol defined by Modicon in 1979.

The Address of Modbus

Modbus has four types of address: Coil(Output Coil), Discrete Input Variable(Input Coil), Input Register(Input Variable), and Holding Register(Storage Variable).

Modbus has two types of address space: standard space and extended space.

Following tables show the range of two spaces.

Type Standard Space Extended Space
Coil 00001-09999 000001-065536
Discrete Input Variable 10001-19999 100001-165536
Input Register 30001-39999 300001-365536
Holding Register 40001-49999 400001-465536

Modbus.Net supported two namespaces at the same time and support extended space as default, you need to check the range of the space from specifications by device.

Modbus.Net uses different address description method, following table shows the difference between them.

Standard Modbus Modbus.Net Address
00001 0X 1
00002 0X 2
09999 0X 9999
065536 0X 65536
10001 1X 1
30001 3X 1
40001 4X 1

In other way, Modbus.Net can also describe bit position.

Standard Modbus Modbus.Net Address
30001 13 3X 1.12
40133 12 4X 133.11

Address Encoding

Area in Modbus.Net.Modbus are written as: "0X"(Coil), "1X"(Discrete Input), "3X"(Input Register), "4X"(Holding Register).

Don't forget to add a space between area and address.

If you want to use sub address, add dot "." between address and subaddress.

4X 1.12

Sub Address

Byte length of 0X and 1X is 0.125, every time add 1 address, it will add 1 bit.

You could only read data in "1X".

Sub address of 0X and 1X are always 0. There are no sub address system here.

Byte length of 3X and 4X is 2, every time add 1 address, it will add 2 bytes.

The range of sub address is from 0 to 15.

Attention: There is a change from standard Modbus to Modbus.Net.Modbus.
Sub address is always one smaller than standard Modbus.

Standard Modbus

1 0 1 1 1 0 0 0 1 0 0 0 0 1 1 0
16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

Modbus.Net.Modbus

1 0 1 1 1 0 0 0 1 0 0 0 0 1 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Home

中文

English

Clone this wiki locally