フィルターのクリア

Error in Serial communication between a measurement instrument and matlab via RS232

2 ビュー (過去 30 日間)
Nidhi Singh
Nidhi Singh 2015 年 10 月 29 日
コメント済み: Walter Roberson 2015 年 10 月 29 日
Hi I am trying to setup serial communication between my measurement instrument and matlab through RS232. I have setup the following parameters on my measurement instrument through a setup key on the front panel of the instrument:
  • Communication port-RS232
  • Baudrate-9600
  • Parity-none
  • Databits-8
  • The terminator of the instrument as given in the datasheet is LF/CR
I am getting an error ' * Warning: A timeout occurred before the Terminator was reached*'. I have done some basic troubleshooting like
  • putting pause(2); before fscanf(s);,
  • double checking the terminator of my instrument,
  • testing the RS232 cable
but the error keeps on popping everytime. Please let me know how can I resolve it.
Below given is my Matlab code.
s = serial('COM1');
set(s,'BaudRate',9600,'Parity','none','Terminator','CR');
fopen(s);
fprintf(s,'*IDN?');
out = fscanf(s);
fclose(s);
delete(s);
clear s

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 10 月 29 日
You indicated that the device datasheet has LF/CR but you configure CR . It would be more secure to configure for LF or CRLF for the serial port. "LF/CR" sometimes means either, but more often means both.
  2 件のコメント
Nidhi Singh
Nidhi Singh 2015 年 10 月 29 日
Dear Walter
I replaced 'CR' with 'LF/CR' in the code but it's still giving the same error.
Walter Roberson
Walter Roberson 2015 年 10 月 29 日
Time to use a different program like TeraTerm or MS-Kermit to confirm that you can communicate with the device outside of MATLAB.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInstrument Control Toolbox Supported Hardware についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by