How to check connection status with arduino?
4 次查看(过去 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 个评论
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 Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!