Suggestions for programming structure and storage of animatronic sequences

I am working on animatronics for an art installation that will use several stepper motors and some powerful LEDs. Previously, when I did such things, I used an attached computer to process logic and time. For this project, I would like to try to make it standalone (for example, just an Arduino panel). For Arduino hardware, I have an Arduino Mega and can expand it with an SD shield card for future storage, if necessary.

I really welcome any ideas or suggestions on how to approach this (and I am not asking for code).

For the data, in essence, I would save the signals for each step and each LED. And, of course, I need some kind of clock or timestamp to keep track of things.

The key label will look something like this:

  • recording start time
  • step id
  • step direction
  • power speed
  • number of steps

The LED label will look something like this:

  • recording start time
  • LED identifier
  • Initial brightness
  • Ultimate brightness
  • Duration

So what interests me is:

  • data format ideas are compact enough to hold many replicas
  • any suggestions for hours or time stamps. (A simple counter is an obvious choice.)

As for the total number of replicas / how much data, since I am just starting this, I will work within any limits that I encounter.

+5
source share
1 answer

, , . , .

Ardunio Mega 128 -, , SD-. Flash- PROGMEM , .

, . . , , : , , x, y, , . , .

Flash lib FLASH_TABLE, PROGMEM . .

, .

// :

#include <Flash.h>

FLASH_TABLE(int, command_table, 4 /* width of table */, 
    {111, 222, 333, 444},
    {1001, 900, 3210, -4567},
    {1002, 1000, 3210, -4567},
    {1003, 1100, 3210, -4567},
    {666, 777, 888, 999}
    );

void setup() {
    Serial.begin(9600);
    Serial.print("Mem: "); Serial.println(availableMemory());

    // Determine the size of the array
    Serial.print("Rows: "); Serial.println(command_table.rows());
    Serial.print("Cols: "); Serial.println(command_table.cols());
    Serial.print("RAM: "); Serial.println(sizeof(command_table));

     Serial.print(command_table[8][0]);
     Serial.print("s");
     Serial.print(command_table[8][1]);
     Serial.print("r");
     Serial.print(command_table[8][2]);
     Serial.print("x");
     Serial.print(command_table[8][3]);
     Serial.print("y");
     Serial.println("gi");  
}

void loop() {


}

int availableMemory() 
{
  int size = 1024;
  byte *buf;
  while ((buf = (byte *) malloc(--size)) == NULL);
  free(buf);
  return size;
}
0

All Articles