Which are the issues occurring when I am acquiring data in background and I want to execute a callback function which is much more time demanding

2 visualizzazioni (ultimi 30 giorni)
Hello everybody,
I am working with the data acquisition toolbox. I built a GUI that allows to acquire data in back ground.
The next step is to add a few callback functions, by using addlistener that allows to process the data acquired in real time and carry out some vibration analyses.
In the case the added callback funtion execution takes longer than 1 second, which issues I will have?
Thanks for any answer.

Risposta accettata

Walter Roberson
Walter Roberson il 20 Ago 2020
Data acquisition and transfer into internal buffers takes place in the background even when you are inside a listener callback, if I understand correctly (it is possible I am wrong about this.)
The buffers would continue to fill until the configured buffer size had been reached.
If the buffer gets filled, then incoming data will be dropped.
If your analysis occassionally takes longer than the interval between incoming samples, then you might be okay.
If your analysis regularly takes longer than the interval between incoming samples, then you need to log signals (somehow) or select the most important ones for later processing.
If yur analysis sometimes takes much longer, then if that is probabilitistic, then even if the events are independent you would run the risk of filling up the buffer if you happened to get a burst of those long-analysis events in a row, even if the mean time to process was relatively low.
  2 Commenti
DAVIDE DELLA VALLE
DAVIDE DELLA VALLE il 20 Ago 2020
Hello Walter, first thanks for the comment. However it's not that clear to me and maybe you can help me out.
To be clearer, I will report herein an example. In such a context I am using the Session-Based Interface to acquire data from a NI-Usb Daq device (MATLAB release 2017b).
I'm acquiring data at 51200Hz in background, and I want to run a function MY_FUNCTION every second (I thus launch the function as the amount of data acquired exceeds 51200).
In my case, the execution of MY_FUNCTION takes 8 seconds. Which problems I will have during my acquisition? Is there any way to solve it?
Walter Roberson
Walter Roberson il 20 Ago 2020
Every one second you need 8 CPU seconds of data processing. The one way to handle that in real-time is to add 7 more CPUs every second.
The alternative is to buffer the data until you can get around to it. As the buffer would be building up at roughly 400 kilobytes per second, you could only sustain that for perhaps 10000 seconds. This would, however, not be considered real time: after 7 1/2 minutes you would already be an hour behind in the processing.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by