Modbus over TCP/IP#
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.
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 :
Single bit fields :
discrete inputs : digital inputs, only readable
coils : digital outputs, both readable and writable
16 bits fields :
input registers : analog inputs, only readable
holding registers : analog outputs, both readable and writable
Function codes are defined to cover all possibilities of reading and writing fields.
Modbus specifies that for 16 bits values, the MSB is transmitted first, so it is a Big Endian protocol.
To get the latest specifications, visit the site of the Modbus organisation.
For python, more documentation is available here.