0

I am working on a simple data acquisition system based on an Arduino Uno. Each run would ideally collect up to 10k data points (all doubles). Obviously, the Arduino doesn't have the capacity to hold all that at once. However, as one would expect, printing out the data as its being acquired significantly slows the process down (by about a factor of 7). I have looked around to find if there's a standard way to deal with this issue in the world of Arduinos, but have come up short. I come from a background where memory is never an issue, so I'm not as well versed in this side of things.

Obviously I don't expect perfection, but any insight or sources would be helpful.

4
  • Have you tried a higher baudrate? And transmitting binary data instead of ASCII text? Without code there isn't much else to say besides getting a microcontroller with more memory
    – chrisl
    Commented May 17, 2022 at 19:46
  • I have maxed out the baud, but I'm unfamiliar with the idea of sending binary data instead of ASCII. I'll look that up. Is the idea there that it's sending bits rather than bytes? And I was afraid you were going to say that last part.
    – Ben
    Commented May 17, 2022 at 19:53
  • it sounds like you need something newer/better than an Uno. I like the esp8266, even w/o wifi enabled.
    – dandavis
    Commented May 17, 2022 at 20:23
  • You are still sending bytes. But 1 byte can hold a number between 0 to 255. If you want to send 255 in ASCII text you already need 3 bytes for that. Though I would second dandavis with that you will be way better off with a better microcontroller
    – chrisl
    Commented May 17, 2022 at 20:53

3 Answers 3

3

This is all about choosing the right tool for the job.

At the moment you're trying to fit 50 clowns into a mini. While there are ways of doing it (by extending the "mini" outwards with extra "room") it's not what you'd normally do.

Instead you'd hire a coach.

If you have a scenario whereby you need to store more data than an Uno can store then you would typically use a different board with a more powerful chip.

There's plenty out there, many that are cheaper than the Uno...

If you desperately do want to use the Uno then:

  • Reduce your data size: consider using smaller variables, such as 16 bit integers and fixed point arithmetic instead of floating point values.
  • Improve your data transmission: send binary data instead of ASCII data, and increase your baud rate to the highest that can be reliably achieved
  • Consider adding external storage, such as an SPI SRAM chip or an SD card.
0

My solution is to use FRAM, it is much faster then printing and has almost unlimited read and write cycles. It is also non volatile so if power fails the data does not. They can be gotten I2C or SPI your preference. I purchased 32K x 8 devices for well under $6.00 last year from my favorite china supplier. You can treat it as one big ring buffer and print from it while you load data into it.

-1

Don't use String and others dynamic allocated object in your code. There is not any reason for slow down serial output, only inefficient memory management.

4
  • What do you mean by your second sentence? Why exactly is there no reason that the Serial output slows things down?
    – chrisl
    Commented May 17, 2022 at 19:48
  • I'm not actually using Strings, and all the variables I have are allocated in stack. I'm inclined to disagree with you that printing doesn't slow programs down; that's always been my experience.
    – Ben
    Commented May 17, 2022 at 19:48
  • Serial use ring input and output buffer. Its mean that you can output some count of characters to this buffer. If you send 10k double you overfill this buffer. Then you must wait for transfer chars by UART. Maybe this you consider as slow down printing. But transfer speed for serial line is baudrate/10 bytes per second (one char consist from 1 start bit, 8 data bits and one stop bit) This speed is guaranteed by hw UART and not change in time. Commented May 17, 2022 at 20:46
  • Si transferring over Serial does slow the code down, since it has to wait for the data to be actually send. Sorry, your answer doesn't make much sense to me in this context
    – chrisl
    Commented May 17, 2022 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.