Fread com device too slow

5 次查看(过去 30 天)
Jason Riley
Jason Riley 2021-1-23
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 中查找有关 Workspace Variables and MAT-Files 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by