フィルターのクリア

A timeout occurred before the Terminator was reached. first

23 ビュー (過去 30 日間)
samir
samir 2012 年 4 月 2 日
コメント済み: kiarash 2021 年 4 月 29 日
ok this is my code
s=serial('com5');
set(s,'BaudRate',9600,'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none','Terminator','CR');
fopen(s);
while(1)
fprintf(s,'0');
pause(0.5);
data=fscanf(s);
data=str2num(data);
display(data);
if(data<=10)
fprintf(s,'1');
pause(0.5);
fprintf(s,'2');
pause(0.5);
fprintf(s,'3');
pause(0.5);
fprintf(s,'0');
pause(0.5);
data=fscanf(s);
data=str2num(data);
display('first');
i=0;
if(data<=10)
fprintf(s,'2');
pause(0.5);
i=i+1;
end
display('second');
end
end
fprintf(s,''1') fprintf(s,''2') fprintf(s,''3') are just commands sending in one direction so no returned data is excepted
fprintf(s,''0') sends a command to a roboter to use his pingsenzor the roboter returns a value stored in data(by the way the returned data from the roboter is [DEC distance, CR] -dec meaning decimal ,distance - variable,CR - terminator)
if the returned value is <10 then try to avoid the object.When i use a second time fprintf(s,'0') i always get the message
Warning: A timeout occurred before the Terminator was reached. first last
so why does this always appears the second time and how to avoid it.
  1 件のコメント
Hoang Nguyen
Hoang Nguyen 2015 年 9 月 17 日
I had the same your error when arduino uno was interfacing with matlab :(. I don't know how to solve this problem

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

採用された回答

samir
samir 2012 年 4 月 2 日
ok i put an puase (2) before fprintf(s,'0'); and it works now wihtout the error.Don't know why it works now or why it didn't work earlier but at least it works now

その他の回答 (1 件)

Hoang Nguyen
Hoang Nguyen 2015 年 9 月 17 日
hi every body! i used "Encoder Read" block in simulink to read value encoder of my motor. but if my motor operate with hight speed then following error occurred: "Error evaluating registered method 'Outputs' of MATLAB S-Function 'msfun_arduino_encoderread' in 'DaoChieuDongCo/Encoder Read'. The following is the MATLAB call stack (file names and line numbers) that produced this error: ['C:\MATLAB\SupportPackages\R2013b\ArduinoIO\simulink\msfun_arduino_encoderread.m'] [100]
Caused by: Invalid assignment in 'DaoChieuDongCo/Encoder Read': attempt to assign a matrix to a vector" so, how do i solve this error?
  2 件のコメント
Waldri
Waldri 2020 年 8 月 13 日
In my case I change the baud rate in arduino to 500000
kiarash
kiarash 2021 年 4 月 29 日
Hi,
Please check the help of "baudrate". Maximum allowed value I think was 115200.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by