Storage a large array

Guys , I need hel please.

It is possible storage an amount data like this? I have issues to finisch my program beacause i need storage large data and many variables.


volatile int     m1Dist_learn[3600];
int   rpmL1_learn[3600];
int    m1pwmMan_learn[3600];
volatile int     m2Dist_learn[3600];
int   rpmR1_learn[3600];
int    m2pwmMan_learn[3600];

unsigned long  Cont1segundo = 0;
int Limitecont1s;

volatile int     m1Dist_2learn[3600];
int   rpmL1_2learn[3600];
int    m1pwmMan_2learn[3600];
volatile int     m2Dist_2learn[3600];
int   rpmR1_2learn[3600];
int    m2pwmMan_2learn[3600];

int Limitecont2s;

volatile int     emwDist_learn[3600];
int   erwmL1_learn[3600];
int    em1OnStwate_learn[3600];
volatile int     em2Dwist_learn[3600];
int   erpwmR1_learn[3600];
int    em2OnStawte_learn[3600];


volatile int     femwDist_learn[3600];
int   ferwmL1_learn[3600];
int    fem1OnStwate_learn[3600];
volatile int     fem2Dwist_learn[3600];
int   ferpwmR1_learn[3600];
int    fem2OnStawte_learn[3600];

volatile int     gfemwDist_learn[3600];
int   gferwmL1_learn[3600];
int    gfem1OnStwate_learn[3600];
volatile int     gfem2Dwist_learn[3600];
int   gferpwmR1_learn[3600];
int    gfem2OnStawte_learn[3600];

volatile int     hgfemwDist_learn[3600];
int   hgferwmL1_learn[3600];
int    hgfem1OnStwate_learn[3600];
volatile int     hgfem2Dwist_learn[3600];
int   hgferpwmR1_learn[3600];
int    hgfem2OnStawte_learn[3600];

volatile int     jhgfemwDist_learn[3600];
int   jhgferwmL1_learn[3600];
int    jhgfem1OnStwate_learn[3600];
volatile int     jhgfem2Dwist_learn[3600];
int   jhgferpwmR1_learn[3600];
int    jhgfem2OnStawte_learn[3600];

volatile int     qhgfemwDist_learn[3600];
int   qhgferwmL1_learn[3600];
int    qhgfem1OnStwate_learn[3600];
volatile int     qhgfem2Dwist_learn[3600];
int   qhgferpwmR1_learn[3600];
int    qhgfem2OnStawte_learn[3600];

volatile int     vqhgfemwDist_learn[3600];
int   vqhgferwmL1_learn[3600];
int    vqhgfem1OnStwate_learn[3600];
volatile int     vqhgfem2Dwist_learn[3600];
int   vqhgferpwmR1_learn[3600];
int    vqhgfem2OnStawte_learn[3600];

volatile int     fvqhgfemwDist_learn[3600];
int   fvqhgferwmL1_learn[3600];
int    fvqhgfem1OnStwate_learn[3600];
volatile int     fvqhgfem2Dwist_learn[3600];
int   fvqhgferpwmR1_learn[3600];
int    fvqhgfem2OnStawte_learn[3600];


void setup() {
  // put your setup code here, to run once:
}

