A friend and I are planning some animatronics projects for Halloween/Christmas. These animatronics would be outdoors for at least a couple weeks at a time, so running from a laptop probably isn't appropriate.
I wrote an Arduino program that records servo movements from a joystick, and allows playback. It's working well. So far, I've allotted 3K for the storage array for a single servo, which would give me a minimum of 5 minutes recording at 10 ticks/second, and should handle the length of a normal song. I've built in compression to record ticks where the servo doesn't move. It's working well.
But we want to be able to record/playback at least 4 servos. This means I would need 12kb RAM + overhead.
So, is there a way to increase Arduino RAM? Specifically, I'm testing using a Mega 2560, but same would be asked for the UNO.
You can get "Serial SRAM" chips that will connect to an AVR by SPI (or I2C); or FRAM, which is actually non-volatile (but more expensive.)
EEPROM or Serial Flash might be another option, if you're more careful about how often they are written.
If you use an ESP32, you have about 290k of RAM, and probably won't need additional memory. (Still the modules with extra PSRAM aren't much more expensive, so...)
(an ESP32 actually has about 384k of data ram, but ~100k is used by the internal IP and BT stacks.) (Where is my RAM ?, i want more ! - ESP32 Forum )
OTOH, most ESP32 boards may be pretty short on pins when it comes to driving multiple motors and joysticks/etc.
If you declare an array and initialise it with a large amount of data, then that data gets stored in the Arduino's flash memory when the sketch is uploaded. When the sketch begins, before setup() runs, the data is copied from flash to ram memory ready for use by the sketch. This is done on the assumption that the data might need to change as the sketch runs. That's not the case with your sketch, I suspect. If so, it's possible to prevent the data getting copied to ram, and have your sketch read it directly from flash memory. It's slightly trickier to code, but we can help you get it right. The keyword PROGMEM and functions like pgm_read_word_near() need to be used.
Yes, I believe so. At least on AVR based Arduino, which have Harvard architecture, so accessing data stored in program memory requires the use of those special functions. The compiler won't take care of all that for you if your data is const, unfortunately. I don't know why. It would be nice.