# Data Acquiring Delay

**URL:** https://discourse.processing.org/t/data-acquiring-delay/18438
**Category:** Electronics (Arduino, etc.)
**Created:** [March 6, 2020, 5:55am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438 "2020-03-06T05:55:13Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![KGS](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@KGS](https://discourse.processing.org/u/KGS)
#### Post date: [March 6, 2020, 5:55am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/1 "2020-03-06T05:55:13Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [March 6, 2020, 7:20am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/2 "2020-03-06T07:20:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [March 6, 2020, 8:15am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/4 "2020-03-06T08:15:51Z")

</div>

Have you tried the sketch without printing anyhing to console?

---

<div class="post-metadata">

### Author: ![KGS](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@KGS](https://discourse.processing.org/u/KGS)
#### Post date: [March 6, 2020, 8:25am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/5 "2020-03-06T08:25:14Z")

</div>

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

---

<div class="post-metadata">

### Author: ![KGS](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@KGS](https://discourse.processing.org/u/KGS)
#### Post date: [March 6, 2020, 8:34am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/6 "2020-03-06T08:34:01Z")

</div>

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??

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [March 6, 2020, 8:53am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/7 "2020-03-06T08:53:27Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![KGS](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@KGS](https://discourse.processing.org/u/KGS)
#### Post date: [March 6, 2020, 9:00am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/8 "2020-03-06T09:00:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [March 6, 2020, 9:29am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/9 "2020-03-06T09:29:32Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![KGS](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@KGS](https://discourse.processing.org/u/KGS)
#### Post date: [March 6, 2020, 10:24am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/10 "2020-03-06T10:24:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [March 6, 2020, 10:33am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/11 "2020-03-06T10:33:13Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [March 6, 2020, 11:51am UTC](https://discourse.processing.org/t/data-acquiring-delay/18438/12 "2020-03-06T11:51:04Z")

</div>

Hello,

I am interested.

Please format your code:  
[https://discourse.processing.org/faq#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](https://processing.org/reference/libraries/serial/serialEvent_.html)  
You can do a search and find examples for this in the forums.

`:)`
