Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: problem using fscanf to continuously read serial data
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
dpb

Posts: 8,181
Registered: 6/7/07
problem using fscanf to continuously read serial data
Posted: Aug 21, 2014 4:57 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I am using Matlab and programming an Arduino that communicates back and
forth with Matlab by sending serial data via USB back and forth. Basic
idea is:
...
I am successful in sending bytes from Matlab to Arduino, BUT I cannot
get the "K" to consistently be read by Matlab. It seems that fscanf is
either too slow or randomly gets or doesn't get the value, can't figure
out why. It will scan for ages and find nothing, even though Arduino is
sending "K" every second!! Have been at this for weeks with extremely
limited success, so any help would be appreciated!!!
Simplified versions of my code below:

Matlab:

s = serial('/dev/tty.usbmodem411','BaudRate',19200)
fopen(s)
...
Serial.println("K"); <------------- IMPORTANT
...


I've never used or even looked at doc's for the Arduino, but my guess
would be that you don't have the communication protocols set identically
between it and the Matlab serial port object.

The baud rate, parity and data length are the obvious, but other things
to look for and check are the control protocol (hardware/software),
terminator character, synchronous/asynchronous, etc., etc., etc., ...

There's a pretty good discussion of the basics in the Matlab doc's; work
your way thru it item-by-item until you know how both ends are
configured and are sure they're on the same wavelength in all regards.

--




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.