计算Modbus RTU 3.5字符时间

13

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


1
你必须知道波特率。这给出了一个比特的时间,即“1/波特率”秒。将其乘以十就得到了字符的时间。 - Hans Passant
2个回答

19

请查看《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; 
}

9
需要注意的是,Modbus RTU每个字符使用11位(8个数据位、奇偶校验位、起始位和停止位),而不是10位。上述数值适用于非标准实现,这些实现通常使用10位,即省略奇偶校验位并未补偿添加另一个停止位。对于11位,则分别应为16500000/baud38500000/baud - a cat

2

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接