Help Reading Continuous Serial Port Data Stream?

  • Follow


I haven't done too much in the past using the serial port functions within Matlab so I'm trying to figure out what I'll need to do to read in my data correctly. Here's what I have.

My packet size is 23 bytes. I've added a image link below with data packet

http://tinypic.com/r/2jcfz2f/7

So my X Gyro value is two bytes (x Gyro H, x Gyro L) and so on for the other values. Here's what I'm doing in Matlab right now and I can read in the data.

BTserial=serial('COM40');
set(BTserial,'BaudRate',115200);
fopen(BTserial);
N=fread(BTserial,'int16');

The thing I'm seeing is I don't know how to account for the start/stop bits and I have no point of reference when I read the data stream. 

I have a windows executable that reads the serial port data and places the x-y-z data into a text file for me. I'm basically trying to recreate that in Matlab but place the data in a 9 column matrix [x_gyro y_gyro z_gyro x_accel y_accel z_accel x_comp y_comp z_comp] as I read it. Thanks for your help
0
Reply Joe 1/2/2011 7:04:04 AM

"Joe K" <jkrysto@gmail.com> wrote in message <ifp814$as6$1@fred.mathworks.com>...
> I haven't done too much in the past using the serial port functions within Matlab so I'm trying to figure out what I'll need to do to read in my data correctly. Here's what I have.
> 
> My packet size is 23 bytes. I've added a image link below with data packet
> 
> http://tinypic.com/r/2jcfz2f/7
> 
> So my X Gyro value is two bytes (x Gyro H, x Gyro L) and so on for the other values. Here's what I'm doing in Matlab right now and I can read in the data.
> 
> BTserial=serial('COM40');
> set(BTserial,'BaudRate',115200);
> fopen(BTserial);
> N=fread(BTserial,'int16');
> 
> The thing I'm seeing is I don't know how to account for the start/stop bits and I have no point of reference when I read the data stream. 
> 
> I have a windows executable that reads the serial port data and places the x-y-z data into a text file for me. I'm basically trying to recreate that in Matlab but place the data in a 9 column matrix [x_gyro y_gyro z_gyro x_accel y_accel z_accel x_comp y_comp z_comp] as I read it. Thanks for your help


Anyone have some insight who is familiar with polling data from a board via Matlabs serial functions have some recommendations on this? I'd just like to be able to make sure I'm taking the correct bytes from the data stream when I place them in my matrix. I haven't done much on this in the past so any help is appreciated. Thanks. 
0
Reply Joe 1/2/2011 4:44:04 PM


On 02/01/11 10:44 AM, Joe K wrote:

> Anyone have some insight who is familiar with polling data from a board
> via Matlabs serial functions have some recommendations on this?

Joe,
   Give us a chance to recover from New Years Day. Your first posting 
was at about 1:30 AM my time, at which time I was useless for anything 
other than playing computer games slowly.
0
Reply Walter 1/2/2011 6:23:57 PM

Walter Roberson <roberson@hushmail.com> wrote in message <2p3Uo.11348$ge2.10343@newsfe07.iad>...
> On 02/01/11 10:44 AM, Joe K wrote:
> 
> > Anyone have some insight who is familiar with polling data from a board
> > via Matlabs serial functions have some recommendations on this?
> 
> Joe,
>    Give us a chance to recover from New Years Day. Your first posting 
> was at about 1:30 AM my time, at which time I was useless for anything 
> other than playing computer games slowly.

Oh no problem, I understand with the new years. Had to do a bit of recovering myself. I had been working on another aspect of my project this morning and posted a bit premature for this, my apologies. Hope the gaming is getting back to normal levels. 
0
Reply Joe 1/2/2011 6:43:05 PM

3 Replies
827 Views

(page loaded in 0.059 seconds)

Similiar Articles:













7/23/2012 5:14:01 PM


Reply: