Serial Port Timing Issues
Show older comments
I am trying to establish serial communications between an Arduino and a WIN10 machine. I am using the USB / FTDI arduino connection.
The arduino code is simple-it listens on the serial port, and when ANYthing arrives it simply sends out a phrase. I tested this on a windows serial terminal and it works fine--entering any character returns the phrase. I use the LED on the board to show that data arrived. (see attached zip)
Now, coding the Matlab side, it works sporadically. In the attached code and I show a work around--issue the character to the arduino twice, and wait 2 seconds in between sends. The LED lights both times. Waiting a smaller amout of time generally (but not aways) results in a "Not returned within Timeout" condiiton.
I am expecting that this is some type of timing problem-the MATLAB session is not "listening" in time. I did not see any timing settings in the serialport command. And trying to code a wait on NumBytesAvailable hung matlab as well.
Any ideas appreciated
Fritz
Answers (1)
Fritz Sonnichsen
on 4 Jul 2022
0 votes
Categories
Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!