Modbus Communication Precautions

Source: Internet
Author: User

Many students in the Modbus communication, need to continuously read a number of field equipment data, although also wrote the Modbus polling program, but sometimes can not communicate normally. Sometimes, although communication is guaranteed, all field devices have a long polling cycle. This article describes the importance of the time-out setting from the Mbus_ctrl time-out parameter setting.
A: Modbus communication protocol is a single master multi-Slave communication protocol, if you need to read multiple live Modbus slave device data, many plc does not support the Modbus communication function block automatic sequencing, need to write their own Modbus polling program to achieve, Only one modbus read-write function block can be activated at polling time.
As an example of a common master read slave register, the master makes a request that requires 8 bytes, and the slave returns a response of 5 2*n bytes. where n is the number of registers.
If the communication rate is 9600, according to the usual Modbus rtu,8 data bits, a stop bit, and even parity, the time required for each transmission of 1 bytes of data is:
(8 1 1)/9600=1.04ms/byte
Therefore, the time period at which the master sends a response to the slave to return data is:
(8 5 2*n) *1.04 T1 T2, where n is the number of registers,T1 response time for the slave(if it is a plc, the scanning time of the PLC),T2 is a communication allowance, generally 20~50ms。
If you readTendata, the slave response time is 50ms, the entire period is:
(8 5 2*10) *1.04 50=134.32ms。
Therefore, the time-out must be greater than 134.32ms and can be set to more than 150ms.
If the time-out is too short, the response cannot be fully returned and the communication will be error.
If the timeout setting is too long, according to the above example, there are altogether 10 slave stations, each slave reads 10 characters of data, and the timeout time is set to 1s. If there are 1 slave stations that fail, the entire polling cycle is: 9*134.32=2208.88 Ms.
Similarly, if the time-out is set to 150ms, the entire polling cycle is: 9*134.32=1358.88 Ms.
As a result, it can be seencorrect time-out settingCan Shortenentire polling cycle, incorrect settings will cause communication errors or the entire communication cycle to be too long

Modbus Communication Precautions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.