Robofun 機器人論壇

 找回密碼
 申請會員
搜索
熱搜: 活動 交友 discuz
查看: 5633|回復: 8
打印 上一主題 下一主題

有關srf02 輸了入了2bytes的資料

[複製鏈接]
跳轉到指定樓層
1#
發表於 2007-9-6 13:07:44 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
請問一下  我利用單晶片 傳輸為9600bps 送01 與80 的資料,之後又送01 與94的資料,可是這樣 我的srf02 並不會動
,不然就是偶爾送出一些資料,請問一下 要如何送資料 srf02才會動,而他送出的結果,要如何去解讀,謝謝
2#
 樓主| 發表於 2007-9-6 13:09:42 | 只看該作者
我使用的是盛群的晶片,我在01和81之間 有加delay,讓資料傳輸值正確
3#
 樓主| 發表於 2007-9-6 13:11:08 | 只看該作者
在送出01與81後,做一個超過67ms的delay 在送後面的資料
4#
發表於 2007-9-6 13:28:46 | 只看該作者

是用RS-232吧?

9600bps傳送1個byte需時1ms,所以第二個byte要在1ms之後才能送。除非有硬體的buffer,但buffer滿了仍有1ms的工作時間。
而您所說的67ms應是指接收器需要反應的最小時間吧。並不是可以傳送的最短時間。

[ 本帖最後由 wallace_tsou 於 2007-9-6 13:34 編輯 ]
5#
 樓主| 發表於 2007-9-6 13:31:55 | 只看該作者
傳出資料 經由hin232 在送出rs232
6#
發表於 2007-9-6 13:38:45 | 只看該作者
可以利用PC的超極終端機來看接收字是否正常。
最好用示波器看看傳輸的信號是否有正確。
7#
 樓主| 發表於 2007-9-6 13:40:17 | 只看該作者
訊號正確,不經由SFR02送出的話, 他輸出的資料 確定是 01 81 與 01 94
8#
發表於 2007-9-8 01:00:44 | 只看該作者
原帖由 sacosaco 於 2007-9-6 13:07 發表
請問一下  我利用單晶片 傳輸為9600bps 送01 與80 的資料,之後又送01 與94的資料,可是這樣 我的srf02 並不會動
,不然就是偶爾送出一些資料,請問一下 要如何送資料 srf02才會動,而他送出的結果,要如何去解 ...


Serial Communication
To use the SRF02 in Serial mode, make sure the Mode pin is connected to 0v Ground.
Serial data is fixed at 9600 baud 1 start, 2 stop and no parity bits. Serial data is a TTL level signal - It is NOT RS232. Do not connect the SRF02 to an RS232 port - you will destroy the module! If you would like to connect the SRF02 to your PC's RS232 port, you must use a MAX232 or similar device. It can also be used (in I2C mode) with the USBI2C module to make a self powered USB ranger, see the examples page for details. Many small controllers such as the OOPic, Stamp BS2p, PicAxe etc. as well as a wide variety of micro-controllers have serial ports. To communicate with the SRF02, you simply need to send two bytes, the address of the SRF02 (factory default is 0) and the command. The default shipped address can be changed by the user to any of 16 addresses 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, or 15, therefore up to 16 sonar's can be used.

基本上,SRF02 的預設值應該是0,
也就是說傳送的資料應該是 00、80,
如果需要馬上取出值的話,建議您使用00、83,

關於兩個命令的時間,基本上完全不用延遲也可以取得資料。
9#
 樓主| 發表於 2007-9-10 10:49:25 | 只看該作者
謝謝,我解決我的問題了,我延遲的原因是因為,如果你一次傳2bytes的資料,在單晶片測出的結果 有錯誤,有delay才能保證資料的正確性
您需要登錄後才可以回帖 登錄 | 申請會員

本版積分規則

小黑屋|手機版|Archiver|機器人論壇 from 2005.07

GMT+8, 2024-4-28 03:06 , Processed in 0.083411 second(s), 8 queries , Apc On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表