I’m working on some animatronics for an art installation which will use several stepper motors and some high-power LEDs. In the past, when I have done this sort of thing I have used a tethered computer to handle the logic and timing. For this project, I would like to try making it self-contained (for example, just the Arduino board). For Arduino hardware, I have an Arduino Mega and could expand it with an SD card shield for more storage, if need be.
I’d really welcome any ideas or suggestions on how to approach this (and am not asking for code).
For the data, essentially I would be storing cues for each stepper and each LED. And of course I would need some kind of clock or timestamp to keep track of things.
A stepper cue would be something like:
- cue start time
- stepper ID
- stepper direction
- stepper speed
- number of steps
An LED cue would be something like:
- cue start time
- LED ID
- Start brightness
- End brightness
- duration
So what I am wondering about:
- ideas about a data format compact enough to store lots of cues
- any suggestions for a clock or timestamp. (A simple counter is the obvious choice.)
As for just how many cues/how much data, since I am just beginning this, I will work within whatever limits I bump up against.
So for now I have decided to roll my own simple data format in order to keep the project moving. I was also concerned about storing cue data in a way that doesn’t eat up RAM.
Since I am using an Ardunio Mega with 128 KB of Flash memory I want to use that before resorting to an SD card. With the excellent Flash Library accessing PROGMEM is very easy and I was able to rough out a test sketch in minutes.
For motor control I am using dedicated motor controller boards using serial comm. Each board controls two motors. For testing the maximum data size I needed to send was four values: rate, slope, x target, y target in order to make a move so that determines my data format for motors. This will change when I add a timestamp and board ID values.
With the Flash lib, you can define a FLASH_TABLE, store it in PROGMEM and then access it using simple array bracket access. Testing with a couple of thousand entries shows no issues.
So it becomes a simple task of pulling data out and sending it to the standalone boards or using it internally.
// simple example: