
Overview
In the S7-1200 Modbus RTU communication network, when multiple slave stations are involved, polling must read and write data from each station individually. This article will explore the factors that affect the overall polling time and propose corresponding optimization strategies and troubleshooting methods.

Key Factors Affecting Polling Time
- Baud Rate Setting: The higher the baud rate, the faster the data transmission speed, thereby reducing the polling time.
- Communication Data Volume: The smaller the communication data volume per station, the faster the instruction execution, and the polling time is correspondingly shortened.
- Number of Stations: The fewer the stations, the less data needs to be processed, and the polling time is shorter.
- Communication Distance: The shorter the communication distance, the higher the baud rate that can be set, which is beneficial for reducing the polling time.
- Connection Time of Each Station: The shorter the connection time, the shorter the overall polling time.
Optimization of connection time at each site
In Modbus RTU communication, the following parameters are closely related to "connection time at each site":
- Slave response time (RESPTO): Refers to the response time of the slave to the master's request.
- Retry count (RETRIES): Refers to the number of times a connection is attempted again after no response is received during the initial connection.
- Master timing parameter (Blocked_Proc_Timeout): Used to control the waiting time before the master executes the next function block or polls the next site.
Setting parameters for "connection time at each site"
1. Signal interference, hardware quality-induced slave dropouts, and temporary closure of sites due to engineering reasons will increase the "connection time at each site", greatly extending the polling time of the communication system;
2. Parameters related to "connection time at each site" in Modbus RTU communication:
- Slave response time RESP_TO;
- Retry count RETRIES;
- Master timing parameter Blocked_Proc_Timeout.
Retry count RETRIES
1. Setting method of the RETRIES parameter
- The RETRIES parameter can be set in the background data block of the function block MB_COMM_LOAD
- The number of retries before the master station returns a no-response error code 0x80C8 (default: 2 times)

2. Meaning of the RETRIES parameter
- The RETRIES parameter indicates the number of times to retry a connection after an initial connection fails to respond. Taking the default of 2 times as an example, the actual number of connection attempts is 3;
- After changing the parameter, the REQ pin of the MB_COMM_LOAD function block needs to be re-enabled, otherwise the parameter change will not take effect.
Master timing Blocked_Proc_Timeout
1. Setting method of the Blocked_Proc_Timeout parameter
- If neither Done nor Error is set to 1, a fixed time should be provided to set the bit after the time has elapsed, so as to execute the next function block or poll the next station.
- The MB_Master background data block provides the master timing parameters (range from 0S to 5.5S)

2. The difference between the slave response time parameter and the master timing parameter
- The slave response time parameter RESP_TO is specific to the slave response time, while the master timing parameter Blocked_Proc_Timeout is specific to the master's timing;
- Master timing can prevent a single MB_Master instruction from monopolizing/locking access to the port
Common issues with Modbus latency
1. How to reduce the impact of extended polling cycle time caused by a slave station dropping out?
- The S7-1200 can adjust both the slave response time parameter and the retry count parameter simultaneously, to reduce the increased polling cycle time caused by Modbus slave station dropouts/temporary closures;
- The slave response time RESP_TO can be appropriately reduced based on the actual working conditions of the project. Since this time cannot be estimated, it is recommended to conduct multiple tests to confirm that each slave station can connect normally and stably, and then set this time as small as possible.
- Taking setting 500ms as an example: Set RETRIES to 0. That is, the master will only attempt to connect once for each slave station, with a total time consumption of 500ms.
2. How to handle the situation where MB_MASTER reports error 8200 (port is busy processing transmit requests)?
- In this case, DONE/ERROR is not set, which conflicts with subsequent MB_MASTER;
- Ensure that the next MBMASTER time is greater than the time set by the Blocked Proc Timeout (default time is 3S)
Conclusion
By optimizing key factors such as baud rate settings, communication data volume, number of stations, communication distance, and connection time of each station, the efficiency of the Modbus RTU communication system can be significantly improved. At the same time, reasonably setting the slave station response time, retry count, and master station timing parameters can effectively handle communication failures and ensure stable operation of the system. This is of great significance for improving the performance and reliability of industrial automation systems.
Leave a Reply