Fread com device too slow

5 Ansichten (letzte 30 Tage)
Jason Riley
Jason Riley am 23 Jan. 2021
Kommentiert: Jason Riley am 28 Jan. 2021
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

Antworten (1)

Vimal Rathod
Vimal Rathod am 28 Jan. 2021
  1 Kommentar
Jason Riley
Jason Riley am 28 Jan. 2021
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by