Problem with serial port communication

2 Ansichten (letzte 30 Tage)
Swarnava Pramanik
Swarnava Pramanik am 15 Jun. 2016
Hi,
I'm interfacing ALtera MAX10 fpga development kit with Matlab and trying to acquire data continuously. I can send command to the fpga board through Matlab regarding how many samples of data I want to capture (Also I'm increasing the buffer size according to the number of samples to be captured). Till 30000 samples I am getting the data correctly. Whenever I'm increasing the sample count to 50000, Matlab is throwing an error that the buffer size cannot be increased to this amount. I want to acquire data continuously say for 5 minutes ( corresponding to 300,000 samples ). Can anyone please kindly help me resolve this issue ? Note that baud rate is set to 115200 bps.
Thanks, Swarnava Pramanik

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 15 Jun. 2016
Use a BytesAvailableFcn callback to save the data from time to time.
  14 Kommentare
Swarnava Pramanik
Swarnava Pramanik am 18 Jun. 2016
Hi Walter,
Could you please kindly help me in another problem. I'm able to continuously get the data from my fpga board and at the same time I'm processing my data. It's happening so that my board is sending suppose 12000 samples but I'm only able to receive 11770 samples (losing around 300 samples corresponding to 0.3 seconds of data ). I'm attaching my code also
function store_plot_data(serialObject,event,chunk)
strRecv = fscanf(serialObject, '%s', chunk);
if( strcmp(strRecv(end), ',') == 1)
data_draw = [ data_draw dataStringTail strRecv ];
dataStringTail = [];
elseif( ( isempty(dataStringTail) == 0 ) && ( strcmp(strRecv(end), ',') == 0))
lastCommaIndex = max(strfind(strRecv,','));
% dataStringTail = strRecv(lastCommaIndex : end);
data_draw = [data_draw dataStringTail strRecv];
dataStringTail = [];
else
lastCommaIndex = max(strfind(strRecv,','));
dataStringTail = strRecv(lastCommaIndex : end);
data_draw = [data_draw strRecv(1 : lastCommaIndex - 1)];
end
end
Please note that "data_draw", "dataStringTail" are global variables.
Thanks,
Swarnava Pramanik
Swarnava Pramanik am 26 Jun. 2016
Hi Walter,
The callback function to the BytesAvailableFcn occurs only when the number of bytes specified by the BytesAvailableFcnCount is available in the input buffer. Suppose if the input buffer doesn't have the number of bytes specified by the BytesAvailableFcnCount property then the callback function is not executed. This is why I'm loosing some sample. Is there anyway to get around this ?
Thanks,

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by