Memory Limit and Writting speed


I’m a intern (mechanical engineering) and I have to continue a project started by people before me.

I’ve to get the acceleration from an acquisistion system placed iside a metal ball that fall from a height (between 0.1 to 3m) and bounce on the floor. But the mesure takes between 100ms to 1s, and I need to get an acquisition every 0.1ms (I can go up to 0.5 but this is not ideal, because the norm is 0.1ms)

So obviously to have a fast writting speed: I need to write on the Arduino own memory (I’ve tried sending the acquisition directly to the PC but it is way too slow)

Here comes my problem: The Arduino memory only allows me to stock 800 points (so 80ms <<1s).
How can I increase the Arduino own memory?

Use a SD card wouldn’t work because the writting speed would be too slow (I guess).

Thank you for your answer, and sorry if it’s a stupid question, I’m not familiar with programmation, even if I understand it well.

I attach my Arduino file.

acquisitionAcceleroPrecision.ino (1.76 KB)

An Arduino DUE has 96 Kbytes of contiguous SRAM plus 4K non contiguous SRAM, therefore you could easily store up to 90 K Bytes.

90 Kbytes gives you enough space to store 23040 32_bit values. Furthermore, there is a native USB port much faster for Serial prints (SerialUSB.print () or SerialUSB.Write()) than the programming port (Serial.print()).

Arduino DUE : 17 Euros

Thank you for your answer.

I’ve an Arduino UNO for the moment, and I was hoping for a solution that wouldn’t make me buy a new device (If there is no cheaper or other solution that’s probably what I’ll do)… but I guess the easy thing would be to change for an Arduino DUE.

Due is larger than Uno, and more expensive.

There are many alternatives available these days which are faster, smaller have more ram memory and are almost 100% compatible with Arduino sketches and IDE.


Teensy lc
Maple Mini clones

Thanks but I'd rather keep working on a system I know approximately :)

I'm concerned about the DUE. Will my code work on the DUE directly?

External SRAM (or FRAM) should surely work. Also EEPROM whith large enough pages or SD card will be sufficient I guess. Depends how much data you want to write each 0.1 ms.

With minor changes, you will get your ADC samples. See the code below (not tested):

/*        46080 samples   from A0                          */

volatile uint32_t Array[23040];
uint64_t Old_micros;

void setup() {
  pinMode(A0, INPUT); 
  analogReadResolution(12);  // 0<= analogRead(A0) <= 2exp12  - 1 = 4095

  Old_micros = micros();

void loop() {

  static uint32_t Index;
  boolean Flag_Even = false;
  boolean Flag_Stop = false;

  while (Flag_Stop == false) {
    if ((micros() - Old_micros) > 100) {  // Sample every 100 us
      if (Flag_Even == false) {
        Array[Index] = analogRead(A0);
        Flag_Even = true;
      else {
        Array[Index] |= analogRead(A0) << 16;
        Flag_Even = false;
      Old_micros = micros();
    if (Index > 23040) Flag_Stop = true;  // Buffer is filled with 23040 * 2 samples
Serial.println(" End of sampling");
// TODO : Send your buffer to PC

An SD card is more than fast enough on an UNO. It's easily capable of 200KB per second. I recently helped another user achieve 20Hz sampling of GPS (5 values) plus 100Hz sampling of an IMU (9 values), two wheel speed sensors and one ADC conversion, all with timestamps.

After looking at your sketch, I see you are just taking one ADC sample. 10Hz (or higher) would be very easy.

You could also write some software to "compress" the samples in some way. I suspect a falling ball will produce nearly-identical acceleration readings (zero) until it hits the ground. After the impact vibration settles down, it will have the same readings until it hits the ground again.

An SD card reader is an easy addition, and a microSD card won't take up much more space. Try to get one that has 5V-to-3V level shifting (with FETs) instead of resistors... That's a little more reliable.

Cheers, /dev

The OP is reading at 10 kHz. Anyway

If you want to retrieve the data from Arduino later by computer AND you can ensure it will be constantly powered, SPI SRAM is probably the best way.

If you cannot ensure power all the time you can 1) backup power for the SRAM 2) use FRAM 3) use SPI EEPROM(s) with 256B pages (if you need to write only a few bytes per measurement) 4) use SD card - I have no idea what writing speed you can get and how quickly you will wear it out but you will be able to retrieve it and read it in computer directly. But you need level shifting, possibly better power source and more complicated program 5) write data to Arduino's own flash

Personaly I think 1 > 2 > 3 > 4 > 5 but it is up to you.

The OP is reading at 10 kHz. Anyway

LOL, totally misread that! At 10kHz, writing 20 bytes per sample to an SD is 200kB/s. This is still easily achievable for one ADC value of 2 binary bytes, 2 HEX chars, or 4 decimal chars plus newlines.

A little more than 512 bytes of RAM will be used for the SD library, and you may want a small ring buffer for your samples.