Fread com device too slow

조회 수: 6 (최근 30일)
Jason Riley
Jason Riley 2021년 1월 23일
댓글: Jason Riley 2021년 1월 28일
Hi,
So I am currently using matlabd to read continuously from a device set um on COM4.
the device is streaming 5 32Bit Ints @4kHz. If i acquire data for say 4 seconds i appear to be waiting a further 7 or 8 seconds for the fread() function to catch up. any thoughts on how to speed this up as this delay is problematic when trying to acquire multiple scans, i am waiting longer than i am scanning.
Cheers,
Jason

답변 (1개)

Vimal Rathod
Vimal Rathod 2021년 1월 28일
  댓글 수: 1
Jason Riley
Jason Riley 2021년 1월 28일
i don't see solutions in these only commentries, could you be more specific when you say use these solutions? these appear as discussions without answers.
I know uaing standard usb serial data readers that i can run at ful speed, but matlab seems slower.
here is the specific code:
set(app.obj1, 'ReadAsyncMode','continuous');
done=0;
while (done==0)
if app.obj1.BytesAvailable>0
while app.obj1.BytesAvailable>0
values(1,1)=fread(app.obj1,1,"uint32");
values(1,2:5)=fread(app.obj1,4,"int32");
Values=[Values;values];
done=1;
end
end
end
stopasync(app.obj1);
currently the device streams 5x32bit numbers at 4kHz. if i scan for 2 seconds, i currently wait 4-5s for the buffer to catch up. Given using other streaming programs i have 0 wait time, i assume there is some paraemter which needs to be set in matlab to make this run faster? but as to what, i find no answers in your suggested reading.

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

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by