The Modbus protocol is a communication protocol that is based on a master-slave or client / server architecture. It was established in 1979 by Gould - Modicon for communication with its programmable logic controllers into life. In the industry, Modbus has become a de facto standard because it is an open protocol. Since 2007, the version Modbus TCP is part of the standard IEC 61158.
- 3.1 Protocol structure
- 4.1 Protocol structure
Using Modbus can be connected (eg, measurement and control systems ), a master (eg a PC) and several slaves. There are two versions: one for the serial interface (EIA -232 and EIA- 485 ) and one for Ethernet.
When transmitting data in three different modes are distinguished:
- Modbus ASCII
- Modbus RTU
- Modbus TCP
Each node must have a unique address. The address 0 is reserved for broadcast. Each participant is allowed to send messages via the bus. In general, however, this is initiated by the master and an addressed slave responds.
In Modbus ASCII not binary sequence, but ASCII code is transmitted. Thus, it is read directly by humans, however, the data throughput is compared to RTU lower.
In ASCII mode, messages start with a preceding colon, the end of the message is represented by the string carriage return - line feed marks (CRLF ).
The first two bytes contain two ASCII characters that represent the recipient's address. The command to execute is coded on the next two bytes. About n characters, the data follow. About the whole message ( without start and end markers ) a LRC is performed to check for errors whose parity data word is placed in the final two characters.
Modbus RTU (RTU: Remote Terminal Unit, remote terminal unit ) transmits the data in binary form. This provides a good throughput, but the data can not be directly evaluated by the people, but must first be converted to a readable format.
In RTU mode, the transmission start is marked by a hiatus of at least three characters in length. The length of the silent period thus depends on the transmission speed. The address field is composed of eight bits that represent the receiver address. The slave sends back when it replies to the master this same address, so that the master can assign the answer. The function field is composed of 8 bits. If the slave has received the master's request correctly, so he responds with the same function code. If an error occurred, so he changed the function code by setting the most significant bit of the function field to 1. The data field contains notices which registers the slave to read, and from what address to start this. The slave employeth the read data ( eg measured values ) in order to send them to the master. If an error occurs, an error code is transferred there. The field for the checksum, which is determined by means of CRC is 16 bits. The entire message frame must be transmitted in a continuous stream. Passage between two characters, a transmit interrupt, which is longer than 1.5 characters, the telegram is to be regarded as incomplete and should be discarded by the receiver.
Modbus / TCP
MODBUS / TCP is very similar to RTU, although TCP / IP packets are used to transmit the data. The TCP port 502 is reserved for Modbus / TCP. Modbus / TCP is established since 2007 in the IEC 61158 and IEC 61784-2 as referenced in CPF 15/1.
The fact that there is no control bytes are to be calculated, the implementation of a driver for the TCP interface is much simpler than for the serial interface.