关于MODBUS的帧间隔时间经验值?
按照MODBUS的协议上说明:帧间隔应该是3.5个字符静止时间。 这个是理论值,请问各位朋友实际使用的经验值是多少?一般来讲使用MODBUS发送帧间隔要远远大于理论值。我使用的是串口半双工。
我使用的是 8个字符静止时间。 正在学着用。顶一下。 参照freemodbus-v1.4.0上的时间为:
/* If baudrate > 19200 then we should use the fixed timer values
* t35 = 1750us. Otherwise t35 must be 3.5 times the character time.
*/
if( ulBaudRate > 19200 )
{
usTimerT35_50us = 35; /* 1800us. */
}
else
{
/* The timer reload value for a character is given by:
*
* ChTimeValue = Ticks_per_1s / ( Baudrate / 11 )
* = 11 * Ticks_per_1s / Baudrate
* = 220000 / Baudrate
* The reload for t3.5 is 1.5 times this value and similary
* for t3.5.
*/
usTimerT35_50us = ( 7UL * 220000UL ) / ( 2UL * ulBaudRate );
} 静止时间和波特率有关
例如:波特率=9600,则:一位停止位+1位校验位+8位数据位+1位起始位=11位
也就是说1秒钟传输9600位,则1秒钟传输9600/11=872字节
显然3.5字符静止时间
1000ms x
-------- = ----- ===> x=4ms
872 3.5
即:静止时间=4ms
可定义一个1ms的定时中断,当接收到一个字符后,开启定时器,并且清除计时值,当中断中“读数值”累计>=4时,表示已经接收到一帧完整的MODBUS数据。 波特率再高点儿1ms就不行了 mark{:biggrin:} 太感谢 ba wang mao了,终于明白了,这个3.5个字符时间 是怎么得来的。。。{:tongue:} 这样算对吗?改天测试一下试试 原来是这样算出来的啊 记号,以后慢慢理解! 学习了,{:victory:}
页:
[1]