Matlab code to read data from nexys2 board

1 次查看(过去 30 天)
Hi,
I am using matlab to read data from nexys2 board. Actually I am sending the range sensor data from nexys board to matlab through serial communication using the command below.
nexys = serial('COM1', 'BaudRate', 9600, 'Parity', 'odd', 'Terminator', '', 'Timeout', 1);
There are nine bits for representing sensor data. Because the maximum range can be represented using nine bits and the* serial communication I can do only in bytes.*
when I try to concatenating with zeros
The data I am sending is something like this in hexadecimal:
00 0A 00 1A 00 14 (2 BYTES)
But Matlab is unable to receive the data *from board through serial communication. *
Later* I tried to concatenating with ones*. then
The data I am sending is something like this in hexadecimal: FF 0A FF 1A FF 14 (2 BYTES)
*Now Matlab is able to receive this data.
Why the matlab is unable to receive zeros?*
If the data I am sending is more than 1 byte. Then how can I replace the ninth bit of 1(with zero)*bold*
Can anyone suggest something about this?
Thanks in advance
  2 个评论
Walter Roberson
Walter Roberson 2013-5-21
Caution: if you are using odd parity or even parity, then one of your 8 bits will be "stolen" for the parity bits, so you only have 7 usable transmission bits per byte in that case.
Jim
Jim 2013-5-22
编辑:Jim 2013-5-22
Hi walter,
Thanks for your reply.
Can you please explain in detail. you mean I should not use even or odd parity. How can I send the data to Matlab without losing information for parity bit.
And why the matlab is unable to receive information starting with all 0's in first byte?
Can you give me the link for document explaining this?
Thanks

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by