How to check connection status with arduino?

5 次查看(过去 30 天)
I am creating a graphical user interface of servo motor control. For this, I am using MATLAB support package for Arduino. I need to check the connection status of my Arduino with my PC. Is there any command for checking the connection status?
  3 个评论
Omkar Bhanap
Omkar Bhanap 2018-9-29
No, I don't want to generate any C/Cpp code to run, not trying for any standalone application.
Walter Roberson
Walter Roberson 2018-9-29
It is not a matter of generating C/C++ code for standalone application.
The arduino runs a program. The program it runs can either be C/C++ code that you provide (perhaps having generated it, perhaps having written it yourself, perhaps having found a convenient source code online), or it can be a generic MATLAB-specific program that listens for commands from MATLAB, executes them, and returns the results. "Stand-alone" would be for the case where you wanted the arduino to execute without a MATLAB program communicating with it.
Having C/C++ code devoted to the exact task on hand can give much higher performance, and leaves open the possibility that the arduino could monitor conditions and report back only when needed, and leaves open the possibility of (for example) advancing only to the motor stop, or advancing to a particular location or until a particular input was recognized.
If you use the generic connection from MATLAB, you have to send queries and mostly single motor steps, always checking on the MATLAB side whether you had gone far enough. This is much slower than having the arduino handle things, as the communications between the arduino and MATLAB is not fast. The polling loop is, if I recall correctly, limited to at most 1 Khz by the USB connection, and usually gets much less with 40-ish Hz seeming to be typical.
The reason all of this matters is that the method of checking for connectivity is going to depend upon whether you are running a custom program on the Arduino or if you are running the generic program.
... Or is the real question not about testing to see if communications with the Arduino has been lost, and is instead a question about proving to see which COM port the arduino is living on ?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

标签

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by