2013-12-23 434 views
3

是Modbus新手和使用Modbus RTU開發應用程序。我想知道如何找出RTU消息幀分離時間。在Modbus RTU規範中,它提到3.5個字符的時間,但沒有關於如何決定這個間隔的更多數據。和wat是計算分離時間的步驟?計算modbus RTU 3.5字符時間

+1

您必須知道波特率。這給了你一點時間,'1/baud'秒。乘以十來得到一個字符的時間。 –

回答

5

看看的Modbus Serial Line Protocol and Implementation Guide V1.02

13頁在底部,你會發現此言解釋字符間超時(T1.5)和幀間延遲(T3.5)值。

對於19200以上的波特率值是固定的。對於傳輸速率較慢,需要對它們進行計算(摘自SimpleModbusMaster庫的Arduino):

// 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; 
} 
+1

應該注意的是,Modbus RTU使用每個字符11位(8 *數據,奇偶校驗,啓動,停止)而不是10.上述值對於使用10位的非標準實現是正確的,通常通過忽略奇偶校驗位而不是通過添加另一個停止位來補償這一點。對於11位,它們應分別爲'16500000/baud'和'38500000/baud'。 –

1

的Modbus RTU使用11位字符,無論使用奇偶與否。公式應該是:11 * 1000000 /(波特率)一個字符時間,這適用於波特率< = 19200 bps。對於波特率> 19200 bps,使用固定時間,3.5個字符時間爲1750微秒,1.5個字符時間爲750微秒