필터 지우기
필터 지우기

problem with serial communication

조회 수: 1 (최근 30일)
Jim
Jim 2013년 5월 24일
Hi,
I am using the following command for serial communication
nexys = serial('COM1', 'BaudRate', 9600, 'Parity', 'odd', 'Terminator', '', 'Timeout', 1);
s = 's';
fwrite(nexys,s,'uchar');
scan_s1 = fread(nexys,1,'uint16');
t = 't';
fwrite(nexys,t,'uchar');
scan_s2 = fread(nexys,1,'uint16');
The data that is storing in scan_s1, scan_s2 is like:2048, 55040
I do not understand which format is this data
Actually I am sending 2 bytes of data from nexys2 board tp matlab
Can anybody help me in understanding this
Thanks Jim
  댓글 수: 3
Jim
Jim 2013년 5월 24일
Hi walter, Thanks for your reply
Yes, it represent 16 bit binary value
But I do not understand why it is showing the values like 2048,3042
It is in decimal like
Regards Jim
Walter Roberson
Walter Roberson 2013년 5월 24일
2048 and 3042 and 55040 are quite valid 16 bit unsigned values.
If you want to see the bits composing the numbers, then use dec2bin(scan_s1, 16)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Acquisition Toolbox Supported Hardware에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by