How to check connection status with arduino?

7 views (last 30 days)
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 Comments
Omkar Bhanap
Omkar Bhanap on 29 Sep 2018
No, I don't want to generate any C/Cpp code to run, not trying for any standalone application.
Walter Roberson
Walter Roberson on 29 Sep 2018
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 ?

Sign in to comment.

Answers (0)

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!