Fread com device too slow

5 visualizaciones (últimos 30 días)
Jason Riley
Jason Riley el 23 de En. de 2021
Comentada: Jason Riley el 28 de En. de 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

Respuestas (1)

Vimal Rathod
Vimal Rathod el 28 de En. de 2021
  1 comentario
Jason Riley
Jason Riley el 28 de En. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Workspace Variables and MAT-Files en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by