11

我是 Modbus 新手,正在使用 Modbus RTU 开发应用程序。我想知道如何找出 RTU 消息帧分离时间。在 Modbus RTU 规范中,它提到了 3.5 个字符的时间,但没有更多关于我如何决定这个间隔的数据。计算分离时间的步骤是什么?

4

2 回答 2

17

查看Modbus 串行线路协议和实施指南 V1.02的第 13 页

在底部,您将找到解释字符间超时 (t1.5) 和帧间延迟 (t3.5) 值的注释。

对于超过 19200 的波特率值是固定的。对于较慢的波特率,需要计算它们(从 Arduino 的 SimpleModbusMaster 库中提取):

// Modbus states that a baud rate higher than 19200 must use a fixed 750 us 
// for inter character time out and 1.75 ms for a frame delay.
// For baud rates below 19200 the timeing is more critical and has to be calculated.
// E.g. 9600 baud in a 10 bit packet is 960 characters per second
// In milliseconds this will be 960characters per 1000ms. So for 1 character
// 1000ms/960characters is 1.04167ms per character and finaly modbus states an
// intercharacter must be 1.5T or 1.5 times longer than a normal character and thus
// 1.5T = 1.04167ms * 1.5 = 1.5625ms. A frame delay is 3.5T.    

if (baud > 19200)
{
    T1_5 = 750; 
    T3_5 = 1750; 
}
else 
{
    T1_5 = 15000000/baud; 
    T3_5 = 35000000/baud; 
}
于 2014-01-19T22:40:59.667 回答
3

Modbus RTU 使用 11 位字符,无论是否使用奇偶校验。公式应为:11 * 1000000 / ( baud_rate ) 一个字符时间,这适用于波特率 <= 19200 bps。对于波特率 > 19200 bps,使用固定时间,即 1750 微秒用于 3.5 字符时间,750 微秒用于 1.5 字符时间

于 2017-07-04T10:57:21.797 回答