Modbus data refresh rate depends on several non-obvious parameters. At the design stage, the problem arises of how to evaluate the speed of a future interface line. In this article, we consider the factors affecting the speed of updating data on Modbus RTU, make some standard calculations, and at the end of the article there will be a link to a web calculator of the speed of the Modbus RTU line.Modbus is still the most widely used communications protocol for industrial equipment. A description of the protocol and the reasons for its prevalence can be found in many articles, for example here . It is further understood that you are familiar with the basics of how the protocol works.We will consider Modbus RTU, but the findings will be partially applicable to Modbus TCP.To calculate the speed, we start by considering the physical protocol (1st level of the OSI model). Modbus RTU uses the physical interface RS-485, RS-422 or RS-232 (the latter is practically not used for Modbus). For signal transmission, these interfaces use UART (Universal Asynchronous Receiver-Transmitter). You can read more about UART here .A standard UART package consists of:- start bit () 1 bit
- useful data (data) 7-8 bits
- parity bit (parity_bit) 0-1 bit
- stop bit (stop_bit) 1-2 bit
That is, for every 7-8 bits of useful data, 2-4 auxiliary bits are transmitted. Payload Rate (Vdata) will be lower than the interface speed (Vuart) CalculateVdata can be according to the formula:Vdata=Vuartβdatastart_bit+data+parity_bit+stop_bit
Next, you need to understand how the Modbus master communicates with slaves at the data link layer (OSI model level 2). Due to the peculiarities of the physical interface of the device, connected to the line transmit data sequentially, that is, only one device at a given time can send data. Because of this, the wizard communicates with the slaves cyclically, sequentially reading and writing registers to the slaves. The full cycle of reading registers from the slave will look like this:- delay (minimum 3.5 characters = 28 bits, count below in seconds)
- read request transmission (8 bytes)
- delay in the response of the slave device (at least 28 bits, often tens of milliseconds to form a response message)
- slave transmission of a response message (maximum 256 bytes for Modbus RTU).
Some engineers choose a four-wire version of the interface, hoping for faster transmission (implying a parallel transfer of data to receive and transmit). Obviously this solution does not work. The sequence of sending data will be the same for 2x and 4x - wire lines.We calculate the time spent on a full reading cycle of 125 holding registers (the maximum number for Modbus RTU) with the following line parameters:Frame format: 8N1 ββ(8 data bit, no parity bit, 1 stop bit)Speed ββuart:Vuart= 19200 bit / sPayload transfer rate:Vdata= 15360 bit / sMaster Delay:master_silence = 28 bit / Vuart(this is the minimum allowable delay, usually more)Slave response delay:slave_silence= 0.04 s (the value depends on the slave device)Sending a request with 125 holding registers: 8 byte or 64 bitAnswer with 125 holding registers: 256 byte or 2048 bitFormula for calculating the reading cycle time:Tcycle=silence_master+64bit/Vdata+slave_silence+2048bit/Vdata=0.179s
The sequence for writing registers is almost identical. The package size of the master will be larger, Includes information about writable registers. Confirmation of a successful recording from the slave will be 8 bytes.According to the Modbus specification, 32 slaves can be connected to the RS-485/422 line. Interrogation of slaves is also carried out sequentially, usually in a circle. To understand how fast data will be updated fromN slaves need to multiply Tcycleon the NCall it the full update time. Tfull.A few calculationsTfull(read and write the maximum number of holding registers) for various communication parameters:Frame format: 8N1,Vuart = 19200 bit / s, Number of slaves, N= 16Tfull= 5.727 sFrame format: 8N1,Vuart = 9600 bit / s, Number of slaves, N= 16Tfull= 10.173 sFrame format: 7E1,Vuart = 19200 bit / s, Number of slaves, N= 16Tfull= 6.355 sFrame format: 8N1,Vuart = 19200 bit / s, Number of slaves, N= 2Tfull= 0.716 sAs you can see, the frame format affects the data update time, but not much. The data transfer speed significantly affects, but in our example we transfer the maximum number of registers, in real projects this factor may not be so significant. Most of all, the number of slaves affects the data refresh rate.To simplify the calculations, we made a web application for estimating the time for updating data via Modbus