Data Acquiring Delay

I am using processing software to acquire data from 4 arduino microcontrollers simultaneously.
I have seen that after a few minutes data plotting gets delayed and increasing it.

At initially it works fine and the latter stage is happening this. How can I get rid of delay.
I have used a USB hub to connect all the ardunios to the PC.

Without code it is difficult, but I guess that it is a memory problem.
You have to free it as soon as possible

Have you tried the sketch without printing anyhing to console?

No, I have printed the all the data to console. I will try it without printing.

The delay is still there after removing the print lines to console.
The delay happens after 8000 data points plotted in the plot.
Are there any alternative solutions??

I think the points arrays can be kept small, you only need them as an intermediate for plotting and printing to file, isn’t it?

Yes. Point arrays are used as intermediate virtual variables. Furthermore, the data sampling rate is 25 Hz and I have to acquire data for 15 minutes. Minimum of 22500 samples needed to be saved into the file.

So I think this is what you need to try; emptying the arrays and keeping them as small as possible, and as soon as possible. I don’t see any other reason until now.

I have reduced the array sizes of all the data parameters. Still the delay appears after 8000 samples acquired. What else can be done ???

Well, I would break it down by not executing some tasks, as for instance plotting, to find the culprit. And also keep track of the frameRate.

Hello,

I am interested.

Please format your code:
https://discourse.processing.org/faq#format-your-code

I can’t look at the code as is and unable to cut and past working code (try and you will see why).

I have been looking into the use of multiple serial ports and was planning to explore this further this weekend.

Please provide code on Arduino side; enough that I get a sense of format sent and any delays so I can simulate.

I have access to many Arduinos.

I suspect that you are trying to acquire and send data (< 60Hz from code comments) to Processing faster than the draw frame rate (50 Hz set by you) and that the serial port reads in the draw loop are “blocking”.
You may want to consider:
https://processing.org/reference/libraries/serial/serialEvent_.html
You can do a search and find examples for this in the forums.

:)

1 Like