void loop() {
  m1Dist_learn[Cont1segundo] = 0;
  rpmL1_learn[Cont1segundo] = 0;
  m1pwmMan_learn[Cont1segundo] = 0;
  m2Dist_learn[Cont1segundo] = 0;
  rpmR1_learn[Cont1segundo] = 0;
  m2pwmMan_learn[Cont1segundo] = 0;/**/

  Limitecont1s = 0;

  m1Dist_2learn[3600] = 0;
  rpmL1_2learn[3600] = 0;
  m1pwmMan_2learn[3600] = 0;
  m2Dist_2learn[3600] = 0;
  rpmR1_2learn[3600] = 0;
  m2pwmMan_2learn[3600] = 0;

  Limitecont2s = 0;;

 emwDist_learn[3600] = 0;
  erwmL1_learn[3600] = 0;
  em1OnStwate_learn[3600] = 0;
  em2Dwist_learn[3600] = 0;
  erpwmR1_learn[3600] = 0;
  em2OnStawte_learn[3600] = 0;

  femwDist_learn[3600] = 0;
  ferwmL1_learn[3600] = 0;
  fem1OnStwate_learn[3600] = 0;
  fem2Dwist_learn[3600] = 0;
  ferpwmR1_learn[3600] = 0;
  fem2OnStawte_learn[3600] = 0;

  gfemwDist_learn[3600] = 0;
  gferwmL1_learn[3600] = 0;
  gfem1OnStwate_learn[3600] = 0;
  gfem2Dwist_learn[3600] = 0;
  gferpwmR1_learn[3600] = 0;
  gfem2OnStawte_learn[3600] = 0;

  hgfemwDist_learn[3600] = 0;
  hgferwmL1_learn[3600] = 0;
  hgfem1OnStwate_learn[3600] = 0;
  hgfem2Dwist_learn[3600] = 0;
  hgferpwmR1_learn[3600] = 0;
  hgfem2OnStawte_learn[3600] = 0;

  jhgfemwDist_learn[3600] = 0;
  jhgferwmL1_learn[3600] = 0;
  jhgfem1OnStwate_learn[3600] = 0;
  jhgfem2Dwist_learn[3600] = 0;
  jhgferpwmR1_learn[3600] = 0;
  jhgfem2OnStawte_learn[3600] = 0;

  qhgfemwDist_learn[3600] = 0;
  qhgferwmL1_learn[3600] = 0;
  qhgfem1OnStwate_learn[3600] = 0;
  qhgfem2Dwist_learn[3600] = 0;
  qhgferpwmR1_learn[3600] = 0;
  qhgfem2OnStawte_learn[3600] = 0;

  vqhgfemwDist_learn[3600] = 0;
  vqhgferwmL1_learn[3600] = 0;
  vqhgfem1OnStwate_learn[3600] = 0;
  vqhgfem2Dwist_learn[3600] = 0;
  vqhgferpwmR1_learn[3600] = 0;
  vqhgfem2OnStawte_learn[3600] = 0;

  fvqhgfemwDist_learn[3600] = 0;
  fvqhgferwmL1_learn[3600] = 0;
  fvqhgfem1OnStwate_learn[3600] = 0;
  fvqhgfem2Dwist_learn[3600] = 0;
  fvqhgferpwmR1_learn[3600] = 0;
  fvqhgfem2OnStawte_learn[3600] = 0;
}

You have problems over and above the amount of memory needed to store such large arrays

int   rpmL1_learn[3600];

declares an array of ints, then you do this

rpmL1_learn[Cont1segundo] = 0;

but you previously did this

unsigned long  Cont1segundo = 0;

so you are putting an unsigned long in an array of itns

Thank you by your suggestion, I Replace it by: int Cont1segundo = 0;
but the remain the error:

Arduino: 1.8.13 (Windows 10), Placa:"ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 115200, None"

c:/users/apa4/desktop/segard/arduino-1.8.13/portable/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\apa4\AppData\Local\Temp\arduino_build_210267/sketch_nov12a.ino.elf section .dram0.bss' will not fit in region dram0_0_seg'

c:/users/apa4/desktop/segard/arduino-1.8.13/portable/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: DRAM segment data does not fit.

c:/users/apa4/desktop/segard/arduino-1.8.13/portable/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: region `dram0_0_seg' overflowed by 754000 bytes

collect2.exe: error: ld returned 1 exit status

exit status 1

Changing Cont1segundo from an unsigned long to an int does not make the amount of memory required by the arrays any smaller

What exactly is your project intended to do ?

Make sense.
The robot will learn the move when I control in the first time. Thus the variables will remain in the storage and after it , the robot will be able to repeat it.
I'm using a large numbers to read enconder.
I test it and worked perfect, but the robot save only 1/10 of data that i would need.

Consider saving the data on an SD card

Thank you by support

1 Like

I described a technique for using SD card memory to store large arrays in the blog below, in case this helps.

https://arduinoplusplus.wordpress.com/2020/08/12/virtual-arrays-using-an-sd-card/