필터 지우기
필터 지우기

Unstable streaming from external device

조회 수: 1 (최근 30일)
Nicolò Francesco Bernardi
Nicolò Francesco Bernardi 2011년 3월 8일
I have to receive a continuous stream of information from a device connected to the serial port. The device continuously transmits one byte at a frequency of 200 Hz. I can succesfully connect to the device, with
s = serial('COM6');
set(s,'BaudRate',115200,'DataBits',8,'StopBits',1)
fopen(s);
and also I get the stream of data, with
data(i) = fread(s,1,'uint8');
My problem is that during the acquisition process I often loss pieces of information, in an erratic and unpredictable way. Thus, the streaming appears so far neither stable nor reliable. What could be the problem? Maybe something with memory/buffer, or else that the computer occasionally starts some other operation and looses the timing with the serial port...or something similar; in fact, it improves a little with a faster computer and it gets worse if I load the routine with other operations (e.g., real-time plotting of the data during the streaming).
How could I fix this problem? Is there any other explanation? The slowest machine I'm using it's an Intel Core Duo CPU T7500 @ 2.20 Ghz, 2.12 GHz and 3 GB of RAM, with Windows XP. Matlab version is 2008b. However, it seems to me that 200Hz transmission rate should be well below the limits of any actual computer, so the problem should be something else. Thank you very much

답변 (2개)

Walter Roberson
Walter Roberson 2011년 3월 8일
You are only using 2000 bits per second of bandwidth, but you are configured for 115200 bits per second. The higher the rate you configure for, the more problems you will have with electromagnetic noise and poor-quality cables and flow control. If you switch down to 2400 or 4800 bits per second, you should be fine with those factors in all but the noisiest environments. 9600 is the practical dividing line, usually working but not always. Above 9600 it is advised to use hardware flow control.

Vieniava
Vieniava 2011년 3월 8일

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by