Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

MATLAB & RS232

Status
Not open for further replies.

tommyears

Industrial
Apr 18, 2006
3
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
 
Replies continue below

Recommended for you

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor