×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Noob need help reading rs232 via matlab

Noob need help reading rs232 via matlab

Noob need help reading rs232 via matlab

(OP)
Hi,

Here is what I am trying to do.

On one computer i open matlab and run the program (posted below) to open the serial port and read data.  On the other computer i open hyperterminal and send data.  If the data i receive in matlab is the same as the data i sent then you know the matlab program is working correctly.

So I am trying to read data from the rs232 via matlab, but i am struggling g
reatly.

here is my code:

s = serial('com1');
s.InputBufferSize = 10;
fopen(s);
fid = fopen('C\out.txt', 'w')
a = fread(s,8);
fwrite(fid,char(a));
fclose(s);
fclose(fid);
Results:

fid =

     3

Warning: The specified amount of data was not returned within the Timeout period.

I don't really know what is wrong.

Please if anyone could, I would greatly appreciated.  This is taking me so much time, and I am on the brink of madness.  thank you.

RE: Noob need help reading rs232 via matlab

Are both computers set to the same baud-rate? Maybe some of the other serial properties are different on your computers. Use get(s) to get at list of all properties.

Are you using a nullmodem cable? See http://www.zytrax.com/tech/layer_1/cables/tech_rs232.htm#null_db9 for more info.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources