필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Obtain sets of data using serial communication

조회 수: 1 (최근 30일)
Shawn Chang
Shawn Chang 2012년 10월 19일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi all,
I wish to obtain sets of data which resulted from my robotic car through serial communication. The code that I written to obtain sets of from robotic car is as below. After troubleshooting for many time but the code still didn't worked.
s_port=serial('COM6','BaudRate',115200,'Parity','none'...
,'DataBits',8,'FlowControl','none');
set(s_port,'InputBufferSize',15,'OutputBufferSize',15,'Timeout',1);
fopen(s_port);
%send the time and speed to Robocar
fprintf(s_port,sprintf('%s %d', speed, sim_t));
%for loop to get receive granted signal for robotic car
for i=1:(sim_t*10)
access = fgetl(s_port);
if (access == 'OK')
break;
end
end
%for loop to obtain sets of data
for i=1:(sim_t*10)
data = fgetl(s_port);
pause(0.001);
end
  댓글 수: 3
Shawn Chang
Shawn Chang 2012년 10월 21일
If the code working, the robotic car will run based on the speed and time specified by user in matlab gui. Afterwards, obtain and process the data when matlab detected the string 'OK' sent by robotic car.
Walter Roberson
Walter Roberson 2012년 10월 21일
That is what it is intended to do: what happens instead? For example are any error messages produced?

답변 (1개)

Walter Roberson
Walter Roberson 2012년 10월 19일
Do not use "==" to compare strings: use strcmp() instead.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by