NI產品與技術 討論區

取消
顯示結果 
搜尋替代 
您的意思是: 

rs232

0 積分
1 條訊息(共 9 條)
9,181 檢視
你好

關於你的問題,既然你的學長已經使用C成功控制了,建議研究程式碼的每一個步驟,再將之轉換為labview code,會比較節省時間
0x0d的指令為
CR,也就是Carriage Return,是RS232控制中常見的一個結束字元
RS232程式的部份可以參考labview中內建的範例程式 Basic serial write and read
程式中front panel的string to write部份是以codes display顯示,可以看到在每個指令之後會加入\r\n兩個結束字元
其中\r就是
Carriage Return,所以你的指令格式應該為*idn?\n
可以試試看用這個範例程式跟機械手臂溝通

此外關於一次送多個指令的部份,如果上述的方法可行,可以在read之後再加入write與read,寫入另外一組指令
只是要注意在指令與指令之間可能要加一些delay,以免機器反應不及

希望對你有幫助嘍


0 積分
2 條訊息(共 9 條)
9,147 檢視
請問這個VI (Advanced Serial Read and Write.VI)是在哪裡? 我怎麼搜尋不到.
 
謝謝回覆!
0 積分
3 條訊息(共 9 條)
8,912 檢視

To: kchuang11

在Example Finder搜尋serial的第一個範例就是了

0 積分
4 條訊息(共 9 條)
8,899 檢視
謝謝回覆!
另外一個問題想請問:
我用VB透過RS232和MCU通訊, 傳送和接收都沒有問題
 
但是用LabView出現下列錯誤訊息:
Error -1073807339 occurred at VISA Read in basic_serial_write_and_read.vi
Possible reason(s):
VISA:  (Hex 0xBFFF0015) Timeout expired before operation completed.
使用Advanced Serial Write and Read.vi也是一樣的結果
 
請問要如何解決這個問題?
 
謝謝回覆!
0 積分
5 條訊息(共 9 條)
8,888 檢視

To: kchuang11

1.你可以先在MAX底下或使用超級終端機先測試com port是否沒問題

2.如果你的rs232是使用USB轉RS-232的話,你必須先確認實際的com port是多少

0 積分
6 條訊息(共 9 條)
8,877 檢視

Sorry!沒有說明清楚.

RS232的參數設定, 應該沒有問題, 我用VB測試OK.

 用LabView測試, 送出字串後接收, 也可以接收, 但是接收不正確

Ex: Send String: "This is a test"  --->  Receive String: "This is a te", 並且出現上列錯誤

<註> : 1. 我是用LV 8.0, 範例是LV 6.1, 有沒有關係?

            2. bytes to read , 正常應該設多少? 我設20.

            3. 我是用PC, 只有一個COM Port

 

謝謝回覆!

0 積分
7 條訊息(共 9 條)
8,854 檢視

For bytes to read...

  • If you set it to i.e. 20 bytes, the VISA Read will expects 20 bytes of data before a successful read occurs. Else, it returns timeout error
  • If you do not set it, the VISA Read reads just whatever is available at the port. In this case, you might get incomplete data.

Therefore, as of how many bytes to set for the Byte Count, it really depending on what you are expecting from the port at that very moment.

Sometimes, it could be continous reading of data bytes until a certain condition i.e. CR etc is met.

Hope this helps in one way or another 😉

Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
8 條訊息(共 9 條)
8,761 檢視
謝謝您的回覆.
0 積分
9 條訊息(共 9 條)
8,723 檢視