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

最佳答案

看看Modbus Serial Line Protocol and Implementation Guide 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;
}

关于communication - 计算Modbus RTU 3.5个字符的时间,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20740012/

10-09 21:59