×
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

MATLAB & RS232

MATLAB & RS232

MATLAB & RS232

(OP)
Hi,

I am looking for some exmaples or pointer regarding the following problem. I have a piece of electronics connected to my computers serial port which sends data over RS232 to my computer, an exmaple string is:

                  2D 78 EB FA 80 78 67 0A

There are 8 bytes send, with the 8th byte being the terminator, LF.

I have tried many methods to get these packets into MATLAB, however MATLAB seems to read and store them as ASCII not as HEX as I would like. So I may receive:

                  *???????
Is there a method of converting ASCII to HEX? Can I read in serially in HEX format?

I would also like to monitor these data packets for a 24hr period with the packets arriving every 4-5 seconds. Is there a method/example code etc... where I could do this and save the packet to an element of an array each time one is received?

Thank you for your time, I look forward to your thoughts and comments.

Regards,
Tom

RE: MATLAB & RS232

I believe hexadecimal numbers are always treated as ascii by Matlab. Use the hex2dec or the hex2num function to convert.

The serial port object has some events and callbacks that will help you with the data collection part.
Search the help for BytesAvailableFcn, BytesAvailableFcnCount and BytesAvailableFcnMode.

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