Modbus over TCP/IP#

Quick definition#

Modbus is quite an old protocol, mostly used with PLC. It is openly published and is therefore popular in industrial environments. Modbus packets can be transmitted either on serial lines like RS-485 (we are then talking of Modbus RTU) or over a network (Modbus TCP/IP). This document focuses only on the version with TCP/IP as transport medium.

Description#

Modbus communication’s model is client - server. The server is most likely a PLC with inputs such as temperature sensors and outputs like motor drivers. The client could be a Notebook connected to the same network that might want to see the inputs and control outputs.

Modbus servers contain at least one of the following type of field :

  1. Single bit fields :

    1. discrete inputs : digital inputs, only readable

    2. coils : digital outputs, both readable and writable

  2. 16 bits fields :

    1. input registers : analog inputs, only readable

    2. holding registers : analog outputs, both readable and writable

Function codes are defined to cover all possibilities of reading and writing fields.

MQTT overview,

Modbus function codes, source : https://instrumentationtools.com/modbus-communication-interview-questions-answers/#

Modbus specifies that for 16 bits values, the MSB is transmitted first, so it is a Big Endian protocol.

Ressources#

To get the latest specifications, visit the site of the Modbus organisation.

For python, more documentation is available here.

Protocols Modbus Python